MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / LLMConfig

Class LLMConfig

src/harness/llms/client.py:22–55  ·  view source on GitHub ↗

Configuration for LLM client.

Source from the content-addressed store, hash-verified

20
21@dataclass
22class LLMConfig:
23 """Configuration for LLM client."""
24
25 api_base: Optional[str] = None
26 api_key: Optional[str] = None
27 timeout: int = DEFAULT_TIMEOUT
28 num_retries: int = DEFAULT_RETRIES
29 temperature: Optional[float] = None
30 drop_params: bool = True
31 _env_keys: Dict[str, str] = field(default_factory=dict, repr=False)
32
33 def __post_init__(self):
34 env_mappings = {
35 "OPENAI_API_KEY": "openai",
36 "ANTHROPIC_API_KEY": "anthropic",
37 "GOOGLE_API_KEY": "google",
38 "COHERE_API_KEY": "cohere",
39 "MISTRAL_API_KEY": "mistral",
40 "AZURE_API_KEY": "azure",
41 "HOSTED_VLLM_API_KEY": "hosted_vllm",
42 "VLLM_API_KEY": "hosted_vllm",
43 }
44 for env_var, provider in env_mappings.items():
45 value = os.environ.get(env_var)
46 if value:
47 self._env_keys[provider] = value
48
49 if not self.api_key:
50 self.api_key = os.environ.get("OPENAI_API_KEY")
51
52 if not self.api_base:
53 self.api_base = os.environ.get("VLLM_API_BASE") or os.environ.get(
54 "HOSTED_VLLM_API_BASE"
55 )
56
57
58def normalize_model_name(model: str) -> str:

Callers 2

_make_clientMethod · 0.90
__init__Method · 0.85

Calls

no outgoing calls

Tested by 1

_make_clientMethod · 0.72