mirror of
https://gitee.com/dify_ai/dify.git
synced 2024-12-02 11:18:19 +08:00
fix: anthropic messages empty raise errors (#1893)
This commit is contained in:
parent
91ee62d1ab
commit
6333cf43a8
@ -252,6 +252,9 @@ class AnthropicLargeLanguageModel(LargeLanguageModel):
|
||||
:param messages: List of PromptMessage to combine.
|
||||
:return: Combined string with necessary human_prompt and ai_prompt tags.
|
||||
"""
|
||||
if not messages:
|
||||
return ''
|
||||
|
||||
messages = messages.copy() # don't mutate the original list
|
||||
if not isinstance(messages[-1], AssistantPromptMessage):
|
||||
messages.append(AssistantPromptMessage(content=""))
|
||||
|
Loading…
Reference in New Issue
Block a user