Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplifies start-up of assistants #231

Merged
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
1 change: 0 additions & 1 deletion assistants/explorer-assistant/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"name": "assistants: explorer-assistant",
"cwd": "${workspaceFolder}",
"module": "semantic_workbench_assistant.start",
"args": ["assistant.chat:app"],
"consoleTitle": "${workspaceFolderBasename}"
}
]
Expand Down
2 changes: 1 addition & 1 deletion assistants/explorer-assistant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ command line, using `uv`:
```
cd <PATH TO THIS FOLDER>

uv run start-semantic-workbench-assistant assistant.chat:app
uv run start-assistant
```

## Create your own assistant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"name": "assistants: guided-conversation-assistant",
"cwd": "${workspaceFolder}",
"module": "semantic_workbench_assistant.start",
"args": ["assistant.chat:app"],
"consoleTitle": "${workspaceFolderBasename}"
}
]
Expand Down
2 changes: 1 addition & 1 deletion assistants/guided-conversation-assistant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ command line, using `uv`:
```
cd <PATH TO THIS FOLDER>

uv run start-semantic-workbench-assistant assistant.chat:app
uv run start-assistant
```

## Create your own assistant
Expand Down
1 change: 0 additions & 1 deletion assistants/prospector-assistant/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"name": "assistants: prospector-assistant",
"cwd": "${workspaceFolder}",
"module": "semantic_workbench_assistant.start",
"args": ["assistant.chat:app"],
"consoleTitle": "${workspaceFolderBasename}"
}
]
Expand Down
2 changes: 1 addition & 1 deletion assistants/prospector-assistant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ command line, using `uv`:
```
cd <PATH TO THIS FOLDER>

uv run start-semantic-workbench-assistant assistant.chat:app
uv run start-assistant
```

## Create your own assistant
Expand Down
1 change: 0 additions & 1 deletion assistants/skill-assistant/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"name": "assistants: skill-assistant",
"cwd": "${workspaceFolder}",
"module": "semantic_workbench_assistant.start",
"args": ["assistant.skill_assistant:app"],
"consoleTitle": "${workspaceFolderBasename}"
}
]
Expand Down
2 changes: 1 addition & 1 deletion assistants/skill-assistant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ command line, using `uv`:
```
cd <PATH TO THIS FOLDER>

uv run start-semantic-workbench-assistant assistant.chat:app
uv run start-assistant
```

## Create your own assistant
Expand Down
1 change: 0 additions & 1 deletion examples/python/python-01-echo-bot/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"name": "examples: python-01-echo-bot",
"cwd": "${workspaceFolder}",
"module": "semantic_workbench_assistant.start",
"args": ["assistant.chat:app"],
"consoleTitle": "${workspaceFolderBasename}"
}
]
Expand Down
2 changes: 1 addition & 1 deletion examples/python/python-01-echo-bot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ command line, using `uv`:
```
cd <PATH TO THIS FOLDER>

uv run start-semantic-workbench-assistant assistant.chat:app
uv run start-assistant
```

## Create your own assistant
Expand Down
3 changes: 3 additions & 0 deletions examples/python/python-01-echo-bot/assistant/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .chat import app

__all__ = ["app"]
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"name": "examples: python-02-simple-chatbot",
"cwd": "${workspaceFolder}",
"module": "semantic_workbench_assistant.start",
"args": ["assistant.chat:app"],
"consoleTitle": "${workspaceFolderBasename}"
}
]
Expand Down
2 changes: 1 addition & 1 deletion examples/python/python-02-simple-chatbot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ command line, using `uv`:
```
cd <PATH TO THIS FOLDER>

uv run start-semantic-workbench-assistant assistant.chat:app
uv run start-assistant
```

## Create your own assistant
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .chat import app

__all__ = ["app"]
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"name": "examples: python-03-multimodel-chatbot",
"cwd": "${workspaceFolder}",
"module": "semantic_workbench_assistant.start",
"args": ["assistant.chat:app"],
"consoleTitle": "${workspaceFolderBasename}",
"justMyCode": false
}
Expand Down
2 changes: 1 addition & 1 deletion examples/python/python-03-multimodel-chatbot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ command line, using `uv`:
```
cd <PATH TO THIS FOLDER>

uv run start-semantic-workbench-assistant assistant.chat:app
uv run start-assistant
```

## Create your own assistant
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .chat import app

__all__ = ["app"]
2 changes: 1 addition & 1 deletion libraries/python/semantic-workbench-assistant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ To start the canonical assistant:

