Skip to content

examples/tool-call-stream: Duplicates tool arguments #427

@tv42

Description

@tv42

I think this:

arguments: tool_call_data
.function
.as_ref()
.and_then(|f| f.arguments.clone())
.unwrap_or_default(),

and this:

if let Some(arguments) = tool_call_chunk
.function
.as_ref()
.and_then(|f| f.arguments.as_ref())
{
state.function.arguments.push_str(arguments);
}

store the arguments to a tool call twice. The later call to parse

let function_args: serde_json::Value = args.parse().unwrap();

fails:

thread 'tokio-runtime-worker' panicked at src/bin/tool-call-stream.rs:243:57:
called `Result::unwrap()` on an `Err` value: Error("trailing characters", line: 1, column: 23)

and printing out args at that point shows

args={"location":"Boston, MA"}{"location":"Boston, MA"}
args={"location":"Atlanta, GA"}{"location":"Atlanta, GA"}

Commenting out the second args storing with push_str fixes the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions