Move from legacy proxy to gateway#191
Conversation
Braintrust eval reportEvals failed: Error: Command failed with exit code 1 |
|
|
||
| self._is_wrapped = isinstance(self.openai, NamedWrapper) | ||
| self._is_wrapped = isinstance(self.openai, NamedWrapper) or ( | ||
| not has_customization and wrap_openai.__module__.startswith("braintrust.") |
There was a problem hiding this comment.
drive-by, the test was broken
Olmo Maldonado (ibolmo)
left a comment
There was a problem hiding this comment.
just various nits, but none blocking. i wonder if you'd want to. bump the version as either minor or major. i'd ask in sdk channel.
| } | ||
|
|
||
| const PROXY_URL = "https://api.braintrust.dev/v1/proxy"; | ||
| const GATEWAY_URL = "https://gateway.braintrust.dev"; |
There was a problem hiding this comment.
(i know it's outside of your change, but) we should move to an env var, and default to this.
| * | ||
| * @example | ||
| * // Using with Anthropic via Braintrust proxy | ||
| * // Using with Anthropic via Braintrust Gateway |
There was a problem hiding this comment.
#nit Braintrust AI Gateway? what's the official product name? 🤔
There was a problem hiding this comment.
Braintrust Gateway -- https://www.braintrust.dev/docs/deploy/gateway
| # Configure client to use the Braintrust Gateway with Claude | ||
| client = AsyncOpenAI( | ||
| base_url="https://api.braintrust.dev/v1/proxy", | ||
| base_url="https://gateway.braintrust.dev", |
There was a problem hiding this comment.
ditto os.getenv('BRAINTRUST_AI_GATEWAY_URL') or 'https://...'
| from typing import Any, Optional, Protocol, TypedDict, TypeVar, Union, cast, runtime_checkable | ||
|
|
||
| PROXY_URL = "https://api.braintrust.dev/v1/proxy" | ||
| GATEWAY_URL = "https://gateway.braintrust.dev" |
There was a problem hiding this comment.
Olmo Maldonado (ibolmo)
left a comment
There was a problem hiding this comment.
nothing blocking, ty!
| const DEFAULT_GATEWAY_URL = "https://gateway.braintrust.dev"; | ||
|
|
||
| const getGatewayURL = (): string => | ||
| process.env.BRAINTRUST_AI_GATEWAY_URL || DEFAULT_GATEWAY_URL; |
There was a problem hiding this comment.
I'd encourage a sanitizing like:
(process.env.BRAINTRUST_AI_GATEWAY_URL ?? '').trim() || DEFAULT_GATEWAY_URL
|
|
||
|
|
||
| def test_prepare_openai_defaults_to_gateway(monkeypatch: pytest.MonkeyPatch): | ||
| monkeypatch.delenv("OPENAI_BASE_URL", raising=False) |
There was a problem hiding this comment.
(fyi) i like to use getEnv() and similar helpers to avoid monkey patching. you can then just set/unset env vars more easily.
The AI Proxy will be deprecated soon, and the AI Gateway is being continually updated with bug fixes and new features, and so we should move this repository to use that.