fix: map base_url to endpoint for Azure credentials (#741)
* fix: map base_url to endpoint for Azure credentials The Azure credential form only exposes a base_url field, but the connection tester, key provisioner, and Esperanto config all expect an endpoint field. This maps base_url to endpoint for Azure providers so credentials work without requiring a dedicated endpoint form field. Closes #727 * docs: update Azure credential docs to reflect base_url mapping
This commit is contained in:
parent
ade4adc0b2
commit
4222329451
4 changed files with 19 additions and 16 deletions
|
|
@ -107,7 +107,7 @@ Navigation: Settings → API Keys
|
||||||
|
|
||||||
| Provider | Required Fields | Optional Fields |
|
| Provider | Required Fields | Optional Fields |
|
||||||
|----------|-----------------|-----------------|
|
|----------|-----------------|-----------------|
|
||||||
| Azure OpenAI | API Key, Endpoint, API Version | Service-specific endpoints (LLM, Embedding, STT, TTS) |
|
| Azure OpenAI | API Key, URL Base (Azure endpoint) | Service-specific endpoints (LLM, Embedding, STT, TTS) |
|
||||||
| OpenAI-Compatible | Base URL | API Key, Service-specific configs |
|
| OpenAI-Compatible | Base URL | API Key, Service-specific configs |
|
||||||
| Vertex AI | Project ID, Location, Credentials Path | — |
|
| Vertex AI | Project ID, Location, Credentials Path | — |
|
||||||
|
|
||||||
|
|
@ -208,17 +208,13 @@ Ollama allows localhost and private IPs since it runs locally.
|
||||||
|
|
||||||
### Azure OpenAI
|
### Azure OpenAI
|
||||||
|
|
||||||
Azure requires multiple fields:
|
1. Add credential with provider **Azure OpenAI**
|
||||||
|
2. Enter your API key
|
||||||
|
3. Enter your Azure endpoint in the **URL Base** field (e.g., `https://myresource.openai.azure.com`)
|
||||||
|
4. Test connection
|
||||||
|
5. Discover and register models
|
||||||
|
|
||||||
| Field | Example | Required |
|
The URL Base field is automatically mapped to the Azure endpoint. The API version defaults to `2024-10-21` if not set via environment variable.
|
||||||
|-------|---------|----------|
|
|
||||||
| API Key | `abc123...` | Yes |
|
|
||||||
| Endpoint | `https://myresource.openai.azure.com` | Yes |
|
|
||||||
| API Version | `2024-02-15-preview` | Yes |
|
|
||||||
| LLM Endpoint | `https://myresource-llm.openai.azure.com` | No |
|
|
||||||
| Embedding Endpoint | `https://myresource-embed.openai.azure.com` | No |
|
|
||||||
|
|
||||||
Service-specific endpoints override the main endpoint for that service type.
|
|
||||||
|
|
||||||
### OpenAI-Compatible
|
### OpenAI-Compatible
|
||||||
|
|
||||||
|
|
@ -377,8 +373,8 @@ API keys stored in the database are encrypted using Fernet (AES-128-CBC + HMAC-S
|
||||||
- Ensure Ollama server is running
|
- Ensure Ollama server is running
|
||||||
|
|
||||||
### Azure OpenAI
|
### Azure OpenAI
|
||||||
- Endpoint format: `https://{resource-name}.openai.azure.com`
|
- Enter your Azure endpoint in the **URL Base** field (format: `https://{resource-name}.openai.azure.com`)
|
||||||
- API version format: `YYYY-MM-DD` or `YYYY-MM-DD-preview`
|
- API version defaults to `2024-10-21`; override via `AZURE_OPENAI_API_VERSION` environment variable if needed
|
||||||
- Deployment names configured separately when registering models via the credential's Discover Models dialog
|
- Deployment names configured separately when registering models via the credential's Discover Models dialog
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,9 @@ async def test_provider_connection(
|
||||||
return await _test_openai_compatible_connection(test_base_url, test_api_key)
|
return await _test_openai_compatible_connection(test_base_url, test_api_key)
|
||||||
|
|
||||||
if normalized_provider == "azure":
|
if normalized_provider == "azure":
|
||||||
return await _test_azure_connection(endpoint, api_key, api_version)
|
# For Azure, base_url from the UI form maps to endpoint
|
||||||
|
azure_endpoint = endpoint or base_url
|
||||||
|
return await _test_azure_connection(azure_endpoint, api_key, api_version)
|
||||||
|
|
||||||
# Get test model for provider
|
# Get test model for provider
|
||||||
if normalized_provider not in TEST_MODELS:
|
if normalized_provider not in TEST_MODELS:
|
||||||
|
|
|
||||||
|
|
@ -190,8 +190,10 @@ async def _provision_azure() -> bool:
|
||||||
os.environ["AZURE_OPENAI_API_VERSION"] = cred.api_version
|
os.environ["AZURE_OPENAI_API_VERSION"] = cred.api_version
|
||||||
logger.debug("Set AZURE_OPENAI_API_VERSION from Credential")
|
logger.debug("Set AZURE_OPENAI_API_VERSION from Credential")
|
||||||
any_set = True
|
any_set = True
|
||||||
if cred.endpoint:
|
# For Azure, base_url from the UI form maps to endpoint
|
||||||
os.environ["AZURE_OPENAI_ENDPOINT"] = cred.endpoint
|
azure_endpoint = cred.endpoint or cred.base_url
|
||||||
|
if azure_endpoint:
|
||||||
|
os.environ["AZURE_OPENAI_ENDPOINT"] = azure_endpoint
|
||||||
logger.debug("Set AZURE_OPENAI_ENDPOINT from Credential")
|
logger.debug("Set AZURE_OPENAI_ENDPOINT from Credential")
|
||||||
any_set = True
|
any_set = True
|
||||||
if cred.endpoint_llm:
|
if cred.endpoint_llm:
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,9 @@ class Credential(ObjectModel):
|
||||||
config["api_key"] = self.api_key.get_secret_value()
|
config["api_key"] = self.api_key.get_secret_value()
|
||||||
if self.base_url:
|
if self.base_url:
|
||||||
config["base_url"] = self.base_url
|
config["base_url"] = self.base_url
|
||||||
|
# For Azure, base_url from the UI form maps to endpoint
|
||||||
|
if self.provider and self.provider.lower() == "azure" and not self.endpoint:
|
||||||
|
config["endpoint"] = self.base_url
|
||||||
if self.endpoint:
|
if self.endpoint:
|
||||||
config["endpoint"] = self.endpoint
|
config["endpoint"] = self.endpoint
|
||||||
if self.api_version:
|
if self.api_version:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue