Skip to content

Commit

Permalink
Fix summarization including empty descriptions (microsoft#1124)
Browse files Browse the repository at this point in the history
* Fix summarization including empty descriptions

* Update
  • Loading branch information
AlonsoGuevara authored and KylinMountain committed Sep 12, 2024
1 parent 88a071d commit fa2c3d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .semversioner/next-release/patch-20240911214150592475.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "patch",
"description": "Fix summarization including empty descriptions"
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async def __call__(
result = ""
if len(descriptions) == 0:
result = ""
if len(descriptions) == 1:
elif len(descriptions) == 1:
result = descriptions[0]
else:
result = await self._summarize_descriptions(items, descriptions)
Expand All @@ -87,7 +87,11 @@ async def _summarize_descriptions(
if not isinstance(descriptions, list):
descriptions = [descriptions]

# Iterate over descriptions, adding all until the max input tokens is reached
# Sort description lists
if len(descriptions) > 1:
descriptions = sorted(descriptions)

# Iterate over descriptions, adding all until the max input tokens is reached
usable_tokens = self._max_input_tokens - num_tokens_from_string(
self._summarization_prompt
)
Expand Down

0 comments on commit fa2c3d0

Please sign in to comment.