chat_engine = index.as_chat_engine(
streaming=True,
similarity_top_k=5,
chat_mode="condense_plus_context",
llm=llm,
response_synthesizer=response_synthesizer,
node_postprocessors=[SentenceEmbeddingOptimizer(threshold_cutoff=0.8)],
verbose=True,
system_prompt=(
"""Where possible use bulleted list and good formatting to help understand the content better. Please note to answer the questions within the context of the documents provided."""
),
)
response = chat_engine.stream_chat(query)
sources = []
for node in response.source_nodes:
sources.append(node.node.metadata["file_name"] + " (score="+ str(node.score) + ")")