Skip to content

Commit abafac5

Browse files
authored
Merge pull request #1064 from cheshire-cat-ai/develop
1.9.1
2 parents 98a3535 + cabe89f commit abafac5

File tree

6 files changed

+19
-20
lines changed

6 files changed

+19
-20
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ local_vector_memory
1919
*metadata.json
2020
*metadata-test.json
2121
test_db.db
22+
/qdrant
2223

2324
# old admin folder
2425
admin

core/cat/auth/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ async def __call__(
4343
# extract credentials (user_id, token_or_key) from connection
4444
user_id, credential = self.extract_credentials(connection)
4545
auth_handlers = [
46-
# try to get user from local idp
47-
connection.app.state.ccat.core_auth_handler,
4846
# try to get user from auth_handler
4947
connection.app.state.ccat.custom_auth_handler,
48+
# try to get user from local idp
49+
connection.app.state.ccat.core_auth_handler,
5050
]
5151
for ah in auth_handlers:
5252
user: AuthUserInfo = ah.authorize_user_from_credential(

core/cat/looking_glass/stray_cat.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def run(self, user_message_json, return_message=False):
575575
log.warning(ex)
576576

577577
def classify(
578-
self, sentence: str, labels: List[str] | Dict[str, List[str]]
578+
self, sentence: str, labels: List[str] | Dict[str, List[str]], score_threshold: float = 0.5
579579
) -> str | None:
580580
"""Classify a sentence.
581581
@@ -635,8 +635,7 @@ def classify(
635635
key=lambda x: x[1],
636636
)
637637

638-
# set 0.5 as threshold - let's see if it works properly
639-
return best_label if score < 0.5 else None
638+
return best_label if score < score_threshold else None
640639

641640
def langchainfy_chat_history(self, latest_n: int = 20) -> List[BaseMessage]:
642641
"""Redirects to WorkingMemory.langchainfy_chat_history. Will be removed from this class in v2."""

core/cat/memory/vector_memory_collection.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def create_db_collection_if_not_exists(self):
9595
# create collection
9696
def create_collection(self):
9797
log.warning(f'Creating collection "{self.collection_name}" ...')
98-
self.client.recreate_collection(
98+
self.client.create_collection(
9999
collection_name=self.collection_name,
100100
vectors_config=VectorParams(
101101
size=self.embedder_size, distance=Distance.COSINE
@@ -107,7 +107,6 @@ def create_collection(self):
107107
type=ScalarType.INT8, quantile=0.95, always_ram=True
108108
)
109109
),
110-
# shard_number=3,
111110
)
112111

113112
self.client.update_collection_aliases(
@@ -219,9 +218,9 @@ def recall_memories_from_embedding(
219218
):
220219
"""Retrieve similar memories from embedding"""
221220

222-
memories = self.client.search(
221+
memories = self.client.query_points(
223222
collection_name=self.collection_name,
224-
query_vector=embedding,
223+
query=embedding,
225224
query_filter=self._qdrant_filter_from_dict(metadata),
226225
with_payload=True,
227226
with_vectors=True,
@@ -234,7 +233,7 @@ def recall_memories_from_embedding(
234233
oversampling=2.0, # Available as of v1.3.0
235234
)
236235
),
237-
)
236+
).points
238237

239238
# convert Qdrant points to langchain.Document
240239
langchain_documents_from_points = []

core/cat/startup.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ async def validation_exception_handler(request, exc):
124124
# openapi customization
125125
cheshire_cat_api.openapi = get_openapi_configuration_function(cheshire_cat_api)
126126

127-
128-
@cheshire_cat_api.get("/docs", include_in_schema=False)
129-
async def scalar_docs():
130-
return get_scalar_api_reference(
131-
openapi_url=cheshire_cat_api.openapi_url,
132-
title=cheshire_cat_api.title,
133-
scalar_favicon_url="https://cheshirecat.ai/wp-content/uploads/2023/10/Logo-Cheshire-Cat.svg",
134-
)
127+
if get_env("CCAT_DEBUG") == "true":
128+
@cheshire_cat_api.get("/docs", include_in_schema=False)
129+
async def scalar_docs():
130+
return get_scalar_api_reference(
131+
openapi_url=cheshire_cat_api.openapi_url,
132+
title=cheshire_cat_api.title,
133+
scalar_favicon_url="https://cheshirecat.ai/wp-content/uploads/2023/10/Logo-Cheshire-Cat.svg",
134+
)

core/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "Cheshire-Cat"
33
description = "Production ready AI assistant framework"
4-
version = "1.9.0"
4+
version = "1.9.1"
55
requires-python = ">=3.10"
66
license = { file = "LICENSE" }
77
authors = [
@@ -21,7 +21,7 @@ dependencies = [
2121
"Jinja2==3.1.4",
2222
"pandas==1.5.3",
2323
"scikit-learn==1.2.1",
24-
"qdrant_client==1.11.0",
24+
"qdrant_client==1.13.3",
2525
"langchain==0.2.1",
2626
"langchain-community==0.2.1",
2727
"langchain-ollama==0.1.3",

0 commit comments

Comments
 (0)