feat: solution for 'Повторный экзамен: FAQ-бот — ChromaDB + один MCP-tool'

This commit is contained in:
2026-07-01 14:07:19 +00:00
parent b9cdb4d26f
commit 6a74aa2b28
4 changed files with 195 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
import os
import json
import httpx
def fetch_course_meta(query: str) -> str:
"""
Fetch metadata about the course from the MCP service.
Tries to GET from MCP_ENDPOINT; falls back to local JSON file.
"""
endpoint = os.getenv("MCP_ENDPOINT")
if endpoint:
try:
resp = httpx.get(endpoint, timeout=5.0)
resp.raise_for_status()
data = resp.json()
return f"{query}: {data.get(query, 'Not found')}"
except Exception:
pass
# Fallback to local file
local_path = os.path.join("data", "course_meta.json")
with open(local_path, "r", encoding="utf-8") as f:
data = json.load(f)
return f"{query}: {data.get(query, 'Not found')}"