Skip to content

Commit bb8394b

Browse files
committed
feat: add kwargs support for model configuration
- Add kwargs field in model config for passing extra params to LiteLLM - Support temperature, top_p, max_tokens, reasoning_effort, etc. - Update config_example.yaml with usage examples
1 parent 38d94a4 commit bb8394b

File tree

2 files changed

+53
-34
lines changed

2 files changed

+53
-34
lines changed

easyagent/config/base.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,29 +58,30 @@ def get_summary_model(fallback: str = "gpt-4o") -> str:
5858
class ModelConfig(BaseConfig):
5959
models: dict[str, dict[str, Any]] = {}
6060

61-
def get_model(self, name: str) -> dict:
62-
if name not in self.models:
63-
raise KeyError(f"Model '{name}' not found")
64-
65-
cfg = self.models[name]
66-
api_type = cfg.get("api_type", "openai")
67-
model_name = f"{api_type}/{name}"
68-
69-
if cost := cfg.get("cost"):
70-
litellm.register_model({model_name: {"litellm_provider": api_type, **cost}})
71-
aliases = cfg.get("aliases") or []
72-
if isinstance(aliases, str):
73-
aliases = [aliases]
74-
for alias in aliases:
75-
alias_name = f"{api_type}/{alias}"
76-
litellm.register_model(
77-
{alias_name: {"litellm_provider": api_type, **cost}}
78-
)
61+
def get_model(self, name: str) -> dict:
62+
if name not in self.models:
63+
raise KeyError(f"Model '{name}' not found")
64+
65+
cfg = self.models[name]
66+
api_type = cfg.get("api_type", "openai")
67+
model_name = f"{api_type}/{name}"
68+
69+
if cost := cfg.get("cost"):
70+
litellm.register_model({model_name: {"litellm_provider": api_type, **cost}})
71+
aliases = cfg.get("aliases") or []
72+
if isinstance(aliases, str):
73+
aliases = [aliases]
74+
for alias in aliases:
75+
alias_name = f"{api_type}/{alias}"
76+
litellm.register_model(
77+
{alias_name: {"litellm_provider": api_type, **cost}}
78+
)
7979

8080
return {
8181
"model": model_name,
8282
"api_base": cfg.get("base_url"),
8383
"api_key": cfg.get("api_key"),
84+
**(cfg.get("kwargs") or {}),
8485
}
8586

8687

easyagent/config/config_example.yaml

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,43 @@ summary_model: gpt-4o-mini
55
models:
66
gpt-4o-mini:
77
api_type: openai
8-
base_url:
9-
api_key:
10-
gemini-2.5-flash:
8+
base_url: https://api.openai.com/v1
9+
api_key: sk-xxx
10+
11+
# OpenAI o1/o3 reasoning models
12+
o3-mini:
13+
api_type: openai
14+
base_url: https://api.openai.com/v1
15+
api_key: sk-xxx
16+
kwargs:
17+
reasoning_effort: high # none, minimal, low, medium, high, xhigh
18+
max_completion_tokens: 8192
19+
20+
# Custom model with full config
21+
gemini-3-flash-preview:
1122
api_type: openai
12-
base_url:
13-
api_key:
23+
base_url: https://your-proxy.com/v1
24+
api_key: your-key
25+
# cost: model metadata for litellm cost calculation
1426
cost:
1527
input_cost_per_token: 0.0000003
1628
output_cost_per_token: 0.00000252
17-
max_tokens: 8192
29+
max_tokens: 8192 # model's max capability
1830
max_input_tokens: 1048576
1931
max_output_tokens: 8192
20-
gemini-3-pro-preview:
21-
api_type: openai
22-
base_url:
23-
api_key:
24-
cost:
25-
input_cost_per_token: 0.00000125
26-
output_cost_per_token: 0.00001
27-
max_tokens: 65536
28-
max_input_tokens: 1048576
29-
max_output_tokens: 65536
32+
# kwargs: API call parameters
33+
kwargs:
34+
temperature: 0.7
35+
top_p: 0.9
36+
max_tokens: 4096 # actual limit per request
37+
38+
# Claude with thinking
39+
claude-sonnet-4.5:
40+
api_type: anthropic
41+
api_key: sk-ant-xxx
42+
kwargs:
43+
temperature: 1.0
44+
max_tokens: 8192
45+
# thinking: # Anthropic extended thinking
46+
# type: enabled
47+
# budget_tokens: 5000

0 commit comments

Comments
 (0)