Skip to content

Commit

Permalink
Add summary kind to summarize endpoint (#1764)
Browse files Browse the repository at this point in the history
  • Loading branch information
jotare authored Jan 23, 2024
1 parent 66baf3f commit fb0712a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions nucliadb/nucliadb/search/search/summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
async def summarize(kbid: str, request: SummarizeRequest) -> SummarizedResponse:
predict_request = SummarizeModel()
predict_request.user_prompt = request.user_prompt
predict_request.summary_kind = request.summary_kind

for rid, field_id, extracted_text in await get_extracted_texts(
kbid, request.resources
Expand Down
12 changes: 12 additions & 0 deletions nucliadb_models/nucliadb_models/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,13 +782,19 @@ class SummarizeResourceModel(BaseModel):
fields: Dict[str, str] = {}


class SummaryKind(str, Enum):
SIMPLE = "simple"
EXTENDED = "extended"


class SummarizeModel(BaseModel):
"""
Model for the summarize predict api request payload
"""

resources: Dict[str, SummarizeResourceModel] = {}
user_prompt: Optional[str] = None
summary_kind: SummaryKind = SummaryKind.SIMPLE


class SummarizeRequest(BaseModel):
Expand All @@ -809,6 +815,12 @@ class SummarizeRequest(BaseModel):
description="Uids of the resources to summarize",
)

summary_kind: SummaryKind = Field(
default=SummaryKind.SIMPLE,
title="Summary kind",
description="Option to customize how the summary will be",
)


class SummarizedResource(BaseModel):
summary: str
Expand Down

1 comment on commit fb0712a

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: fb0712a Previous: c67870a Ratio
nucliadb/search/tests/unit/search/test_fetch.py::test_highligh_error 13009.879232621099 iter/sec (stddev: 0.0000010297539606278186) 12887.24555746259 iter/sec (stddev: 2.385970996903907e-7) 0.99

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.