Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions grafi_dev/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
app = typer.Typer(add_completion=False)


def _load_assistant(path: Path):
def _load_assistant(path: Path, assistant_name: str):
# Ensure we're working with an absolute path
abs_path = path.absolute().resolve()

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

if not hasattr(mod, "assistant"):
if not hasattr(mod, assistant_name):
raise typer.BadParameter(
f"{path} must define a global variable `assistant` "
f"{path} must define a global variable `{assistant_name}` "
f"that is an instance of grafi.assistants.Assistant"
)
return mod.assistant
return getattr(mod, assistant_name)
finally:
# Restore the original sys.path
sys.path = original_sys_path
Expand All @@ -51,11 +51,12 @@ def run(
script: Path,
host: str = "127.0.0.1",
port: int = 8080,
assistant_name: str = "assistant",
open_browser: bool = True,
):
"""Run the assistant in *script* and launch the web UI."""
logger.info("Starting server with %s", script)
assistant = _load_assistant(script)
assistant = _load_assistant(script, assistant_name)
logger.info("Assistant loaded: %s", getattr(assistant, "name", assistant))

if open_browser:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ build-backend = "setuptools.build_meta"

[project]
name = "grafi-dev"
version = "0.0.1"
version = "0.0.2"
description = "Run a grafi Assistant locally with a live workflow graph & trace viewer"
authors = [{ name = "Craig Li", email = "craig@binome.dev" }]
readme = "README.md"
requires-python = ">=3.12"
requires-python = ">=3.11,<3.13"
dependencies = [
"fastapi>=0.115.12",
"grafi>=0.0.12",
Expand Down
Loading