Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type mismatch in system message handling for Claude API #109

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions utils/pipelines/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ def get_last_assistant_message(messages: List[dict]) -> str:
return None


def get_system_message(messages: List[dict]) -> dict:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_system_message should return message dict

feel free to create get_system_message_content util to meet your needs.

def get_system_message(messages: List[dict]) -> str:
for message in messages:
if message["role"] == "system":
return message
if isinstance(message["content"], list):
for item in message["content"]:
if item["type"] == "text":
return item["text"]
return message["content"]
return None


Expand Down