[SDK Custom Patch] Add provider_data param for API keys during client initialization#14
[SDK Custom Patch] Add provider_data param for API keys during client initialization#14
Conversation
ashwinb
left a comment
There was a problem hiding this comment.
This works -- but we need to figure out how to make this work across the next Stainless generation (i.e., we need a check which makes sure this won't get overwritten silently if someone forgets something.)
Our stainless sync script pushes changes in a separate branch to this repo and we currently make a PR every time we sync stainless to this repo. I think we can just add a CI check to see if there's any changes in this _client.py file. |
|
Can we try to apply this same exact patch to the |
|
scripts for applying patch: sed -i '' '/from __future__/a\
import json
' $META_LLAMA_PYTHON_SDK_REPO/src/llama_stack_client/_client.py
# Add provider_data parameter to both sync and async client __init__ methods
sed -i '' '/def __init__/,/_strict_response_validation: bool = False,/{/_strict_response_validation: bool = False,/a\
provider_data: Mapping[str, Any] | None = None,
}' $META_LLAMA_PYTHON_SDK_REPO/src/llama_stack_client/_client.py
# Add provider_data handling logic after base_url check in both sync and async clients
sed -i '' '/base_url = f"http:\/\/any-hosted-llama-stack.com"/a\
\
if provider_data is not None:\
if default_headers is None:\
default_headers = {}\
default_headers["X-LlamaStack-ProviderData"] = json.dumps(provider_data)' $META_LLAMA_PYTHON_SDK_REPO/src/llama_stack_client/_client.py |
This is a followup for: add client-side utility for getting OAuth tokens simply llamastack#230 - Add extra_headers parameter to ReActAgent.__init__ method - Pass extra_headers to parent Agent class
TL;DR
provider_datatoLlamaStackClientfor specifying API keysTests
Run in llama-stack-apps w/ Together inference