pub struct RouteLayerBuilder { /* private fields */ }
Expand description
A builder for creating a RouteLayer
.
ⓘ
let captial_route = Router::new(
"captial",
&[
"Capital of France is Paris.",
"What is the captial of France?",
],
);
let weather_route = Router::new(
"temperature",
&[
"What is the temperature?",
"Is it raining?",
"Is it cloudy?",
],
);
let router_layer = RouteLayerBuilder::default()
.embedder(OpenAiEmbedder::default())
.add_route(captial_route)
.add_route(weather_route)
.aggregation_method(AggregationMethod::Sum)
.threshold(0.82)
.build()
.await
.unwrap();
Implementations§
Source§impl RouteLayerBuilder
impl RouteLayerBuilder
pub fn new() -> Self
pub fn top_k(self, top_k: usize) -> Self
pub fn llm<L: LLM + 'static>(self, llm: L) -> Self
pub fn index<I: Index + 'static>(self, index: I) -> Self
pub fn embedder<E: Embedder + 'static>(self, embedder: E) -> Self
Sourcepub fn threshold(self, threshold: f64) -> Self
pub fn threshold(self, threshold: f64) -> Self
The threshold is the minimum similarity score that a route must have to be considered. This depends on the similarity metric used by the embedder. For open ai text-embedding-ada-002, the best threshold is 0.82
pub fn add_route(self, route: Router) -> Self
pub fn aggregation_method(self, aggregation_method: AggregationMethod) -> Self
pub async fn build(self) -> Result<RouteLayer, RouteLayerBuilderError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RouteLayerBuilder
impl !RefUnwindSafe for RouteLayerBuilder
impl !Send for RouteLayerBuilder
impl !Sync for RouteLayerBuilder
impl Unpin for RouteLayerBuilder
impl !UnwindSafe for RouteLayerBuilder
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