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

Message object does not have tool_call_id which is required when we add tool call message to history #325

Closed
gurvinder-dhillon opened this issue Oct 21, 2024 · 3 comments · May be fixed by #361

Comments

@gurvinder-dhillon
Copy link

Basically, if we add tool call to message history, it expects a follow up message that is tool result and it should have the tool_call_id.
Here is the reference - https://platform.openai.com/docs/guides/function-calling
and https://community.openai.com/t/formatting-assistant-messages-after-tool-function-calls-in-gpt-conversations/535360/2

BadRequestError: Error code: 400 - {'error': {'message': "Missing parameter 'tool_call_id': messages with role 'tool' must have a 'tool_call_id'.", 'type': 'invalid_request_error', 'param': 'messages.[3].tool_call_id', 'code': None}

@alex-dixon
Copy link
Contributor

@gurvinder-dhillon Are you using the collect and call tools method like this example https://github.com/MadcowD/ell/blob/main/examples/future/use_tool_once.py or something else?

gurvinder-dhillon added a commit to gurvinder-dhillon/ell that referenced this issue Nov 1, 2024
Fixes MadcowD#325

Add `tool_call_id` attribute to `Message` class and update methods to handle it.

* Add `tool_call_id` attribute to `Message` class in `src/ell/types/message.py`.
* Update `__init__` method in `Message` class to accept `tool_call_id` parameter.
* Update `model_validate` method in `Message` class to handle `tool_call_id`.
* Update `translate_to_provider` method in `src/ell/providers/openai.py` to add `tool_call_id` to `Message` object.
* Update `translate_from_provider` method in `src/ell/providers/openai.py` to process `tool_call_id` in `Message` object.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/MadcowD/ell/issues/325?shareId=XXXX-XXXX-XXXX-XXXX).
@MadcowD
Copy link
Owner

MadcowD commented Nov 5, 2024

Isn't tool call id already on the ToolCall object and ToolResult object. @alex-dixon's suggestion is the correct one.,

@MadcowD
Copy link
Owner

MadcowD commented Nov 14, 2024

Yeah it's in that content blopck object.

@MadcowD MadcowD closed this as completed Nov 14, 2024
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 a pull request may close this issue.

3 participants