Skip to content

Commit 2814229

Browse files
committed
Add templating agentstack config validation
1 parent b064693 commit 2814229

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

agentstack/generation/files.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
from pathlib import Path
55
from pydantic import BaseModel
6+
from agentstack.utils import get_version
67

78

89
DEFAULT_FRAMEWORK = "crewai"
@@ -34,12 +35,21 @@ class ConfigFile(BaseModel):
3435
Whether the user has opted out of telemetry.
3536
default_model: Optional[str]
3637
The default model to use when generating agent configurations.
38+
agentstack_version: Optional[str]
39+
The version of agentstack used to generate the project.
40+
template: Optional[str]
41+
The template used to generate the project.
42+
template_version: Optional[str]
43+
The version of the template system used to generate the project.
3744
"""
3845

3946
framework: str = DEFAULT_FRAMEWORK
4047
tools: list[str] = []
4148
telemetry_opt_out: Optional[bool] = None
4249
default_model: Optional[str] = None
50+
agentstack_version: Optional[str] = get_version()
51+
template: Optional[str] = None
52+
template_version: Optional[str] = None
4353

4454
def __init__(self, path: Union[str, Path, None] = None):
4555
path = Path(path) if path else Path.cwd()

tests/test_generation_files.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
verify_agentstack_project,
88
get_framework,
99
get_telemetry_opt_out,
10+
get_version,
1011
)
1112

1213
BASE_PATH = Path(__file__).parent
@@ -19,6 +20,9 @@ def test_read_config(self):
1920
assert config.tools == []
2021
assert config.telemetry_opt_out is None
2122
assert config.default_model is None
23+
assert config.agentstack_version == get_version()
24+
assert config.template is None
25+
assert config.template_version is None
2226

2327
def test_write_config(self):
2428
try:
@@ -30,6 +34,9 @@ def test_write_config(self):
3034
config.tools = ["tool1", "tool2"]
3135
config.telemetry_opt_out = True
3236
config.default_model = "openai/gpt-4o"
37+
config.agentstack_version = "0.2.1"
38+
config.template = "default"
39+
config.template_version = "1"
3340

3441
tmp_data = open(BASE_PATH / "tmp/agentstack.json").read()
3542
assert (
@@ -41,7 +48,10 @@ def test_write_config(self):
4148
"tool2"
4249
],
4350
"telemetry_opt_out": true,
44-
"default_model": "openai/gpt-4o"
51+
"default_model": "openai/gpt-4o",
52+
"agentstack_version": "0.2.1",
53+
"template": "default",
54+
"template_version": "1"
4555
}"""
4656
)
4757
except Exception as e:

0 commit comments

Comments
 (0)