Skip to content

Commit 32838b9

Browse files
merge: dev into branch
2 parents 90ce86b + 1b53f94 commit 32838b9

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Usage examples are available in the [examples](./examples/) directory.
2020
import workflowai
2121

2222
wai = workflowai.start(
23-
url=..., # defaults to WORKFLOWAI_API_URL env var or https://api.workflowai.ai
23+
url=..., # defaults to WORKFLOWAI_API_URL env var or https://api.workflowai.com
2424
api_key=..., # defaults to WORKFLOWAI_API_KEY env var
2525
)
2626
```

workflowai/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def start(url: Optional[str] = None, api_key: Optional[str] = None) -> Client:
1919
2020
Args:
2121
url (Optional[str], optional): The API endpoint to use.
22-
If not provided, the env variable WORKFLOWAI_API_URL is used. Otherwise defaults to https://api.workflowai.ai
22+
If not provided, the env variable WORKFLOWAI_API_URL is used. Otherwise defaults to https://api.workflowai.com
2323
api_key (Optional[str], optional): _description_. If not provided, the env variable WORKFLOWAI_API_KEY is used.
2424
2525
Returns:

workflowai/core/client/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import asyncio
2+
import importlib.metadata
23
import os
34
from typing import (
45
Any,
@@ -37,10 +38,10 @@ def __init__(self, endpoint: Optional[str] = None, api_key: Optional[str] = None
3738
self.additional_headers = {
3839
"x-workflowai-source": "sdk",
3940
"x-workflowai-language": "python",
40-
"x-workflowai-version": "0.1.3" #__version__,
41+
"x-workflowai-version": importlib.metadata.version("workflowai"),
4142
}
4243
self.api = APIClient(
43-
endpoint or os.getenv("WORKFLOWAI_API_URL", "https://api.workflowai.ai"),
44+
endpoint or os.getenv("WORKFLOWAI_API_URL", "https://api.workflowai.com"),
4445
api_key or os.getenv("WORKFLOWAI_API_KEY", ""),
4546
self.additional_headers
4647
)

workflowai/core/client/client_test.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import importlib.metadata
12
import json
23

34
import pytest
@@ -105,6 +106,34 @@ async def test_run_with_env(self, httpx_mock: HTTPXMock, client: Client):
105106
"stream": False,
106107
"use_cache": "when_available",
107108
}
109+
110+
async def test_success_with_headers(self, httpx_mock: HTTPXMock, client: Client):
111+
httpx_mock.add_response(json=fixtures_json("task_run.json"))
112+
task = HelloTask(id="123", schema_id=1)
113+
114+
task_run = await client.run(task, task_input=HelloTaskInput(name="Alice"))
115+
116+
assert task_run.id == "8f635b73-f403-47ee-bff9-18320616c6cc"
117+
118+
reqs = httpx_mock.get_requests()
119+
assert len(reqs) == 1
120+
assert reqs[0].url == "http://localhost:8000/tasks/123/schemas/1/run"
121+
headers = {
122+
"x-workflowai-source": "sdk",
123+
"x-workflowai-language": "python",
124+
"x-workflowai-version": importlib.metadata.version("workflowai"),
125+
}
126+
127+
body = json.loads(reqs[0].content)
128+
assert body == {
129+
"task_input": {"name": "Alice"},
130+
"group": {"properties": {}},
131+
"stream": False,
132+
"use_cache": "when_available",
133+
}
134+
# Check for additional headers
135+
for key, value in headers.items():
136+
assert reqs[0].headers[key] == value
108137

109138
async def test_run_retries_on_too_many_requests(self, httpx_mock: HTTPXMock, client: Client):
110139
task = HelloTask(id="123", schema_id=1)

0 commit comments

Comments
 (0)