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 append_message #1223

Closed
wants to merge 2 commits into from
Closed

fix append_message #1223

wants to merge 2 commits into from

Conversation

yiranwu0
Copy link
Contributor

Handle error: InvalidRequestError: Invalid parameter: only messages with role 'assistant' can have a function call.

Why are these changes needed?

Related issue number

Checks

@sonichi
Copy link
Contributor

sonichi commented Sep 23, 2023

Please make PR in the new repo https://github.com/microsoft/autogen

@@ -275,6 +275,8 @@ def _append_oai_message(self, message: Union[Dict, str], role, conversation_id:
return False

oai_message["role"] = "function" if message.get("role") == "function" else role
if "function_call" in oai_message:
oai_message["role"] = "assistant" # only messages with role 'assistant' can have a function call.
Copy link
Contributor

Choose a reason for hiding this comment

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

Raise a warning when this condition is triggered. The warning msg should print the original value for the "role" field and inform the users that the original value is changed to "assistant" because messages with the role 'assistant' can have a function call.

@yiranwu0 yiranwu0 closed this Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants