Skip to content

Commit

Permalink
fix: get documents API and text files connector
Browse files Browse the repository at this point in the history
  • Loading branch information
tnunamak committed Mar 14, 2024
1 parent d2b6bdf commit 13ab121
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
5 changes: 3 additions & 2 deletions selfie/api/documents.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
from typing import List, Optional

from fastapi import APIRouter, Query
Expand Down Expand Up @@ -27,8 +28,8 @@ class FetchedDocument(BaseModel):
id: int = Field(..., description="The unique identifier of the document")
name: str = Field(..., description="The name of the document")
size: int = Field(..., description="The size of the document")
created_at: str = Field(..., description="The timestamp of the document creation")
updated_at: str = Field(..., description="The timestamp of the document update")
created_at: datetime = Field(..., description="The timestamp of the document creation")
updated_at: datetime = Field(..., description="The timestamp of the document update")
content_type: str = Field(..., description="The content type of the document")
connector_name: str = Field(..., description="The name of the connector")

Expand Down
5 changes: 1 addition & 4 deletions selfie/connectors/text_files/uischema.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"files": {
"ui:widget": "nativeFile",
"ui:options": {
"accept": ".json"
}
"ui:widget": "nativeFile"
}
}
4 changes: 3 additions & 1 deletion selfie/embeddings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def __init__(self, character_name, storage_path: str = config.embeddings_storage
self.completion = completion or get_default_completion()
self.character_name = character_name
self.embeddings = Embeddings(
hybrid=True,
sqlite={"wal": True},
# For now, sqlite w/the default driver is the only way to use WAL.
content=True
Expand Down Expand Up @@ -346,6 +347,7 @@ async def recall(
include_summary=True,
local_llm=True,
min_score=0.4,
hybrid_search_weight=1.0, # TODO: Setting this to only use the dense index until this is tuned, e.g., with min_score
):
if min_score is None:
min_score = 0.4
Expand All @@ -354,7 +356,7 @@ async def recall(
return {"documents": [], "summary": "No documents found.", "mean_score": 0}
self.embeddings.load(self.storage_path)

results = self._query(where="similar(:topic)", parameters={"topic": topic}, limit=limit)
results = self._query(where=f"similar(:topic, {hybrid_search_weight})", parameters={"topic": topic}, limit=limit)
documents_list: List[ScoredEmbeddingDocumentModel] = []
for result in results:
document = EmbeddingDocumentModel(
Expand Down

0 comments on commit 13ab121

Please sign in to comment.