Skip to content

Commit 8ed1e96

Browse files
authored
Merge pull request #129 from bmacer/improve-template-arg
improve template arg to accept remote and local json files
2 parents aa391b1 + a5cafb5 commit 8ed1e96

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

agentstack/proj_templates.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional, Literal
1+
from typing import Literal
22
import os, sys
33
from pathlib import Path
44
import pydantic
@@ -98,6 +98,16 @@ def write_to_file(self, filename: Path):
9898

9999
@classmethod
100100
def from_template_name(cls, name: str) -> 'TemplateConfig':
101+
# if url
102+
if name.startswith('https://'):
103+
return cls.from_url(name)
104+
105+
# if .json file
106+
if name.endswith('.json'):
107+
path = os.getcwd() / Path(name)
108+
return cls.from_file(path)
109+
110+
# if named template
101111
path = get_package_path() / f'templates/proj_templates/{name}.json'
102112
if not name in get_all_template_names():
103113
raise ValidationError(f"Template {name} not bundled with agentstack.")

0 commit comments

Comments
 (0)