fix Qdrant
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
import threading
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from datetime import datetime, timezone
|
||||
from typing import Any
|
||||
@@ -23,6 +22,8 @@ DEFAULT_PROFILE: dict[str, Any] = {
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
_RAG_EXECUTOR = ThreadPoolExecutor(max_workers=2, thread_name_prefix="rag")
|
||||
|
||||
|
||||
class MemoryService:
|
||||
def __init__(self, db: Session, user_id: int):
|
||||
@@ -47,7 +48,7 @@ class MemoryService:
|
||||
except Exception:
|
||||
logger.exception("RAG background task failed")
|
||||
|
||||
threading.Thread(target=runner, daemon=True).start()
|
||||
_RAG_EXECUTOR.submit(runner)
|
||||
|
||||
@staticmethod
|
||||
def _rag_fact_payload(fact: MemoryFact) -> dict[str, Any]:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from functools import lru_cache
|
||||
from typing import Any
|
||||
|
||||
from qdrant_client import QdrantClient
|
||||
@@ -14,11 +15,13 @@ COLLECTION_FACTS = "memory_facts"
|
||||
COLLECTION_SUMMARIES = "session_summaries"
|
||||
COLLECTION_DOC_CHUNKS = "document_chunks"
|
||||
VECTOR_SIZE = 1536
|
||||
QDRANT_TIMEOUT_SEC = 30.0
|
||||
|
||||
|
||||
@lru_cache
|
||||
def _client() -> QdrantClient:
|
||||
settings = get_settings()
|
||||
return QdrantClient(url=settings.qdrant_url)
|
||||
return QdrantClient(url=settings.qdrant_url, timeout=QDRANT_TIMEOUT_SEC)
|
||||
|
||||
|
||||
def ensure_collections() -> None:
|
||||
|
||||
Reference in New Issue
Block a user