llamaIndex - ✅(Solved) Fix [Bug]: DashScope DashScope MultimodalEmbedding embedding failed [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
run-llama/llama_index#21532Fetched 2026-05-02 05:27:34
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
labeled ×2commented ×1cross-referenced ×1mentioned ×1

Error Message

logger.error("Calling MultiModalEmbedding failed, details: %s" % response)

Fix Action

Fixed

PR fix notes

PR #21534: Fix DashScope multimodal embedding response parsing

Description (problem / solution / changelog)

Summary

Fixes DashScope multimodal embedding parsing for the current API response shape, where embeddings are returned under output.embeddings[0].embedding instead of the older output.embedding field.

The adapter still accepts the legacy singular response shape so existing older DashScope clients do not regress.

Fixes #21532.

Validation

  • uv run --directory llama-index-integrations/embeddings/llama-index-embeddings-dashscope pytest tests/test_embeddings_dashscope.py -q
  • uv run --directory llama-index-integrations/embeddings/llama-index-embeddings-dashscope ruff check llama_index/embeddings/dashscope/base.py tests/test_embeddings_dashscope.py
  • git diff --check

Changed files

  • llama-index-integrations/embeddings/llama-index-embeddings-dashscope/llama_index/embeddings/dashscope/base.py (modified, +7/-1)
  • llama-index-integrations/embeddings/llama-index-embeddings-dashscope/tests/test_embeddings_dashscope.py (modified, +57/-0)

Code Example

response.output["embedding"]

---

{
  "output": {
    "embeddings": [
      {
        "embedding": [...],
        "index": 0,
        "type": "text"
      }
    ]
  }
}

---

response = dashscope.MultiModalEmbedding.call(
        model=model, input=input, api_key=api_key, kwargs=kwargs
    )
if response.status_code == HTTPStatus.OK:
        return response.output["embedding"]
else:
        logger.error("Calling MultiModalEmbedding failed, details: %s" % response)
        return []
RAW_BUFFERClick to expand / collapse

Bug Description

The current implementation of get_multimodal_embedding uses an outdated response format. DashScope has updated the multimodal embedding API, and the response field has changed from embedding to embeddings.

The code currently parses:

response.output["embedding"]

However, the new API returns:

{
  "output": {
    "embeddings": [
      {
        "embedding": [...],
        "index": 0,
        "type": "text"
      }
    ]
  }
}

Version

llama-index-embeddings-dashscope>=0.5.0

Steps to Reproduce

response = dashscope.MultiModalEmbedding.call(
        model=model, input=input, api_key=api_key, kwargs=kwargs
    )
if response.status_code == HTTPStatus.OK:
        return response.output["embedding"]
else:
        logger.error("Calling MultiModalEmbedding failed, details: %s" % response)
        return []

API Docs: https://bailian.console.aliyun.com/cn-beijing?tab=api#/api/?type=model&url=2712517

extent analysis

TL;DR

Update the code to parse the new response format by accessing response.output["embeddings"] instead of response.output["embedding"].

Guidance

  • Identify the line of code that needs to be updated: return response.output["embedding"]
  • Replace the outdated field with the new one: return response.output["embeddings"]
  • Since the new API returns a list of embeddings, consider handling the list structure, e.g., by returning the first embedding: return response.output["embeddings"][0]["embedding"]
  • Verify the update by checking the response format and the returned embedding values

Example

if response.status_code == HTTPStatus.OK:
    # Handle the list of embeddings
    embeddings = response.output["embeddings"]
    # Return the first embedding, for example
    return embeddings[0]["embedding"]

Notes

The provided solution assumes that the first embedding in the list is the desired one. Depending on the specific requirements, additional logic might be needed to handle the list of embeddings.

Recommendation

Apply the workaround by updating the code to parse the new response format, as the issue is caused by an outdated implementation.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING