Skip to content

Azure OpenAI methods for embeddings and chat completions don't have a deployment parameter #895

@tonybaloney

Description

@tonybaloney

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

The Azure AsyncAzureOpenAI class has a single parameter to set the deployment name azure_deployment.

A common situation is to have an embeddings model deployment and a chat model deployment. In the calls for embeddings.create() and chat.completions.create() there is no parameter to set the deployment name.

What this means is you need to create multiple clients for each deployment you want to use.

To Reproduce

openai_client = AsyncAzureOpenAI(
            api_version="2023-07-01-preview",
            azure_endpoint=f"https://{AZURE_OPENAI_SERVICE}.openai.azure.com",
            azure_ad_token_provider=token_provider,
            organization=OPENAI_ORGANIZATION,
            azure_deployment='?', # A single parameter for the whole client?
        )

# No parameter for the chat deployment name?
await openai_client.chat.completions.create(
            model='gpt-35-turbo',
            messages=messages,
            temperature=0.0,
            max_tokens=100,
            n=1,
            functions=functions,
            function_call="auto",
        )
# No deployment name parameter?
await openai_client.embeddings.create(model=embedding_model, input=query_text)

Without the deployment name being correct, calls to the embeddings API give an error message

Code snippets

No response

OS

macOS

Python version

Python 3.11.1

Library version

1.3.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions