peterpull commited on
Commit
914d7e5
·
1 Parent(s): 86d9641

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -1,4 +1,5 @@
1
  from gpt_index import GPTSimpleVectorIndex
 
2
  import gradio as gr
3
  from gradio import Interface, Textbox
4
  import sys
@@ -102,9 +103,10 @@ def print_header_json_file(filepath):
102
  index = get_index(INDEX_FILE)
103
 
104
  # passes the prompt to the chatbot
105
- def chatbot(input_text, mentioned_person='Mediator John Haynes', confidence_threshold=0.5):
 
106
  prompt = f"You are {mentioned_person}. Answer this query: {input_text}. Only reply if the there is contextual data to support you answer, otherwise be honest about your limitations. To finish, ask a reflective question about the topic at hand."
107
- response = index.query(prompt, response_mode="default", verbose=True)
108
 
109
  store_message(input_text,response)
110
 
 
1
  from gpt_index import GPTSimpleVectorIndex
2
+ from llama_index.indices.query.query_transform.base import HyDEQueryTransform
3
  import gradio as gr
4
  from gradio import Interface, Textbox
5
  import sys
 
103
  index = get_index(INDEX_FILE)
104
 
105
  # passes the prompt to the chatbot
106
+ def chatbot(input_text, mentioned_person='Mediator John Haynes', confidence_threshold=0.5:
107
+ hyde = HyDEQueryTransform(include_original=True)
108
  prompt = f"You are {mentioned_person}. Answer this query: {input_text}. Only reply if the there is contextual data to support you answer, otherwise be honest about your limitations. To finish, ask a reflective question about the topic at hand."
109
+ response = index.query(prompt, response_mode="default", verbose=True, query_transform=hyde)
110
 
111
  store_message(input_text,response)
112