Skip to content

Fix OpenAI ChatCompletion message content format issue #106

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

Merged
merged 1 commit into from
Apr 8, 2025

Conversation

askme765cs
Copy link
Contributor

  • Modified execute_tool_call method in OpenAIAugmentedLLM to convert content list to string
  • Used "\n".join() to concatenate list items into a single string
  • This addresses issue content in OpenAI ChatCompletion messages is a list, not string #25 where OpenAI API rejects list-type content
  • Follows OpenAI API specification requiring content to be string or null
  • Prevents errors with LLMs like deepseek that strictly validate input format

The change ensures compatibility with OpenAI's API requirements which specify: "content can only be a string or null. It cannot be a list, object, or any other type."

- Modified `execute_tool_call` method in OpenAIAugmentedLLM to convert content list to string
- Used "\n".join() to concatenate list items into a single string
- This addresses issue lastmile-ai#25 where OpenAI API rejects list-type content
- Follows OpenAI API specification requiring content to be string or null
- Prevents errors with LLMs like deepseek that strictly validate input format

The change ensures compatibility with OpenAI's API requirements which specify:
"content can only be a string or null. It cannot be a list, object, or any other type."
Copy link
Collaborator

@saqadri saqadri left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution, @askme765cs! Merging this in, though there may be a wider fix that may be needed to follow the pattern from @StreetLamb's latest fix in the Anthropic class.

@saqadri saqadri merged commit 2d93a6b into lastmile-ai:main Apr 8, 2025
4 checks passed
saqadri pushed a commit that referenced this pull request Apr 17, 2025
- Modified `execute_tool_call` method in OpenAIAugmentedLLM to convert content list to string
- Used "\n".join() to concatenate list items into a single string
- This addresses issue #25 where OpenAI API rejects list-type content
- Follows OpenAI API specification requiring content to be string or null
- Prevents errors with LLMs like deepseek that strictly validate input format

The change ensures compatibility with OpenAI's API requirements which specify:
"content can only be a string or null. It cannot be a list, object, or any other type."

Co-authored-by: ask <[email protected]>
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.

2 participants