-
Notifications
You must be signed in to change notification settings - Fork 97
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
Contributor
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, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.