OpenAIModel subclass that patches non-standard API proxy responses. Some OpenAI-compatible proxies return responses with fields like choices[].index set to None instead of an integer. This subclass fixes those fields before pydantic validation runs.
| 68 | return True |
| 69 | # If base_url points to OpenAI directly, newer models may need it |
| 70 | if base_url and "api.openai.com" in base_url: |
| 71 | return True |
| 72 | return False |
| 73 | |
| 74 | |
| 75 | def _build_model_settings(config: Config, model_name: str) -> OpenAIChatModelSettings: |
| 76 | """Build model settings with the correct token parameter. |
| 77 | |
| 78 | No temperature is sent: some providers/models (e.g. reasoning models that |
| 79 | only accept temperature=1) reject explicit values, so requests rely on the |
| 80 | provider default. |
| 81 | """ |
| 82 | if _should_use_max_completion_tokens(model_name, config.llm_base_url): |
| 83 | return OpenAIChatModelSettings( |
| 84 | max_completion_tokens=config.max_tokens |
| 85 | ) |
| 86 | return OpenAIChatModelSettings( |
| 87 | max_tokens=config.max_tokens |
no outgoing calls
no test coverage detected