Update app.py
Browse files
app.py
CHANGED
@@ -58,10 +58,9 @@ def submit_message(user_token, prompt, prompt_template, good_foods, bad_foods, t
|
|
58 |
max_tokens=max_tokens,
|
59 |
stream=False)
|
60 |
|
61 |
-
history.append(prompt_msg
|
62 |
answer = completion.choices[0].message.content
|
63 |
-
|
64 |
-
history.append(answer)
|
65 |
|
66 |
state['total_tokens'] += completion['usage']['total_tokens']
|
67 |
|
@@ -80,14 +79,14 @@ def submit_message(user_token, prompt, prompt_template, good_foods, bad_foods, t
|
|
80 |
state['total_tokens'] += completion2['usage']['total_tokens']
|
81 |
|
82 |
except Exception as e:
|
83 |
-
history.append(prompt_msg
|
84 |
history.append({
|
85 |
"role": "system",
|
86 |
"content": f"Error: {e}"
|
87 |
})
|
88 |
|
89 |
total_tokens_used_msg = f"Total tokens used: {state['total_tokens']}"
|
90 |
-
chat_messages = [(history[i], history[i+1]) for i in range(0, len(history)-1, 2)]
|
91 |
|
92 |
return '', chat_messages, total_tokens_used_msg, state, table
|
93 |
|
|
|
58 |
max_tokens=max_tokens,
|
59 |
stream=False)
|
60 |
|
61 |
+
history.append(prompt_msg)
|
62 |
answer = completion.choices[0].message.content
|
63 |
+
history.append(completion.choices[0].message)
|
|
|
64 |
|
65 |
state['total_tokens'] += completion['usage']['total_tokens']
|
66 |
|
|
|
79 |
state['total_tokens'] += completion2['usage']['total_tokens']
|
80 |
|
81 |
except Exception as e:
|
82 |
+
history.append(prompt_msg)
|
83 |
history.append({
|
84 |
"role": "system",
|
85 |
"content": f"Error: {e}"
|
86 |
})
|
87 |
|
88 |
total_tokens_used_msg = f"Total tokens used: {state['total_tokens']}"
|
89 |
+
chat_messages = [(history[i]['content'], history[i+1]['content']) for i in range(0, len(history)-1, 2)]
|
90 |
|
91 |
return '', chat_messages, total_tokens_used_msg, state, table
|
92 |
|