(token_budget: int, *, use_response_format: bool)
| 1250 | ] |
| 1251 | |
| 1252 | def _create_completion(token_budget: int, *, use_response_format: bool): |
| 1253 | kwargs = { |
| 1254 | "model": model, |
| 1255 | "messages": messages, |
| 1256 | "temperature": 0, |
| 1257 | "max_tokens": token_budget, |
| 1258 | } |
| 1259 | if use_response_format: |
| 1260 | kwargs["response_format"] = {"type": "json_object"} |
| 1261 | for effort in _openai_reasoning_effort_candidates(): |
| 1262 | try: |
| 1263 | return client.chat.completions.create(**{**kwargs, "reasoning_effort": effort}) |
| 1264 | except Exception as exc: |
| 1265 | if not _is_unsupported_reasoning_error(exc): |
| 1266 | raise |
| 1267 | return client.chat.completions.create(**kwargs) |
| 1268 | |
| 1269 | def _parse_response(response: Any) -> Optional[Dict[str, Any]]: |
| 1270 | try: |
no test coverage detected