fix insight context to improve citations

This commit is contained in:
LUIS NOVO 2024-11-13 17:02:18 -03:00
parent 066c7a06e2
commit 06c6842f11

View file

@ -141,15 +141,16 @@ class Source(ObjectModel):
def get_context( def get_context(
self, context_size: Literal["short", "long"] = "short" self, context_size: Literal["short", "long"] = "short"
) -> Dict[str, Any]: ) -> Dict[str, Any]:
insights = [insight.model_dump() for insight in self.insights]
if context_size == "long": if context_size == "long":
return dict( return dict(
id=self.id, id=self.id,
title=self.title, title=self.title,
insights=[insight.model_dump() for insight in self.insights], insights=insights,
full_text=self.full_text, full_text=self.full_text,
) )
else: else:
return dict(id=self.id, title=self.title, insights=self.insights) return dict(id=self.id, title=self.title, insights=insights)
@property @property
def embedded_chunks(self) -> int: def embedded_chunks(self) -> int: