pub struct ToolsOutputParser;Expand description
Parser that extracts tool calls from an AI message.
Can operate in two modes:
- Message-based: Extracts
ToolCallvalues directly from an AI message variant. - Text-based: Parses a JSON array of tool calls from raw text (via the
OutputParsertrait).
§Examples
use synwire_core::output_parsers::ToolsOutputParser;
use synwire_core::messages::Message;
let parser = ToolsOutputParser;
let msg = Message::ai("No tools needed");
let calls = parser.parse_message(&msg).unwrap();
assert!(calls.is_empty());Implementations§
Source§impl ToolsOutputParser
impl ToolsOutputParser
Sourcepub fn parse_message(
&self,
message: &Message,
) -> Result<Vec<ToolCall>, SynwireError>
pub fn parse_message( &self, message: &Message, ) -> Result<Vec<ToolCall>, SynwireError>
Extract tool calls from a message.
Returns the tool calls if the message is an AI message, or an empty vector for any other message type.
§Errors
This method currently does not produce errors, but returns Result
for forward compatibility.
Trait Implementations§
Source§impl OutputParser for ToolsOutputParser
impl OutputParser for ToolsOutputParser
Auto Trait Implementations§
impl Freeze for ToolsOutputParser
impl RefUnwindSafe for ToolsOutputParser
impl Send for ToolsOutputParser
impl Sync for ToolsOutputParser
impl Unpin for ToolsOutputParser
impl UnsafeUnpin for ToolsOutputParser
impl UnwindSafe for ToolsOutputParser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more