Spaces:
Running
Running
Update apps/agents/agents.py
Browse files- apps/agents/agents.py +4 -4
apps/agents/agents.py
CHANGED
|
@@ -24,7 +24,7 @@ from typing import Any, Dict, List, Optional, Tuple, Union
|
|
| 24 |
|
| 25 |
import gradio as gr
|
| 26 |
import openai
|
| 27 |
-
import
|
| 28 |
import tenacity
|
| 29 |
|
| 30 |
from apps.agents.text_utils import split_markdown_code
|
|
@@ -196,7 +196,7 @@ def role_playing_start(
|
|
| 196 |
extend_task_specify_meta_dict=meta_dict,
|
| 197 |
output_language=language,
|
| 198 |
)
|
| 199 |
-
except (
|
| 200 |
RuntimeError) as ex:
|
| 201 |
print("OpenAI API exception 0 " + str(ex))
|
| 202 |
return (state, str(ex), "", [], gr.update())
|
|
@@ -247,7 +247,7 @@ def role_playing_chat_init(state) -> \
|
|
| 247 |
try:
|
| 248 |
init_assistant_msg: BaseMessage
|
| 249 |
init_assistant_msg, _ = session.init_chat()
|
| 250 |
-
except (
|
| 251 |
RuntimeError) as ex:
|
| 252 |
print("OpenAI API exception 1 " + str(ex))
|
| 253 |
state.session = None
|
|
@@ -289,7 +289,7 @@ def role_playing_chat_cont(state) -> \
|
|
| 289 |
try:
|
| 290 |
assistant_response, user_response = session.step(
|
| 291 |
state.saved_assistant_msg)
|
| 292 |
-
except (
|
| 293 |
RuntimeError) as ex:
|
| 294 |
print("OpenAI API exception 2 " + str(ex))
|
| 295 |
state.session = None
|
|
|
|
| 24 |
|
| 25 |
import gradio as gr
|
| 26 |
import openai
|
| 27 |
+
from openai import OpenAIError
|
| 28 |
import tenacity
|
| 29 |
|
| 30 |
from apps.agents.text_utils import split_markdown_code
|
|
|
|
| 196 |
extend_task_specify_meta_dict=meta_dict,
|
| 197 |
output_language=language,
|
| 198 |
)
|
| 199 |
+
except (OpenAIError, tenacity.RetryError,
|
| 200 |
RuntimeError) as ex:
|
| 201 |
print("OpenAI API exception 0 " + str(ex))
|
| 202 |
return (state, str(ex), "", [], gr.update())
|
|
|
|
| 247 |
try:
|
| 248 |
init_assistant_msg: BaseMessage
|
| 249 |
init_assistant_msg, _ = session.init_chat()
|
| 250 |
+
except (OpenAIError, tenacity.RetryError,
|
| 251 |
RuntimeError) as ex:
|
| 252 |
print("OpenAI API exception 1 " + str(ex))
|
| 253 |
state.session = None
|
|
|
|
| 289 |
try:
|
| 290 |
assistant_response, user_response = session.step(
|
| 291 |
state.saved_assistant_msg)
|
| 292 |
+
except (OpenAIError, tenacity.RetryError,
|
| 293 |
RuntimeError) as ex:
|
| 294 |
print("OpenAI API exception 2 " + str(ex))
|
| 295 |
state.session = None
|