Skip to content

Commit 342518d

Browse files
committed
fix types
1 parent 764ece6 commit 342518d

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

main.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
EmbeddingResponse,
1919
EmbeddingBatchCreateRequest,
2020
EmbeddingBatchCreateResponse,
21-
VectorStoreListResponse
21+
VectorStoreListResponse,
22+
ContentChunk
2223
)
2324
from config import settings
2425
from embedding_service import embedding_service
@@ -288,17 +289,26 @@ async def search_vector_store(
288289
# Cosine distance ranges from 0 (identical) to 2 (opposite)
289290
similarity_score = max(0, 1 - (row['distance'] / 2))
290291

292+
# Extract filename from metadata or use a default
293+
metadata = row[fields.metadata_field] or {}
294+
filename = metadata.get('filename', 'document.txt')
295+
296+
content_chunks = [ContentChunk(type="text", text=row[fields.content_field])]
297+
291298
result = SearchResult(
292-
id=row[fields.id_field],
293-
content=row[fields.content_field],
299+
file_id=row[fields.id_field],
300+
filename=filename,
294301
score=similarity_score,
295-
metadata=row[fields.metadata_field] if request.return_metadata else None
302+
attributes=metadata if request.return_metadata else None,
303+
content=content_chunks
296304
)
297305
search_results.append(result)
298306

299307
return VectorStoreSearchResponse(
308+
search_query=request.query,
300309
data=search_results,
301-
usage={"total_tokens": len(search_results)}
310+
has_more=False, # TODO: Implement pagination
311+
next_page=None
302312
)
303313

304314
except HTTPException:

models.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,25 @@ class VectorStoreSearchRequest(BaseModel):
3232
return_metadata: Optional[bool] = True
3333

3434

35+
class ContentChunk(BaseModel):
36+
type: str = "text"
37+
text: str
38+
39+
3540
class SearchResult(BaseModel):
36-
id: str
37-
content: str
41+
file_id: str
42+
filename: str
3843
score: float
39-
metadata: Optional[Dict[str, Any]] = None
44+
attributes: Optional[Dict[str, Any]] = None
45+
content: List[ContentChunk]
4046

4147

4248
class VectorStoreSearchResponse(BaseModel):
43-
object: str = "vector_store.search"
49+
object: str = "vector_store.search_results.page"
50+
search_query: str
4451
data: List[SearchResult]
45-
usage: Dict[str, int]
52+
has_more: bool = False
53+
next_page: Optional[str] = None
4654

4755

4856
class EmbeddingCreateRequest(BaseModel):

0 commit comments

Comments
 (0)