Skip to content

issue-2394: use deployment variable instead of model for embeddings API call#2395

Merged
danielaskdd merged 1 commit intoHKUDS:mainfrom
Amrit75:issue-2394
Nov 20, 2025
Merged

issue-2394: use deployment variable instead of model for embeddings API call#2395
danielaskdd merged 1 commit intoHKUDS:mainfrom
Amrit75:issue-2394

Conversation

@Amrit75
Copy link
Contributor

@Amrit75 Amrit75 commented Nov 20, 2025

Description

This pull request fixes a critical bug in azure_openai_embed() where the Azure embeddings API is called with the wrong model value.

The function correctly resolves the Azure deployment name into the deployment variable, but it mistakenly passes the unused model parameter (typically None) to embeddings.create(). This causes Azure to look for a deployment literally named "None" and results in a 404 DeploymentNotFound error.

This PR updates the call to:

model=deployment

which is the correct behavior and aligns with how Azure OpenAI routing works.

Related Issues

Fixes: #
(If you haven’t created the issue yet, you can add it afterward.)

Changes Made

Updated lightrag/llm/azure_openai.py in azure_openai_embed():

Replaced model=model with model=deployment

Added in-line comment explaining why Azure requires model=deployment

Verified the change through local testing with Azure embeddings

Checklist

Changes tested locally

Code reviewed

Documentation updated (not required for this change)

Unit tests added (optional — no tests currently exist for this module)

Additional Notes

This fix resolves a blocking issue for all Azure OpenAI embedding users.

Without this change, embedding requests always fail with 404, even with correct Azure configuration.

Happy to make any adjustments requested by maintainers.

@danielaskdd
Copy link
Collaborator

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Can't wait for the next one!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielaskdd danielaskdd merged commit cc78e2d into HKUDS:main Nov 20, 2025
4 checks passed
@danielaskdd
Copy link
Collaborator

Using deployment directly as the model parameter leads to:

  • The incoming model parameter being ignored (unless the environment variable AZURE_EMBEDDING_DEPLOYMENT is unset)
  • Inconsistent handling compared to the azure_openai_complete_if_cache function in the same file

We should prioritize the model parameter if provided, falling back to the deployment name only when necessary. I have updated the code on the main branch—please verify that it behaves as expected.

    response = await openai_async_client.embeddings.create(
        model=model or deployment, input=texts, encoding_format="float"
    )

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