Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -101,20 +101,21 @@ def print_header_json_file(filepath):
|
|
| 101 |
print(file_contents[:500]) # print only the first 500 characters
|
| 102 |
|
| 103 |
index = get_index(INDEX_FILE)
|
| 104 |
-
|
|
|
|
|
|
|
| 105 |
# passes the prompt to the chatbot
|
| 106 |
-
def chatbot(input_text,
|
| 107 |
-
global conversation_history
|
| 108 |
hyde= HyDEQueryTransform(include_original=True)
|
| 109 |
prompt = f"In character as John Haynes, please respond to: {input_text}. Only reply with contextual information or say you cannot find an answer. End with a reflective question."
|
| 110 |
response = index.query(prompt, response_mode="default", verbose=True, query_transform=hyde)
|
| 111 |
store_message(input_text,response)
|
| 112 |
|
| 113 |
# append the current input and response to the conversation history
|
| 114 |
-
|
| 115 |
|
| 116 |
# return the response and updated conversation history
|
| 117 |
-
return response.response,
|
| 118 |
|
| 119 |
with open('about.txt', 'r') as file:
|
| 120 |
about = file.read()
|
|
|
|
| 101 |
print(file_contents[:500]) # print only the first 500 characters
|
| 102 |
|
| 103 |
index = get_index(INDEX_FILE)
|
| 104 |
+
# define the conversation_history list
|
| 105 |
+
conversation_history = []
|
| 106 |
+
|
| 107 |
# passes the prompt to the chatbot
|
| 108 |
+
def chatbot(input_text, history=conversation_history):
|
|
|
|
| 109 |
hyde= HyDEQueryTransform(include_original=True)
|
| 110 |
prompt = f"In character as John Haynes, please respond to: {input_text}. Only reply with contextual information or say you cannot find an answer. End with a reflective question."
|
| 111 |
response = index.query(prompt, response_mode="default", verbose=True, query_transform=hyde)
|
| 112 |
store_message(input_text,response)
|
| 113 |
|
| 114 |
# append the current input and response to the conversation history
|
| 115 |
+
history.append((input_text, response.response))
|
| 116 |
|
| 117 |
# return the response and updated conversation history
|
| 118 |
+
return response.response, history
|
| 119 |
|
| 120 |
with open('about.txt', 'r') as file:
|
| 121 |
about = file.read()
|