```sh
cd workbench-service
start-semantic-workbench-assistant semantic_workbench_assistant.canonical:app
start-assistant semantic_workbench_assistant.canonical:app
```
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ semantic-workbench-api-model = { path = "../semantic-workbench-api-model", edita

[project.scripts]
start-semantic-workbench-assistant = "semantic_workbench_assistant.start:main"
start-assistant = "semantic_workbench_assistant.start:main"

[build-system]
requires = ["hatchling"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ def main():
parse_args = argparse.ArgumentParser(
description="start a FastAPI assistant service", formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parse_args.add_argument(
"--app",
type=str,
help="assistant app to start; ex: workbench_assistant.canonical:app",
default=os.getenv("ASSISTANT_APP", "assistant:app"),
)
parse_args.add_argument(
"--port",
dest="port",
Expand Down Expand Up @@ -66,21 +72,6 @@ def main():
"--reload", dest="reload", nargs="?", action="store", type=str, default="false", help="enable auto-reload"
)

app = os.getenv("ASSISTANT_APP", None)
if app:
parse_args.add_argument(
"--app",
type=str,
help="assistant app to start; ex: workbench_assistant.canonical:app",
default=app,
)
else:
parse_args.add_argument(
"app",
type=str,
help="assistant app to start; ex: workbench_assistant.canonical:app",
)

args = parse_args.parse_args()

assistant_root_module = args.app.split(":")[0].split(".")[0]
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.assistant
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ ENV assistant__port=3001

SHELL ["/bin/bash", "-c"]
ENTRYPOINT ["/scripts/docker-entrypoint.sh"]
CMD ["start-semantic-workbench-assistant"]
CMD ["start-assistant"]
5 changes: 5 additions & 0 deletions tools/makefiles/docker-assistant.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ ASSISTANT__WORKBENCH_SERVICE_URL ?= http://host.docker.internal:3000

docker-run-local: docker-build
docker run --rm -it --add-host=host.docker.internal:host-gateway --env assistant__workbench_service_url=$(ASSISTANT__WORKBENCH_SERVICE_URL) $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)


.PHONY: start
start:
uv run start-assistant
2 changes: 1 addition & 1 deletion tools/run-canonical-agent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ Set-Location $root
Set-Location "workbench-service"

# Run the command
uv run start-semantic-workbench-assistant semantic_workbench_assistant.canonical:app
uv run start-assistant semantic_workbench_assistant.canonical:app
2 changes: 1 addition & 1 deletion tools/run-canonical-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ cd $ROOT

cd workbench-service

uv run start-semantic-workbench-assistant semantic_workbench_assistant.canonical:app
uv run start-assistant semantic_workbench_assistant.canonical:app
2 changes: 1 addition & 1 deletion tools/run-python-example1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ cd $ROOT

cd examples/python/python-01-echo-bot

uv run start-semantic-workbench-assistant assistant.chat:app
uv run start-assistant
2 changes: 1 addition & 1 deletion tools/run-python-example2.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ Set-Location $root
Set-Location "examples/python/python-02-simple-chatbot"

# Run the commands
uv run start-semantic-workbench-assistant assistant.chat:app
uv run start-assistant
2 changes: 1 addition & 1 deletion tools/run-python-example2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ cd $ROOT

cd examples/python/python-02-simple-chatbot

uv run start-semantic-workbench-assistant assistant.chat:app
uv run start-assistant
2 changes: 1 addition & 1 deletion tools/run-service.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ Set-Location "workbench-service"
# Note: this creates the .data folder at
# path ./workbench-service/.data
# rather than ./workbench-service/.data
uv run start-semantic-workbench-service
uv run start-service
2 changes: 1 addition & 1 deletion tools/run-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ cd workbench-service
# Note: this creates the .data folder at
# path ./workbench-service/.data
# rather than ./workbench-service/.data
uv run start-semantic-workbench-service
uv run start-service
4 changes: 4 additions & 0 deletions workbench-app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ format: install
lint: install
pnpm run lint

.PHONY: start
start:
pnpm run start

include $(repo_root)/tools/makefiles/shell.mk
2 changes: 1 addition & 1 deletion workbench-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ ENV workbench__service__port=3000

SHELL ["/bin/bash", "-c"]
ENTRYPOINT ["/scripts/docker-entrypoint.sh"]
CMD ["start-semantic-workbench-service"]
CMD ["start-service"]
12 changes: 12 additions & 0 deletions workbench-service/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@ repo_root = $(shell git rev-parse --show-toplevel)

include $(repo_root)/tools/makefiles/python.mk

-include ./.env

DBTYPE ?= sqlite

ifeq ($(DBTYPE), postgresql)
WORKBENCH__DB__URL ?= postgresql:///workbench
else
WORKBENCH__DB__URL ?= sqlite:///.data/workbench.db
endif

.PHONY: start
start:
WORKBENCH__DB__URL="$(WORKBENCH__DB__URL)" uv run start-service

.PHONY: alembic-upgrade-head
alembic-upgrade-head:
Expand Down
2 changes: 1 addition & 1 deletion workbench-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ To run and/or debug in VS Code, View->Run, "service: semantic-workbench-service"
In the [workbench-service](./) directory

```sh
uv run start-semantic-workbench-service
uv run start-service
```
1 change: 1 addition & 0 deletions workbench-service/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ semantic-workbench-assistant = { path = "../libraries/python/semantic-workbench-

[project.scripts]
start-semantic-workbench-service = "semantic_workbench_service.start:main"
start-service = "semantic_workbench_service.start:main"

[build-system]
requires = ["hatchling"]
Expand Down