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:error when adding the ollama embedding model #8236

Merged
merged 3 commits into from
Sep 11, 2024

Conversation

Howe829
Copy link
Contributor

@Howe829 Howe829 commented Sep 11, 2024

Checklist:

Important

Please review the checklist below before submitting your pull request.

  • Please open an issue before creating a PR or link to an existing issue
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Description

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue. Close issue syntax: Fixes #<issue number>, see documentation for more details.

Fixes #8209

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update, included: Dify Document
  • Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
  • Dependency upgrade

Testing Instructions

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working labels Sep 11, 2024
@AAEE86
Copy link
Contributor

AAEE86 commented Sep 11, 2024

You can Fixes #8209 in Description.

laipz8200
laipz8200 previously approved these changes Sep 11, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 11, 2024
Copy link
Member

@crazywoola crazywoola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be "true", otherwise it will report 500 error.

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Sep 11, 2024
@crazywoola
Copy link
Member

Maybe fix #6493

@crazywoola crazywoola merged commit 82c42b9 into langgenius:main Sep 11, 2024
6 checks passed
@Howe829
Copy link
Contributor Author

Howe829 commented Sep 11, 2024

It should be "true", otherwise it will report 500 error.

Hi, actually I think "true" will cause 500 error
image
@crazywoola
image
@AAEE86
Please check the ollama source code, you will see the UseMmap Option Field is of type *bool, which means it can be nil,true or false.it can't be a string.
https://github.com/ollama/ollama/blob/735a0ca2e480b40fc714751b73848c08cf4eed43/api/types.go#L242

@AAEE86
Copy link
Contributor

AAEE86 commented Sep 11, 2024

Looks like it should be True.

You can create a new PR.

@kksmi
Copy link

kksmi commented Sep 11, 2024

I changed that place in [api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py] to True, but it still reports an error when adding the embedded model.

@Howe829
Copy link
Contributor Author

Howe829 commented Sep 11, 2024

I changed that place in [api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py] to True, but it still reports an error when adding the embedded model.

Could you please paste the error here? I think you can check whether you can connect to the Ollama API server or if the Base URL of the Ollama server is correct
image
image

@Howe829 Howe829 mentioned this pull request Sep 11, 2024
12 tasks
@kksmi
Copy link

kksmi commented Sep 11, 2024

I changed that place in [api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py] to True, but it still reports an error when adding the embedded model.

Could you please paste the error here? I think you can check whether you can connect to the Ollama API server or if the Base URL of the Ollama server is correct image image

image
The URL and name are correct and it can be added as LLM.

@AAEE86
Copy link
Contributor

AAEE86 commented Sep 11, 2024

I changed that place in [api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py] to True, but it still reports an error when adding the embedded model.

Could you please paste the error here? I think you can check whether you can connect to the Ollama API server or if the Base URL of the Ollama server is correct image image

image The URL and name are correct and it can be added as LLM.

payload = {"input": inputs, "model": model, "options": {"use_mmap": True}}
# Make the request to the Ollama API
response = requests.post(endpoint_url, headers=headers, data=json.dumps(payload), timeout=(10, 300))

Are you sure it was modified according to the above code?

@Howe829
Copy link
Contributor Author

Howe829 commented Sep 11, 2024

I changed that place in [api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py] to True, but it still reports an error when adding the embedded model.

Could you please paste the error here? I think you can check whether you can connect to the Ollama API server or if the Base URL of the Ollama server is correct image image

image The URL and name are correct and it can be added as LLM.

Could you show me the code you changed? I guess you are running it with docker and the error you showed above is already fixed by this pr. The True or "true" problem is an other issue.

@kksmi
Copy link

kksmi commented Sep 11, 2024

我把[api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py]中那地方改成了True,但是在添加嵌入模型的时候还是报错。

您能把错误粘贴到这里吗?我认为您可以检查是否可以连接到 Ollama API 服务器,或者 Ollama 服务器的基本 URL 是否正确图像 图像

图像URL 和名称正确,可以添加为 LLM。

你能给我看一下你修改的代码吗?我猜你是用docker运行的,上面显示的错误已经被这个pr修复了。True或“true”问题是另一个问题。
Thank you very much for your guidance, I pulled the repository multiple times, updated the dify and as a result did not implement the update of that code, by manually modifying the file but got a 500 service error, finally modified True and he finally worked.

@liuxiaohao-xn
Copy link

liuxiaohao-xn commented Sep 11, 2024

1726046144(1)

i have change the file ,But when I uploaded the knowledge base,Still the following error occurs:
1726046386(1)

1726046593(1)

@kksmi
Copy link

kksmi commented Sep 11, 2024

1726046144(1)

我已经修改了文件,但是当我上传知识库时,仍然出现以下错误: 1726046386(1)

1726046593(1)

我也遇到了这个问题,刚刚发现

@AAEE86
Copy link
Contributor

AAEE86 commented Sep 11, 2024

我觉得可以尝试将 "options": {"use_mmap": True} 删除,我不太清楚它在这里起什么作用?

@crazywoola
Copy link
Member

我觉得可以尝试将 "options": {"use_mmap": True} 删除,我不太清楚它在这里起什么作用?

Try to fix this one. #8128

@kksmi
Copy link

