From e7bd571ac589357b7a687024a642c46419183af4 Mon Sep 17 00:00:00 2001 From: Stan Girard Date: Thu, 25 Jan 2024 20:19:56 -0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20rag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit now works with 30 chunks --- backend/llm/knowledge_brain_qa.py | 2 +- backend/llm/rags/quivr_rag.py | 4 +++- backend/models/databases/repository.py | 4 +--- backend/models/databases/supabase/vectors.py | 4 ++-- .../repository/brain/get_question_context_from_brain.py | 1 + backend/vectorstore/supabase.py | 9 ++++++--- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/backend/llm/knowledge_brain_qa.py b/backend/llm/knowledge_brain_qa.py index bc33681d3219..27adc99480e2 100644 --- a/backend/llm/knowledge_brain_qa.py +++ b/backend/llm/knowledge_brain_qa.py @@ -60,7 +60,7 @@ class Config: temperature: float = 0.1 chat_id: str = None # pyright: ignore reportPrivateUsage=none brain_id: str # pyright: ignore reportPrivateUsage=none - max_tokens: int = 256 + max_tokens: int = 2000 streaming: bool = False knowledge_qa: Optional[RAGInterface] metadata: Optional[dict] = None diff --git a/backend/llm/rags/quivr_rag.py b/backend/llm/rags/quivr_rag.py index dd8a945a06c8..d0eb23918bab 100644 --- a/backend/llm/rags/quivr_rag.py +++ b/backend/llm/rags/quivr_rag.py @@ -60,7 +60,7 @@ class Config: temperature: float = 0.1 chat_id: str = None # pyright: ignore reportPrivateUsage=none brain_id: str = None # pyright: ignore reportPrivateUsage=none - max_tokens: int = 256 + max_tokens: int = 2000 streaming: bool = False @property @@ -91,6 +91,7 @@ def __init__( chat_id: str, streaming: bool = False, prompt_id: Optional[UUID] = None, + max_tokens: int = 2000, **kwargs, ): super().__init__( @@ -103,6 +104,7 @@ def __init__( self.supabase_client = self._create_supabase_client() self.vector_store = self._create_vector_store() self.prompt_id = prompt_id + self.max_tokens = max_tokens def _create_supabase_client(self) -> Client: return create_client( diff --git a/backend/models/databases/repository.py b/backend/models/databases/repository.py index dc62ff06b4d5..cfc1c41f4f32 100644 --- a/backend/models/databases/repository.py +++ b/backend/models/databases/repository.py @@ -59,9 +59,7 @@ def get_vectors_by_file_name(self, file_name: str): pass @abstractmethod - def similarity_search( - self, query_embedding, table: str, top_k: int, threshold: float - ): + def similarity_search(self, query_embedding, table: str, k: int, threshold: float): pass @abstractmethod diff --git a/backend/models/databases/supabase/vectors.py b/backend/models/databases/supabase/vectors.py index 8c52d8eb2764..5b16d49cf581 100644 --- a/backend/models/databases/supabase/vectors.py +++ b/backend/models/databases/supabase/vectors.py @@ -30,12 +30,12 @@ def get_vectors_by_file_sha1(self, file_sha1): return response # TODO: remove duplicate similarity_search in supabase vector store - def similarity_search(self, query_embedding, table, top_k, threshold): + def similarity_search(self, query_embedding, table, k, threshold): response = self.db.rpc( table, { "query_embedding": query_embedding, - "match_count": top_k, + "match_count": k, "match_threshold": threshold, }, ).execute() diff --git a/backend/repository/brain/get_question_context_from_brain.py b/backend/repository/brain/get_question_context_from_brain.py index 7aaca453a308..9f6fde6391e6 100644 --- a/backend/repository/brain/get_question_context_from_brain.py +++ b/backend/repository/brain/get_question_context_from_brain.py @@ -29,6 +29,7 @@ def get_question_context_from_brain(brain_id: UUID, question: str) -> str: embeddings, table_name="vectors", brain_id=str(brain_id), + number_docs=20, ) documents = vector_store.similarity_search(question, k=20, threshold=0.8) diff --git a/backend/vectorstore/supabase.py b/backend/vectorstore/supabase.py index e303cbc2a788..1e2e1e07944a 100644 --- a/backend/vectorstore/supabase.py +++ b/backend/vectorstore/supabase.py @@ -14,6 +14,7 @@ class CustomSupabaseVectorStore(SupabaseVectorStore): brain_id: str = "none" user_id: str = "none" + number_docs: int = 35 def __init__( self, @@ -22,10 +23,12 @@ def __init__( table_name: str, brain_id: str = "none", user_id: str = "none", + number_docs: int = 35, ): super().__init__(client, embedding, table_name) self.brain_id = brain_id self.user_id = user_id + self.number_docs = number_docs def find_brain_closest_query( self, @@ -42,7 +45,7 @@ def find_brain_closest_query( table, { "query_embedding": query_embedding, - "match_count": k, + "match_count": self.number_docs, "p_user_id": str(self.user_id), }, ).execute() @@ -62,7 +65,7 @@ def find_brain_closest_query( def similarity_search( self, query: str, - k: int = 6, + k: int = 35, table: str = "match_vectors", threshold: float = 0.5, **kwargs: Any, @@ -73,7 +76,7 @@ def similarity_search( table, { "query_embedding": query_embedding, - "match_count": k, + "match_count": self.number_docs, "p_brain_id": str(self.brain_id), }, ).execute() From 3892a990d269a70d71b27d9772fbefad7bcb4a87 Mon Sep 17 00:00:00 2001 From: Stan Girard Date: Thu, 25 Jan 2024 21:35:47 -0800 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20=F0=9F=90=9B=20close-brains?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit improved --- backend/modules/chat/controller/chat/brainful_chat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/modules/chat/controller/chat/brainful_chat.py b/backend/modules/chat/controller/chat/brainful_chat.py index a0a15a35c5c5..7b114275e4f1 100644 --- a/backend/modules/chat/controller/chat/brainful_chat.py +++ b/backend/modules/chat/controller/chat/brainful_chat.py @@ -88,7 +88,7 @@ def get_answer_generator( # Calculate the closest brains to the question list_brains = vector_store.find_brain_closest_query(user_id, question) - metadata["close_brains"] = list_brains + metadata["close_brains"] = list_brains[:5] if list_brains and not brain_id_to_use: brain_id_to_use = list_brains[0]["id"] From 5342de8d7b47c2cde696a9784b30202a7c8c3899 Mon Sep 17 00:00:00 2001 From: Stan Girard Date: Thu, 25 Jan 2024 22:02:48 -0800 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20=F0=9F=90=9B=20public-brains?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add --- backend/modules/brain/repository/brains.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/modules/brain/repository/brains.py b/backend/modules/brain/repository/brains.py index 21f426c8392f..db5a1b9632ab 100644 --- a/backend/modules/brain/repository/brains.py +++ b/backend/modules/brain/repository/brains.py @@ -46,7 +46,8 @@ def get_public_brains(self): if not item["brain_definition"]: del item["brain_definition"] else: - item["brain_definition"] = item["brain_definition"][0] + logger.info("brain_definition;;") + logger.info(item["brain_definition"]) item["brain_definition"]["secrets"] = [] public_brains.append(PublicBrain(**item)) From ef31cd9eb26f1ce1aae565c00f34815a75a7a451 Mon Sep 17 00:00:00 2001 From: Stan Girard Date: Thu, 25 Jan 2024 22:08:49 -0800 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20=F0=9F=90=9B=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixed unused --- .../QADisplay/components/MessageRow/MessageRow.tsx | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/frontend/app/chat/[chatId]/components/ChatDialogueArea/components/ChatDialogue/components/QADisplay/components/MessageRow/MessageRow.tsx b/frontend/app/chat/[chatId]/components/ChatDialogueArea/components/ChatDialogue/components/QADisplay/components/MessageRow/MessageRow.tsx index 24b128ea5a6c..189638341b78 100644 --- a/frontend/app/chat/[chatId]/components/ChatDialogueArea/components/ChatDialogue/components/QADisplay/components/MessageRow/MessageRow.tsx +++ b/frontend/app/chat/[chatId]/components/ChatDialogueArea/components/ChatDialogue/components/QADisplay/components/MessageRow/MessageRow.tsx @@ -19,14 +19,7 @@ type MessageRowProps = { export const MessageRow = React.forwardRef( ( - { - speaker, - text, - brainName, - promptName, - children, - metadata, - }: MessageRowProps, + { speaker, text, brainName, promptName, children }: MessageRowProps, ref: React.Ref ) => { const { @@ -42,9 +35,6 @@ export const MessageRow = React.forwardRef( }); const messageContent = text ?? ""; - const sourcesContent = metadata?.sources ?? []; - - const hasSources = Boolean(sourcesContent); return (
From 64ba190d6c8208feefc3856621e17792e3eed1c7 Mon Sep 17 00:00:00 2001 From: Stan Girard Date: Thu, 25 Jan 2024 22:15:39 -0800 Subject: [PATCH 5/5] chore(main): release 0.0.184 (#2089) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit :robot: I have created a release *beep* *boop* --- ## 0.0.184 (2024-01-26) ## What's Changed * feat(panel): added by @Zewed in https://github.com/StanGirard/quivr/pull/2088 * feat: 🎸 api by @StanGirard in https://github.com/StanGirard/quivr/pull/2078 * fix(frontend): clear message input on submit by @Zewed in https://github.com/StanGirard/quivr/pull/2087 * fix: 🐛 related by @StanGirard in https://github.com/StanGirard/quivr/pull/2090 * feat: Added translation status badge from inlang by @NilsJacobsen in https://github.com/StanGirard/quivr/pull/2080 * fix(streaming): Data Truncation Issue in useHandleStream Function by @openperf in https://github.com/StanGirard/quivr/pull/2079 * feat: 🎸 sources by @StanGirard in https://github.com/StanGirard/quivr/pull/2092 * fix(frontend): clean related Brains useEffect by @Zewed in https://github.com/StanGirard/quivr/pull/2091 ## New Contributors * @openperf made their first contribution in https://github.com/StanGirard/quivr/pull/2079 **Full Changelog**: https://github.com/StanGirard/quivr/compare/v0.0.183...v0.0.184 --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- CHANGELOG.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f85aeec0a6a..623337ed91a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## 0.0.184 (2024-01-26) + +## What's Changed +* feat(panel): added by @Zewed in https://github.com/StanGirard/quivr/pull/2088 +* feat: 🎸 api by @StanGirard in https://github.com/StanGirard/quivr/pull/2078 +* fix(frontend): clear message input on submit by @Zewed in https://github.com/StanGirard/quivr/pull/2087 +* fix: 🐛 related by @StanGirard in https://github.com/StanGirard/quivr/pull/2090 +* feat: Added translation status badge from inlang by @NilsJacobsen in https://github.com/StanGirard/quivr/pull/2080 +* fix(streaming): Data Truncation Issue in useHandleStream Function by @openperf in https://github.com/StanGirard/quivr/pull/2079 +* feat: 🎸 sources by @StanGirard in https://github.com/StanGirard/quivr/pull/2092 +* fix(frontend): clean related Brains useEffect by @Zewed in https://github.com/StanGirard/quivr/pull/2091 + +## New Contributors +* @openperf made their first contribution in https://github.com/StanGirard/quivr/pull/2079 + +**Full Changelog**: https://github.com/StanGirard/quivr/compare/v0.0.183...v0.0.184 + ## 0.0.183 (2024-01-24) ## What's Changed