Conversation
• Added VectorStoreService base class with config model • Implemented ChromaVectorStore integration with HuggingFace embeddings • Created RetrieverService for document search in pipeline • Updated docker-compose for Chroma • Excluded from pipeline flow (WIP) TODO: Connect to pipeline services (in progress)
| self.vector_store = QdrantClient(url=vector_store_url) | ||
| self.retriever = SentenceTransformer(retriever_model) | ||
|
|
||
| def execute(self, user_query: str, ctx: Dict[str, Any], **kwargs) -> Dict[str, Any]: |
There was a problem hiding this comment.
See response_tutorial for information on how to subclass BaseResponse.
| context = "\n".join([hit.payload["text"] for hit in results]) | ||
| ctx["cached_rag_context"] = context | ||
|
|
||
| prompt = f"Контекст: {context}\nВопрос: {user_query}" |
There was a problem hiding this comment.
Would like prompt customization (i.e. ability to change prompt template via __init__).
| def __init__(self, vector_store_url: str, retriever_model: str, **kwargs): | ||
| super().__init__(**kwargs) | ||
| self.vector_store = QdrantClient(url=vector_store_url) | ||
| self.retriever = SentenceTransformer(retriever_model) |
There was a problem hiding this comment.
Cannot use local models:
- additional heavy dependencies;
- CPU load.
| from typing import Dict, Any | ||
| from sentence_transformers import SentenceTransformer | ||
| from qdrant_client import QdrantClient | ||
| from chatsky.responses.base_response import BaseResponse |
There was a problem hiding this comment.
There should be an empty line separating import groups (pep-8):
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.
Imports should be grouped in the following order:
Standard library imports. Related third party imports. Local application/library specific imports.You should put a blank line between each group of imports.
from typing import Dict, Any
from sentence_transformers import SentenceTransformer
from qdrant_client import QdrantClient
from chatsky.responses.base_response import BaseResponse|
|
||
| def execute(self, user_query: str, ctx: Dict[str, Any], **kwargs) -> Dict[str, Any]: | ||
| if "cached_rag_context" in ctx: | ||
| context = ctx["cached_rag_context"] |
There was a problem hiding this comment.
context and ctx are similar parameter names which can be confusing. It's better to rename context to something else (e.g. rag_context).
| assert docs == expected_docs | ||
|
|
||
|
|
||
| async def test_retriever_with_threshold(pipeline_with_retrievers): |
There was a problem hiding this comment.
If these two tests were previously implemented as one parametrized test in order to keep them grouped (since both are tests for retriever), you can achieve this with test classes instead:
https://docs.pytest.org/en/stable/getting-started.html#group-multiple-tests-in-a-class
So it would look like
class TestRetriever:
async def test_get_documents(self, pipeline_with_retrievers):
async def test_threshold(self, pipeline_with_retrievers):
Description
Add RAG integration.
Checklist
To Consider
.ignorefiles, scripts (such aslint), distribution manifest (if files are added/deleted)