Skip to content

Commit c12c280

Browse files
committed
new: generator can now be specified as an optional field in the yml
1 parent cbd50e2 commit c12c280

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

examples/changelog/agent.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
agent: >
22
You are an helpful assistant that generates changelogs for projects.
3-
3+
44
## Guidance
55
66
- Do not use the get_new_commits tool since you already have the list of commits.
@@ -44,4 +44,4 @@ tools:
4444
complete_task: true
4545
# will just print to stdout
4646
tool: "echo {{ markdown }}"
47-
print: true
47+
print: true

nerve/cli/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def run(
3939
] = pathlib.Path("."),
4040
generator: t.Annotated[
4141
str,
42-
typer.Option("--generator", "-g", help="Generator to use"),
42+
typer.Option("--generator", "-g", help="If the agent generator field is not set, use this generator."),
4343
] = DEFAULT_GENERATOR,
4444
conversation_strategy: t.Annotated[
4545
str,

nerve/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ class Configuration(BaseModel):
6464
# legacy field used to detect if the user is loading a legacy file
6565
system_prompt: str | None = Field(default=None, exclude=True)
6666

67-
# TODO: add optional generator and use -g as override (or if generator not set in yaml)
68-
67+
# optional generator
68+
generator: str | None = None
6969
# used for versioning the agents
7070
version: str = "1.0.0"
7171
# the system prompt, the agent identity

nerve/runtime/agent.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def create(
4444
Create an agent from a generator and configuration.
4545
4646
Args:
47-
generator: The generator string to use.
47+
generator: The generator string to use if not set in the configuration.
4848
configuration: The configuration to use.
4949
start_state: Initial variables for the agent.
5050
window_strategy: How to handle conversation history.
@@ -67,10 +67,12 @@ def create(
6767
)
6868
)
6969

70+
generator_to_use = configuration.generator or generator
71+
7072
runtime = Runtime.build(
7173
working_dir=working_dir,
7274
name=name,
73-
generator=generator,
75+
generator=generator_to_use,
7476
using=configuration.using,
7577
jail=configuration.jail,
7678
tools=configuration.tools,
@@ -79,7 +81,7 @@ def create(
7981
return cls(
8082
runtime=runtime,
8183
configuration=configuration,
82-
generation_engine=LiteLLMEngine(generator, window_strategy, runtime.tools),
84+
generation_engine=LiteLLMEngine(generator_to_use, window_strategy, runtime.tools),
8385
conv_window_strategy=window_strategy,
8486
)
8587

0 commit comments

Comments
 (0)