Skip to content

Commit f7070b6

Browse files
committed
feat: run chat api with python -m askui.chat
also: - make default chat api port consistent to allow for easier testing
1 parent cc3c428 commit f7070b6

File tree

5 files changed

+36
-4
lines changed

5 files changed

+36
-4
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"preLaunchTask": "Create .env.tmp file",
2929
"postDebugTask": "Delete .env.tmp file",
3030
"module": "uvicorn",
31-
"args": ["src.askui.chat.api.app:app","--reload","--port","8000"],
31+
"args": ["src.askui.chat.api.app:app","--reload","--port","9261"],
3232
"envFile": "${workspaceFolder}/.env.tmp",
3333
"env": {
3434
"ASKUI_WORKSPACES__LOG__FORMAT": "logfmt",

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,19 +792,22 @@ To use the chat, configure the following environment variables:
792792
- `ASKUI_TOKEN`: AskUI Vision Agent behind chat uses currently the AskUI API
793793
- `ASKUI_WORKSPACE_ID`: AskUI Vision Agent behind chat uses currently the AskUI API
794794
- `ASKUI__CHAT_API__DATA_DIR` (optional, defaults to `$(pwd)/chat`): Currently, the AskUI chat stores all data in a directory locally. You can change the default directory by setting this environment variable.
795+
- `ASKUI__CHAT_API__HOST` (optional, defaults to `127.0.0.1`): The host to bind the chat API to.
796+
- `ASKUI__CHAT_API__PORT` (optional, defaults to `9261`): The port to bind the chat API to.
797+
- `ASKUI__CHAT_API__LOG_LEVEL` (optional, defaults to `info`): The log level to use for the chat API.
795798

796799
#### Installation
797800

798801
```bash
799-
pdm install # is going to install the dependencies of the api
802+
pip install askui[chat]
800803
```
801804

802805
You may need to give permissions on the fast run of the Chat UI to demonstrate actions (aka record clicks).
803806

804807
#### Usage
805808

806809
```bash
807-
pdm run chat:api # is going to start the api at port 8000
810+
python -m askui.chat
808811
```
809812

810813
You can use the chat to record a workflow and redo it later. For that, just tell the agent to redo all previous steps.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ lint = "ruff check src tests"
5454
"lint:fix" = "ruff check --fix src tests"
5555
typecheck = "mypy"
5656
"typecheck:all" = "mypy src tests"
57-
"chat:api" = "uvicorn askui.chat.api.app:app --reload --port 8000"
57+
"chat:api" = "uvicorn askui.chat.api.app:app --reload --port 9261"
5858
"mcp:dev" = "mcp dev src/askui/mcp/__init__.py"
5959

6060
[dependency-groups]

src/askui/chat/__main__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import uvicorn
2+
3+
from askui.chat.api.app import app
4+
from askui.chat.api.dependencies import get_settings
5+
6+
if __name__ == "__main__":
7+
settings = get_settings()
8+
uvicorn.run(
9+
app,
10+
host=settings.host,
11+
port=settings.port,
12+
log_level=settings.log_level,
13+
reload=False,
14+
workers=1,
15+
)

src/askui/chat/api/settings.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,17 @@ class Settings(BaseSettings):
1515
default_factory=lambda: Path.cwd() / "chat",
1616
description="Base directory for storing chat data",
1717
)
18+
host: str = Field(
19+
default="127.0.0.1",
20+
description="Host for the chat API",
21+
)
22+
log_level: str | int = Field(
23+
default="info",
24+
description="Log level for the chat API",
25+
)
26+
port: int = Field(
27+
default=9261,
28+
description="Port for the chat API",
29+
ge=1024,
30+
le=65535,
31+
)

0 commit comments

Comments
 (0)