Skip to content

feat(providers): expose Provider.base_url for the resolved request endpoint - #469

Open
cpsievert wants to merge 3 commits into
mainfrom
provider-base-url
Open

cpsievert wants to merge 3 commits into
mainfrom
provider-base-url

Conversation

@cpsievert

Copy link
Copy Markdown
Collaborator

Summary

Providers that can determine their endpoint now expose it via a base_url attribute (chat.provider.base_url), discovered from the SDK client or construction arguments. This is groundwork for richer telemetry (the OpenTelemetry server.address/server.port attributes, coming in a follow-up PR) and is handy for confirming which endpoint a provider resolved.

  • Provider.__init__ accepts an optional base_url, exposed as a property with a setter (providers like LM Studio/Ollama that already assigned self.base_url keep working unchanged).
  • Populated for: the whole OpenAI-compatible family via the single OpenAIAbstractProvider construction point (plus post-replacement updates in the Azure, Databricks, and Bedrock Responses providers), Anthropic, Google (from the genai client's resolved HTTP options), all three Bedrock flavors, Posit (per-flavor URL), and Snowflake (from the session's account host, best-effort). Providers that can't determine their endpoint leave it as None.

Verification

New tests/test_provider_base_url.py covers the None default, OpenAI, a completions-chain provider (Groq), Anthropic, Google, and Bedrock Converse. Full test suite (1346 passed), ruff, and pyright pass locally.

…dpoint

Providers that can determine their endpoint now expose it via a
`base_url` attribute, discovered from the SDK client or construction
arguments: the whole OpenAI-compatible family (via
OpenAIAbstractProvider), Anthropic, Google (from the genai client's
resolved HTTP options), all three Bedrock flavors, Posit (per-flavor
URL), Databricks, and Snowflake (from the connection's account host).
Providers that can't determine it leave it as None.

Groundwork for richer telemetry (e.g. the OpenTelemetry
server.address/server.port attributes), and handy for confirming which
endpoint a provider resolved.
The Provider.base_url property is typed str | None; these providers always
set it from a required constructor argument, so assert the invariant.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant