Spaces:
Runtime error
Runtime error
Commit
·
2394274
1
Parent(s):
42cf399
Update app.py
Browse files
app.py
CHANGED
|
@@ -123,10 +123,6 @@ def submit_message(prompt, prompt_template, temperature, max_tokens, context_len
|
|
| 123 |
len(texts)
|
| 124 |
embeddings = OpenAIEmbeddings()
|
| 125 |
|
| 126 |
-
|
| 127 |
-
#with open("foo.pkl", 'wb') as f:
|
| 128 |
-
# pickle.dump(embeddings, f)
|
| 129 |
-
|
| 130 |
|
| 131 |
history = state['messages']
|
| 132 |
|
|
@@ -185,16 +181,18 @@ def submit_message(prompt, prompt_template, temperature, max_tokens, context_len
|
|
| 185 |
|
| 186 |
except Exception as e:
|
| 187 |
history.append(prompt_msg.copy())
|
| 188 |
-
|
| 189 |
"role": "system",
|
| 190 |
"content": f"Error: {e}"
|
| 191 |
-
}
|
|
|
|
| 192 |
|
| 193 |
total_tokens_used_msg = f"Total tokens used: {state['total_tokens']}"
|
| 194 |
|
| 195 |
#chat_messages = [(history[i]['content'], history[i+1]['content']) for i in range(0, len(history)-1, 2)]
|
| 196 |
|
| 197 |
-
chat_messages = [(history[0]['content'],history[1]['content'])]
|
|
|
|
| 198 |
return '', chat_messages, total_tokens_used_msg, state
|
| 199 |
|
| 200 |
def clear_conversation():
|
|
|
|
| 123 |
len(texts)
|
| 124 |
embeddings = OpenAIEmbeddings()
|
| 125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
history = state['messages']
|
| 128 |
|
|
|
|
| 181 |
|
| 182 |
except Exception as e:
|
| 183 |
history.append(prompt_msg.copy())
|
| 184 |
+
error = {
|
| 185 |
"role": "system",
|
| 186 |
"content": f"Error: {e}"
|
| 187 |
+
}
|
| 188 |
+
history.append(error.copy())
|
| 189 |
|
| 190 |
total_tokens_used_msg = f"Total tokens used: {state['total_tokens']}"
|
| 191 |
|
| 192 |
#chat_messages = [(history[i]['content'], history[i+1]['content']) for i in range(0, len(history)-1, 2)]
|
| 193 |
|
| 194 |
+
chat_messages = [(history[0]['content'], history[1]['content'])]
|
| 195 |
+
|
| 196 |
return '', chat_messages, total_tokens_used_msg, state
|
| 197 |
|
| 198 |
def clear_conversation():
|