first commit

This commit is contained in:
2026-05-12 23:37:04 +03:00
commit aff0bc2990
67 changed files with 3984 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
from __future__ import annotations
from typing import Any
import aiohttp
from decouple import config
RAG_API_URL = config("RAG_API_URL", default="http://127.0.0.1:8001")
RAG_API_TIMEOUT_SECONDS = float(config("RAG_API_TIMEOUT_SECONDS", default="60"))
class RagApiError(Exception):
pass
async def ask_rag_api(message: str, history: list[dict[str, str]]) -> dict[str, Any]:
timeout = aiohttp.ClientTimeout(total=RAG_API_TIMEOUT_SECONDS)
payload = {
"message": message,
"history": history,
}
async with aiohttp.ClientSession(timeout=timeout) as session:
async with session.post(f"{RAG_API_URL}/chat", json=payload) as response:
if response.status != 200:
text = await response.text()
raise RagApiError(f"RAG API returned {response.status}: {text}")
return await response.json()