Skip to content

Commit a774210

Browse files
Gl/update python version constraint (#6)
* update python version constraint * add new input param * update version
1 parent dc4c002 commit a774210

3 files changed

Lines changed: 309 additions & 320 deletions

File tree

grafi_dev/cli.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
app = typer.Typer(add_completion=False)
1313

1414

15-
def _load_assistant(path: Path):
15+
def _load_assistant(path: Path, assistant_name: str):
1616
# Ensure we're working with an absolute path
1717
abs_path = path.absolute().resolve()
1818

@@ -35,12 +35,12 @@ def _load_assistant(path: Path):
3535
mod = importlib.util.module_from_spec(spec)
3636
spec.loader.exec_module(mod) # type: ignore
3737

38-
if not hasattr(mod, "assistant"):
38+
if not hasattr(mod, assistant_name):
3939
raise typer.BadParameter(
40-
f"{path} must define a global variable `assistant` "
40+
f"{path} must define a global variable `{assistant_name}` "
4141
f"that is an instance of grafi.assistants.Assistant"
4242
)
43-
return mod.assistant
43+
return getattr(mod, assistant_name)
4444
finally:
4545
# Restore the original sys.path
4646
sys.path = original_sys_path
@@ -51,11 +51,12 @@ def run(
5151
script: Path,
5252
host: str = "127.0.0.1",
5353
port: int = 8080,
54+
assistant_name: str = "assistant",
5455
open_browser: bool = True,
5556
):
5657
"""Run the assistant in *script* and launch the web UI."""
5758
logger.info("Starting server with %s", script)
58-
assistant = _load_assistant(script)
59+
assistant = _load_assistant(script, assistant_name)
5960
logger.info("Assistant loaded: %s", getattr(assistant, "name", assistant))
6061

6162
if open_browser:

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "grafi-dev"
7-
version = "0.0.1"
7+
version = "0.0.2"
88
description = "Run a grafi Assistant locally with a live workflow graph & trace viewer"
99
authors = [{ name = "Craig Li", email = "craig@binome.dev" }]
1010
readme = "README.md"
11-
requires-python = ">=3.12"
11+
requires-python = ">=3.11,<3.13"
1212
dependencies = [
1313
"fastapi>=0.115.12",
1414
"grafi>=0.0.12",

0 commit comments

Comments
 (0)