pub struct CohereParser { /* private fields */ }Expand description
Cohere Command model tool call parser
Handles the Cohere-specific format:
<|START_ACTION|>{"tool_name": "func", "parameters": {...}}<|END_ACTION|>
Implementations§
Source§impl CohereParser
impl CohereParser
Trait Implementations§
Source§impl Default for CohereParser
impl Default for CohereParser
Source§impl ToolParser for CohereParser
impl ToolParser for CohereParser
Source§fn parse_complete<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = ParserResult<(String, Vec<ToolCall>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn parse_complete<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = ParserResult<(String, Vec<ToolCall>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Parse complete tool calls from final output
Returns (remaining_normal_text, tool_calls) tuple
Source§fn parse_incremental<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
chunk: &'life1 str,
tools: &'life2 [Tool],
) -> Pin<Box<dyn Future<Output = ParserResult<StreamingParseResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn parse_incremental<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
chunk: &'life1 str,
tools: &'life2 [Tool],
) -> Pin<Box<dyn Future<Output = ParserResult<StreamingParseResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Parse tool calls from model output (streaming)
Parsers now maintain internal state, so self is mutable Read more
Source§fn has_tool_markers(&self, text: &str) -> bool
fn has_tool_markers(&self, text: &str) -> bool
Check if text contains tool calls in this parser’s format
Source§fn get_unstreamed_tool_args(&self) -> Option<Vec<ToolCallItem>>
fn get_unstreamed_tool_args(&self) -> Option<Vec<ToolCallItem>>
Get unstreamed tool call arguments
Returns tool call items for arguments that have been parsed but not yet streamed
Source§fn reset(&mut self)
fn reset(&mut self)
Reset the parser state for reuse across requests.
This should clear all buffers and reset state to initial values.
Source§fn as_token_parser(&self) -> Option<&dyn TokenToolParser>
fn as_token_parser(&self) -> Option<&dyn TokenToolParser>
Optionally expose a token-aware parser implementation.
Default returns
None, meaning the parser only supports text input.Auto Trait Implementations§
impl Freeze for CohereParser
impl RefUnwindSafe for CohereParser
impl Send for CohereParser
impl Sync for CohereParser
impl Unpin for CohereParser
impl UnsafeUnpin for CohereParser
impl UnwindSafe for CohereParser
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more