[Bug] 对于不支持维度修改的嵌入模型报错。

Open Beginner friendly
#7,570 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
65/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python
Domain
ai

Research direction

Start at the embedding provider's get_embedding entry point and inspect how _embedding_kwargs and get_dim supply arguments to the client. Reproduce the issue with Qwen3-Embedding or Qwen2-Embedding, then verify that a zero dimension omits the dimensions argument while nonzero dimensions remain supported.

Written by the indexing model from the issue text.

Description

area:provider bug
What happened / 发生了什么

关联 #6421
这个bug在上述issue中已经提及。现在源码的解决办法是return int(self.provider_config.get("embedding_dimensions", 1024))
但是并非所有此类模型都是1024维。我使用的Qwen3-Embedding 是4096维,上述写法不能覆盖此情况。建议可以允许参数为0,当参数为0的时候就不使用dimensions参数
比如:


    async def get_embedding(self, text: str) -> list[float]:
        """获取文本的嵌入"""
        kwargs = self._embedding_kwargs()
        if self.get_dim():
          embedding = await self.client.embeddings.create(
              input=text,
              model=self.model,
              dimensions=self.get_dim(),
              **kwargs,
          )
        else:
          embedding = await self.client.embeddings.create(
              input=text,
              model=self.model,
              **kwargs,
          )
        return embedding.data[0].embedding
Reproduce / 如何复现?

使用qwen3-embedding或者qwen2-embedding

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

4.23.1

OS

Windows

Logs / 报错日志
Image
Are you willing to submit a PR? / 你愿意提交 PR 吗?
  • Yes!
Code of Conduct
Dominant language
Python
Stars
40.7k
Forks
2.9k
Avg merge
1d 5h
Merged PRs (30d)
112

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AstrBotDevs/AstrBot

All issues in AstrBotDevs/AstrBot

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.