Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for more unstructured data formats. #17

Merged
merged 4 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions api/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ async def query(payload: RequestPayload):
)
chunks = await vector_service.query(input=payload.input, top_k=4)
documents = await vector_service.convert_to_rerank_format(chunks=chunks)
results = await vector_service.rerank(query=payload.input, documents=documents)
return {"success": True, "data": results}
if len(documents):
documents = await vector_service.rerank(
query=payload.input, documents=documents
)
return {"success": True, "data": documents}
2 changes: 0 additions & 2 deletions models/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ class FileType(Enum):
docx = "DOCX"
txt = "TXT"
pptx = "PPTX"
csv = "CSV"
xlsx = "XLSX"
md = "MARKDOWN"


Expand Down
4 changes: 2 additions & 2 deletions models/query.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pydantic import BaseModel
from typing import List
from typing import List, Optional
from models.vector_database import VectorDatabase


Expand All @@ -12,7 +12,7 @@ class RequestPayload(BaseModel):
class ResponseData(BaseModel):
content: str
file_url: str
page_label: str
page_label: Optional[str]


class ResponsePayload(BaseModel):
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dataclasses-json==0.6.3
Deprecated==1.2.14
distro==1.9.0
dnspython==2.4.2
docx2txt==0.8
fastapi==0.109.0
fastavro==1.9.3
filelock==3.13.1
Expand Down
8 changes: 7 additions & 1 deletion service/embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ def __init__(self, files: List[File], index_name: str, vector_credentials: dict)
self.vector_credentials = vector_credentials

def _get_datasource_suffix(self, type: str) -> str:
suffixes = {"TXT": ".txt", "PDF": ".pdf", "MARKDOWN": ".md"}
suffixes = {
"TXT": ".txt",
"PDF": ".pdf",
"MARKDOWN": ".md",
"DOCX": ".docx",
"PPTX": ".pptx",
}
try:
return suffixes[type]
except KeyError:
Expand Down
1 change: 0 additions & 1 deletion service/vector_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ async def convert_to_rerank_format(self, chunks: List[rest.PointStruct]):

async def upsert(self, embeddings: List[tuple[str, list, dict[str, Any]]]) -> None:
points = []

for _embedding in embeddings:
points.append(
rest.PointStruct(
Expand Down