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

Function create_main_model

codewiki/src/be/llm_services.py:109–118  ·  view source on GitHub ↗

Create the main LLM model from configuration.

(config: Config)

Source from the content-addressed store, hash-verified

107class CompatibleOpenAIModel(OpenAIChatModel):
108 """OpenAIChatModel subclass that patches non-standard API proxy responses.
109
110 Some OpenAI-compatible proxies return responses with fields like
111 choices[].index set to None instead of an integer. This subclass
112 fixes those fields before pydantic validation runs.
113 """
114
115 def _validate_completion(self, response: chat.ChatCompletion) -> chat.ChatCompletion:
116 # Patch choices[].index: None -> sequential integer (0, 1, 2, ...)
117 if response.choices:
118 for i, choice in enumerate(response.choices):
119 if choice.index is None:
120 choice.index = i
121 return super()._validate_completion(response)

Callers 1

create_fallback_modelsFunction · 0.85

Calls 2

_build_model_settingsFunction · 0.85

Tested by

no test coverage detected