Skip to content

Commit e036ad5

Browse files
committed
Address Copilot review comments
- test_client: configure mock_page.__iter__.return_value instead of overwriting __iter__ with a lambda (more reliable mock iteration) - examples: use documented env vars (GATEWAY_API_BASE / OTARI_AI_TOKEN) via OtariClient() auto-detection instead of OTARI_API_BASE / OTARI_PLATFORM_TOKEN, avoiding a KeyError when unset
1 parent c3fb35a commit e036ad5

3 files changed

Lines changed: 16 additions & 13 deletions

File tree

examples/quickstart.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
"""Quick smoke test for the otari Python SDK (synchronous client)."""
1+
"""Quick smoke test for the otari Python SDK (synchronous client).
22
3-
import os
3+
Reads credentials from the SDK's documented environment variables:
4+
``GATEWAY_API_BASE`` (optional; defaults to the hosted gateway in platform
5+
mode) and ``OTARI_AI_TOKEN`` (or the legacy ``GATEWAY_PLATFORM_TOKEN``).
6+
"""
47

58
from otari import OtariClient, OtariError
69

710

811
def main() -> None:
9-
client = OtariClient(
10-
api_base=os.environ.get("OTARI_API_BASE", "http://localhost:8100"),
11-
platform_token=os.environ["OTARI_PLATFORM_TOKEN"],
12-
)
12+
# Credentials are picked up from GATEWAY_API_BASE / OTARI_AI_TOKEN.
13+
client = OtariClient()
1314

1415
with client:
1516
# -- Chat completion --

examples/quickstart_async.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
"""Quick smoke test for the otari Python SDK (asynchronous client)."""
1+
"""Quick smoke test for the otari Python SDK (asynchronous client).
2+
3+
Reads credentials from the SDK's documented environment variables:
4+
``GATEWAY_API_BASE`` (optional; defaults to the hosted gateway in platform
5+
mode) and ``OTARI_AI_TOKEN`` (or the legacy ``GATEWAY_PLATFORM_TOKEN``).
6+
"""
27

38
import asyncio
4-
import os
59

610
from otari import AsyncOtariClient, OtariError
711

812

913
async def main() -> None:
10-
client = AsyncOtariClient(
11-
api_base=os.environ.get("OTARI_API_BASE", "http://localhost:8100"),
12-
platform_token=os.environ["OTARI_PLATFORM_TOKEN"],
13-
)
14+
# Credentials are picked up from GATEWAY_API_BASE / OTARI_AI_TOKEN.
15+
client = AsyncOtariClient()
1416

1517
async with client:
1618
# -- Chat completion --

tests/unit/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ def test_list_models_delegates(self, client: OtariClient) -> None:
442442
]
443443

444444
mock_page = MagicMock()
445-
mock_page.__iter__ = lambda _self: iter(mock_models)
445+
mock_page.__iter__.return_value = iter(mock_models)
446446
client.openai.models.list = MagicMock(return_value=mock_page) # type: ignore[method-assign]
447447

448448
result = client.list_models()

0 commit comments

Comments
 (0)