mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 04:29:07 +08:00
fix(anthropic_llm): Ignore non-text parts in the system prompt. (#11107)
This commit is contained in:
parent
cbb4e95928
commit
1db14793fa
@ -461,7 +461,15 @@ class AnthropicLargeLanguageModel(LargeLanguageModel):
|
|||||||
first_loop = True
|
first_loop = True
|
||||||
for message in prompt_messages:
|
for message in prompt_messages:
|
||||||
if isinstance(message, SystemPromptMessage):
|
if isinstance(message, SystemPromptMessage):
|
||||||
message.content = message.content.strip()
|
if isinstance(message.content, str):
|
||||||
|
message.content = message.content.strip()
|
||||||
|
elif isinstance(message.content, list):
|
||||||
|
# System prompt only support text
|
||||||
|
message.content = "".join(
|
||||||
|
c.data.strip() for c in message.content if isinstance(c, TextPromptMessageContent)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
raise ValueError(f"Unknown system prompt message content type {type(message.content)}")
|
||||||
if first_loop:
|
if first_loop:
|
||||||
system = message.content
|
system = message.content
|
||||||
first_loop = False
|
first_loop = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user