From 6780748984da33d02e295f36f781ce11ab136118 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 10 Dec 2024 15:15:59 +0330 Subject: [PATCH 1/5] feat: using newer hivemind-backend lib version! --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4c1e138..4e2b57c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,7 +15,7 @@ neo4j>=5.14.1, <6.0.0 coverage>=7.3.3, <8.0.0 pytest>=7.4.3, <8.0.0 python-dotenv==1.0.0 -tc-hivemind-backend==1.2.2 +tc-hivemind-backend==1.4.2 llama-index-question-gen-guidance==0.1.2 llama-index-vector-stores-postgres==0.1.2 celery[redis]>=5.3.6, <6.0.0 From 59839dfa6d1bd08b824d79364bbc007726c5160f Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Wed, 11 Dec 2024 13:45:48 +0330 Subject: [PATCH 2/5] feat: updgraded dependencies! --- requirements.txt | 20 ++++---------------- utils/query_engine/subquestion_engine.py | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/requirements.txt b/requirements.txt index 4e2b57c..a6c787f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,27 +1,15 @@ -numpy -pymongo -python-dotenv -pgvector -asyncpg -psycopg2-binary -sqlalchemy[asyncio] async-sqlalchemy python-pptx -tc-neo4j-lib +tc-neo4j-lib==2.0.4 google-api-python-client unstructured -cohere -neo4j>=5.14.1, <6.0.0 -coverage>=7.3.3, <8.0.0 -pytest>=7.4.3, <8.0.0 -python-dotenv==1.0.0 -tc-hivemind-backend==1.4.2 +tc-hivemind-backend==1.4.2.post1 llama-index-question-gen-guidance==0.1.2 -llama-index-vector-stores-postgres==0.1.2 +llama-index-vector-stores-postgres celery[redis]>=5.3.6, <6.0.0 guidance==0.1.14 tc-messageBroker==1.7.1 -traceloop-sdk==0.14.1 +traceloop-sdk==0.33.12 backoff==2.2.1 fastapi[standard]==0.114.1 faststream==0.5.28 diff --git a/utils/query_engine/subquestion_engine.py b/utils/query_engine/subquestion_engine.py index 2a67c95..110bedd 100644 --- a/utils/query_engine/subquestion_engine.py +++ b/utils/query_engine/subquestion_engine.py @@ -10,6 +10,13 @@ from llama_index.core.schema import NodeWithScore, QueryBundle from llama_index.core.tools.query_engine import QueryEngineTool from llama_index.core.utils import get_color_mapping, print_text +from llama_index.core.instrumentation.events.query import ( + QueryEndEvent, + QueryStartEvent, +) +import llama_index.core.instrumentation as instrument + +dispatcher = instrument.get_dispatcher(__name__) class CustomSubQuestionQueryEngine(SubQuestionQueryEngine): @@ -74,7 +81,16 @@ def _query( return response, qa_pairs_all + @dispatcher.span def query( self, str_or_query_bundle: str | QueryBundle ) -> tuple[RESPONSE_TYPE, list[NodeWithScore]]: - return super().query(str_or_query_bundle) + dispatcher.event(QueryStartEvent(query=str_or_query_bundle)) + with self.callback_manager.as_trace("query"): + if isinstance(str_or_query_bundle, str): + str_or_query_bundle = QueryBundle(str_or_query_bundle) + query_result, qa_pairs_all = self._query(str_or_query_bundle) + dispatcher.event( + QueryEndEvent(query=str_or_query_bundle, response=query_result) + ) + return query_result, qa_pairs_all From 08293697337e45a2c4243d43b0ef2919ac9929f4 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Thu, 12 Dec 2024 11:20:50 +0330 Subject: [PATCH 3/5] fix: trying more to fix dependency conflicts! --- requirements.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index a6c787f..132ed08 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ +numpy==1.26.4 +pandas==2.2.3 async-sqlalchemy python-pptx tc-neo4j-lib==2.0.4 @@ -9,7 +11,7 @@ llama-index-vector-stores-postgres celery[redis]>=5.3.6, <6.0.0 guidance==0.1.14 tc-messageBroker==1.7.1 -traceloop-sdk==0.33.12 +traceloop-sdk==0.31.0 backoff==2.2.1 fastapi[standard]==0.114.1 faststream==0.5.28 From 08de4c77791905f31ef3e4f875601456c26af88f Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Thu, 12 Dec 2024 11:30:16 +0330 Subject: [PATCH 4/5] fix: isort error! --- utils/query_engine/subquestion_engine.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/utils/query_engine/subquestion_engine.py b/utils/query_engine/subquestion_engine.py index 110bedd..9b482f8 100644 --- a/utils/query_engine/subquestion_engine.py +++ b/utils/query_engine/subquestion_engine.py @@ -1,20 +1,17 @@ from typing import List, Optional, Sequence, cast +import llama_index.core.instrumentation as instrument from llama_index.core.async_utils import run_async_tasks from llama_index.core.base.response.schema import RESPONSE_TYPE from llama_index.core.callbacks.base import CallbackManager from llama_index.core.callbacks.schema import CBEventType, EventPayload +from llama_index.core.instrumentation.events.query import QueryEndEvent, QueryStartEvent from llama_index.core.query_engine import SubQuestionAnswerPair, SubQuestionQueryEngine from llama_index.core.question_gen.types import BaseQuestionGenerator from llama_index.core.response_synthesizers import BaseSynthesizer from llama_index.core.schema import NodeWithScore, QueryBundle from llama_index.core.tools.query_engine import QueryEngineTool from llama_index.core.utils import get_color_mapping, print_text -from llama_index.core.instrumentation.events.query import ( - QueryEndEvent, - QueryStartEvent, -) -import llama_index.core.instrumentation as instrument dispatcher = instrument.get_dispatcher(__name__) From c98fdb6c48e5368885e9baa81040b440ab3bf379 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Thu, 12 Dec 2024 11:35:52 +0330 Subject: [PATCH 5/5] fix: Added missing spacy dependency! --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index c7df417..8b08fee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ FROM python:3.11-bullseye AS base WORKDIR /project COPY . . RUN pip3 install -r requirements.txt +RUN python -m spacy download en_core_web_sm FROM base AS test RUN chmod +x docker-entrypoint.sh