-
Couldn't load subscription status.
- Fork 95
Sync updates from stainless branch: ehhuang/dev #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,10 +98,12 @@ class LlamaStackClient(SyncAPIClient): | |
| with_streaming_response: LlamaStackClientWithStreamedResponse | ||
|
|
||
| # client options | ||
| api_key: str | None | ||
|
|
||
| def __init__( | ||
| self, | ||
| *, | ||
| api_key: str | None = None, | ||
| base_url: str | httpx.URL | None = None, | ||
| api_key: str | None = None, | ||
| timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN, | ||
|
|
@@ -123,7 +125,14 @@ def __init__( | |
| _strict_response_validation: bool = False, | ||
| provider_data: Mapping[str, Any] | None = None, | ||
| ) -> None: | ||
| """Construct a new synchronous llama-stack-client client instance.""" | ||
| """Construct a new synchronous llama-stack-client client instance. | ||
|
|
||
| This automatically infers the `api_key` argument from the `LLAMA_STACK_API_KEY` environment variable if it is not provided. | ||
| """ | ||
| if api_key is None: | ||
| api_key = os.environ.get("LLAMA_STACK_API_KEY") | ||
| self.api_key = api_key | ||
|
|
||
| if base_url is None: | ||
| base_url = os.environ.get("LLAMA_STACK_CLIENT_BASE_URL") | ||
| if base_url is None: | ||
|
|
@@ -182,6 +191,14 @@ def __init__( | |
| def qs(self) -> Querystring: | ||
| return Querystring(array_format="comma") | ||
|
|
||
| @property | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ehhuang how did you get these changes, this was not supposed to be here yet because adding api_key Stainless config was only in a dev branch but not in main. It's ok if we leave this here though we will just need to remove api key changes from the sync_stainless script. |
||
| @override | ||
| def auth_headers(self) -> dict[str, str]: | ||
| api_key = self.api_key | ||
| if api_key is None: | ||
| return {} | ||
| return {"Authorization": f"Bearer {api_key}"} | ||
|
|
||
| @property | ||
| @override | ||
| def default_headers(self) -> dict[str, str | Omit]: | ||
|
|
@@ -194,6 +211,7 @@ def default_headers(self) -> dict[str, str | Omit]: | |
| def copy( | ||
| self, | ||
| *, | ||
| api_key: str | None = None, | ||
| base_url: str | httpx.URL | None = None, | ||
| api_key: str | None = None, | ||
| timeout: float | Timeout | None | NotGiven = NOT_GIVEN, | ||
|
|
@@ -228,6 +246,7 @@ def copy( | |
|
|
||
| http_client = http_client or self._client | ||
| return self.__class__( | ||
| api_key=api_key or self.api_key, | ||
| base_url=base_url or self.base_url, | ||
| api_key=api_key or self.api_key, | ||
| timeout=self.timeout if isinstance(timeout, NotGiven) else timeout, | ||
|
|
@@ -304,10 +323,12 @@ class AsyncLlamaStackClient(AsyncAPIClient): | |
| with_streaming_response: AsyncLlamaStackClientWithStreamedResponse | ||
|
|
||
| # client options | ||
| api_key: str | None | ||
|
|
||
| def __init__( | ||
| self, | ||
| *, | ||
| api_key: str | None = None, | ||
| base_url: str | httpx.URL | None = None, | ||
| api_key: str | None = None, | ||
| timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN, | ||
|
|
@@ -329,7 +350,14 @@ def __init__( | |
| _strict_response_validation: bool = False, | ||
| provider_data: Mapping[str, Any] | None = None, | ||
| ) -> None: | ||
| """Construct a new async llama-stack-client client instance.""" | ||
| """Construct a new async llama-stack-client client instance. | ||
|
|
||
| This automatically infers the `api_key` argument from the `LLAMA_STACK_API_KEY` environment variable if it is not provided. | ||
| """ | ||
| if api_key is None: | ||
| api_key = os.environ.get("LLAMA_STACK_API_KEY") | ||
| self.api_key = api_key | ||
|
|
||
| if base_url is None: | ||
| base_url = os.environ.get("LLAMA_STACK_CLIENT_BASE_URL") | ||
| if base_url is None: | ||
|
|
@@ -388,6 +416,14 @@ def __init__( | |
| def qs(self) -> Querystring: | ||
| return Querystring(array_format="comma") | ||
|
|
||
| @property | ||
| @override | ||
| def auth_headers(self) -> dict[str, str]: | ||
| api_key = self.api_key | ||
| if api_key is None: | ||
| return {} | ||
| return {"Authorization": f"Bearer {api_key}"} | ||
|
|
||
| @property | ||
| @override | ||
| def default_headers(self) -> dict[str, str | Omit]: | ||
|
|
@@ -400,6 +436,7 @@ def default_headers(self) -> dict[str, str | Omit]: | |
| def copy( | ||
| self, | ||
| *, | ||
| api_key: str | None = None, | ||
| base_url: str | httpx.URL | None = None, | ||
| api_key: str | None = None, | ||
| timeout: float | Timeout | None | NotGiven = NOT_GIVEN, | ||
|
|
@@ -434,6 +471,7 @@ def copy( | |
|
|
||
| http_client = http_client or self._client | ||
| return self.__class__( | ||
| api_key=api_key or self.api_key, | ||
| base_url=base_url or self.base_url, | ||
| api_key=api_key or self.api_key, | ||
| timeout=self.timeout if isinstance(timeout, NotGiven) else timeout, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should name this LLAMA_STACK_CLIENT_API_KEY
so it has the same prefix as LLAMA_STACK_CLIENT_BASE_URL. The env name is defined in the Stainless config.