pub struct FewShotSelector { /* private fields */ }Expand description
Selects the most relevant few-shot examples that fit within a token budget.
Implementations§
Source§impl FewShotSelector
impl FewShotSelector
Sourcepub fn new(max_examples: usize) -> Self
pub fn new(max_examples: usize) -> Self
Create a selector that returns at most max_examples examples.
Sourcepub fn add_example(
&mut self,
input: impl Into<String>,
output: impl Into<String>,
tokens: usize,
)
pub fn add_example( &mut self, input: impl Into<String>, output: impl Into<String>, tokens: usize, )
Add a new candidate example.
Sourcepub fn select_relevant<'a>(
&'a self,
query: &str,
token_budget: usize,
) -> Vec<&'a FewShotExample>
pub fn select_relevant<'a>( &'a self, query: &str, token_budget: usize, ) -> Vec<&'a FewShotExample>
Return up to max_examples examples sorted by Jaccard similarity to
query, limited to token_budget total tokens.
Trait Implementations§
Source§impl Debug for FewShotSelector
impl Debug for FewShotSelector
Source§impl Default for FewShotSelector
impl Default for FewShotSelector
Source§fn default() -> FewShotSelector
fn default() -> FewShotSelector
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for FewShotSelector
impl RefUnwindSafe for FewShotSelector
impl Send for FewShotSelector
impl Sync for FewShotSelector
impl Unpin for FewShotSelector
impl UnsafeUnpin for FewShotSelector
impl UnwindSafe for FewShotSelector
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