use async_trait::async_trait;
use super::{MemoryEntry, MemoryError, MemoryService};
#[derive(Debug, Clone)]
pub struct VertexAiRagMemoryConfig {
pub corpus: String,
pub project: String,
pub location: String,
}
#[derive(Debug, Clone)]
pub struct VertexAiRagMemoryService {
config: VertexAiRagMemoryConfig,
}
impl VertexAiRagMemoryService {
pub fn new(config: VertexAiRagMemoryConfig) -> Self {
Self { config }
}
pub fn corpus(&self) -> &str {
&self.config.corpus
}
}
#[async_trait]
impl MemoryService for VertexAiRagMemoryService {
async fn store(&self, _session_id: &str, _entry: MemoryEntry) -> Result<(), MemoryError> {
Ok(())
}
async fn get(&self, _session_id: &str, _key: &str) -> Result<Option<MemoryEntry>, MemoryError> {
Ok(None)
}
async fn list(&self, _session_id: &str) -> Result<Vec<MemoryEntry>, MemoryError> {
Ok(vec![])
}
async fn search(
&self,
_session_id: &str,
_query: &str,
) -> Result<Vec<MemoryEntry>, MemoryError> {
Ok(vec![])
}
async fn delete(&self, _session_id: &str, _key: &str) -> Result<(), MemoryError> {
Ok(())
}
async fn clear(&self, _session_id: &str) -> Result<(), MemoryError> {
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
fn test_config() -> VertexAiRagMemoryConfig {
VertexAiRagMemoryConfig {
corpus: "projects/test/locations/us-central1/ragCorpora/test-corpus".into(),
project: "test".into(),
location: "us-central1".into(),
}
}
#[test]
fn service_metadata() {
let svc = VertexAiRagMemoryService::new(test_config());
assert!(svc.corpus().contains("test-corpus"));
}
#[tokio::test]
async fn store_and_search_stub() {
let svc = VertexAiRagMemoryService::new(test_config());
let entry = MemoryEntry::new("test", serde_json::json!("data"));
svc.store("s1", entry).await.unwrap();
let results = svc.search("s1", "test").await.unwrap();
assert!(results.is_empty()); }
}