tool_parser/types.rs
1use serde::{Deserialize, Serialize};
2
3/// Parsed tool call from model output
4#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
5pub struct ToolCall {
6 /// Function call details
7 pub function: FunctionCall,
8}
9
10/// Function call within a tool call
11#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
12pub struct FunctionCall {
13 /// Name of the function to call
14 pub name: String,
15 /// Arguments as JSON string
16 pub arguments: String,
17}
18
19/// Result of streaming parse operation (matches Python StreamingParseResult)
20#[derive(Debug, Clone, Default)]
21pub struct StreamingParseResult {
22 /// Normal text that's not part of tool calls
23 pub normal_text: String,
24 /// Tool call items parsed from the chunk
25 pub calls: Vec<ToolCallItem>,
26}
27
28/// Simple encapsulation of parsed tool call for streaming (matches Python ToolCallItem)
29#[derive(Debug, Clone)]
30pub struct ToolCallItem {
31 /// Tool index in the array
32 pub tool_index: usize,
33 /// Tool name (only present on first chunk)
34 pub name: Option<String>,
35 /// Incremental JSON arguments
36 pub parameters: String,
37}