Compare commits

...

2 Commits

Author SHA1 Message Date
Happy-Engineer
97445758ed
Merge 3fd1f844ec into 4b2abf8ac2 2024-11-15 10:53:23 +08:00
郭卫东
3fd1f844ec fix: avoid got at least one message error when there was no user message for Claude llm 2024-09-27 09:29:01 +08:00

View File

@ -538,6 +538,10 @@ class AnthropicLargeLanguageModel(LargeLanguageModel):
else:
raise ValueError(f"Got unknown type {message}")
# if no user message, add a system message as the user message to avoid at least one message error
if not prompt_message_dicts:
prompt_message_dicts.append({"role": "user", "content": system})
return system, prompt_message_dicts
def _convert_one_message_to_text(self, message: PromptMessage) -> str: