fix Qdrant

This commit is contained in:
2026-06-18 12:25:15 +03:00
parent b4cc07b9f8
commit 99565ca107
3 changed files with 15 additions and 3 deletions
+3 -2
View File
@@ -1,7 +1,6 @@
import asyncio import asyncio
import json import json
import logging import logging
import threading
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
from datetime import datetime, timezone from datetime import datetime, timezone
from typing import Any from typing import Any
@@ -23,6 +22,8 @@ DEFAULT_PROFILE: dict[str, Any] = {
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
_RAG_EXECUTOR = ThreadPoolExecutor(max_workers=2, thread_name_prefix="rag")
class MemoryService: class MemoryService:
def __init__(self, db: Session, user_id: int): def __init__(self, db: Session, user_id: int):
@@ -47,7 +48,7 @@ class MemoryService:
except Exception: except Exception:
logger.exception("RAG background task failed") logger.exception("RAG background task failed")
threading.Thread(target=runner, daemon=True).start() _RAG_EXECUTOR.submit(runner)
@staticmethod @staticmethod
def _rag_fact_payload(fact: MemoryFact) -> dict[str, Any]: def _rag_fact_payload(fact: MemoryFact) -> dict[str, Any]:
+4 -1
View File
@@ -1,6 +1,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from functools import lru_cache
from typing import Any from typing import Any
from qdrant_client import QdrantClient from qdrant_client import QdrantClient
@@ -14,11 +15,13 @@ COLLECTION_FACTS = "memory_facts"
COLLECTION_SUMMARIES = "session_summaries" COLLECTION_SUMMARIES = "session_summaries"
COLLECTION_DOC_CHUNKS = "document_chunks" COLLECTION_DOC_CHUNKS = "document_chunks"
VECTOR_SIZE = 1536 VECTOR_SIZE = 1536
QDRANT_TIMEOUT_SEC = 30.0
@lru_cache
def _client() -> QdrantClient: def _client() -> QdrantClient:
settings = get_settings() settings = get_settings()
return QdrantClient(url=settings.qdrant_url) return QdrantClient(url=settings.qdrant_url, timeout=QDRANT_TIMEOUT_SEC)
def ensure_collections() -> None: def ensure_collections() -> None:
+8
View File
@@ -21,6 +21,10 @@ services:
- "${QDRANT_GRPC_PORT:-6334}:6334" - "${QDRANT_GRPC_PORT:-6334}:6334"
volumes: volumes:
- qdrant_data:/qdrant/storage - qdrant_data:/qdrant/storage
ulimits:
nofile:
soft: 65535
hard: 65535
restart: unless-stopped restart: unless-stopped
backend: backend:
@@ -31,6 +35,10 @@ services:
environment: environment:
QDRANT_URL: ${QDRANT_URL:-http://qdrant:6333} QDRANT_URL: ${QDRANT_URL:-http://qdrant:6333}
DATABASE_URL: postgresql+psycopg2://${POSTGRES_USER:-assistant}:${POSTGRES_PASSWORD:-assistant}@postgres:5432/${POSTGRES_DB:-assistant} DATABASE_URL: postgresql+psycopg2://${POSTGRES_USER:-assistant}:${POSTGRES_PASSWORD:-assistant}@postgres:5432/${POSTGRES_DB:-assistant}
ulimits:
nofile:
soft: 65535
hard: 65535
depends_on: depends_on:
postgres: postgres:
condition: service_healthy condition: service_healthy