hymai commited on
Commit
072c024
·
verified ·
1 Parent(s): f633b78

Update app.py

Browse files

added source nodes

Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -116,7 +116,7 @@ retriever = DocumentSummaryIndexEmbeddingRetriever(
116
  # set up retriever
117
  retriever = VectorIndexRetriever(
118
  index = index,
119
- similarity_top_k = 10,
120
  #vector_store_query_mode="mmr",
121
  #vector_store_kwargs={"mmr_threshold": 0.4}
122
  )
@@ -198,8 +198,11 @@ with gr.Blocks() as demo:
198
  def bot(history):
199
  user_message = history[-1][0]
200
  #bot_message = chat_engine.chat(user_message)
 
201
  bot_message = query_engine.query(user_message + "Let's think step by step to get the correct answer. If you cannot provide an answer, say you don't know.")
202
- source_nodes = bot_message.source_nodes
 
 
203
  final_response = bot_message.response + "\n Source nodes: \n" + source_nodes
204
  history[-1][1] = ""
205
  for character in final_response:
 
116
  # set up retriever
117
  retriever = VectorIndexRetriever(
118
  index = index,
119
+ similarity_top_k = 15,
120
  #vector_store_query_mode="mmr",
121
  #vector_store_kwargs={"mmr_threshold": 0.4}
122
  )
 
198
  def bot(history):
199
  user_message = history[-1][0]
200
  #bot_message = chat_engine.chat(user_message)
201
+ source_nodes = ""
202
  bot_message = query_engine.query(user_message + "Let's think step by step to get the correct answer. If you cannot provide an answer, say you don't know.")
203
+ source_nodes_list = bot_message.source_nodes
204
+ for nodes in source_nodes_list:
205
+ source_nodes = source_nodes + nodes + "\n\n"
206
  final_response = bot_message.response + "\n Source nodes: \n" + source_nodes
207
  history[-1][1] = ""
208
  for character in final_response: