feat: apiError

This commit is contained in:
ai-business-hql
2025-07-29 16:43:48 +08:00
parent b797d07406
commit 2b2d31dea4
2 changed files with 1248 additions and 452 deletions
+1245 -450
View File
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -19,6 +19,7 @@ from agents.run import Runner
from agents.tracing import set_tracing_disabled
from ..service.workflow_rewrite_agent import create_workflow_rewrite_agent
from openai.types.responses import ResponseTextDeltaEvent
from openai import APIError
# Load environment variables from server.env
def load_env_config():
@@ -266,7 +267,7 @@ You must adhere to the following constraints to complete the task:
else:
pass # Ignore other event types
except (AttributeError, TypeError) as attr_error:
except (AttributeError, TypeError, APIError) as attr_error:
# Handle specific OpenAI streaming errors like "NoneType has no attribute strip"
if "'NoneType' object has no attribute 'strip'" in str(attr_error):
print(f"OpenAI streaming chunk error (NoneType strip): {attr_error}")
@@ -291,7 +292,7 @@ You must adhere to the following constraints to complete the task:
# If we get here, streaming completed successfully
break
except (AttributeError, TypeError, ConnectionError, OSError) as stream_error:
except (AttributeError, TypeError, ConnectionError, OSError, APIError) as stream_error:
retry_count += 1
error_msg = str(stream_error)