From 0b30dbb8dea93602c7d19ac6b7d033112c39719e Mon Sep 17 00:00:00 2001 From: ccnetcore Date: Wed, 4 Feb 2026 23:46:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AF=86=E5=88=ABClaude=E4=B8=8A?= =?UTF-8?q?=E4=B8=8B=E6=96=87=E8=B6=85=E9=99=90=E9=94=99=E8=AF=AF=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 补充对“input tokens exceeds the model's maximum context length”错误信息的判断,统一提示上下文过长的解决建议,提升异常提示准确性。 --- .../Impl/ThorClaude/Chats/AnthropicChatCompletionsService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiGateWay/Impl/ThorClaude/Chats/AnthropicChatCompletionsService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiGateWay/Impl/ThorClaude/Chats/AnthropicChatCompletionsService.cs index 8643cac2..4a2270c5 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiGateWay/Impl/ThorClaude/Chats/AnthropicChatCompletionsService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiGateWay/Impl/ThorClaude/Chats/AnthropicChatCompletionsService.cs @@ -77,7 +77,7 @@ public class AnthropicChatCompletionsService( var error = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); var message = $"恭喜你运气爆棚遇到了错误,尊享包对话异常:StatusCode【{response.StatusCode.GetHashCode()}】,ErrorId【{errorId}】"; - if (error.Contains("prompt is too long") || error.Contains("提示词太长")) + if (error.Contains("prompt is too long") || error.Contains("提示词太长")||error.Contains("input tokens exceeds the model's maximum context length")) { message += $", tip: 当前提示词过长,上下文已达到上限,如在 claudecode中使用,建议执行/compact压缩当前会话,或开启新会话后重试"; } @@ -128,7 +128,7 @@ public class AnthropicChatCompletionsService( var error = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); var message = $"恭喜你运气爆棚遇到了错误,尊享包对话异常:StatusCode【{response.StatusCode.GetHashCode()}】,ErrorId【{errorId}】"; - if (error.Contains("prompt is too long") || error.Contains("提示词太长")) + if (error.Contains("prompt is too long") || error.Contains("提示词太长")||error.Contains("input tokens exceeds the model's maximum context length")) { message += $", tip: 当前提示词过长,上下文已达到上限,如在 claudecode中使用,建议执行/compact压缩当前会话,或开启新会话后重试"; }