Files
imphnen-backend-service/imphnen-dimentorin/src/ai_agent/domain/repository.rs
T
asepharyana 164c1860da feat(dimentorin): AI agent RAG (embedding materi -> Qdrant + chat via 9router)
- ENV: AI_LLM_BASE_URL/API_KEY/MODEL, AI_EMBEDDING_MODEL (gemini-embedding-001), QDRANT_URL
- ai_agent module: chunking materi, embed_text + chat_completion (9router, SSE parse), Qdrant repo (dimentorin_materi collection, 3072d cosine)
- routes: POST /ai/chat (RAG answer + sources), POST /ai/materials/{id}/index, POST /ai/reindex
- e2e verified: reindex 3 chunks; chat 'ownership' -> materi Rust paling relevan 0.88; chat 'endpoint axum' -> materi Axum 0.82; jawaban gronding konteks
2026-08-05 17:15:11 +07:00

26 lines
693 B
Rust

use async_trait::async_trait;
use uuid::Uuid;
use super::rag_document::RagDocument;
use imphnen_utils::AppError;
#[async_trait]
pub trait RagRepository: Send + Sync {
/// Upsert a document chunk into the vector store.
async fn upsert_document(
&self,
point_id: u64,
doc: &RagDocument,
embedding: Vec<f32>,
) -> Result<(), AppError>;
/// Search the vector store for the closest chunks to `embedding`.
async fn search(
&self,
embedding: Vec<f32>,
limit: u64,
material_id: Option<Uuid>,
) -> Result<Vec<(RagDocument, f32)>, AppError>;
/// Remove all chunks for a material (re-index support).
async fn delete_material(&self, material_id: Uuid) -> Result<(), AppError>;
}