Spaces:
Configuration error
Configuration error
Update app.py
Browse files
app.py
CHANGED
@@ -73,7 +73,7 @@ chat_history = []
|
|
73 |
def interact(user_input, history):
|
74 |
global tokenizer, model
|
75 |
try:
|
76 |
-
if tokenizer is None or model is
|
77 |
raise ValueError("Tokenizer or model is not initialized.")
|
78 |
|
79 |
messages = history + [{"role": "user", "content": user_input}]
|
@@ -97,7 +97,7 @@ def interact(user_input, history):
|
|
97 |
formatted_history = [(entry["content"], None) if entry["role"] == "user" else (None, entry["content"]) for entry in history if entry["role"] in ["user", "assistant"]]
|
98 |
return "", formatted_history, history
|
99 |
except Exception as e:
|
100 |
-
if torch.cuda.
|
101 |
torch.cuda.empty_cache()
|
102 |
print(f"Error during interaction: {e}")
|
103 |
raise gr.Error(f"An error occurred during interaction: {str(e)}")
|
@@ -208,4 +208,4 @@ with gr.Blocks() as demo:
|
|
208 |
send_message_button.click(fn=interact, inputs=[chatbot_input, chat_history_json], outputs=[chatbot_input, chatbot_output, chat_history_json])
|
209 |
save_button.click(fn=save_comment_score, inputs=[chatbot_output, score_input, comment_input, story_dropdown, user_dropdown], outputs=[data_table, comment_input])
|
210 |
|
211 |
-
demo.launch()
|
|
|
73 |
def interact(user_input, history):
|
74 |
global tokenizer, model
|
75 |
try:
|
76 |
+
if tokenizer is None or model is None:
|
77 |
raise ValueError("Tokenizer or model is not initialized.")
|
78 |
|
79 |
messages = history + [{"role": "user", "content": user_input}]
|
|
|
97 |
formatted_history = [(entry["content"], None) if entry["role"] == "user" else (None, entry["content"]) for entry in history if entry["role"] in ["user", "assistant"]]
|
98 |
return "", formatted_history, history
|
99 |
except Exception as e:
|
100 |
+
if torch.cuda.is_available():
|
101 |
torch.cuda.empty_cache()
|
102 |
print(f"Error during interaction: {e}")
|
103 |
raise gr.Error(f"An error occurred during interaction: {str(e)}")
|
|
|
208 |
send_message_button.click(fn=interact, inputs=[chatbot_input, chat_history_json], outputs=[chatbot_input, chatbot_output, chat_history_json])
|
209 |
save_button.click(fn=save_comment_score, inputs=[chatbot_output, score_input, comment_input, story_dropdown, user_dropdown], outputs=[data_table, comment_input])
|
210 |
|
211 |
+
demo.launch()
|