Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Commit a33c411

Browse files
authored
Merge pull request #30 from dreadnode/revert-29-simone/eng-652-support-user-provided-api-keys-and-model-configurations-for
Revert "new: implemented user models support (ENG-652)"
2 parents 894b39e + 773303e commit a33c411

File tree

5 files changed

+18
-96
lines changed

5 files changed

+18
-96
lines changed

dreadnode_cli/agent/cli.py

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@
1616
from dreadnode_cli.agent.format import (
1717
format_agent,
1818
format_agent_versions,
19+
format_models,
1920
format_run,
2021
format_runs,
21-
format_strike_models,
2222
format_strikes,
23-
format_user_models,
2423
)
2524
from dreadnode_cli.agent.templates import cli as templates_cli
2625
from dreadnode_cli.agent.templates.format import format_templates
2726
from dreadnode_cli.agent.templates.manager import TemplateManager
28-
from dreadnode_cli.config import UserConfig, UserModel, UserModels
27+
from dreadnode_cli.config import UserConfig
2928
from dreadnode_cli.profile.cli import switch as switch_profile
3029
from dreadnode_cli.types import GithubRepo
3130
from dreadnode_cli.utils import download_and_unzip_archive, get_repo_archive_source_path, pretty_cli
@@ -340,22 +339,14 @@ def deploy(
340339
if strike is None:
341340
raise Exception("No strike specified, use -s/--strike or set the strike in the agent config")
342341

343-
user_models = UserModels.read()
344-
user_model: UserModel | None = None
345-
346342
# Verify the model if it was supplied
347343
if model is not None:
348-
# check if it's a user model
349-
user_model = next((m for m in user_models.models if m.key == model), None)
350-
if not user_model:
351-
# check if it's a strike model
352-
strike_response = client.get_strike(strike)
353-
if not any(m.key == model for m in strike_response.models):
354-
models(directory, strike=strike)
355-
print()
356-
raise Exception(f"Model '{model}' is not a user model nor was found in strike '{strike_response.name}'")
357-
358-
run = client.start_strike_run(agent.latest_version.id, strike=strike, model=model, user_model=user_model)
344+
strike_response = client.get_strike(strike)
345+
if not any(m.key == model for m in strike_response.models):
346+
print(format_models(strike_response.models))
347+
raise Exception(f"Model '{model}' not found in strike '{strike_response.name}'")
348+
349+
run = client.start_strike_run(agent.latest_version.id, strike=strike, model=model)
359350
agent_config.add_run(run.id).write(directory)
360351
formatted = format_run(run)
361352

@@ -378,11 +369,6 @@ def models(
378369
] = pathlib.Path("."),
379370
strike: t.Annotated[str | None, typer.Option("--strike", "-s", help="The strike to query")] = None,
380371
) -> None:
381-
user_models = UserModels.read()
382-
if user_models.models:
383-
print("[bold]User models:[/]\n")
384-
print(format_user_models(user_models.models))
385-
386372
if strike is None:
387373
agent_config = AgentConfig.read(directory)
388374
ensure_profile(agent_config)
@@ -392,9 +378,7 @@ def models(
392378
raise Exception("No strike specified, use -s/--strike or set the strike in the agent config")
393379

394380
strike_response = api.create_client().get_strike(strike)
395-
if user_models.models:
396-
print("\n[bold]Strike models:[/]\n")
397-
print(format_strike_models(strike_response.models))
381+
print(format_models(strike_response.models))
398382

399383

400384
@cli.command(help="List available strikes")

dreadnode_cli/agent/format.py

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from rich.text import Text
1010

1111
from dreadnode_cli import api
12-
from dreadnode_cli.config import UserModel
1312

1413
P = t.ParamSpec("P")
1514

@@ -63,26 +62,7 @@ def format_time(dt: datetime | None) -> str:
6362
return dt.astimezone().strftime("%c") if dt else "-"
6463

6564

66-
def format_user_models(models: list[UserModel]) -> RenderableType:
67-
table = Table(box=box.ROUNDED)
68-
table.add_column("key")
69-
table.add_column("name")
70-
table.add_column("provider")
71-
table.add_column("api_key")
72-
73-
for model in models:
74-
provider_style = get_model_provider_style(model.provider)
75-
table.add_row(
76-
Text(model.key),
77-
Text(model.name, style=f"bold {provider_style}"),
78-
Text(model.provider, style=provider_style),
79-
Text("yes" if model.api_key else "no", style="green" if model.api_key else "dim"),
80-
)
81-
82-
return table
83-
84-
85-
def format_strike_models(models: list[api.Client.StrikeModel]) -> RenderableType:
65+
def format_models(models: list[api.Client.StrikeModel]) -> RenderableType:
8666
table = Table(box=box.ROUNDED)
8767
table.add_column("key")
8868
table.add_column("name")
@@ -292,8 +272,7 @@ def format_run(run: api.Client.StrikeRunResponse, *, verbose: bool = False, incl
292272
agent_name = f"[bold magenta]{run.agent_key}[/]"
293273

294274
table.add_row("", "")
295-
# um@ is added to indicate a user model
296-
table.add_row("model", run.model.replace("um@", "") if run.model else "<default>")
275+
table.add_row("model", run.model or "<default>")
297276
table.add_row("agent", f"{agent_name} ([dim]rev[/] [yellow]{run.agent_revision}[/])")
298277
table.add_row("image", Text(run.agent_version.container.image, style="cyan"))
299278
table.add_row("notes", run.agent_version.notes or "-")
@@ -325,8 +304,7 @@ def format_runs(runs: list[api.Client.StrikeRunSummaryResponse]) -> RenderableTy
325304
str(run.id),
326305
f"[bold magenta]{run.agent_key}[/] [dim]:[/] [yellow]{run.agent_revision}[/]",
327306
Text(run.status, style="bold " + get_status_style(run.status)),
328-
# um@ is added to indicate a user model
329-
Text(run.model.replace("um@", "") if run.model else "-"),
307+
Text(run.model or "-"),
330308
format_time(run.start),
331309
Text(format_duration(run.start, run.end), style="bold cyan"),
332310
)

dreadnode_cli/api.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from rich import print
1212

1313
from dreadnode_cli import __version__, utils
14-
from dreadnode_cli.config import UserConfig, UserModel
14+
from dreadnode_cli.config import UserConfig
1515
from dreadnode_cli.defaults import (
1616
DEBUG,
1717
DEFAULT_MAX_POLL_TIME,
@@ -430,20 +430,14 @@ def create_strike_agent_version(
430430
return self.StrikeAgentResponse(**response.json())
431431

432432
def start_strike_run(
433-
self,
434-
agent_version_id: UUID,
435-
*,
436-
model: str | None = None,
437-
user_model: UserModel | None = None,
438-
strike: UUID | str | None = None,
433+
self, agent_version_id: UUID, *, model: str | None = None, strike: UUID | str | None = None
439434
) -> StrikeRunResponse:
440435
response = self.request(
441436
"POST",
442437
"/api/strikes/runs",
443438
json_data={
444439
"agent_version_id": str(agent_version_id),
445440
"model": model,
446-
"user_model": user_model.model_dump(mode="json") if user_model else None,
447441
"strike": str(strike) if strike else None,
448442
},
449443
)

dreadnode_cli/config.py

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from pydantic import BaseModel
1+
import pydantic
22
from rich import print
33
from ruamel.yaml import YAML
44

5-
from dreadnode_cli.defaults import DEFAULT_PROFILE_NAME, USER_CONFIG_PATH, USER_MODELS_CONFIG_PATH
5+
from dreadnode_cli.defaults import DEFAULT_PROFILE_NAME, USER_CONFIG_PATH
66

77

8-
class ServerConfig(BaseModel):
8+
class ServerConfig(pydantic.BaseModel):
99
"""Server specific authentication data and API URL."""
1010

1111
url: str
@@ -16,7 +16,7 @@ class ServerConfig(BaseModel):
1616
refresh_token: str
1717

1818

19-
class UserConfig(BaseModel):
19+
class UserConfig(pydantic.BaseModel):
2020
"""User configuration supporting multiple server profiles."""
2121

2222
active: str | None = None
@@ -74,31 +74,3 @@ def set_server_config(self, config: ServerConfig, profile: str | None = None) ->
7474
profile = profile or self.active or DEFAULT_PROFILE_NAME
7575
self.servers[profile] = config
7676
return self
77-
78-
79-
class UserModel(BaseModel):
80-
"""
81-
A user defined model.
82-
"""
83-
84-
key: str
85-
name: str
86-
provider: str
87-
generator_id: str
88-
api_key: str | None = None
89-
90-
91-
class UserModels(BaseModel):
92-
"""User models configuration."""
93-
94-
models: list[UserModel] = []
95-
96-
@classmethod
97-
def read(cls) -> "UserModels":
98-
"""Read the user models configuration from the file system or return an empty instance."""
99-
100-
if not USER_MODELS_CONFIG_PATH.exists():
101-
return cls()
102-
103-
with USER_MODELS_CONFIG_PATH.open("r") as f:
104-
return cls.model_validate(YAML().load(f))

dreadnode_cli/defaults.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@
2525
os.getenv("DREADNODE_USER_CONFIG_FILE") or pathlib.Path.home() / ".dreadnode" / "config"
2626
)
2727

28-
# path to the user models configuration file
29-
USER_MODELS_CONFIG_PATH = pathlib.Path(
30-
# allow overriding the user config file via env variable
31-
os.getenv("DREADNODE_USER_CONFIG_FILE") or pathlib.Path.home() / ".dreadnode" / "models.yml"
32-
)
33-
3428
# path to the templates directory
3529
TEMPLATES_PATH = pathlib.Path(
3630
# allow overriding the templates path via env variable

0 commit comments

Comments
 (0)