Skip to main content

openai_protocol/
parser.rs

1use serde::{Deserialize, Serialize};
2
3use crate::common::Tool;
4
5/// Request to parse function calls from model output text.
6#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
7pub struct ParseFunctionCallRequest {
8    /// The text to parse for function calls.
9    pub text: String,
10    /// The parser type/name to use for parsing (e.g., "json", "pythonic").
11    pub tool_call_parser: String,
12    /// The list of available tools that the model can call.
13    pub tools: Vec<Tool>,
14}
15
16/// Response from parsing function calls.
17#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
18pub struct ParseFunctionCallResponse {
19    /// Remaining text after extracting function calls.
20    pub remaining_text: String,
21    /// Extracted tool calls.
22    pub tool_calls: Vec<serde_json::Value>,
23    /// Whether parsing succeeded.
24    pub success: bool,
25}
26
27/// Request to separate reasoning from normal text in model output.
28#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
29pub struct SeparateReasoningRequest {
30    /// The text to parse for reasoning content.
31    pub text: String,
32    /// The parser type/name to use for reasoning detection (e.g., "step3", "deepseek_r1").
33    pub reasoning_parser: String,
34}
35
36/// Response from separating reasoning.
37#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
38pub struct SeparateReasoningResponse {
39    /// Normal (non-reasoning) text.
40    pub normal_text: String,
41    /// Extracted reasoning text.
42    pub reasoning_text: String,
43    /// Whether parsing succeeded.
44    pub success: bool,
45}