Skip to content

Commit

Permalink
Merge branch 'main' into feat/removeExploreView
Browse files Browse the repository at this point in the history
  • Loading branch information
Zewed committed Jan 26, 2024
2 parents 516b417 + 64ba190 commit f449884
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 12 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion backend/llm/knowledge_brain_qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion backend/llm/rags/quivr_rag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -91,6 +91,7 @@ def __init__(
chat_id: str,
streaming: bool = False,
prompt_id: Optional[UUID] = None,
max_tokens: int = 2000,
**kwargs,
):
super().__init__(
Expand All @@ -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(
Expand Down
4 changes: 1 addition & 3 deletions backend/models/databases/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions backend/models/databases/supabase/vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion backend/modules/brain/repository/brains.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion backend/modules/chat/controller/chat/brainful_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 6 additions & 3 deletions backend/vectorstore/supabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class CustomSupabaseVectorStore(SupabaseVectorStore):

brain_id: str = "none"
user_id: str = "none"
number_docs: int = 35

def __init__(
self,
Expand All @@ -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,
Expand All @@ -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()
Expand All @@ -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,
Expand All @@ -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()
Expand Down

0 comments on commit f449884

Please sign in to comment.