MCPcopy Create free account
hub / github.com/FSoft-AI4Code/CodeWiki / CompatibleOpenAIModel

Class CompatibleOpenAIModel

codewiki/src/be/llm_services.py:70–84  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

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
75def _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

Callers 2

create_main_modelFunction · 0.85
create_fallback_modelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected