Skip to content

Commit

Permalink
print sources in a separate section with some meta info
Browse files Browse the repository at this point in the history
  • Loading branch information
Quantisan committed Sep 19, 2023
1 parent baa3e09 commit 2e442ea
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mind_palace/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ def load_index(model):
if st.session_state.messages[-1]["role"] != "assistant":
with st.chat_message("assistant"):
with st.spinner("Thinking..."):

response = query_engine.query(prompt)
st.write(response.response)
for source_node in response.source_nodes:
st.write(source_node.node.get_text())

message = {"role": "assistant", "content": response.response}
st.session_state.messages.append(message) # Add response to message history

for i, source_node in enumerate(response.source_nodes):
st.write(f"[{i+1}]")
st.write(f"id: {source_node.node.node_id}")
st.write(f"score: {source_node.score}")
st.write(f"text: {source_node.node.get_text().split(':', 1)[1]}")

0 comments on commit 2e442ea

Please sign in to comment.