pub struct CotParser;Expand description
Parses chain-of-thought responses into structured ThoughtSteps.
Implementations§
Source§impl CotParser
impl CotParser
Sourcepub fn parse_steps(&self, response: &str) -> Vec<ThoughtStep>
pub fn parse_steps(&self, response: &str) -> Vec<ThoughtStep>
Extract numbered steps from a response.
Recognises lines of the form:
Step N: <thought> -> <conclusion>
Step N: <thought> → <conclusion>If no arrow separator is present the entire text is treated as the thought and the conclusion is left empty.
Sourcepub fn extract_final_answer(&self, response: &str) -> String
pub fn extract_final_answer(&self, response: &str) -> String
Extract the final answer from a response.
Looks for lines beginning with Therefore:, Answer:, or
Conclusion: (case-insensitive) and returns the text that follows.
If none is found, returns an empty string.
Sourcepub fn compute_confidence(&self, steps: &[ThoughtStep]) -> f64
pub fn compute_confidence(&self, steps: &[ThoughtStep]) -> f64
Compute average confidence across all steps.
Heuristic: longer thought text implies more thorough reasoning, which
maps to a higher confidence, capped at 1.0.
Sourcepub fn parse(&self, response: &str) -> ChainOfThought
pub fn parse(&self, response: &str) -> ChainOfThought
Convenience: parse steps and final answer, then produce a full
ChainOfThought.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CotParser
impl RefUnwindSafe for CotParser
impl Send for CotParser
impl Sync for CotParser
impl Unpin for CotParser
impl UnsafeUnpin for CotParser
impl UnwindSafe for CotParser
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request