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

feat: handle multiple tool calls #224

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vacekj
Copy link

@vacekj vacekj commented Jan 20, 2025

fixes #179

feedback wanted!

@vacekj vacekj marked this pull request as ready for review January 20, 2025 22:57
@0xMochan
Copy link
Contributor

Hey, thanks for this PR. I have a feeling this will greatly break with my upcoming #199 messages refactor. I'll keep an eye our on how this affects this PR and maybe can help rebase / merge from main to assist in the new messages layout.

@vacekj
Copy link
Author

vacekj commented Jan 24, 2025

@0xMochan sure, I will rebase periodically to ease the merge once you merge yours.

@0xMochan 0xMochan self-requested a review February 3, 2025 16:41
@0xMochan
Copy link
Contributor

0xMochan commented Feb 5, 2025

@0xMochan sure, I will rebase periodically to ease the merge once you merge yours.

Hey #199 was finally merged, please let me know if you need help rebasing or merging, it was quite an intense commit! Part of multi-tool-calling was resolved but not entirely.

@carlos-verdes
Copy link
Contributor

@vacekj check #290 I think you will like it

Comment on lines +226 to +227
/// Represents a completion response with multiple tool calls
MultipleToolCalls(Vec<ModelChoice>),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is not correct approach, from the model of OpenAI you can have just one message or 1 to many tool calls:
image

So I propose something like this:

#[derive(Debug)]
pub enum ModelChoice {
    /// Represents a completion response as a message
    Message(String),
    /// Represents a completion response as a tool call of the form
    /// `ToolCall(function_name, id, function_params)`.
    ToolCalls(OneOrMany<ToolCall>),
}

pub struct ToolCall {
    function_name: String, 
    id: String, 
    function_params: serde_json::Value)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Multiple tool calls in one completion response are not handled
4 participants