Skip to content

Commit 71a7c96

Browse files
committed
various fixes
1 parent fca5ad1 commit 71a7c96

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

examples/rag/data/made-up-animals.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
A Darmepinter is an animal that looks like a zebra and sounds like a snake.
1+
A Darmepinter is a made up animal that looks like a zebra and sounds like a snake.

src/agent/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -232,16 +232,18 @@ impl Agent {
232232

233233
// for each parsed invocation
234234
for inv in invocations {
235-
let mut mut_state = self.state.lock().await;
236235
// lookup action
236+
let mut mut_state = self.state.lock().await;
237237
let action = mut_state.get_action(&inv.action);
238+
238239
if action.is_none() {
239240
mut_state.metrics.errors.unknown_actions += 1;
240241
// tell the model that the action name is wrong
241242
mut_state.add_error_to_history(
242243
inv.clone(),
243244
format!("'{}' is not a valid action name", inv.action),
244245
);
246+
drop(mut_state);
245247
} else {
246248
let action = action.unwrap();
247249
// validate prerequisites

src/agent/namespaces/rag/mod.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,16 @@ impl Action for Search {
3737
let docs = state.lock().await.rag_query(&query, 1).await?;
3838

3939
if !docs.is_empty() {
40-
println!(
41-
"[{}] {} results for '{query}' in {:?}",
42-
"rag".bold(),
43-
docs.len(),
44-
start.elapsed()
45-
);
40+
println!("\n {} results in {:?}", docs.len(), start.elapsed());
4641
for (doc, score) in &docs {
47-
println!(" [{score}] {} ", &doc.name);
42+
println!(" * {} ({})", &doc.name, score);
4843
}
44+
println!("");
4945

5046
Ok(Some(format!(
5147
"Here is some supporting information:\n\n{}",
5248
docs.iter()
53-
.map(|(doc, _)| format!("{}", doc.data))
49+
.map(|(doc, _)| doc.data.clone())
5450
.collect::<Vec<String>>()
5551
.join("\n")
5652
)))

src/agent/namespaces/rag/ns.prompt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Use these actions to search and retrieve information.
1+
Use these actions to search and retrieve information from your long term storage.
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
To search for information:
1+
All information from your long term storage is true. To search for information on your long term storage:

0 commit comments

Comments
 (0)