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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user