Skip to content

Commit 81516c6

Browse files
authored
feat: restore provider_data constructor kwarg (#343)
## Summary Adds back the `provider_data: Mapping[str, Any] | None` kwarg on `OgxClient` and `AsyncOgxClient` that was present in the previous `llama-stack-client` SDK but lost during the rename to `ogx-client`. When provided, it is JSON-serialized and merged into `default_headers` under `X-OGX-Provider-Data` — the header the OGX server reads to thread per-request provider credentials through. ## Why Without this kwarg, every caller upgrading from `llama-stack-client` has to construct the header themselves on every client instantiation: ```python OgxClient( base_url=..., default_headers={"X-OGX-Provider-Data": json.dumps(get_provider_data())}, ) ``` That breaks a large surface of OGX integration tests and downstream code on upgrade. Restoring the affordance keeps the migration to `ogx-client` source-compatible for the constructor signature. ## Behavior matches the old SDK The previous implementation in `llama-stack-client` v0.7.2-alpha.3 was: ```python custom_headers = default_headers or {} if provider_data is not None: custom_headers["X-LlamaStack-Provider-Data"] = json.dumps(provider_data) ``` This PR mirrors that, with the only intentional difference being the header name (`X-OGX-Provider-Data`, matching the renamed server). ## Test plan - [x] `OgxClient(base_url=..., provider_data={"k": "v"})` accepts the kwarg - [x] `client.default_headers["X-OGX-Provider-Data"]` contains `{"k": "v"}` JSON-encoded - [x] Same for `AsyncOgxClient` Signed-off-by: Charlie Doern <[email protected]>
1 parent d67b7f3 commit 81516c6

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/ogx_client/_client.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import os
6+
import json
67
from typing import TYPE_CHECKING, Any, Mapping
78
from typing_extensions import Self, override
89

@@ -112,6 +113,7 @@ def __init__(
112113
# outlining your use-case to help us decide if it should be
113114
# part of our public interface in the future.
114115
_strict_response_validation: bool = False,
116+
provider_data: Mapping[str, Any] | None = None,
115117
) -> None:
116118
"""Construct a new synchronous OgxClient client instance.
117119
@@ -135,6 +137,12 @@ def __init__(
135137
parsed[line[:colon].strip()] = line[colon + 1 :].strip()
136138
default_headers = {**parsed, **(default_headers if is_mapping_t(default_headers) else {})}
137139

140+
if provider_data is not None:
141+
default_headers = {
142+
**(default_headers if is_mapping_t(default_headers) else {}),
143+
"X-OGX-Provider-Data": json.dumps(provider_data),
144+
}
145+
138146
super().__init__(
139147
version=__version__,
140148
base_url=base_url,
@@ -436,6 +444,7 @@ def __init__(
436444
# outlining your use-case to help us decide if it should be
437445
# part of our public interface in the future.
438446
_strict_response_validation: bool = False,
447+
provider_data: Mapping[str, Any] | None = None,
439448
) -> None:
440449
"""Construct a new async AsyncOgxClient client instance.
441450
@@ -459,6 +468,12 @@ def __init__(
459468
parsed[line[:colon].strip()] = line[colon + 1 :].strip()
460469
default_headers = {**parsed, **(default_headers if is_mapping_t(default_headers) else {})}
461470

471+
if provider_data is not None:
472+
default_headers = {
473+
**(default_headers if is_mapping_t(default_headers) else {}),
474+
"X-OGX-Provider-Data": json.dumps(provider_data),
475+
}
476+
462477
super().__init__(
463478
version=__version__,
464479
base_url=base_url,

0 commit comments

Comments
 (0)