Skip to content

Commit

Permalink
Move concept fields to child objects
Browse files Browse the repository at this point in the history
This led to confusion when interacting with the hits, in that passages
seemed to have `concept_counts` and documents, `concepts`. Moving both
to just be on the child object instead makes it clearer the distinction
between them
  • Loading branch information
olaughter committed Feb 17, 2025
1 parent a052b9b commit d58e6b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/cpr_sdk/models/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,8 @@ class Hit(BaseModel):
corpus_type_name: Optional[str] = None
corpus_import_id: Optional[str] = None
metadata: Optional[Sequence[dict[str, str]]] = None
concepts: Optional[Sequence[Concept]] = None
relevance: Optional[float] = None
rank_features: Optional[dict[str, float]] = None
concept_counts: Optional[dict[str, int]] = None

@classmethod
def from_vespa_response(cls, response_hit: dict) -> "Hit":
Expand Down Expand Up @@ -485,6 +483,8 @@ def __eq__(self, other):
class Document(Hit):
"""A document search result hit."""

concept_counts: Optional[dict[str, int]] = None

@classmethod
def from_vespa_response(cls, response_hit: dict) -> "Document":
"""
Expand Down Expand Up @@ -519,7 +519,6 @@ def from_vespa_response(cls, response_hit: dict) -> "Document":
corpus_type_name=fields.get("corpus_type_name"),
corpus_import_id=fields.get("corpus_import_id"),
metadata=fields.get("metadata"),
concepts=fields.get("concepts"),
relevance=response_hit.get("relevance"),
rank_features=fields.get("summaryfeatures"),
concept_counts=fields.get("concept_counts"),
Expand All @@ -534,6 +533,7 @@ class Passage(Hit):
text_block_type: str
text_block_page: Optional[int] = None
text_block_coords: Optional[Sequence[tuple[float, float]]] = None
concepts: Optional[Sequence[Concept]] = None

@classmethod
def from_vespa_response(cls, response_hit: dict) -> "Passage":
Expand Down
2 changes: 1 addition & 1 deletion src/cpr_sdk/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
_MAJOR = "1"
_MINOR = "16"
_PATCH = "1"
_PATCH = "2"
_SUFFIX = ""

VERSION_SHORT = "{0}.{1}".format(_MAJOR, _MINOR)
Expand Down

0 comments on commit d58e6b5

Please sign in to comment.