Files
imphnen-backend-service/imphnen-dimentorin/src/ai_agent/infrastructure/http/routes.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

19 lines
755 B
Rust

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))
}