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
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
use super::handlers::{post_chat, post_index_material, post_reindex_all};
|
||||
use crate::ai_agent::application::RagServiceImpl;
|
||||
use crate::ai_agent::domain::RagService;
|
||||
use crate::ai_agent::infrastructure::QdrantRagRepository;
|
||||
use axum::{Extension, Router, routing::post};
|
||||
use imphnen_libs::AppState;
|
||||
use sea_orm::DatabaseConnection;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn ai_agent_routes(db: DatabaseConnection, _state: Arc<AppState>) -> Router {
|
||||
let repo = Arc::new(QdrantRagRepository::new());
|
||||
let service: Arc<dyn RagService> = Arc::new(RagServiceImpl::new(repo, db));
|
||||
Router::new()
|
||||
.route("/ai/chat", post(post_chat))
|
||||
.route("/ai/materials/{id}/index", post(post_index_material))
|
||||
.route("/ai/reindex", post(post_reindex_all))
|
||||
.layer(Extension(service))
|
||||
}
|
||||
Reference in New Issue
Block a user