197f70ee12
- Added Qdrant service to both docker-compose files for production and development. - Updated environment variables in .env.example and settings.py to include Qdrant configuration. - Included necessary dependencies for Qdrant and ChromaDB in requirements.txt. - Updated .gitignore to exclude ChromaDB data files.
29 lines
796 B
Python
29 lines
796 B
Python
"""
|
|
بازیابی RAG: embed کوئری و جستجو در vector store
|
|
"""
|
|
from .config import load_rag_config, RAGConfig
|
|
from .embedding import embed_single
|
|
from .vector_store import QdrantVectorStore
|
|
|
|
|
|
def search_with_query(
|
|
query: str,
|
|
limit: int = 5,
|
|
score_threshold: float | None = None,
|
|
config: RAGConfig | None = None,
|
|
) -> list[dict]:
|
|
"""
|
|
کوئری را embed میکند و در vector store جستجو میکند.
|
|
|
|
Returns:
|
|
لیست نتایج با id, score, text, metadata
|
|
"""
|
|
cfg = config or load_rag_config()
|
|
query_vector = embed_single(query, config=cfg)
|
|
store = QdrantVectorStore(config=cfg)
|
|
return store.search(
|
|
query_vector=query_vector,
|
|
limit=limit,
|
|
score_threshold=score_threshold,
|
|
)
|