Skip to content

armgit / dify

Public Imported from GitHub
0

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.

fix: token count includes base64 string of input images (#5868)

Masashi Tomooka3b23d6764fba
diff --git a/api/core/model_runtime/model_providers/bedrock/llm/llm.py b/api/core/model_runtime/model_providers/bedrock/llm/llm.py
index f3ea705e19b..efb8c395fab 100644
--- a/api/core/model_runtime/model_providers/bedrock/llm/llm.py
+++ b/api/core/model_runtime/model_providers/bedrock/llm/llm.py
@@ -554,7 +554,10 @@ class BedrockLargeLanguageModel(LargeLanguageModel):
content = message.content
if isinstance(message, UserPromptMessage):
- message_text = f"{human_prompt_prefix} {content} {human_prompt_postfix}"
+ body = content
+ if (isinstance(content, list)):
+ body = "".join([c.data for c in content if c.type == PromptMessageContentType.TEXT])
+ message_text = f"{human_prompt_prefix} {body} {human_prompt_postfix}"
elif isinstance(message, AssistantPromptMessage):
message_text = f"{ai_prompt} {content}"
elif isinstance(message, SystemPromptMessage):