Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Disiok committed Oct 14, 2024
2 parents 1a3fb93 + 8c3757a commit acf3285
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:4501 (Press CTRL+C to quit)
```

> [!TIP]
> By default, CORS is enabled. If you want to disable it, you can set the `DISABLE_CORS` environment variable:
> ```
> $ DISABLE_CORS=true python -m llama_deploy.apiserver
> ```

From another shell, use `llamactl` to create the deployment:

```
Expand Down
13 changes: 13 additions & 0 deletions llama_deploy/apiserver/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import logging
import os

from fastapi import FastAPI
from fastapi.responses import JSONResponse
from fastapi.middleware.cors import CORSMiddleware

from .routers import status_router, deployments_router
from .server import lifespan
Expand All @@ -10,6 +12,17 @@


app = FastAPI(root_path="/", lifespan=lifespan)

# Configure CORS middleware if the environment variable is set
if not os.environ.get("DISABLE_CORS", False):
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Allows all origins
allow_credentials=True,
allow_methods=["GET", "POST"],
allow_headers=["Content-Type", "Authorization"],
)

app.include_router(deployments_router)
app.include_router(status_router)

Expand Down
2 changes: 1 addition & 1 deletion llama_deploy/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def run(
service: str,
) -> None:
server_url, disable_ssl, timeout = global_config
deploy_url = f"{server_url}/deployments/{deployment}/tasks/create"
deploy_url = f"{server_url}/deployments/{deployment}/tasks/run"
payload = {"input": json.dumps(dict(arg))}
if service:
payload["agent_id"] = service
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ omit = [

[tool.poetry]
name = "llama-deploy"
version = "0.2.1"
version = "0.2.3"
description = ""
authors = ["Logan Markewich <[email protected]>", "Andrei Fajardo <[email protected]>"]
maintainers = [
Expand Down
4 changes: 2 additions & 2 deletions tests/cli/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_run(runner: CliRunner) -> None:
llamactl, ["run", "-d", "deployment_name", "-s", "service_name"]
)
mocked_post.assert_called_with(
"http://localhost:4501/deployments/deployment_name/tasks/create",
"http://localhost:4501/deployments/deployment_name/tasks/run",
verify=True,
json={"input": "{}", "agent_id": "service_name"},
timeout=None,
Expand Down Expand Up @@ -51,7 +51,7 @@ def test_run_args(runner: CliRunner) -> None:
],
)
mocked_post.assert_called_with(
"http://localhost:4501/deployments/deployment_name/tasks/create",
"http://localhost:4501/deployments/deployment_name/tasks/run",
verify=True,
json={
"input": '{"first_arg": "first_value", "second_arg": "\\"second value with spaces\\""}',
Expand Down

0 comments on commit acf3285

Please sign in to comment.