Skip to content

Commit 6263877

Browse files
liulei.88innsd
authored andcommitted
feat: Added support for model API base path and key
1 parent 5f2acc8 commit 6263877

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

agentkit/toolkit/cli/cli_init.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,16 @@ def init_command(
225225
"--model-name",
226226
help="Model name in volcengine ARK platform (default: 'doubao-seed-1-6-250615')",
227227
),
228+
model_api_base: Optional[str] = typer.Option(
229+
None,
230+
"--model-api-base",
231+
help="Base URL for model API requests (e.g., https://ark.cn-beijing.volces.com/api/v3)",
232+
),
233+
model_api_key: Optional[str] = typer.Option(
234+
None,
235+
"--model-api-key",
236+
help="API key for accessing the model",
237+
),
228238
tools: Optional[str] = typer.Option(
229239
None,
230240
"--tools",
@@ -328,6 +338,8 @@ def init_command(
328338
description=description,
329339
system_prompt=system_prompt,
330340
model_name=model_name,
341+
model_api_base=model_api_base,
342+
model_api_key=model_api_key,
331343
tools=tools,
332344
)
333345

agentkit/toolkit/executors/init_executor.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ def init_project(
115115
description: Optional[str] = None,
116116
system_prompt: Optional[str] = None,
117117
model_name: Optional[str] = None,
118+
model_api_base: Optional[str] = None,
119+
model_api_key: Optional[str] = None,
118120
tools: Optional[str] = None,
119121
) -> InitResult:
120122
"""
@@ -193,7 +195,11 @@ def init_project(
193195
)
194196

195197
render_context = self._build_render_context(
196-
agent_name, description, system_prompt, model_name, tools
198+
agent_name,
199+
description,
200+
system_prompt,
201+
model_name,
202+
tools,
197203
)
198204

199205
if source_path.is_dir():
@@ -222,6 +228,14 @@ def init_project(
222228
else:
223229
entry_point_name = file_name
224230

231+
runtime_envs = None
232+
if model_api_base or model_api_key:
233+
runtime_envs = {}
234+
if model_api_base:
235+
runtime_envs["MODEL_AGENT_API_BASE"] = model_api_base
236+
if model_api_key:
237+
runtime_envs["MODEL_AGENT_API_KEY"] = model_api_key
238+
225239
if not config_file_path.exists():
226240
self._create_config_file(
227241
config_file_path=config_file_path,
@@ -232,6 +246,7 @@ def init_project(
232246
description=f"AgentKit project {project_name} - {template_info.get('name', '')}",
233247
entry_point_name=entry_point_name,
234248
dependencies_file_name=dependencies_file_path.name,
249+
runtime_envs=runtime_envs,
235250
)
236251
self.created_files.append("agentkit.yaml")
237252
else:
@@ -544,6 +559,7 @@ def _create_config_file(
544559
description: str,
545560
entry_point_name: str,
546561
dependencies_file_name: str,
562+
runtime_envs: Optional[dict] = None,
547563
):
548564
"""
549565
Create agentkit.yaml configuration file.
@@ -569,6 +585,8 @@ def _create_config_file(
569585
common_config.description = description
570586
common_config.entry_point = entry_point_name
571587
common_config.dependencies_file = dependencies_file_name
588+
if runtime_envs:
589+
common_config.runtime_envs.update(runtime_envs)
572590
config_manager.update_common_config(common_config)
573591

574592
self._setup_config_launch_type(config_manager, common_config)

0 commit comments

Comments
 (0)