kksmi commented Sep 11, 2024

1726046144(1)

i have change the file ,But when I uploaded the knowledge base,Still the following error occurs: 1726046386(1)

1726046593(1)

你去掉之后还会提示错误吗,我还是会,有部分文件不会,但是感觉没有索引成功

@Howe829
Copy link
Contributor Author

Howe829 commented Sep 11, 2024

1726046144(1)
i have change the file ,But when I uploaded the knowledge base,Still the following error occurs: 1726046386(1)
1726046593(1)

你去掉之后还会提示错误吗,我还是会,有部分文件不会,但是感觉没有索引成功

Did you restart your celery worker?
I can successfully index and do the retrieval
image

@kksmi
Copy link

kksmi commented Sep 11, 2024

1726046144(1)
我已经修改了文件,但是当我上传知识库时,仍然出现以下错误:1726046386(1)
1726046593(1)

你去掉之后还会提示错误但是吗,我还是会,有部分文件不会,感觉没有索引成功

你重启了芹菜工人吗? 我可以成功索引和搜索 图像

I've found that I can't synchronize the code files within the api by updating according to the docs' update dedify prompts, so it often changes back to the original code.

@Howe829 Howe829 deleted the fix/ollama_embeddings branch September 11, 2024 13:08
@liuxiaohao-xn
Copy link

1726046144(1)我已经更改了文件,但是当我上传知识库时,仍然出现以下错误:1726046386(1)
1726046593(1)

你去掉之后还会提示错误吗,我还是会,有部分文件不会,但是感觉没有索引成功

你重新启动你的芹菜工人了吗?我可以成功索引并进行检索 image

我全部镜像都手动重启了,但是在创建知识库的时候还是会报这样的错误
image

@kksmi
Copy link

kksmi commented Sep 12, 2024

1726046144(1)我已经更改了文件,但是当我上传知识库时,仍然出现以下错误:1726046386(1)
1726046593(1)

你去掉之后还会提示错误吗,我还是会,有部分文件不会,但是感觉没有索引成功

你重新启动你的芹菜工人了吗?我可以成功索引并进行检索 image

我全部镜像都手动重启了,但是在创建知识库的时候还是会报这样的错误 image

手动重启之后,如果你是windows,需要修改worker和api下该文件,去掉该文件的的options就可以跑了

@kksmi
Copy link

kksmi commented Sep 12, 2024

我觉得可以尝试将 "options": {"use_mmap": True} 删除,我不太清楚它在这里起什么作用?

Try to fix this one. #8128

It turns out that removing the option is the only way to run it, the error may be related to his version of ollama, there is no need to include options, I hope to remove options in the next api image upgrade, it's not convenient for windows users, thank you very much.

ZhouhaoJiang added a commit that referenced this pull request Sep 12, 2024
* main: (141 commits)
  fix(workflow/hooks/use-shortcuts): resolve issue of copy shortcut not working in workflow debug and preview panel (#8249)
  chore: cleanup pycodestyle E rules (#8269)
  let claude models in bedrock support the response_format parameter (#8220)
  enhance: improve empty data display for detail panel (#8266)
  chore: remove useless code (#8198)
  chore: apply pep8-naming rules for naming convention (#8261)
  fix:ollama text embedding 500 error (#8252)
  Update Gitlab query field, add query by path (#8244)
  editor can also create api key (#8214)
  fix: upload img icon mis-align in the chat input area (#8263)
  fix: truthy value (#8208)
  fix(workflow): IF-ELSE nodes connected to the same subsequent node cause execution to stop (#8247)
  fix: workflow parallel limit in ifelse node (#8242)
  fix: CHECK_UPDATE_URL comment (#8235)
  fix:error when adding the ollama embedding model (#8236)
  fix: improving the regionalization of translation (#8231)
  feat: add from_variable_selector for stream chunk / message event (#8228)
  fix(workflow): answers are output simultaneously across different braches in the question classifier node. (#8225)
  fix(workflow): in multi-parallel execution with multiple conditional branches (#8221)
  fix(docker/docker-compose.yaml): Set default value for `REDIS_SENTINEL_SOCKET_TIMEOUT` and `CELERY_SENTINEL_SOCKET_TIMEOUT` (#8218)
  ...
@Howe829
Copy link
Contributor Author

Howe829 commented Sep 13, 2024

我觉得可以尝试将 "options": {"use_mmap": True} 删除,我不太清楚它在这里起什么作用?

Try to fix this one. #8128

It turns out that removing the option is the only way to run it, the error may be related to his version of ollama, there is no need to include options, I hope to remove options in the next api image upgrade, it's not convenient for windows users, thank you very much.

I think you can check the Ollama logs to see if there are any errors. I highly recommend upgrading Ollama to the latest version.

cuiks pushed a commit to cuiks/dify that referenced this pull request Sep 26, 2024
lau-td pushed a commit to heydevs-io/dify that referenced this pull request Oct 23, 2024
@verigle
Copy link

verigle commented Nov 5, 2024

添加文档的时候依然会在80%左右的时候出现 ollama embedding 500 错误

idonotknow pushed a commit to AceDataCloud/Dify that referenced this pull request Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ollama reports an error when adding Text Embedding.
7 participants