mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 23:01:56 +00:00
Allow async streamFn for dynamic proxy settings
- StreamFn type now allows returning Promise - agent-loop awaits streamFn result - createStreamFn takes getProxyUrl callback, reads settings on each call
This commit is contained in:
parent
e0be2e650d
commit
92898f486b
4 changed files with 16 additions and 11 deletions
|
|
@ -211,7 +211,7 @@ async function streamAssistantResponse(
|
|||
const resolvedApiKey =
|
||||
(config.getApiKey ? await config.getApiKey(config.model.provider) : undefined) || config.apiKey;
|
||||
|
||||
const response = streamFunction(config.model, llmContext, {
|
||||
const response = await streamFunction(config.model, llmContext, {
|
||||
...config,
|
||||
apiKey: resolvedApiKey,
|
||||
signal,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,10 @@ import type {
|
|||
} from "@mariozechner/pi-ai";
|
||||
import type { Static, TSchema } from "@sinclair/typebox";
|
||||
|
||||
export type StreamFn = typeof streamSimple;
|
||||
/** Stream function - can return sync or Promise for async config lookup */
|
||||
export type StreamFn = (
|
||||
...args: Parameters<typeof streamSimple>
|
||||
) => ReturnType<typeof streamSimple> | Promise<ReturnType<typeof streamSimple>>;
|
||||
|
||||
/**
|
||||
* Configuration for the agent loop.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue