lobe-chat icon indicating copy to clipboard operation
lobe-chat copied to clipboard

[Bug] 添加ollama的Embedding模型都无法使用

Open lgy1027 opened this issue 10 months ago • 15 comments

📦 Platform

Self hosting Docker

📦 Deploymenet mode

server db(lobe-chat-database image)

📌 Version

latest

💻 Operating System

Ubuntu, Other Linux

🌐 Browser

Chrome

🐛 Bug Description

.env添加如下配置:

EMBEDDING_MODEL=ollama/nomic-embed-text:latest
OLLAMA_PROXY_URL=http://10.0.100.204:11434

OLLAMA_PROXY_URL去掉和添加/v1都试了没用

docker - lobe-chat添加环境变量如下:

'DEFAULT_FILES_CONFIG=embedding_model=${EMBEDDING_MODEL}'

lobe-chat服务提供商配置如下:

Image

上传文件报错如下:

run embedding task 1
embeddingChunks error {
  message: '{"error":{"message":"Not Found","name":"ResponseError","status_code":404},"errorType":"OllamaBizError","provider":"ollama"}',
  name: 'EmbeddingError'
}

单独调用ollama模型列表返回有对应的模型

{
	"object": "list",
	"data": [
		{
			"id": "bge-m3:latest",
			"object": "model",
			"created": 1740555815,
			"owned_by": "library"
		},
		{
			"id": "nomic-embed-text:latest",
			"object": "model",
			"created": 1739008556,
			"owned_by": "library"
		},
		{
			"id": "qwen2.5:latest",
			"object": "model",
			"created": 1737095930,
			"owned_by": "library"
		},
		{
			"id": "llama3:latest",
			"object": "model",
			"created": 1737093640,
			"owned_by": "library"
		}
	]
}

📷 Recurrence Steps

No response

🚦 Expected Behavior

No response

📝 Additional Information

No response

lgy1027 avatar Feb 26 '25 09:02 lgy1027

👀 @lgy1027

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible. Please make sure you have given us as much context as possible.
非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。

lobehubbot avatar Feb 26 '25 09:02 lobehubbot

I found a similar discussion regarding issues with Ollama's embedding models in Lobe Chat. The discussion titled "使用任何ollama的embedding模型都会报错。" is currently unsolved and was last updated on February 21, 2025 [1].

For your specific issue, ensure that your .env file is correctly configured. Here is a recommended configuration for integrating Ollama's embedding models:

DEFAULT_FILES_CONFIG="embedding_model=ollama/nomic-embed-text:latest"
OLLAMA_PROXY_URL=http://10.0.100.204:11434

Make sure that the Ollama service is running and accessible at the specified proxy URL. If you encounter a 404 error, it might be due to incorrect routing or the model not being properly registered or accessible through the proxy. Double-check the Ollama server configuration and ensure that the model is available and correctly listed.

Additionally, verify that the Ollama service is configured to allow cross-origin requests, which can be done by setting the following environment variables on macOS:

launchctl setenv OLLAMA_HOST "0.0.0.0"
launchctl setenv OLLAMA_ORIGINS "*"

If you are using Docker, ensure that the Docker network settings allow for proper communication between Lobe Chat and the Ollama service. You might need to adjust the Docker run command to include network settings that facilitate this communication.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

dosubot[bot] avatar Feb 26 '25 09:02 dosubot[bot]

OLLAMA_HOST "0.0.0.0"

网络是通的:

Image

ollama启动命令:

docker run -d --shm-size=3g -v ./ollama:/root/.ollama -e OLLAMA_HOST="0.0.0.0" -e OLLAMA_ORIGINS="*" -p 11434:11434 --name ollama ollama/ollama

lgy1027 avatar Feb 27 '25 01:02 lgy1027

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


OLLAMA_HOST "0.0.0.0"

The network is connected:

Image

Ollama Start Command:

docker run -d --shm-size=3g -v ./ollama:/root/.ollama -e OLLAMA_HOST="0.0.0.0" -e OLLAMA_ORIGINS="*" -p 11434:11434 --name ollama ollama/ollama

lobehubbot avatar Feb 27 '25 01:02 lobehubbot

OLLAMA_HOST "0.0.0.0"

网络是通的:

Image

ollama启动命令:

docker run -d --shm-size=3g -v ./ollama:/root/.ollama -e OLLAMA_HOST="0.0.0.0" -e OLLAMA_ORIGINS="*" -p 11434:11434 --name ollama ollama/ollama

你有没有发现,不使用“客户端请求模式”网络就不通了?

alao556 avatar Feb 27 '25 01:02 alao556

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


OLLAMA_HOST "0.0.0.0"

The network is connected:

Image

ollama start command:

docker run -d --shm-size=3g -v ./ollama:/root/.ollama -e OLLAMA_HOST="0.0.0.0" -e OLLAMA_ORIGINS="*" -p 11434:11434 --name ollama ollama/ollama

Have you found that the network will not work without using the "client request mode"?

lobehubbot avatar Feb 27 '25 01:02 lobehubbot

OLLAMA_HOST "0.0.0.0"

网络是通的: Image ollama启动命令:

docker run -d --shm-size=3g -v ./ollama:/root/.ollama -e OLLAMA_HOST="0.0.0.0" -e OLLAMA_ORIGINS="*" -p 11434:11434 --name ollama ollama/ollama

你有没有发现,不使用“客户端请求模式”网络就不通了?

通啊。我用ollama的llm模型测试:

Image

ollama日志:

Image

Image

lgy1027 avatar Feb 27 '25 01:02 lgy1027

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


OLLAMA_HOST "0.0.0.0"

