File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 2020
2121from .. import _debug
2222from ..agent_output import AgentOutputSchemaBase
23- from ..exceptions import UserError
23+ from ..exceptions import ModelBehaviorError , UserError
2424from ..handoffs import Handoff
2525from ..items import ModelResponse , TResponseInputItem , TResponseStreamEvent
2626from ..logger import logger
@@ -133,6 +133,15 @@ async def get_response(
133133 stream = False ,
134134 prompt = prompt ,
135135 )
136+
137+ if not response .choices :
138+ provider_error = getattr (response , "error" , None )
139+ error_details = f": { provider_error } " if provider_error is not None else ""
140+ raise ModelBehaviorError (
141+ f"ChatCompletion response has no choices (possible provider error payload)"
142+ f"{ error_details } "
143+ )
144+
136145 message : ChatCompletionMessage | None = None
137146 first_choice : Choice | None = None
138147 if response .choices and len (response .choices ) > 0 :
You can’t perform that action at this time.
0 commit comments