Skip to content

Commit

Permalink
new: updated mini-rag dep
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Jun 27, 2024
1 parent 1855b49 commit e547204
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 13 deletions.
101 changes: 99 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ memory-stats = "1.1.0"
sha256 = "1.5.0"
bitcode = { version = "0.6.0", features = ["serde"] }
intertrait = "0.2.2"
mini-rag = "0.1.0"
mini-rag = "0.2.1"

[features]
default = ["ollama", "groq", "openai", "fireworks"]
Expand Down
22 changes: 12 additions & 10 deletions src/agent/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct State {
// list of executed actions
history: History,
// optional rag engine
rag: Option<Box<dyn mini_rag::VectorStore>>,
rag: Option<mini_rag::VectorStore>,
// set to true when task is complete
complete: bool,
// runtime metrics
Expand Down Expand Up @@ -82,16 +82,18 @@ impl State {
}

// add RAG namespace
let rag: Option<Box<dyn mini_rag::VectorStore>> =
if let Some(config) = task.get_rag_config() {
let v_store = mini_rag::factory("naive", embedder, config).await?;
let rag: Option<mini_rag::VectorStore> = if let Some(config) = task.get_rag_config() {
let mut v_store = mini_rag::VectorStore::new(embedder, config)?;

namespaces.push(namespaces::NAMESPACES.get("rag").unwrap()());
// import new documents if needed
v_store.import_new_documents().await?;

Some(v_store)
} else {
None
};
namespaces.push(namespaces::NAMESPACES.get("rag").unwrap()());

Some(v_store)
} else {
None
};

// add task defined actions
namespaces.append(&mut task.get_functions());
Expand Down Expand Up @@ -148,7 +150,7 @@ impl State {
&mut self,
query: &str,
top_k: usize,
) -> Result<Vec<(mini_rag::document::Document, f64)>> {
) -> Result<Vec<(mini_rag::Document, f64)>> {
if let Some(rag) = &self.rag {
rag.retrieve(query, top_k).await
} else {
Expand Down

0 comments on commit e547204

Please sign in to comment.