Support proxying AI provider traffic

This commit is contained in:
Alex Gleason committed 2025-10-08 16:22:07 -05:00
1 parent 0b95398f2d
commit 1bb949217a
13 files changed
+126 -30

No files matched your search

+4 -1
View File
@@ -60,17 +60,20 @@ export class SessionManager {
private aiSettings: { providers: AIProvider[] };
private getProviderModels?: () => Array<{ id: string; provider: string; contextLength?: number; pricing?: { prompt: import('decimal.js').Decimal; completion: import('decimal.js').Decimal } }>;
private getCurrentUser?: () => { user?: NUser; metadata?: NostrMetadata };
private corsProxy?: string;
constructor(
fs: JSRuntimeFS,
aiSettings: { providers: AIProvider[] },
getProviderModels?: () => Array<{ id: string; provider: string; contextLength?: number; pricing?: { prompt: import('decimal.js').Decimal; completion: import('decimal.js').Decimal } }>,
getCurrentUser?: () => { user?: NUser; metadata?: NostrMetadata },
corsProxy?: string,
) {
this.fs = fs;
this.aiSettings = aiSettings;
this.getProviderModels = getProviderModels;
this.getCurrentUser = getCurrentUser;
this.corsProxy = corsProxy;
}
/**
@@ -206,7 +209,7 @@ export class SessionManager {
// Initialize OpenAI client
const { user, metadata } = this.getCurrentUser?.() ?? {};
const openai = createAIClient(provider, user);
const openai = createAIClient(provider, user, this.corsProxy);
let stepCount = 0;
const maxSteps = session.maxSteps || 50;