pub struct LlamaParser { /* private fields */ }Expand description
Llama 3.2 format parser for tool calls
Handles the Llama 3.2 specific format:
<|python_tag|>{"name": "func", "parameters": {...}}
Also supports plain JSON without the python_tag prefix
Implementations§
Source§impl LlamaParser
impl LlamaParser
Trait Implementations§
Source§impl Default for LlamaParser
impl Default for LlamaParser
Source§impl ToolParser for LlamaParser
impl ToolParser for LlamaParser
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 LlamaParser
impl RefUnwindSafe for LlamaParser
impl Send for LlamaParser
impl Sync for LlamaParser
impl Unpin for LlamaParser
impl UnsafeUnpin for LlamaParser
impl UnwindSafe for LlamaParser
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