mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 18:01:22 +00:00
Add createStreamFn for CORS proxy support
- createStreamFn(proxyUrl?) returns a sync streamFn that applies proxy - Example reads proxy settings once when creating Agent - Matches old ProviderTransport behavior
This commit is contained in:
parent
e49e787322
commit
e0be2e650d
3 changed files with 28 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ import {
|
|||
ChatPanel,
|
||||
CustomProvidersStore,
|
||||
createJavaScriptReplTool,
|
||||
createStreamFn,
|
||||
IndexedDBStorageBackend,
|
||||
// PersistentStorageDialog, // TODO: Fix - currently broken
|
||||
ProviderKeysStore,
|
||||
|
|
@ -160,6 +161,10 @@ const createAgent = async (initialState?: Partial<AgentState>) => {
|
|||
agentUnsubscribe();
|
||||
}
|
||||
|
||||
// Read proxy settings for streamFn
|
||||
const proxyEnabled = await storage.settings.get<boolean>("proxy.enabled");
|
||||
const proxyUrl = proxyEnabled ? (await storage.settings.get<string>("proxy.url")) || undefined : undefined;
|
||||
|
||||
agent = new Agent({
|
||||
initialState: initialState || {
|
||||
systemPrompt: `You are a helpful AI assistant with access to various tools.
|
||||
|
|
@ -181,6 +186,8 @@ Feel free to use these tools when needed to provide accurate and helpful respons
|
|||
const key = await storage.providerKeys.get(provider);
|
||||
return key ?? undefined;
|
||||
},
|
||||
// Use streamFn with CORS proxy support
|
||||
streamFn: createStreamFn(proxyUrl),
|
||||
});
|
||||
|
||||
agentUnsubscribe = agent.subscribe((event: any) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue