Spaces:
Runtime error
Runtime error
Commit
·
7b28d3b
1
Parent(s):
a779927
Update app.py
Browse files
app.py
CHANGED
@@ -109,7 +109,7 @@ def submit_message(prompt, prompt_template, temperature, max_tokens, context_len
|
|
109 |
history.append(prompt_msg)
|
110 |
history.append(completion.choices[0].message.to_dict())
|
111 |
|
112 |
-
state['total_tokens'] += completion['usage']['total_tokens']
|
113 |
|
114 |
except Exception as e:
|
115 |
history.append(prompt_msg)
|
@@ -118,10 +118,10 @@ def submit_message(prompt, prompt_template, temperature, max_tokens, context_len
|
|
118 |
"content": f"Error: {e}"
|
119 |
})
|
120 |
|
121 |
-
total_tokens_used_msg = f"Total tokens used: {state['total_tokens']}"
|
122 |
-
chat_messages =
|
123 |
|
124 |
-
return '', chat_messages
|
125 |
|
126 |
def clear_conversation():
|
127 |
return gr.update(value=None, visible=True), None, "", get_empty_state()
|
|
|
109 |
history.append(prompt_msg)
|
110 |
history.append(completion.choices[0].message.to_dict())
|
111 |
|
112 |
+
#state['total_tokens'] += completion['usage']['total_tokens']
|
113 |
|
114 |
except Exception as e:
|
115 |
history.append(prompt_msg)
|
|
|
118 |
"content": f"Error: {e}"
|
119 |
})
|
120 |
|
121 |
+
#total_tokens_used_msg = f"Total tokens used: {state['total_tokens']}"
|
122 |
+
chat_messages = [(history[i]['content'], history[i+1]['content']) for i in range(0, len(history)-1, 2)]
|
123 |
|
124 |
+
return '', chat_messages #, total_tokens_used_msg, state
|
125 |
|
126 |
def clear_conversation():
|
127 |
return gr.update(value=None, visible=True), None, "", get_empty_state()
|