Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix zhipu embedding error when input is array but not string #1306

Merged
merged 2 commits into from
Apr 27, 2024

Conversation

caixinjiang
Copy link
Contributor

close #issue_number

我已确认该 PR 已自测通过,相关截图如下:
(此处放上测试通过的截图,如果不涉及前端改动或从 UI 上无法看出,请放终端启动成功的截图)

image image

@songquanpeng songquanpeng changed the title fix zhipu embedding error when input is array but not string fix: fix zhipu embedding error when input is array but not string Apr 21, 2024
@songquanpeng
Copy link
Owner

智谱的这个本身就不支持传入 list 吧,如果我们这样搞了,返回的结果还是只有一个,而且还是非预期的手动拼起来的字符串的 embedding

@caixinjiang
Copy link
Contributor Author

提这个 PR, 是因为一些上游应用, 比如 fastgpt, 在调用 embedding 的时候, 传入的是数组. 相关代码:

> packages/service/core/ai/embedding/index.ts
    const result = await ai.embeddings
      .create({
        ...model.defaultConfig,
        model: model.model,
        **input: [input]**
      })

当 oneapi 走 openai 的时候, embedding 传入 string 还是 list 都可以.
然后参考着已有代码写了 PR

> relay/adaptor/ollama/main.go:144
func ConvertEmbeddingRequest(request model.GeneralOpenAIRequest) *EmbeddingRequest {
	return &EmbeddingRequest{
		Model:  request.Model,
		Prompt: strings.Join(request.ParseInput(), " "),
	}
}

麻烦看看是否合适

@songquanpeng songquanpeng merged commit 6cffb11 into songquanpeng:main Apr 27, 2024
@songquanpeng
Copy link
Owner

Thx~

mxdlzg pushed a commit to mxdlzg/one-api that referenced this pull request Apr 29, 2024
…ngquanpeng#1306)

* fix zhipu embedding error when input is array but not string

* fix: only use the first one

---------

Co-authored-by: 蔡新疆 <[email protected]>
Co-authored-by: JustSong <[email protected]>
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