Skip to content

Commit

Permalink
Merge pull request #179 from enoch3712/178-typeerror-unhashable-type-…
Browse files Browse the repository at this point in the history
…list

Paginate not merging properly (List Hashing)
  • Loading branch information
enoch3712 authored Jan 3, 2025
2 parents 04712a0 + a193d4b commit fdf5d3a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion extract_thinker/pagination_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,21 @@ def _merge_results(self, results: List[Any], response_model: type[BaseModel], pa
if len(non_null_values) == 0:
merged[field_name] = None
else:
distinct_values = list(set(non_null_values))
# Convert unhashable types (e.g., lists) to hashable types
hashable_values = [tuple(item) if isinstance(item, list) else item for item in non_null_values]

try:
distinct_values = list(set(hashable_values))
except TypeError:
# Fallback to order-preserving method if conversion fails
seen = set()
distinct_values = []
for item in hashable_values:
if item not in seen:
seen.add(item)
distinct_values.append(item)
# **Modification Ends Here**

if len(distinct_values) == 1:
merged[field_name] = distinct_values[0]
else:
Expand Down

0 comments on commit fdf5d3a

Please sign in to comment.