MCPcopy Create free account
hub / github.com/Dizzy-K/AutoPT / _build_llm

Function _build_llm

config/loader.py:129–160  ·  view source on GitHub ↗
(raw: Mapping[str, Any])

Source from the content-addressed store, hash-verified

127
128
129def _build_llm(raw: Mapping[str, Any]) -> LLMConfig:
130 llm_data = _as_mapping(raw.get("llm"))
131 if llm_data:
132 provider_payloads = {
133 str(name): _build_llm_provider(_as_mapping(payload))
134 for name, payload in _as_mapping(llm_data.get("providers")).items()
135 }
136 return LLMConfig(
137 default_provider=str(llm_data.get("default_provider", "openai")),
138 default_model=str(llm_data.get("default_model", "")),
139 temperature=float(llm_data.get("temperature", 0.0)),
140 providers=provider_payloads,
141 )
142
143 legacy_data = _as_mapping(raw.get("ai", raw.get("providers", {})))
144 return LLMConfig(
145 default_provider=str(legacy_data.get("default_provider", "openai")),
146 default_model=str(legacy_data.get("default_model", raw.get("default_model", ""))),
147 temperature=float(legacy_data.get("temperature", 0.0)),
148 providers={
149 "openai": LLMProviderConfig(
150 api_base=str(legacy_data.get("openai_base", "")),
151 api_key=str(legacy_data.get("openai_key", "")),
152 ),
153 "nvidia": LLMProviderConfig(
154 api_key=str(legacy_data.get("nvidia_key", "")),
155 ),
156 "together": LLMProviderConfig(
157 api_key=str(legacy_data.get("together_key", "")),
158 ),
159 },
160 )
161
162
163def _build_optimization(data: Mapping[str, Any]) -> OptimizationConfig:

Callers 1

load_app_configFunction · 0.85

Calls 4

_as_mappingFunction · 0.85
_build_llm_providerFunction · 0.85
LLMConfigClass · 0.85
LLMProviderConfigClass · 0.85

Tested by

no test coverage detected