Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -71,16 +71,26 @@ def get_index(index_file_path):
|
|
| 71 |
print(f"Error: '{index_file_path}' does not exist.")
|
| 72 |
sys.exit()
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
index = get_index(INDEX_FILE)
|
| 77 |
-
prompt = f"You are {mentioned_person}. Answer this: {input_text}. Only reply from the contextual data, or say you don't know. At the end of your answer ask an insightful question."
|
| 78 |
-
response = index.query(prompt, response_mode="compact", temperature=0.8)
|
| 79 |
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
# return the response
|
| 83 |
-
return response.response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
with open('about.txt', 'r') as file:
|
| 86 |
about = file.read()
|
|
|
|
| 71 |
print(f"Error: '{index_file_path}' does not exist.")
|
| 72 |
sys.exit()
|
| 73 |
|
| 74 |
+
openai = OpenAI()
|
| 75 |
+
index = get_index(INDEX_FILE)
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
+
# passes the prompt to the chatbot
|
| 78 |
+
#def chatbot(input_text, mentioned_person='Mediator John Haynes', confidence_threshold=0.5):
|
| 79 |
+
#
|
| 80 |
+
# prompt = f"You are {mentioned_person}. Answer this: {input_text}. Only reply from the contextual data, or say you don't know. At the end of your answer ask an insightful question."
|
| 81 |
+
# response = index.query(prompt, response_mode="compact")
|
| 82 |
+
#
|
| 83 |
+
# store_message(input_text,response)
|
| 84 |
|
| 85 |
# return the response
|
| 86 |
+
# return response.response
|
| 87 |
+
|
| 88 |
+
def chatbot(input_text, mentioned_person='Mediator John Haynes', temperature=0.8):
|
| 89 |
+
prompt = f"You are {mentioned_person}. Answer this: {input_text}. Only reply from the contextual data, or say you don't know. At the end of your answer ask an insightful question."
|
| 90 |
+
context = index.get_context(prompt)
|
| 91 |
+
response = openai.complete(prompt, context=context, temperature=temperature)['choices'][0]['text']
|
| 92 |
+
store_message(input_text,response)
|
| 93 |
+
return response
|
| 94 |
|
| 95 |
with open('about.txt', 'r') as file:
|
| 96 |
about = file.read()
|