-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e57a7af
commit 4a189ce
Showing
31 changed files
with
348 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.html linguist-documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,65 @@ | ||
"""Abstractions for search functionality.""" | ||
|
||
import uuid | ||
from typing import Any, Optional | ||
from typing import Any, Dict, List, Optional | ||
|
||
from pydantic import BaseModel | ||
|
||
|
||
class SearchRequest(BaseModel): | ||
class VectorSearchRequest(BaseModel): | ||
"""Request for a search operation.""" | ||
|
||
query: str | ||
limit: int | ||
filters: Optional[dict[str, Any]] = None | ||
|
||
|
||
class SearchResult(BaseModel): | ||
class VectorSearchResult(BaseModel): | ||
"""Result of a search operation.""" | ||
|
||
id: uuid.UUID | ||
score: float | ||
metadata: dict[str, Any] | ||
|
||
def __str__(self) -> str: | ||
return f"SearchResult(id={self.id}, score={self.score}, metadata={self.metadata})" | ||
return f"VectorSearchResult(id={self.id}, score={self.score}, metadata={self.metadata})" | ||
|
||
def __repr__(self) -> str: | ||
return f"SearchResult(id={self.id}, score={self.score}, metadata={self.metadata})" | ||
return f"VectorSearchResult(id={self.id}, score={self.score}, metadata={self.metadata})" | ||
|
||
def dict(self) -> dict: | ||
return { | ||
"id": self.id, | ||
"score": self.score, | ||
"metadata": self.metadata, | ||
} | ||
|
||
|
||
class KGSearchRequest(BaseModel): | ||
"""Request for a knowledge graph search operation.""" | ||
|
||
query: str | ||
|
||
|
||
KGSearchResult = List[List[Dict[str, Any]]] | ||
|
||
|
||
class AggregateSearchResult(BaseModel): | ||
"""Result of an aggregate search operation.""" | ||
|
||
vector_search_results: Optional[List[VectorSearchResult]] | ||
kg_search_results: Optional[KGSearchResult] = None | ||
|
||
def __str__(self) -> str: | ||
return f"AggregateSearchResult(vector_search_results={self.vector_search_results}, kg_search_results={self.kg_search_results})" | ||
|
||
def __repr__(self) -> str: | ||
return f"AggregateSearchResult(vector_search_results={self.vector_search_results}, kg_search_results={self.kg_search_results})" | ||
|
||
def dict(self) -> dict: | ||
return { | ||
"vector_search_results": [ | ||
result.dict() for result in self.vector_search_results | ||
], | ||
"kg_search_results": self.kg_search_results, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.