mirror of
https://github.com/enricoros/big-AGI.git
synced 2026-05-10 21:50:14 -07:00
AIX: Anthropic: auto-header for programmatic tool calling (calling from code, not just llm)
This commit is contained in:
@@ -49,14 +49,24 @@ export function createChatGenerateDispatch(access: AixAPI_Access, model: AixAPI_
|
||||
const { dialect } = access;
|
||||
switch (dialect) {
|
||||
case 'anthropic': {
|
||||
|
||||
// [Anthropic, 2025-11-24] Detect if any tool uses Programmatic Tool Calling features (allowed_callers, input_examples)
|
||||
const usesProgrammaticToolCalling = chatGenerate.tools?.some(tool =>
|
||||
tool.type === 'function_call' && (
|
||||
tool.function_call.allowed_callers?.includes('code_execution') ||
|
||||
(tool.function_call.input_examples && tool.function_call.input_examples.length > 0)
|
||||
),
|
||||
) ?? false;
|
||||
|
||||
const anthropicRequest = anthropicAccess(access, '/v1/messages', {
|
||||
modelIdForBetaFeatures: model.id,
|
||||
vndAntWebFetch: model.vndAntWebFetch === 'auto',
|
||||
vndAnt1MContext: model.vndAnt1MContext === true,
|
||||
vndAntEffort: !!model.vndAntEffort,
|
||||
enableSkills: !!model.vndAntSkills,
|
||||
enableToolSearch: !!model.vndAntToolSearch,
|
||||
enableStrictOutputs: !!model.strictJsonOutput || !!model.strictToolInvocations, // [Anthropic, 2025-11-13] for both JSON output and grammar-constrained tool invocations inputs
|
||||
enableToolSearch: !!model.vndAntToolSearch,
|
||||
enableProgrammaticToolCalling: usesProgrammaticToolCalling,
|
||||
// enableCodeExecution: ...
|
||||
});
|
||||
|
||||
|
||||
@@ -77,8 +77,9 @@ export type AnthropicHeaderOptions = {
|
||||
vndAntEffort?: boolean; // [Anthropic, effort-2025-11-24]
|
||||
enableSkills?: boolean;
|
||||
enableCodeExecution?: boolean;
|
||||
enableToolSearch?: boolean; // [Anthropic, 2025-11-24] Tool Search Tool
|
||||
enableStrictOutputs?: boolean; // [Anthropic, 2025-11-13] Structured Outputs (JSON outputs & strict tool use)
|
||||
enableToolSearch?: boolean; // [Anthropic, 2025-11-24] Tool Search Tool
|
||||
enableProgrammaticToolCalling?: boolean; // [Anthropic, 2025-11-24] Programmatic Tool Calling (allowed_callers, input_examples)
|
||||
clientSideFetch?: boolean; // whether the request will be made from client-side (browser) - adds CORS header
|
||||
};
|
||||
|
||||
@@ -163,8 +164,9 @@ function _anthropicHeaders(options?: AnthropicHeaderOptions): Record<string, str
|
||||
if (options?.vndAntEffort)
|
||||
betaFeatures.push('effort-2025-11-24');
|
||||
|
||||
// [Anthropic, 2025-11-24] Add beta feature for Tool Search Tool (Claude Opus 4.5, Sonnet 4.5)
|
||||
if (options?.enableToolSearch)
|
||||
// [Anthropic, 2025-11-24] Add beta feature for Advanced Tool Use (Tool Search Tool, Programmatic Tool Calling)
|
||||
// Same beta header covers both features: tool discovery and programmatic calling from code execution
|
||||
if (options?.enableToolSearch || options?.enableProgrammaticToolCalling)
|
||||
betaFeatures.push('advanced-tool-use-2025-11-20');
|
||||
|
||||
// [Anthropic, 2025-11-13] Add beta feature for Structured Outputs (JSON outputs & strict tool use)
|
||||
|
||||
Reference in New Issue
Block a user