The network is connected: Image ollama start command:

docker run -d --shm-size=3g -v ./ollama:/root/.ollama -e OLLAMA_HOST="0.0.0.0" -e OLLAMA_ORIGINS="*" -p 11434:11434 --name ollama ollama/ollama

Have you found that the network will not work without using the "client request mode"?

It's clear. I tested using ollama's llm model:

Image

Ollama log:

Image

Image

lobehubbot avatar Feb 27 '25 01:02 lobehubbot

OLLAMA_HOST "0.0.0.0"

网络是通的: Image ollama启动命令:

docker run -d --shm-size=3g -v ./ollama:/root/.ollama -e OLLAMA_HOST="0.0.0.0" -e OLLAMA_ORIGINS="*" -p 11434:11434 --name ollama ollama/ollama

你有没有发现,不使用“客户端请求模式”网络就不通了?

通啊。我用ollama的llm模型测试:

Image

ollama日志:

Image

Image

我的就不行,关掉客户端请求模式就无法连通模型服务(火狐、edge)

alao556 avatar Feb 27 '25 02:02 alao556

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


OLLAMA_HOST "0.0.0.0"

The network is connected: Image ollama start command:

docker run -d --shm-size=3g -v ./ollama:/root/.ollama -e OLLAMA_HOST="0.0.0.0" -e OLLAMA_ORIGINS="*" -p 11434:11434 --name ollama ollama/ollama

Have you found that the network will not work without using the "client request mode"?

It's clear. I tested using ollama's llm model:

Image

ollama log:

Image

Image

Mine doesn't work. If you turn off the client request mode, you can't connect to the model service

lobehubbot avatar Feb 27 '25 02:02 lobehubbot

我也是一样的,向量模型不能使用

amDosion avatar Feb 27 '25 09:02 amDosion

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


The same is true for me, the vector model cannot be used

lobehubbot avatar Feb 27 '25 09:02 lobehubbot

我也是chat模型可以正常使用,就是向量模型不行。

Image

ruanjunmin avatar Mar 05 '25 06:03 ruanjunmin

同样的问题,lobe的ollama模型管理界面关闭了“客户端请求”的,应该是服务器请求。 去ollama服务端,看了一下,相应时刻,有embedding日志:

Mar 06 12:01:59 r3175 ollama[6192]: [GIN] 2025/03/06 - 12:01:59 | 200 |   762.53722ms |  192.168.199.59 | POST     "/api/embeddings"
Mar 06 12:01:59 r3175 ollama[6192]: [GIN] 2025/03/06 - 12:01:59 | 200 |  775.942729ms |  192.168.199.59 | POST     "/api/embeddings"
Mar 06 12:01:59 r3175 ollama[6192]: [GIN] 2025/03/06 - 12:01:59 | 200 |  782.680352ms |  192.168.199.59 | POST     "/api/embeddings"
Mar 06 12:01:59 r3175 ollama[6192]: [GIN] 2025/03/06 - 12:01:59 | 200 |  798.854501ms |  192.168.199.59 | POST     "/api/embeddings"
Mar 06 12:01:59 r3175 ollama[6192]: [GIN] 2025/03/06 - 12:01:59 | 200 |   811.44602ms |  192.168.199.59 | POST     "/api/embeddings"

berlin2123 avatar Mar 06 '25 04:03 berlin2123

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


The same problem is that the "client request" of lobe's ollama model management interface should be the server request. Go to the ollama server and checked it. At the corresponding moment, there is an embedding log:

Mar 06 12:01:59 r3175 ollama[6192]: [GIN] 2025/03/06 - 12:01:59 | 200 | 762.53722ms | 192.168.199.59 | POST "/api/embeddings"
Mar 06 12:01:59 r3175 ollama[6192]: [GIN] 2025/03/06 - 12:01:59 | 200 | 775.942729ms | 192.168.199.59 | POST "/api/embeddings"
Mar 06 12:01:59 r3175 ollama[6192]: [GIN] 2025/03/06 - 12:01:59 | 200 | 782.680352ms | 192.168.199.59 | POST "/api/embeddings"
Mar 06 12:01:59 r3175 ollama[6192]: [GIN] 2025/03/06 - 12:01:59 | 200 | 798.854501ms | 192.168.199.59 | POST "/api/embeddings"
Mar 06 12:01:59 r3175 ollama[6192]: [GIN] 2025/03/06 - 12:01:59 | 200 | 811.44602ms | 192.168.199.59 | POST "/api/embeddings"

lobehubbot avatar Mar 06 '25 04:03 lobehubbot

我也碰到了同样的问题。 message: '{"error":{"message":"[object Object]","name":"ResponseError","status_code":404},"errorType":"OllamaBizError","provider":"ollama"}', run embedding task 1 }

wxyzh avatar Jun 23 '25 08:06 wxyzh

如果能在ollama日志(systemctl status ollama.service)中发现lobe的embeddings请求信息,说明网络是畅通的。那么另一个常见问题,就是embeddings模型的embedding_length数据与lobechat中的设置并不匹配(参见#5635 )。目前,默认只支持embedding_length=1024的embeddings模型。换用这样的模型即可,例如 mxbai-embed-large

berlin2123 avatar Jun 23 '25 09:06 berlin2123

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


If you can find lobe's embeddings request information in the ollama log (systemctl status ollama.service), it means that the network is smooth. Another common problem, then, is that the embedding_length data of the embeddings model does not match the settings in lobechat (see #5635). Currently, only embeddings models with embedding_length=1024 are supported by default. Just use such a model, for example mxbai-embed-large

lobehubbot avatar Jun 23 '25 09:06 lobehubbot