Struct rig::rag::RagAgentBuilder
source · pub struct RagAgentBuilder<M: CompletionModel, C: VectorStoreIndex, T: VectorStoreIndex> { /* private fields */ }
Expand description
Builder for creating a RAG agent
§Example
use rig::{providers::openai, rag_agent::RagAgentBuilder};
use serde_json::json;
let openai_client = openai::Client::from_env();
let model = openai_client.completion_model("gpt-4");
// Configure the agent
let agent = RagAgentBuilder::new(model)
.preamble("System prompt")
.static_context("Context document 1")
.static_context("Context document 2")
.dynamic_context(2, vector_index)
.tool(tool1)
.tool(tool2)
.temperature(0.8)
.additional_params(json!({"foo": "bar"}))
.build();
Implementations§
source§impl<M: CompletionModel, C: VectorStoreIndex, T: VectorStoreIndex> RagAgentBuilder<M, C, T>
impl<M: CompletionModel, C: VectorStoreIndex, T: VectorStoreIndex> RagAgentBuilder<M, C, T>
pub fn new(model: M) -> Self
sourcepub fn static_context(self, doc: &str) -> Self
pub fn static_context(self, doc: &str) -> Self
Add a static context document to the RAG agent
sourcepub fn static_tool(self, tool: impl Tool + 'static) -> Self
pub fn static_tool(self, tool: impl Tool + 'static) -> Self
Add a static tool to the RAG agent
sourcepub fn dynamic_context(self, sample: usize, dynamic_context: C) -> Self
pub fn dynamic_context(self, sample: usize, dynamic_context: C) -> Self
Add some dynamic context to the RAG agent. On each prompt, sample
documents from the
dynamic context will be inserted in the request.
sourcepub fn dynamic_tools(
self,
sample: usize,
dynamic_tools: T,
toolset: ToolSet,
) -> Self
pub fn dynamic_tools( self, sample: usize, dynamic_tools: T, toolset: ToolSet, ) -> Self
Add some dynamic tools to the RAG agent. On each prompt, sample
tools from the
dynamic toolset will be inserted in the request.
sourcepub fn temperature(self, temperature: f64) -> Self
pub fn temperature(self, temperature: f64) -> Self
Set the temperature of the model
Auto Trait Implementations§
impl<M, C, T> Freeze for RagAgentBuilder<M, C, T>where
M: Freeze,
impl<M, C, T> !RefUnwindSafe for RagAgentBuilder<M, C, T>
impl<M, C, T> Send for RagAgentBuilder<M, C, T>
impl<M, C, T> Sync for RagAgentBuilder<M, C, T>
impl<M, C, T> Unpin for RagAgentBuilder<M, C, T>
impl<M, C, T> !UnwindSafe for RagAgentBuilder<M, C, T>
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