gemini_adk_rs/tools/retrieval/
vertex_ai_rag.rs1use async_trait::async_trait;
6
7use super::base::{BaseRetrievalTool, RetrievalResult};
8use crate::error::ToolError;
9
10#[derive(Debug, Clone)]
12pub struct VertexAiRagConfig {
13 pub corpus: String,
16 pub similarity_threshold: f64,
18}
19
20#[derive(Debug, Clone)]
25pub struct VertexAiRagRetrievalTool {
26 config: VertexAiRagConfig,
27}
28
29impl VertexAiRagRetrievalTool {
30 pub fn new(config: VertexAiRagConfig) -> Self {
32 Self { config }
33 }
34
35 pub fn corpus(&self) -> &str {
37 &self.config.corpus
38 }
39}
40
41#[async_trait]
42impl BaseRetrievalTool for VertexAiRagRetrievalTool {
43 fn name(&self) -> &str {
44 "vertex_ai_rag_retrieval"
45 }
46
47 async fn retrieve(
48 &self,
49 query: &str,
50 _top_k: usize,
51 ) -> Result<Vec<RetrievalResult>, ToolError> {
52 let _ = query;
58 Ok(vec![])
59 }
60}
61
62#[cfg(test)]
63mod tests {
64 use super::*;
65
66 #[test]
67 fn tool_metadata() {
68 let tool = VertexAiRagRetrievalTool::new(VertexAiRagConfig {
69 corpus: "projects/my-proj/locations/us-central1/ragCorpora/my-corpus".into(),
70 similarity_threshold: 0.7,
71 });
72 assert_eq!(tool.name(), "vertex_ai_rag_retrieval");
73 assert!(tool.corpus().contains("my-corpus"));
74 }
75
76 #[tokio::test]
77 async fn retrieve_returns_empty_stub() {
78 let tool = VertexAiRagRetrievalTool::new(VertexAiRagConfig {
79 corpus: "test-corpus".into(),
80 similarity_threshold: 0.5,
81 });
82 let results = tool.retrieve("test query", 5).await.unwrap();
83 assert!(results.is_empty());
84 }
85}