Skip to content

feat(azure): support separate deployment names and improve configuration validation#732

Open
Pranay772629 wants to merge 3 commits into
emcie-co:developfrom
Pranay772629:azure-service-fix
Open

feat(azure): support separate deployment names and improve configuration validation#732
Pranay772629 wants to merge 3 commits into
emcie-co:developfrom
Pranay772629:azure-service-fix

Conversation

@Pranay772629
Copy link
Copy Markdown

Summary

Adds support for custom Azure OpenAI deployment names separate from model names, and refactors configuration validation to improve error handling and reduce code duplication.

Problem

Azure OpenAI allows custom deployment names that differ from model names, but the previous implementation assumed deployment_name == model_name, causing:

  • Token estimation failures (tiktoken needs actual model names)
  • Inability to use custom deployment names

Changes

New Environment Variables

  • AZURE_GENERATIVE_MODEL_DEPLOYMENT_NAME - Deployment name in Azure Portal
  • AZURE_EMBEDDING_MODEL_DEPLOYMENT_NAME - Deployment name in Azure Portal

Key distinction:

  • *_MODEL_NAME → For tokenizer initialization (e.g., gpt-4o)
  • *_MODEL_DEPLOYMENT_NAME → For Azure API requests (can be any custom name)

Refactoring

  • Added _get_custom_params(kind: Literal["EMBEDDING", "GENERATIVE"]) method to centralize validation
  • Validates both MODEL_NAME and MODEL_DEPLOYMENT_NAME are provided together
  • Raises clear exception if only one is set
  • Updated get_schematic_generator() and get_embedder() to use shared validation
  • Added Literal type import for stricter type safety

Example Configuration

Supports custom deployment names

export AZURE_GENERATIVE_MODEL_NAME="gpt-4o" # For tokenizer
export AZURE_GENERATIVE_MODEL_DEPLOYMENT_NAME="my-company-gpt4o" # For API

…om model names

Azure OpenAI uses the deployment name in chat/embeddings requests, while tiktoken expects a real model name for tokenizer lookup. The previous implementation implicitly assumed deployment name == model name, which breaks token estimation when users configure arbitrary deployment names in Azure.

This change:
- Introduces explicit deployment name fields for generative + embedding models
- Uses *_MODEL_NAME for tokenizer/estimation and *_MODEL_DEPLOYMENT_NAME for Azure API calls
- Adds AZURE_GENERATIVE_MODEL_DEPLOYMENT_NAME and AZURE_EMBEDDING_MODEL_DEPLOYMENT_NAME
- Updates verify_environment() documentation

Signed-off-by: Pranay Chandra Devasani <49197121+Pranay772629@users.noreply.github.com>
…method

Extract environment variable retrieval and validation logic for Azure custom models into a reusable `_get_custom_params` method. This improves error handling by explicitly checking that both model name and deployment name are provided together, and reduces code duplication between the generative and embedding model getters.

Changes:
- Fix typos
- Add `Literal` type import for stricter type hints
- Create `_get_custom_params` method to handle EMBEDDING and GENERATIVE model configuration
- Validate that both MODEL_NAME and MODEL_DEPLOYMENT_NAME are provided together
- Raise explicit exception when only one of the pair is set
- Update `get_schematic_generator` and `get_embedder` to use the new method

Signed-off-by: Pranay Chandra Devasani <49197121+Pranay772629@users.noreply.github.com>
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.

2 participants