@mariozechner/pi-ai 0.5.45 → 0.5.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/agent-loop.js +1 -0
- package/dist/agent/agent-loop.js.map +1 -1
- package/dist/models.generated.d.ts +142 -40
- package/dist/models.generated.d.ts.map +1 -1
- package/dist/models.generated.js +266 -164
- package/dist/models.generated.js.map +1 -1
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +1 -0
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/google.d.ts.map +1 -1
- package/dist/providers/google.js +1 -0
- package/dist/providers/google.js.map +1 -1
- package/dist/providers/openai-completions.d.ts.map +1 -1
- package/dist/providers/openai-completions.js +1 -0
- package/dist/providers/openai-completions.js.map +1 -1
- package/dist/providers/openai-responses.d.ts.map +1 -1
- package/dist/providers/openai-responses.js +1 -0
- package/dist/providers/openai-responses.js.map +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/agent/agent-loop.js
CHANGED
|
@@ -176,6 +176,7 @@ async function executeToolCalls(tools, assistantMessage, signal, stream) {
|
|
|
176
176
|
output: typeof resultOrError === "string" ? resultOrError : resultOrError.output,
|
|
177
177
|
details: typeof resultOrError === "string" ? {} : resultOrError.details,
|
|
178
178
|
isError,
|
|
179
|
+
timestamp: Date.now(),
|
|
179
180
|
};
|
|
180
181
|
results.push(toolResultMessage);
|
|
181
182
|
stream.push({ type: "message_start", message: toolResultMessage });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-loop.js","sourceRoot":"","sources":["../../src/agent/agent-loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,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;QAED,MAAM,CAAC,IAAI,CAAC;YACX,IAAI,EAAE,oBAAoB;YAC1B,UAAU,EAAE,QAAQ,CAAC,EAAE;YACvB,QAAQ,EAAE,QAAQ,CAAC,IAAI;YACvB,MAAM,EAAE,aAAa;YACrB,OAAO;SACP,CAAC,CAAC;QAEH,MAAM,iBAAiB,GAAyB;YAC/C,IAAI,EAAE,YAAY;YAClB,UAAU,EAAE,QAAQ,CAAC,EAAE;YACvB,QAAQ,EAAE,QAAQ,CAAC,IAAI;YACvB,MAAM,EAAE,OAAO,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM;YAChF,OAAO,EAAE,OAAO,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAE,EAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO;YAC9E,OAAO;SACP,CAAC;QAEF,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC,CAAC;QACnE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import { streamSimple } from \"../stream.js\";\nimport type { AssistantMessage, Context, Message, ToolResultMessage, UserMessage } from \"../types.js\";\nimport { EventStream } from \"../utils/event-stream.js\";\nimport { validateToolArguments } from \"../utils/validation.js\";\nimport type { AgentContext, AgentEvent, AgentLoopConfig, AgentTool, AgentToolResult, QueuedMessage } from \"./types.js\";\n\n// Main prompt function - returns a stream of events\nexport function agentLoop(\n\tprompt: UserMessage,\n\tcontext: AgentContext,\n\tconfig: AgentLoopConfig,\n\tsignal?: AbortSignal,\n\tstreamFn?: typeof streamSimple,\n): EventStream<AgentEvent, AgentContext[\"messages\"]> {\n\tconst stream = new EventStream<AgentEvent, AgentContext[\"messages\"]>(\n\t\t(event: AgentEvent) => event.type === \"agent_end\",\n\t\t(event: AgentEvent) => (event.type === \"agent_end\" ? event.messages : []),\n\t);\n\n\t// Run the prompt async\n\t(async () => {\n\t\t// Track new messages generated during this prompt\n\t\tconst newMessages: AgentContext[\"messages\"] = [];\n\t\t// Create user message for the prompt\n\t\tconst messages = [...context.messages, prompt];\n\t\tnewMessages.push(prompt);\n\n\t\tstream.push({ type: \"agent_start\" });\n\t\tstream.push({ type: \"turn_start\" });\n\t\tstream.push({ type: \"message_start\", message: prompt });\n\t\tstream.push({ type: \"message_end\", message: prompt });\n\n\t\t// Update context with new messages\n\t\tconst currentContext: AgentContext = {\n\t\t\t...context,\n\t\t\tmessages,\n\t\t};\n\n\t\t// Keep looping while we have tool calls or queued messages\n\t\tlet hasMoreToolCalls = true;\n\t\tlet firstTurn = true;\n\t\tlet queuedMessages: QueuedMessage<any>[] = (await config.getQueuedMessages?.()) || [];\n\n\t\twhile (hasMoreToolCalls || queuedMessages.length > 0) {\n\t\t\tif (!firstTurn) {\n\t\t\t\tstream.push({ type: \"turn_start\" });\n\t\t\t} else {\n\t\t\t\tfirstTurn = false;\n\t\t\t}\n\n\t\t\t// Process queued messages first (inject before next assistant response)\n\t\t\tif (queuedMessages.length > 0) {\n\t\t\t\tfor (const { original, llm } of queuedMessages) {\n\t\t\t\t\tstream.push({ type: \"message_start\", message: original });\n\t\t\t\t\tstream.push({ type: \"message_end\", message: original });\n\t\t\t\t\tif (llm) {\n\t\t\t\t\t\tcurrentContext.messages.push(llm);\n\t\t\t\t\t\tnewMessages.push(llm);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tqueuedMessages = [];\n\t\t\t}\n\n\t\t\t// console.log(\"agent-loop: \", [...currentContext.messages]);\n\n\t\t\t// Stream assistant response\n\t\t\tconst message = await streamAssistantResponse(currentContext, config, signal, stream, streamFn);\n\t\t\tnewMessages.push(message);\n\n\t\t\tif (message.stopReason === \"error\" || message.stopReason === \"aborted\") {\n\t\t\t\t// Stop the loop on error or abort\n\t\t\t\tstream.push({ type: \"turn_end\", message, toolResults: [] });\n\t\t\t\tstream.push({ type: \"agent_end\", messages: newMessages });\n\t\t\t\tstream.end(newMessages);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Check for tool calls\n\t\t\tconst toolCalls = message.content.filter((c) => c.type === \"toolCall\");\n\t\t\thasMoreToolCalls = toolCalls.length > 0;\n\n\t\t\tconst toolResults: ToolResultMessage[] = [];\n\t\t\tif (hasMoreToolCalls) {\n\t\t\t\t// Execute tool calls\n\t\t\t\ttoolResults.push(...(await executeToolCalls(currentContext.tools, message, signal, stream)));\n\t\t\t\tcurrentContext.messages.push(...toolResults);\n\t\t\t\tnewMessages.push(...toolResults);\n\t\t\t}\n\t\t\tstream.push({ type: \"turn_end\", message, toolResults: toolResults });\n\n\t\t\t// Get queued messages after turn completes\n\t\t\tqueuedMessages = (await config.getQueuedMessages?.()) || [];\n\t\t}\n\t\tstream.push({ type: \"agent_end\", messages: newMessages });\n\t\tstream.end(newMessages);\n\t})();\n\n\treturn stream;\n}\n\n// Helper functions\nasync function streamAssistantResponse(\n\tcontext: AgentContext,\n\tconfig: AgentLoopConfig,\n\tsignal: AbortSignal | undefined,\n\tstream: EventStream<AgentEvent, AgentContext[\"messages\"]>,\n\tstreamFn?: typeof streamSimple,\n): Promise<AssistantMessage> {\n\t// Convert AgentContext to Context for streamSimple\n\t// Use a copy of messages to avoid mutating the original context\n\tconst processedMessages = config.preprocessor\n\t\t? await config.preprocessor(context.messages, signal)\n\t\t: [...context.messages];\n\tconst processedContext: Context = {\n\t\tsystemPrompt: context.systemPrompt,\n\t\tmessages: [...processedMessages].map((m) => {\n\t\t\tif (m.role === \"toolResult\") {\n\t\t\t\tconst { details, ...rest } = m;\n\t\t\t\treturn rest;\n\t\t\t} else {\n\t\t\t\treturn m;\n\t\t\t}\n\t\t}),\n\t\ttools: context.tools, // AgentTool extends Tool, so this works\n\t};\n\n\t// Use custom stream function if provided, otherwise use default streamSimple\n\tconst streamFunction = streamFn || streamSimple;\n\tconst response = await streamFunction(config.model, processedContext, { ...config, signal });\n\n\tlet partialMessage: AssistantMessage | null = null;\n\tlet addedPartial = false;\n\n\tfor await (const event of response) {\n\t\tswitch (event.type) {\n\t\t\tcase \"start\":\n\t\t\t\tpartialMessage = event.partial;\n\t\t\t\tcontext.messages.push(partialMessage);\n\t\t\t\taddedPartial = true;\n\t\t\t\tstream.push({ type: \"message_start\", message: { ...partialMessage } });\n\t\t\t\tbreak;\n\n\t\t\tcase \"text_start\":\n\t\t\tcase \"text_delta\":\n\t\t\tcase \"text_end\":\n\t\t\tcase \"thinking_start\":\n\t\t\tcase \"thinking_delta\":\n\t\t\tcase \"thinking_end\":\n\t\t\tcase \"toolcall_start\":\n\t\t\tcase \"toolcall_delta\":\n\t\t\tcase \"toolcall_end\":\n\t\t\t\tif (partialMessage) {\n\t\t\t\t\tpartialMessage = event.partial;\n\t\t\t\t\tcontext.messages[context.messages.length - 1] = partialMessage;\n\t\t\t\t\tstream.push({ type: \"message_update\", assistantMessageEvent: event, message: { ...partialMessage } });\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase \"done\":\n\t\t\tcase \"error\": {\n\t\t\t\tconst finalMessage = await response.result();\n\t\t\t\tif (addedPartial) {\n\t\t\t\t\tcontext.messages[context.messages.length - 1] = finalMessage;\n\t\t\t\t} else {\n\t\t\t\t\tcontext.messages.push(finalMessage);\n\t\t\t\t}\n\t\t\t\tstream.push({ type: \"message_end\", message: finalMessage });\n\t\t\t\treturn finalMessage;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn await response.result();\n}\n\nasync function executeToolCalls<T>(\n\ttools: AgentTool<any, T>[] | undefined,\n\tassistantMessage: AssistantMessage,\n\tsignal: AbortSignal | undefined,\n\tstream: EventStream<AgentEvent, Message[]>,\n): Promise<ToolResultMessage<T>[]> {\n\tconst toolCalls = assistantMessage.content.filter((c) => c.type === \"toolCall\");\n\tconst results: ToolResultMessage<any>[] = [];\n\n\tfor (const toolCall of toolCalls) {\n\t\tconst tool = tools?.find((t) => t.name === toolCall.name);\n\n\t\tstream.push({\n\t\t\ttype: \"tool_execution_start\",\n\t\t\ttoolCallId: toolCall.id,\n\t\t\ttoolName: toolCall.name,\n\t\t\targs: toolCall.arguments,\n\t\t});\n\n\t\tlet resultOrError: AgentToolResult<T> | string;\n\t\tlet isError = false;\n\n\t\ttry {\n\t\t\tif (!tool) throw new Error(`Tool ${toolCall.name} not found`);\n\n\t\t\t// Validate arguments using shared validation function\n\t\t\tconst validatedArgs = validateToolArguments(tool, toolCall);\n\n\t\t\t// Execute with validated, typed arguments\n\t\t\tresultOrError = await tool.execute(toolCall.id, validatedArgs, signal);\n\t\t} catch (e) {\n\t\t\tresultOrError = e instanceof Error ? e.message : String(e);\n\t\t\tisError = true;\n\t\t}\n\n\t\tstream.push({\n\t\t\ttype: \"tool_execution_end\",\n\t\t\ttoolCallId: toolCall.id,\n\t\t\ttoolName: toolCall.name,\n\t\t\tresult: resultOrError,\n\t\t\tisError,\n\t\t});\n\n\t\tconst toolResultMessage: ToolResultMessage<T> = {\n\t\t\trole: \"toolResult\",\n\t\t\ttoolCallId: toolCall.id,\n\t\t\ttoolName: toolCall.name,\n\t\t\toutput: typeof resultOrError === \"string\" ? resultOrError : resultOrError.output,\n\t\t\tdetails: typeof resultOrError === \"string\" ? ({} as T) : resultOrError.details,\n\t\t\tisError,\n\t\t};\n\n\t\tresults.push(toolResultMessage);\n\t\tstream.push({ type: \"message_start\", message: toolResultMessage });\n\t\tstream.push({ type: \"message_end\", message: toolResultMessage });\n\t}\n\n\treturn results;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"agent-loop.js","sourceRoot":"","sources":["../../src/agent/agent-loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,0B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C,CAAC;YAC3D,OAAO,GAAG,IAAI,CAAC;QAChB,CAAC;QAED,MAAM,CAAC,IAAI,CAAC;YACX,IAAI,EAAE,oBAAoB;YAC1B,UAAU,EAAE,QAAQ,CAAC,EAAE;YACvB,QAAQ,EAAE,QAAQ,CAAC,IAAI;YACvB,MAAM,EAAE,aAAa;YACrB,OAAO;SACP,CAAC,CAAC;QAEH,MAAM,iBAAiB,GAAyB;YAC/C,IAAI,EAAE,YAAY;YAClB,UAAU,EAAE,QAAQ,CAAC,EAAE;YACvB,QAAQ,EAAE,QAAQ,CAAC,IAAI;YACvB,MAAM,EAAE,OAAO,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM;YAChF,OAAO,EAAE,OAAO,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAE,EAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO;YAC9E,OAAO;YACP,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACrB,CAAC;QAEF,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC,CAAC;QACnE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import { streamSimple } from \"../stream.js\";\nimport type { AssistantMessage, Context, Message, ToolResultMessage, UserMessage } from \"../types.js\";\nimport { EventStream } from \"../utils/event-stream.js\";\nimport { validateToolArguments } from \"../utils/validation.js\";\nimport type { AgentContext, AgentEvent, AgentLoopConfig, AgentTool, AgentToolResult, QueuedMessage } from \"./types.js\";\n\n// Main prompt function - returns a stream of events\nexport function agentLoop(\n\tprompt: UserMessage,\n\tcontext: AgentContext,\n\tconfig: AgentLoopConfig,\n\tsignal?: AbortSignal,\n\tstreamFn?: typeof streamSimple,\n): EventStream<AgentEvent, AgentContext[\"messages\"]> {\n\tconst stream = new EventStream<AgentEvent, AgentContext[\"messages\"]>(\n\t\t(event: AgentEvent) => event.type === \"agent_end\",\n\t\t(event: AgentEvent) => (event.type === \"agent_end\" ? event.messages : []),\n\t);\n\n\t// Run the prompt async\n\t(async () => {\n\t\t// Track new messages generated during this prompt\n\t\tconst newMessages: AgentContext[\"messages\"] = [];\n\t\t// Create user message for the prompt\n\t\tconst messages = [...context.messages, prompt];\n\t\tnewMessages.push(prompt);\n\n\t\tstream.push({ type: \"agent_start\" });\n\t\tstream.push({ type: \"turn_start\" });\n\t\tstream.push({ type: \"message_start\", message: prompt });\n\t\tstream.push({ type: \"message_end\", message: prompt });\n\n\t\t// Update context with new messages\n\t\tconst currentContext: AgentContext = {\n\t\t\t...context,\n\t\t\tmessages,\n\t\t};\n\n\t\t// Keep looping while we have tool calls or queued messages\n\t\tlet hasMoreToolCalls = true;\n\t\tlet firstTurn = true;\n\t\tlet queuedMessages: QueuedMessage<any>[] = (await config.getQueuedMessages?.()) || [];\n\n\t\twhile (hasMoreToolCalls || queuedMessages.length > 0) {\n\t\t\tif (!firstTurn) {\n\t\t\t\tstream.push({ type: \"turn_start\" });\n\t\t\t} else {\n\t\t\t\tfirstTurn = false;\n\t\t\t}\n\n\t\t\t// Process queued messages first (inject before next assistant response)\n\t\t\tif (queuedMessages.length > 0) {\n\t\t\t\tfor (const { original, llm } of queuedMessages) {\n\t\t\t\t\tstream.push({ type: \"message_start\", message: original });\n\t\t\t\t\tstream.push({ type: \"message_end\", message: original });\n\t\t\t\t\tif (llm) {\n\t\t\t\t\t\tcurrentContext.messages.push(llm);\n\t\t\t\t\t\tnewMessages.push(llm);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tqueuedMessages = [];\n\t\t\t}\n\n\t\t\t// console.log(\"agent-loop: \", [...currentContext.messages]);\n\n\t\t\t// Stream assistant response\n\t\t\tconst message = await streamAssistantResponse(currentContext, config, signal, stream, streamFn);\n\t\t\tnewMessages.push(message);\n\n\t\t\tif (message.stopReason === \"error\" || message.stopReason === \"aborted\") {\n\t\t\t\t// Stop the loop on error or abort\n\t\t\t\tstream.push({ type: \"turn_end\", message, toolResults: [] });\n\t\t\t\tstream.push({ type: \"agent_end\", messages: newMessages });\n\t\t\t\tstream.end(newMessages);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Check for tool calls\n\t\t\tconst toolCalls = message.content.filter((c) => c.type === \"toolCall\");\n\t\t\thasMoreToolCalls = toolCalls.length > 0;\n\n\t\t\tconst toolResults: ToolResultMessage[] = [];\n\t\t\tif (hasMoreToolCalls) {\n\t\t\t\t// Execute tool calls\n\t\t\t\ttoolResults.push(...(await executeToolCalls(currentContext.tools, message, signal, stream)));\n\t\t\t\tcurrentContext.messages.push(...toolResults);\n\t\t\t\tnewMessages.push(...toolResults);\n\t\t\t}\n\t\t\tstream.push({ type: \"turn_end\", message, toolResults: toolResults });\n\n\t\t\t// Get queued messages after turn completes\n\t\t\tqueuedMessages = (await config.getQueuedMessages?.()) || [];\n\t\t}\n\t\tstream.push({ type: \"agent_end\", messages: newMessages });\n\t\tstream.end(newMessages);\n\t})();\n\n\treturn stream;\n}\n\n// Helper functions\nasync function streamAssistantResponse(\n\tcontext: AgentContext,\n\tconfig: AgentLoopConfig,\n\tsignal: AbortSignal | undefined,\n\tstream: EventStream<AgentEvent, AgentContext[\"messages\"]>,\n\tstreamFn?: typeof streamSimple,\n): Promise<AssistantMessage> {\n\t// Convert AgentContext to Context for streamSimple\n\t// Use a copy of messages to avoid mutating the original context\n\tconst processedMessages = config.preprocessor\n\t\t? await config.preprocessor(context.messages, signal)\n\t\t: [...context.messages];\n\tconst processedContext: Context = {\n\t\tsystemPrompt: context.systemPrompt,\n\t\tmessages: [...processedMessages].map((m) => {\n\t\t\tif (m.role === \"toolResult\") {\n\t\t\t\tconst { details, ...rest } = m;\n\t\t\t\treturn rest;\n\t\t\t} else {\n\t\t\t\treturn m;\n\t\t\t}\n\t\t}),\n\t\ttools: context.tools, // AgentTool extends Tool, so this works\n\t};\n\n\t// Use custom stream function if provided, otherwise use default streamSimple\n\tconst streamFunction = streamFn || streamSimple;\n\tconst response = await streamFunction(config.model, processedContext, { ...config, signal });\n\n\tlet partialMessage: AssistantMessage | null = null;\n\tlet addedPartial = false;\n\n\tfor await (const event of response) {\n\t\tswitch (event.type) {\n\t\t\tcase \"start\":\n\t\t\t\tpartialMessage = event.partial;\n\t\t\t\tcontext.messages.push(partialMessage);\n\t\t\t\taddedPartial = true;\n\t\t\t\tstream.push({ type: \"message_start\", message: { ...partialMessage } });\n\t\t\t\tbreak;\n\n\t\t\tcase \"text_start\":\n\t\t\tcase \"text_delta\":\n\t\t\tcase \"text_end\":\n\t\t\tcase \"thinking_start\":\n\t\t\tcase \"thinking_delta\":\n\t\t\tcase \"thinking_end\":\n\t\t\tcase \"toolcall_start\":\n\t\t\tcase \"toolcall_delta\":\n\t\t\tcase \"toolcall_end\":\n\t\t\t\tif (partialMessage) {\n\t\t\t\t\tpartialMessage = event.partial;\n\t\t\t\t\tcontext.messages[context.messages.length - 1] = partialMessage;\n\t\t\t\t\tstream.push({ type: \"message_update\", assistantMessageEvent: event, message: { ...partialMessage } });\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase \"done\":\n\t\t\tcase \"error\": {\n\t\t\t\tconst finalMessage = await response.result();\n\t\t\t\tif (addedPartial) {\n\t\t\t\t\tcontext.messages[context.messages.length - 1] = finalMessage;\n\t\t\t\t} else {\n\t\t\t\t\tcontext.messages.push(finalMessage);\n\t\t\t\t}\n\t\t\t\tstream.push({ type: \"message_end\", message: finalMessage });\n\t\t\t\treturn finalMessage;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn await response.result();\n}\n\nasync function executeToolCalls<T>(\n\ttools: AgentTool<any, T>[] | undefined,\n\tassistantMessage: AssistantMessage,\n\tsignal: AbortSignal | undefined,\n\tstream: EventStream<AgentEvent, Message[]>,\n): Promise<ToolResultMessage<T>[]> {\n\tconst toolCalls = assistantMessage.content.filter((c) => c.type === \"toolCall\");\n\tconst results: ToolResultMessage<any>[] = [];\n\n\tfor (const toolCall of toolCalls) {\n\t\tconst tool = tools?.find((t) => t.name === toolCall.name);\n\n\t\tstream.push({\n\t\t\ttype: \"tool_execution_start\",\n\t\t\ttoolCallId: toolCall.id,\n\t\t\ttoolName: toolCall.name,\n\t\t\targs: toolCall.arguments,\n\t\t});\n\n\t\tlet resultOrError: AgentToolResult<T> | string;\n\t\tlet isError = false;\n\n\t\ttry {\n\t\t\tif (!tool) throw new Error(`Tool ${toolCall.name} not found`);\n\n\t\t\t// Validate arguments using shared validation function\n\t\t\tconst validatedArgs = validateToolArguments(tool, toolCall);\n\n\t\t\t// Execute with validated, typed arguments\n\t\t\tresultOrError = await tool.execute(toolCall.id, validatedArgs, signal);\n\t\t} catch (e) {\n\t\t\tresultOrError = e instanceof Error ? e.message : String(e);\n\t\t\tisError = true;\n\t\t}\n\n\t\tstream.push({\n\t\t\ttype: \"tool_execution_end\",\n\t\t\ttoolCallId: toolCall.id,\n\t\t\ttoolName: toolCall.name,\n\t\t\tresult: resultOrError,\n\t\t\tisError,\n\t\t});\n\n\t\tconst toolResultMessage: ToolResultMessage<T> = {\n\t\t\trole: \"toolResult\",\n\t\t\ttoolCallId: toolCall.id,\n\t\t\ttoolName: toolCall.name,\n\t\t\toutput: typeof resultOrError === \"string\" ? resultOrError : resultOrError.output,\n\t\t\tdetails: typeof resultOrError === \"string\" ? ({} as T) : resultOrError.details,\n\t\t\tisError,\n\t\t\ttimestamp: Date.now(),\n\t\t};\n\n\t\tresults.push(toolResultMessage);\n\t\tstream.push({ type: \"message_start\", message: toolResultMessage });\n\t\tstream.push({ type: \"message_end\", message: toolResultMessage });\n\t}\n\n\treturn results;\n}\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export declare const MODELS: {
|
|
2
2
|
readonly anthropic: {
|
|
3
|
-
readonly "claude-
|
|
3
|
+
readonly "claude-opus-4-0": {
|
|
4
4
|
id: string;
|
|
5
5
|
name: string;
|
|
6
6
|
api: "anthropic-messages";
|
|
7
7
|
provider: string;
|
|
8
8
|
baseUrl: string;
|
|
9
|
-
reasoning:
|
|
9
|
+
reasoning: true;
|
|
10
10
|
input: ("text" | "image")[];
|
|
11
11
|
cost: {
|
|
12
12
|
input: number;
|
|
@@ -17,7 +17,7 @@ export declare const MODELS: {
|
|
|
17
17
|
contextWindow: number;
|
|
18
18
|
maxTokens: number;
|
|
19
19
|
};
|
|
20
|
-
readonly "claude-3-5-sonnet-
|
|
20
|
+
readonly "claude-3-5-sonnet-20241022": {
|
|
21
21
|
id: string;
|
|
22
22
|
name: string;
|
|
23
23
|
api: "anthropic-messages";
|
|
@@ -34,13 +34,13 @@ export declare const MODELS: {
|
|
|
34
34
|
contextWindow: number;
|
|
35
35
|
maxTokens: number;
|
|
36
36
|
};
|
|
37
|
-
readonly "claude-
|
|
37
|
+
readonly "claude-opus-4-1": {
|
|
38
38
|
id: string;
|
|
39
39
|
name: string;
|
|
40
40
|
api: "anthropic-messages";
|
|
41
41
|
provider: string;
|
|
42
42
|
baseUrl: string;
|
|
43
|
-
reasoning:
|
|
43
|
+
reasoning: true;
|
|
44
44
|
input: ("text" | "image")[];
|
|
45
45
|
cost: {
|
|
46
46
|
input: number;
|
|
@@ -51,7 +51,7 @@ export declare const MODELS: {
|
|
|
51
51
|
contextWindow: number;
|
|
52
52
|
maxTokens: number;
|
|
53
53
|
};
|
|
54
|
-
readonly "claude-
|
|
54
|
+
readonly "claude-haiku-4-5": {
|
|
55
55
|
id: string;
|
|
56
56
|
name: string;
|
|
57
57
|
api: "anthropic-messages";
|
|
@@ -68,13 +68,13 @@ export declare const MODELS: {
|
|
|
68
68
|
contextWindow: number;
|
|
69
69
|
maxTokens: number;
|
|
70
70
|
};
|
|
71
|
-
readonly "claude-sonnet-
|
|
71
|
+
readonly "claude-3-5-sonnet-20240620": {
|
|
72
72
|
id: string;
|
|
73
73
|
name: string;
|
|
74
74
|
api: "anthropic-messages";
|
|
75
75
|
provider: string;
|
|
76
76
|
baseUrl: string;
|
|
77
|
-
reasoning:
|
|
77
|
+
reasoning: false;
|
|
78
78
|
input: ("text" | "image")[];
|
|
79
79
|
cost: {
|
|
80
80
|
input: number;
|
|
@@ -85,13 +85,13 @@ export declare const MODELS: {
|
|
|
85
85
|
contextWindow: number;
|
|
86
86
|
maxTokens: number;
|
|
87
87
|
};
|
|
88
|
-
readonly "claude-
|
|
88
|
+
readonly "claude-3-5-haiku-latest": {
|
|
89
89
|
id: string;
|
|
90
90
|
name: string;
|
|
91
91
|
api: "anthropic-messages";
|
|
92
92
|
provider: string;
|
|
93
93
|
baseUrl: string;
|
|
94
|
-
reasoning:
|
|
94
|
+
reasoning: false;
|
|
95
95
|
input: ("text" | "image")[];
|
|
96
96
|
cost: {
|
|
97
97
|
input: number;
|
|
@@ -102,7 +102,7 @@ export declare const MODELS: {
|
|
|
102
102
|
contextWindow: number;
|
|
103
103
|
maxTokens: number;
|
|
104
104
|
};
|
|
105
|
-
readonly "claude-3-
|
|
105
|
+
readonly "claude-3-opus-20240229": {
|
|
106
106
|
id: string;
|
|
107
107
|
name: string;
|
|
108
108
|
api: "anthropic-messages";
|
|
@@ -119,13 +119,13 @@ export declare const MODELS: {
|
|
|
119
119
|
contextWindow: number;
|
|
120
120
|
maxTokens: number;
|
|
121
121
|
};
|
|
122
|
-
readonly "claude-
|
|
122
|
+
readonly "claude-sonnet-4-5": {
|
|
123
123
|
id: string;
|
|
124
124
|
name: string;
|
|
125
125
|
api: "anthropic-messages";
|
|
126
126
|
provider: string;
|
|
127
127
|
baseUrl: string;
|
|
128
|
-
reasoning:
|
|
128
|
+
reasoning: true;
|
|
129
129
|
input: ("text" | "image")[];
|
|
130
130
|
cost: {
|
|
131
131
|
input: number;
|
|
@@ -136,7 +136,7 @@ export declare const MODELS: {
|
|
|
136
136
|
contextWindow: number;
|
|
137
137
|
maxTokens: number;
|
|
138
138
|
};
|
|
139
|
-
readonly "claude-
|
|
139
|
+
readonly "claude-sonnet-4-5-20250929": {
|
|
140
140
|
id: string;
|
|
141
141
|
name: string;
|
|
142
142
|
api: "anthropic-messages";
|
|
@@ -153,7 +153,7 @@ export declare const MODELS: {
|
|
|
153
153
|
contextWindow: number;
|
|
154
154
|
maxTokens: number;
|
|
155
155
|
};
|
|
156
|
-
readonly "claude-
|
|
156
|
+
readonly "claude-sonnet-4-20250514": {
|
|
157
157
|
id: string;
|
|
158
158
|
name: string;
|
|
159
159
|
api: "anthropic-messages";
|
|
@@ -170,13 +170,13 @@ export declare const MODELS: {
|
|
|
170
170
|
contextWindow: number;
|
|
171
171
|
maxTokens: number;
|
|
172
172
|
};
|
|
173
|
-
readonly "claude-
|
|
173
|
+
readonly "claude-opus-4-20250514": {
|
|
174
174
|
id: string;
|
|
175
175
|
name: string;
|
|
176
176
|
api: "anthropic-messages";
|
|
177
177
|
provider: string;
|
|
178
178
|
baseUrl: string;
|
|
179
|
-
reasoning:
|
|
179
|
+
reasoning: true;
|
|
180
180
|
input: ("text" | "image")[];
|
|
181
181
|
cost: {
|
|
182
182
|
input: number;
|
|
@@ -187,13 +187,13 @@ export declare const MODELS: {
|
|
|
187
187
|
contextWindow: number;
|
|
188
188
|
maxTokens: number;
|
|
189
189
|
};
|
|
190
|
-
readonly "claude-
|
|
190
|
+
readonly "claude-3-5-haiku-20241022": {
|
|
191
191
|
id: string;
|
|
192
192
|
name: string;
|
|
193
193
|
api: "anthropic-messages";
|
|
194
194
|
provider: string;
|
|
195
195
|
baseUrl: string;
|
|
196
|
-
reasoning:
|
|
196
|
+
reasoning: false;
|
|
197
197
|
input: ("text" | "image")[];
|
|
198
198
|
cost: {
|
|
199
199
|
input: number;
|
|
@@ -204,13 +204,13 @@ export declare const MODELS: {
|
|
|
204
204
|
contextWindow: number;
|
|
205
205
|
maxTokens: number;
|
|
206
206
|
};
|
|
207
|
-
readonly "claude-
|
|
207
|
+
readonly "claude-3-haiku-20240307": {
|
|
208
208
|
id: string;
|
|
209
209
|
name: string;
|
|
210
210
|
api: "anthropic-messages";
|
|
211
211
|
provider: string;
|
|
212
212
|
baseUrl: string;
|
|
213
|
-
reasoning:
|
|
213
|
+
reasoning: false;
|
|
214
214
|
input: ("text" | "image")[];
|
|
215
215
|
cost: {
|
|
216
216
|
input: number;
|
|
@@ -221,7 +221,7 @@ export declare const MODELS: {
|
|
|
221
221
|
contextWindow: number;
|
|
222
222
|
maxTokens: number;
|
|
223
223
|
};
|
|
224
|
-
readonly "claude-3-7-sonnet-
|
|
224
|
+
readonly "claude-3-7-sonnet-20250219": {
|
|
225
225
|
id: string;
|
|
226
226
|
name: string;
|
|
227
227
|
api: "anthropic-messages";
|
|
@@ -238,7 +238,7 @@ export declare const MODELS: {
|
|
|
238
238
|
contextWindow: number;
|
|
239
239
|
maxTokens: number;
|
|
240
240
|
};
|
|
241
|
-
readonly "claude-sonnet-
|
|
241
|
+
readonly "claude-3-7-sonnet-latest": {
|
|
242
242
|
id: string;
|
|
243
243
|
name: string;
|
|
244
244
|
api: "anthropic-messages";
|
|
@@ -255,13 +255,13 @@ export declare const MODELS: {
|
|
|
255
255
|
contextWindow: number;
|
|
256
256
|
maxTokens: number;
|
|
257
257
|
};
|
|
258
|
-
readonly "claude-
|
|
258
|
+
readonly "claude-sonnet-4-0": {
|
|
259
259
|
id: string;
|
|
260
260
|
name: string;
|
|
261
261
|
api: "anthropic-messages";
|
|
262
262
|
provider: string;
|
|
263
263
|
baseUrl: string;
|
|
264
|
-
reasoning:
|
|
264
|
+
reasoning: true;
|
|
265
265
|
input: ("text" | "image")[];
|
|
266
266
|
cost: {
|
|
267
267
|
input: number;
|
|
@@ -272,7 +272,7 @@ export declare const MODELS: {
|
|
|
272
272
|
contextWindow: number;
|
|
273
273
|
maxTokens: number;
|
|
274
274
|
};
|
|
275
|
-
readonly "claude-
|
|
275
|
+
readonly "claude-opus-4-1-20250805": {
|
|
276
276
|
id: string;
|
|
277
277
|
name: string;
|
|
278
278
|
api: "anthropic-messages";
|
|
@@ -289,13 +289,13 @@ export declare const MODELS: {
|
|
|
289
289
|
contextWindow: number;
|
|
290
290
|
maxTokens: number;
|
|
291
291
|
};
|
|
292
|
-
readonly "claude-
|
|
292
|
+
readonly "claude-3-sonnet-20240229": {
|
|
293
293
|
id: string;
|
|
294
294
|
name: string;
|
|
295
295
|
api: "anthropic-messages";
|
|
296
296
|
provider: string;
|
|
297
297
|
baseUrl: string;
|
|
298
|
-
reasoning:
|
|
298
|
+
reasoning: false;
|
|
299
299
|
input: ("text" | "image")[];
|
|
300
300
|
cost: {
|
|
301
301
|
input: number;
|
|
@@ -306,7 +306,7 @@ export declare const MODELS: {
|
|
|
306
306
|
contextWindow: number;
|
|
307
307
|
maxTokens: number;
|
|
308
308
|
};
|
|
309
|
-
readonly "claude-
|
|
309
|
+
readonly "claude-haiku-4-5-20251001": {
|
|
310
310
|
id: string;
|
|
311
311
|
name: string;
|
|
312
312
|
api: "anthropic-messages";
|
|
@@ -1799,6 +1799,23 @@ export declare const MODELS: {
|
|
|
1799
1799
|
};
|
|
1800
1800
|
};
|
|
1801
1801
|
readonly openrouter: {
|
|
1802
|
+
readonly "minimax/minimax-m2:free": {
|
|
1803
|
+
id: string;
|
|
1804
|
+
name: string;
|
|
1805
|
+
api: "openai-completions";
|
|
1806
|
+
provider: string;
|
|
1807
|
+
baseUrl: string;
|
|
1808
|
+
reasoning: true;
|
|
1809
|
+
input: "text"[];
|
|
1810
|
+
cost: {
|
|
1811
|
+
input: number;
|
|
1812
|
+
output: number;
|
|
1813
|
+
cacheRead: number;
|
|
1814
|
+
cacheWrite: number;
|
|
1815
|
+
};
|
|
1816
|
+
contextWindow: number;
|
|
1817
|
+
maxTokens: number;
|
|
1818
|
+
};
|
|
1802
1819
|
readonly "openrouter/andromeda-alpha": {
|
|
1803
1820
|
id: string;
|
|
1804
1821
|
name: string;
|
|
@@ -1969,6 +1986,23 @@ export declare const MODELS: {
|
|
|
1969
1986
|
contextWindow: number;
|
|
1970
1987
|
maxTokens: number;
|
|
1971
1988
|
};
|
|
1989
|
+
readonly "z-ai/glm-4.6:exacto": {
|
|
1990
|
+
id: string;
|
|
1991
|
+
name: string;
|
|
1992
|
+
api: "openai-completions";
|
|
1993
|
+
provider: string;
|
|
1994
|
+
baseUrl: string;
|
|
1995
|
+
reasoning: true;
|
|
1996
|
+
input: "text"[];
|
|
1997
|
+
cost: {
|
|
1998
|
+
input: number;
|
|
1999
|
+
output: number;
|
|
2000
|
+
cacheRead: number;
|
|
2001
|
+
cacheWrite: number;
|
|
2002
|
+
};
|
|
2003
|
+
contextWindow: number;
|
|
2004
|
+
maxTokens: number;
|
|
2005
|
+
};
|
|
1972
2006
|
readonly "deepseek/deepseek-v3.2-exp": {
|
|
1973
2007
|
id: string;
|
|
1974
2008
|
name: string;
|
|
@@ -2009,7 +2043,7 @@ export declare const MODELS: {
|
|
|
2009
2043
|
api: "openai-completions";
|
|
2010
2044
|
provider: string;
|
|
2011
2045
|
baseUrl: string;
|
|
2012
|
-
reasoning:
|
|
2046
|
+
reasoning: false;
|
|
2013
2047
|
input: ("text" | "image")[];
|
|
2014
2048
|
cost: {
|
|
2015
2049
|
input: number;
|
|
@@ -2071,6 +2105,23 @@ export declare const MODELS: {
|
|
|
2071
2105
|
contextWindow: number;
|
|
2072
2106
|
maxTokens: number;
|
|
2073
2107
|
};
|
|
2108
|
+
readonly "deepseek/deepseek-v3.1-terminus:exacto": {
|
|
2109
|
+
id: string;
|
|
2110
|
+
name: string;
|
|
2111
|
+
api: "openai-completions";
|
|
2112
|
+
provider: string;
|
|
2113
|
+
baseUrl: string;
|
|
2114
|
+
reasoning: true;
|
|
2115
|
+
input: "text"[];
|
|
2116
|
+
cost: {
|
|
2117
|
+
input: number;
|
|
2118
|
+
output: number;
|
|
2119
|
+
cacheRead: number;
|
|
2120
|
+
cacheWrite: number;
|
|
2121
|
+
};
|
|
2122
|
+
contextWindow: number;
|
|
2123
|
+
maxTokens: number;
|
|
2124
|
+
};
|
|
2074
2125
|
readonly "alibaba/tongyi-deepresearch-30b-a3b:free": {
|
|
2075
2126
|
id: string;
|
|
2076
2127
|
name: string;
|
|
@@ -2258,6 +2309,23 @@ export declare const MODELS: {
|
|
|
2258
2309
|
contextWindow: number;
|
|
2259
2310
|
maxTokens: number;
|
|
2260
2311
|
};
|
|
2312
|
+
readonly "moonshotai/kimi-k2-0905:exacto": {
|
|
2313
|
+
id: string;
|
|
2314
|
+
name: string;
|
|
2315
|
+
api: "openai-completions";
|
|
2316
|
+
provider: string;
|
|
2317
|
+
baseUrl: string;
|
|
2318
|
+
reasoning: false;
|
|
2319
|
+
input: "text"[];
|
|
2320
|
+
cost: {
|
|
2321
|
+
input: number;
|
|
2322
|
+
output: number;
|
|
2323
|
+
cacheRead: number;
|
|
2324
|
+
cacheWrite: number;
|
|
2325
|
+
};
|
|
2326
|
+
contextWindow: number;
|
|
2327
|
+
maxTokens: number;
|
|
2328
|
+
};
|
|
2261
2329
|
readonly "deepcogito/cogito-v2-preview-llama-70b": {
|
|
2262
2330
|
id: string;
|
|
2263
2331
|
name: string;
|
|
@@ -2649,6 +2717,23 @@ export declare const MODELS: {
|
|
|
2649
2717
|
contextWindow: number;
|
|
2650
2718
|
maxTokens: number;
|
|
2651
2719
|
};
|
|
2720
|
+
readonly "qwen/qwen3-coder:exacto": {
|
|
2721
|
+
id: string;
|
|
2722
|
+
name: string;
|
|
2723
|
+
api: "openai-completions";
|
|
2724
|
+
provider: string;
|
|
2725
|
+
baseUrl: string;
|
|
2726
|
+
reasoning: true;
|
|
2727
|
+
input: "text"[];
|
|
2728
|
+
cost: {
|
|
2729
|
+
input: number;
|
|
2730
|
+
output: number;
|
|
2731
|
+
cacheRead: number;
|
|
2732
|
+
cacheWrite: number;
|
|
2733
|
+
};
|
|
2734
|
+
contextWindow: number;
|
|
2735
|
+
maxTokens: number;
|
|
2736
|
+
};
|
|
2652
2737
|
readonly "qwen/qwen3-235b-a22b-2507": {
|
|
2653
2738
|
id: string;
|
|
2654
2739
|
name: string;
|
|
@@ -2819,7 +2904,7 @@ export declare const MODELS: {
|
|
|
2819
2904
|
contextWindow: number;
|
|
2820
2905
|
maxTokens: number;
|
|
2821
2906
|
};
|
|
2822
|
-
readonly "mistralai/magistral-medium-2506": {
|
|
2907
|
+
readonly "mistralai/magistral-medium-2506:thinking": {
|
|
2823
2908
|
id: string;
|
|
2824
2909
|
name: string;
|
|
2825
2910
|
api: "openai-completions";
|
|
@@ -2836,7 +2921,7 @@ export declare const MODELS: {
|
|
|
2836
2921
|
contextWindow: number;
|
|
2837
2922
|
maxTokens: number;
|
|
2838
2923
|
};
|
|
2839
|
-
readonly "mistralai/magistral-medium-2506
|
|
2924
|
+
readonly "mistralai/magistral-medium-2506": {
|
|
2840
2925
|
id: string;
|
|
2841
2926
|
name: string;
|
|
2842
2927
|
api: "openai-completions";
|
|
@@ -3023,6 +3108,23 @@ export declare const MODELS: {
|
|
|
3023
3108
|
contextWindow: number;
|
|
3024
3109
|
maxTokens: number;
|
|
3025
3110
|
};
|
|
3111
|
+
readonly "qwen/qwen3-8b": {
|
|
3112
|
+
id: string;
|
|
3113
|
+
name: string;
|
|
3114
|
+
api: "openai-completions";
|
|
3115
|
+
provider: string;
|
|
3116
|
+
baseUrl: string;
|
|
3117
|
+
reasoning: true;
|
|
3118
|
+
input: "text"[];
|
|
3119
|
+
cost: {
|
|
3120
|
+
input: number;
|
|
3121
|
+
output: number;
|
|
3122
|
+
cacheRead: number;
|
|
3123
|
+
cacheWrite: number;
|
|
3124
|
+
};
|
|
3125
|
+
contextWindow: number;
|
|
3126
|
+
maxTokens: number;
|
|
3127
|
+
};
|
|
3026
3128
|
readonly "qwen/qwen3-14b": {
|
|
3027
3129
|
id: string;
|
|
3028
3130
|
name: string;
|
|
@@ -3703,7 +3805,7 @@ export declare const MODELS: {
|
|
|
3703
3805
|
contextWindow: number;
|
|
3704
3806
|
maxTokens: number;
|
|
3705
3807
|
};
|
|
3706
|
-
readonly "cohere/command-r-
|
|
3808
|
+
readonly "cohere/command-r-08-2024": {
|
|
3707
3809
|
id: string;
|
|
3708
3810
|
name: string;
|
|
3709
3811
|
api: "openai-completions";
|
|
@@ -3720,7 +3822,7 @@ export declare const MODELS: {
|
|
|
3720
3822
|
contextWindow: number;
|
|
3721
3823
|
maxTokens: number;
|
|
3722
3824
|
};
|
|
3723
|
-
readonly "cohere/command-r-08-2024": {
|
|
3825
|
+
readonly "cohere/command-r-plus-08-2024": {
|
|
3724
3826
|
id: string;
|
|
3725
3827
|
name: string;
|
|
3726
3828
|
api: "openai-completions";
|
|
@@ -3805,7 +3907,7 @@ export declare const MODELS: {
|
|
|
3805
3907
|
contextWindow: number;
|
|
3806
3908
|
maxTokens: number;
|
|
3807
3909
|
};
|
|
3808
|
-
readonly "meta-llama/llama-3.1-
|
|
3910
|
+
readonly "meta-llama/llama-3.1-70b-instruct": {
|
|
3809
3911
|
id: string;
|
|
3810
3912
|
name: string;
|
|
3811
3913
|
api: "openai-completions";
|
|
@@ -3822,7 +3924,7 @@ export declare const MODELS: {
|
|
|
3822
3924
|
contextWindow: number;
|
|
3823
3925
|
maxTokens: number;
|
|
3824
3926
|
};
|
|
3825
|
-
readonly "meta-llama/llama-3.1-
|
|
3927
|
+
readonly "meta-llama/llama-3.1-405b-instruct": {
|
|
3826
3928
|
id: string;
|
|
3827
3929
|
name: string;
|
|
3828
3930
|
api: "openai-completions";
|
|
@@ -3958,7 +4060,7 @@ export declare const MODELS: {
|
|
|
3958
4060
|
contextWindow: number;
|
|
3959
4061
|
maxTokens: number;
|
|
3960
4062
|
};
|
|
3961
|
-
readonly "meta-llama/llama-3-
|
|
4063
|
+
readonly "meta-llama/llama-3-70b-instruct": {
|
|
3962
4064
|
id: string;
|
|
3963
4065
|
name: string;
|
|
3964
4066
|
api: "openai-completions";
|
|
@@ -3975,7 +4077,7 @@ export declare const MODELS: {
|
|
|
3975
4077
|
contextWindow: number;
|
|
3976
4078
|
maxTokens: number;
|
|
3977
4079
|
};
|
|
3978
|
-
readonly "meta-llama/llama-3-
|
|
4080
|
+
readonly "meta-llama/llama-3-8b-instruct": {
|
|
3979
4081
|
id: string;
|
|
3980
4082
|
name: string;
|
|
3981
4083
|
api: "openai-completions";
|
|
@@ -4026,7 +4128,7 @@ export declare const MODELS: {
|
|
|
4026
4128
|
contextWindow: number;
|
|
4027
4129
|
maxTokens: number;
|
|
4028
4130
|
};
|
|
4029
|
-
readonly "mistralai/mistral-
|
|
4131
|
+
readonly "mistralai/mistral-tiny": {
|
|
4030
4132
|
id: string;
|
|
4031
4133
|
name: string;
|
|
4032
4134
|
api: "openai-completions";
|
|
@@ -4043,7 +4145,7 @@ export declare const MODELS: {
|
|
|
4043
4145
|
contextWindow: number;
|
|
4044
4146
|
maxTokens: number;
|
|
4045
4147
|
};
|
|
4046
|
-
readonly "mistralai/mistral-
|
|
4148
|
+
readonly "mistralai/mistral-small": {
|
|
4047
4149
|
id: string;
|
|
4048
4150
|
name: string;
|
|
4049
4151
|
api: "openai-completions";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.generated.d.ts","sourceRoot":"","sources":["../src/models.generated.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,MAAM
|
|
1
|
+
{"version":3,"file":"models.generated.d.ts","sourceRoot":"","sources":["../src/models.generated.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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