tool_parser/parsers/
passthrough.rs1use async_trait::async_trait;
8use openai_protocol::common::Tool;
9
10use crate::{
11 errors::ParserResult,
12 traits::ToolParser,
13 types::{StreamingParseResult, ToolCall, ToolCallItem},
14};
15
16#[derive(Default)]
18pub(crate) struct PassthroughParser;
19
20impl PassthroughParser {
21 pub fn new() -> Self {
22 Self
23 }
24}
25
26#[async_trait]
27impl ToolParser for PassthroughParser {
28 async fn parse_complete(&self, output: &str) -> ParserResult<(String, Vec<ToolCall>)> {
29 Ok((output.to_string(), vec![]))
31 }
32
33 async fn parse_incremental(
34 &mut self,
35 chunk: &str,
36 _tools: &[Tool],
37 ) -> ParserResult<StreamingParseResult> {
38 Ok(StreamingParseResult {
40 normal_text: chunk.to_string(),
41 calls: vec![],
42 })
43 }
44
45 fn has_tool_markers(&self, _text: &str) -> bool {
46 false
48 }
49
50 fn get_unstreamed_tool_args(&self) -> Option<Vec<ToolCallItem>> {
51 None
52 }
53}