Chat_engine retrieves the correct documents, but doesn't return all the data from the document? #16170
Replies: 1 comment 8 replies
-
To modify the def _generate_context(self, message: str) -> Tuple[str, List[NodeWithScore]]:
"""Generate context information from a message."""
nodes = self._retriever.retrieve(message)
for postprocessor in self._node_postprocessors:
nodes = postprocessor.postprocess_nodes(
nodes, query_bundle=QueryBundle(message)
)
# Concatenate all content from the nodes
context_str = "\n\n".join(
[n.node.get_content(metadata_mode=MetadataMode.LLM).strip() for n in nodes]
)
return self._context_template.format(context_str=context_str), nodes
async def _agenerate_context(self, message: str) -> Tuple[str, List[NodeWithScore]]:
"""Generate context information from a message."""
nodes = await self._retriever.aretrieve(message)
for postprocessor in self._node_postprocessors:
nodes = postprocessor.postprocess_nodes(
nodes, query_bundle=QueryBundle(message)
)
# Concatenate all content from the nodes
context_str = "\n\n".join(
[n.node.get_content(metadata_mode=MetadataMode.LLM).strip() for n in nodes]
)
return self._context_template.format(context_str=context_str), nodes This modification ensures that all the content from the retrieved nodes is concatenated and included in the context string, which will then be used in the chat responses [1]. Additionally, you can refer to the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
How do you modify the chat_engine to return all the information from a retrieved document? The engine is retrieving the correct document, but it's not displaying all the points from the documents. For example, in one document, I have 20 terms. It's showing only 9 or 10.
Beta Was this translation helpful? Give feedback.
All reactions