use async_trait::async_trait;
use super::base::{BaseRetrievalTool, RetrievalResult};
use crate::error::ToolError;
#[derive(Debug, Clone)]
pub struct VertexAiRagConfig {
pub corpus: String,
pub similarity_threshold: f64,
}
#[derive(Debug, Clone)]
pub struct VertexAiRagRetrievalTool {
config: VertexAiRagConfig,
}
impl VertexAiRagRetrievalTool {
pub fn new(config: VertexAiRagConfig) -> Self {
Self { config }
}
pub fn corpus(&self) -> &str {
&self.config.corpus
}
}
#[async_trait]
impl BaseRetrievalTool for VertexAiRagRetrievalTool {
fn name(&self) -> &str {
"vertex_ai_rag_retrieval"
}
async fn retrieve(
&self,
query: &str,
_top_k: usize,
) -> Result<Vec<RetrievalResult>, ToolError> {
let _ = query;
Ok(vec![])
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn tool_metadata() {
let tool = VertexAiRagRetrievalTool::new(VertexAiRagConfig {
corpus: "projects/my-proj/locations/us-central1/ragCorpora/my-corpus".into(),
similarity_threshold: 0.7,
});
assert_eq!(tool.name(), "vertex_ai_rag_retrieval");
assert!(tool.corpus().contains("my-corpus"));
}
#[tokio::test]
async fn retrieve_returns_empty_stub() {
let tool = VertexAiRagRetrievalTool::new(VertexAiRagConfig {
corpus: "test-corpus".into(),
similarity_threshold: 0.5,
});
let results = tool.retrieve("test query", 5).await.unwrap();
assert!(results.is_empty());
}
}