Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
Fix the situation where output_tokens/input_tokens may be None in response.usage (#10728)
Ding Jiatong3087913b7419
diff --git a/api/core/model_runtime/model_providers/anthropic/llm/llm.py b/api/core/model_runtime/model_providers/anthropic/llm/llm.pyindex 3a5a42ba05b..4e7faab891e 100644--- a/api/core/model_runtime/model_providers/anthropic/llm/llm.py+++ b/api/core/model_runtime/model_providers/anthropic/llm/llm.py@@ -325,14 +325,13 @@ class AnthropicLargeLanguageModel(LargeLanguageModel):assistant_prompt_message.tool_calls.append(tool_call)# calculate num tokens- if response.usage:- # transform usage- prompt_tokens = response.usage.input_tokens- completion_tokens = response.usage.output_tokens- else:- # calculate num tokens- prompt_tokens = self.get_num_tokens(model, credentials, prompt_messages)- completion_tokens = self.get_num_tokens(model, credentials, [assistant_prompt_message])+ prompt_tokens = (response.usage and response.usage.input_tokens) or self.get_num_tokens(+ model, credentials, prompt_messages+ )++ completion_tokens = (response.usage and response.usage.output_tokens) or self.get_num_tokens(+ model, credentials, [assistant_prompt_message]+ )# transform usageusage = self._calc_response_usage(model, credentials, prompt_tokens, completion_tokens)