mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-05 22:32:12 +00:00
refactor(providers): share anthropic tool payload helper
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { StreamFn } from "@mariozechner/pi-agent-core";
|
||||
import { streamSimple } from "@mariozechner/pi-ai";
|
||||
import { createAnthropicToolPayloadCompatibilityWrapper } from "openclaw/plugin-sdk/provider-stream";
|
||||
import { createOpenAIAnthropicToolPayloadCompatibilityWrapper } from "openclaw/plugin-sdk/provider-stream";
|
||||
|
||||
const TOOL_CALLS_SECTION_BEGIN = "<|tool_calls_section_begin|>";
|
||||
const TOOL_CALLS_SECTION_END = "<|tool_calls_section_end|>";
|
||||
@@ -183,9 +183,6 @@ export function createKimiToolCallMarkupWrapper(baseStreamFn: StreamFn | undefin
|
||||
|
||||
export function wrapKimiProviderStream(baseStreamFn: StreamFn | undefined): StreamFn {
|
||||
return createKimiToolCallMarkupWrapper(
|
||||
createAnthropicToolPayloadCompatibilityWrapper(baseStreamFn, {
|
||||
toolSchemaMode: "openai-functions",
|
||||
toolChoiceMode: "openai-string-modes",
|
||||
}),
|
||||
createOpenAIAnthropicToolPayloadCompatibilityWrapper(baseStreamFn),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,10 @@ import {
|
||||
resolveExtraParams,
|
||||
resolvePreparedExtraParams,
|
||||
} from "./pi-embedded-runner.js";
|
||||
import { createAnthropicToolPayloadCompatibilityWrapper } from "./pi-embedded-runner/anthropic-family-tool-payload-compat.js";
|
||||
import {
|
||||
createAnthropicToolPayloadCompatibilityWrapper,
|
||||
createOpenAIAnthropicToolPayloadCompatibilityWrapper,
|
||||
} from "./pi-embedded-runner/anthropic-family-tool-payload-compat.js";
|
||||
import {
|
||||
createBedrockNoCacheWrapper,
|
||||
isAnthropicBedrockModel,
|
||||
@@ -162,10 +165,7 @@ beforeEach(() => {
|
||||
);
|
||||
}
|
||||
if (params.provider === "kimi") {
|
||||
return createAnthropicToolPayloadCompatibilityWrapper(params.context.streamFn, {
|
||||
toolSchemaMode: "openai-functions",
|
||||
toolChoiceMode: "openai-string-modes",
|
||||
});
|
||||
return createOpenAIAnthropicToolPayloadCompatibilityWrapper(params.context.streamFn);
|
||||
}
|
||||
if (params.provider === "minimax" || params.provider === "minimax-portal") {
|
||||
return createMinimaxFastModeWrapper(
|
||||
|
||||
@@ -158,3 +158,12 @@ export function createAnthropicToolPayloadCompatibilityWrapper(
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function createOpenAIAnthropicToolPayloadCompatibilityWrapper(
|
||||
baseStreamFn: StreamFn | undefined,
|
||||
): StreamFn {
|
||||
return createAnthropicToolPayloadCompatibilityWrapper(baseStreamFn, {
|
||||
toolSchemaMode: "openai-functions",
|
||||
toolChoiceMode: "openai-string-modes",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,7 +27,10 @@ export {
|
||||
hasCopilotVisionInput,
|
||||
} from "../agents/copilot-dynamic-headers.js";
|
||||
export { applyAnthropicEphemeralCacheControlMarkers } from "../agents/pi-embedded-runner/anthropic-cache-control-payload.js";
|
||||
export { createAnthropicToolPayloadCompatibilityWrapper } from "../agents/pi-embedded-runner/anthropic-family-tool-payload-compat.js";
|
||||
export {
|
||||
createAnthropicToolPayloadCompatibilityWrapper,
|
||||
createOpenAIAnthropicToolPayloadCompatibilityWrapper,
|
||||
} from "../agents/pi-embedded-runner/anthropic-family-tool-payload-compat.js";
|
||||
export {
|
||||
createBedrockNoCacheWrapper,
|
||||
isAnthropicBedrockModel,
|
||||
|
||||
Reference in New Issue
Block a user