TypeSafe模型生成评分
This commit is contained in:
+17
-9
@@ -1,8 +1,12 @@
|
||||
# ChromaDB 依赖 sqlite3 >= 3.35.0,部分 Linux 发行版自带版本过低
|
||||
# 使用 pysqlite3-binary 提供的现代 SQLite 替代系统 sqlite3
|
||||
__import__('pysqlite3')
|
||||
import sys
|
||||
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')
|
||||
# Windows 无 pysqlite3-binary wheel,回退系统 sqlite3(3.43.1 满足要求)
|
||||
try:
|
||||
__import__('pysqlite3')
|
||||
import sys
|
||||
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
@@ -15,6 +19,7 @@ from app.api.routes_rag import router as rag_router
|
||||
from app.core.embeddings import ollama_embeddings_adapter
|
||||
from app.core.vector_store import get_vector_store_adapter
|
||||
from app.core.llm_client import llm_client
|
||||
from app.core.typesafe_client import typesafe_scorer
|
||||
|
||||
# 配置日志
|
||||
logging.basicConfig(
|
||||
@@ -50,17 +55,19 @@ app.include_router(rag_router)
|
||||
|
||||
@app.get("/health")
|
||||
async def health_check():
|
||||
"""健康检查端点:检查 ChromaDB、Ollama、LLM API 连通性"""
|
||||
"""健康检查端点:检查 ChromaDB、Ollama、LLM API、TypeSafe 连通性"""
|
||||
vector_store = get_vector_store_adapter()
|
||||
chromadb_health = vector_store.health_check()
|
||||
ollama_health = await ollama_embeddings_adapter.health_check()
|
||||
llm_health = await llm_client.health_check()
|
||||
|
||||
typesafe_health = await typesafe_scorer.health_check()
|
||||
|
||||
# disabled 视为正常(可选组件被旁路),只有 unhealthy 才判为降级
|
||||
all_healthy = all(
|
||||
h.get("status") == "healthy"
|
||||
for h in [chromadb_health, ollama_health, llm_health]
|
||||
h.get("status") in ("healthy", "disabled")
|
||||
for h in [chromadb_health, ollama_health, llm_health, typesafe_health]
|
||||
)
|
||||
|
||||
|
||||
return {
|
||||
"status": "healthy" if all_healthy else "degraded",
|
||||
"service": "changzuo-rag-service",
|
||||
@@ -68,7 +75,8 @@ async def health_check():
|
||||
"components": {
|
||||
"chromadb": chromadb_health,
|
||||
"ollama": ollama_health,
|
||||
"llm": llm_health
|
||||
"llm": llm_health,
|
||||
"typesafe": typesafe_health
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user