From cc9d2697cc548a3363d15f45d00a7fe4cae6b67c Mon Sep 17 00:00:00 2001 From: mayfwl <1910527151@qq.com> Date: Sun, 15 Feb 2026 15:04:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20update=20AI=20chat=20and=20provider=20lo?= =?UTF-8?q?gic=20=E2=80=94=20disable=20tools=20for=20non-function=20callin?= =?UTF-8?q?g=20providers,=20ensure=20compatibility=20with=20openai-compati?= =?UTF-8?q?ble=20SDKs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/codeblog/src/ai/chat.ts | 5 ++++- packages/codeblog/src/ai/provider.ts | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/codeblog/src/ai/chat.ts b/packages/codeblog/src/ai/chat.ts index c1cd00e..1a630c3 100644 --- a/packages/codeblog/src/ai/chat.ts +++ b/packages/codeblog/src/ai/chat.ts @@ -52,7 +52,8 @@ export namespace AIChat { model, system: SYSTEM_PROMPT, messages: history, - tools: chatTools, + // Note: tools disabled for openai-compatible providers that don't support function calling + // tools: chatTools, maxSteps: 1, abortSignal: signal, }) @@ -60,7 +61,9 @@ export namespace AIChat { const calls: Array<{ id: string; name: string; input: unknown; output: unknown }> = [] try { + log.info("starting fullStream iteration") for await (const part of result.fullStream) { + log.info("stream part", { type: part.type }) if (signal?.aborted) break switch (part.type) { case "text-delta": { diff --git a/packages/codeblog/src/ai/provider.ts b/packages/codeblog/src/ai/provider.ts index 3822d04..be1061c 100644 --- a/packages/codeblog/src/ai/provider.ts +++ b/packages/codeblog/src/ai/provider.ts @@ -312,6 +312,10 @@ export namespace AIProvider { sdkCache.set(cacheKey, sdk) } + // For openai-compatible provider, use chatModel to ensure /v1/chat/completions endpoint + if (pkg === "@ai-sdk/openai-compatible" && typeof (sdk as any).chatModel === "function") { + return (sdk as any).chatModel(modelID) + } if (typeof (sdk as any).languageModel === "function") { return (sdk as any).languageModel(modelID) }