-
Notifications
You must be signed in to change notification settings - Fork 578
feat: add ANTHROPIC_BASE_URL support
#1886
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -44,11 +44,12 @@ def _create_http_client(self): | |
| @cached_property | ||
| def _anthropic_client(self) -> AsyncAnthropic: | ||
| api_key = self._api_key or os.environ.get("ANTHROPIC_API_KEY") | ||
| base_url = self.base_url or os.environ.get("ANTHROPIC_BASE_URL") | ||
| kwargs = {} | ||
| if api_key: | ||
| kwargs["api_key"] = api_key | ||
| if self.base_url: | ||
| kwargs["base_url"] = self.base_url | ||
| if base_url: | ||
|
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. What would be a use case to inject the
Contributor
Author
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. Thanks @supreme-gg-gg Totally agree. The explicit We keep supporting the Additionally, it provides a smooth out-of-the-box experience for new users: when first installing
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.
Specifically here you mean when running the agent locally? If so why do we need this code in the controller. I think this is a lot of added code with complexity to optimize for a small local use case.
Contributor
Author
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. Thanks @EItanya To clarify the use case: in certain regions (e.g. China), the Anthropic API is not directly accessible. Users need to configure third-party providers that implement the Anthropic Messages API protocol, such as https://help.aliyun.com/zh/model-studio/anthropic-api-messages#ac2a3b4c5d6f7. They set this via ModelConfig.Spec.Anthropic.BaseURL. However, since the controller already passes base_url from ModelConfig to the Python ADK explicitly (via KAgentAnthropicLlm(base_url=...)), injecting ANTHROPIC_BASE_URL as an env var into the pod is indeed redundant for the K8s deployment path. The env var fallback on the Python side is still valuable for local development, but that doesn't require controller involvement. I'll remove the controller-side changes (adk_api_translator.go, providers.go, and the corresponding Go test) and keep only the Python ADK changes. Will push shortly. |
||
| kwargs["base_url"] = base_url | ||
|
dongjiang1989 marked this conversation as resolved.
|
||
| if self.extra_headers: | ||
| kwargs["default_headers"] = self.extra_headers | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.