Ollama reports an error when adding Text Embedding. #5517

Closed
opened 2026-02-21 18:11:22 -05:00 by yindo · 19 comments
Owner

Originally created by @AAEE86 on GitHub (Sep 10, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.8.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

An error occurred during credentials validation: Session.request() got an unexpected keyword argument 'options'

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @AAEE86 on GitHub (Sep 10, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.8.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce An error occurred during credentials validation: Session.request() got an unexpected keyword argument 'options' ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 18:11:22 -05:00
yindo closed this issue 2026-02-21 18:11:23 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 10, 2024):

I found a similar issue related to the error "Session.request() got an unexpected keyword argument 'options'" when adding Text Embedding in Dify version 0.8.0. This error occurs because the requests.post method does not accept an options parameter. The options parameter is incorrectly included in the requests.post call in the _invoke method of the OllamaEmbeddingModel class.

To fix this error, you should remove the options parameter from the requests.post call. Here is the corrected code snippet:

response = requests.post(
    endpoint_url,
    headers=headers,
    data=json.dumps(payload),
    timeout=(10, 300)
)

This change will resolve the error by ensuring that only valid parameters are passed to the requests.post method [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Sep 10, 2024): <!-- Answer --> I found a similar issue related to the error "Session.request() got an unexpected keyword argument 'options'" when adding Text Embedding in Dify version 0.8.0. This error occurs because the `requests.post` method does not accept an `options` parameter. The `options` parameter is incorrectly included in the `requests.post` call in the `_invoke` method of the `OllamaEmbeddingModel` class. To fix this error, you should remove the `options` parameter from the `requests.post` call. Here is the corrected code snippet: ```python response = requests.post( endpoint_url, headers=headers, data=json.dumps(payload), timeout=(10, 300) ) ``` This change will resolve the error by ensuring that only valid parameters are passed to the `requests.post` method <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@AAEE86 commented on GitHub (Sep 10, 2024):

During handling of the above exception, another exception occurred:



Traceback (most recent call last):

  File "/app/api/controllers/console/workspace/models.py", line 151, in post

    model_provider_service.save_model_credentials(

  File "/app/api/services/model_provider_service.py", line 249, in save_model_credentials

    provider_configuration.add_or_update_custom_model_credentials(

  File "/app/api/core/entities/provider_configuration.py", line 375, in add_or_update_custom_model_credentials

    provider_model_record, credentials = self.custom_model_credentials_validate(model_type, model, credentials)

  File "/app/api/core/entities/provider_configuration.py", line 352, in custom_model_credentials_validate

    credentials = model_provider_factory.model_credentials_validate(

  File "/app/api/core/model_runtime/model_providers/model_provider_factory.py", line 123, in model_credentials_validate

    model_instance.validate_credentials(model, filtered_credentials)

  File "/app/api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py", line 146, in validate_credentials

    raise CredentialsValidateFailedError(f'An error occurred during credentials validation: {str(ex)}')

core.model_runtime.errors.validate.CredentialsValidateFailedError: An error occurred during credentials validation: Session.request() got an unexpected keyword argument 'options'
@AAEE86 commented on GitHub (Sep 10, 2024): ``` During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/app/api/controllers/console/workspace/models.py", line 151, in post model_provider_service.save_model_credentials( File "/app/api/services/model_provider_service.py", line 249, in save_model_credentials provider_configuration.add_or_update_custom_model_credentials( File "/app/api/core/entities/provider_configuration.py", line 375, in add_or_update_custom_model_credentials provider_model_record, credentials = self.custom_model_credentials_validate(model_type, model, credentials) File "/app/api/core/entities/provider_configuration.py", line 352, in custom_model_credentials_validate credentials = model_provider_factory.model_credentials_validate( File "/app/api/core/model_runtime/model_providers/model_provider_factory.py", line 123, in model_credentials_validate model_instance.validate_credentials(model, filtered_credentials) File "/app/api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py", line 146, in validate_credentials raise CredentialsValidateFailedError(f'An error occurred during credentials validation: {str(ex)}') core.model_runtime.errors.validate.CredentialsValidateFailedError: An error occurred during credentials validation: Session.request() got an unexpected keyword argument 'options' ```
Author
Owner

@AAEE86 commented on GitHub (Sep 10, 2024):

@crazywoola The rebuilt version 0.8.0 still has this problem. It may be related to this submission of #7624.

@AAEE86 commented on GitHub (Sep 10, 2024): @crazywoola The rebuilt version 0.8.0 still has this problem. It may be related to this submission of #7624.
Author
Owner

@kksmi commented on GitHub (Sep 10, 2024):

Hi. Did you solve the problem?

@kksmi commented on GitHub (Sep 10, 2024): Hi. Did you solve the problem?
Author
Owner

@AAEE86 commented on GitHub (Sep 10, 2024):

你好请问你解决这个问题了吗,我感觉是ollama升级换了options

没有,使用ollama旧版本的镜像依旧报错。查看了ollama日志,没有任何报错。这个问题与ollama无关。

@AAEE86 commented on GitHub (Sep 10, 2024): > 你好请问你解决这个问题了吗,我感觉是ollama升级换了options 没有,使用ollama旧版本的镜像依旧报错。查看了ollama日志,没有任何报错。这个问题与ollama无关。
Author
Owner

@kksmi commented on GitHub (Sep 10, 2024):

你好请问你解决这个问题了吗,我感觉是ollama升级换了options

没有,使用ollama旧版本的镜像依旧报错。查看了ollama日志,没有任何报错。这个问题与ollama无关。

构建LLM时候可以构建,但是嵌入模型就不行,目前好像没有其他人上报这个问题

@kksmi commented on GitHub (Sep 10, 2024): > > 你好请问你解决这个问题了吗,我感觉是ollama升级换了options > > 没有,使用ollama旧版本的镜像依旧报错。查看了ollama日志,没有任何报错。这个问题与ollama无关。 构建LLM时候可以构建,但是嵌入模型就不行,目前好像没有其他人上报这个问题
Author
Owner

@AAEE86 commented on GitHub (Sep 10, 2024):

你好请问你解决这个问题了吗,我感觉是ollama升级换了options

没有,使用ollama旧版本的镜像依旧报错。查看了ollama日志,没有任何报错。这个问题与ollama无关。

构建LLM时候可以构建,但是嵌入模型就不行,目前好像没有其他人上报这个问题

是的 等修复

@AAEE86 commented on GitHub (Sep 10, 2024): > > > 你好请问你解决这个问题了吗,我感觉是ollama升级换了options > > > > > > 没有,使用ollama旧版本的镜像依旧报错。查看了ollama日志,没有任何报错。这个问题与ollama无关。 > > 构建LLM时候可以构建,但是嵌入模型就不行,目前好像没有其他人上报这个问题 是的 等修复
Author
Owner

@racerxdl commented on GitHub (Sep 10, 2024):

Same here. :'(

@racerxdl commented on GitHub (Sep 10, 2024): Same here. :'(
Author
Owner
@Howe829 commented on GitHub (Sep 10, 2024): I think the cause is this line: https://github.com/langgenius/dify/blob/2a3d8c25bc4104f1da65bf045bb732fd9551725a/api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py#L87
Author
Owner
@Howe829 commented on GitHub (Sep 10, 2024): > I think the cause is this line: > > https://github.com/langgenius/dify/blob/2a3d8c25bc4104f1da65bf045bb732fd9551725a/api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py#L87 I submitted a pr #8236
Author
Owner

@algorithmx commented on GitHub (Sep 11, 2024):

Can you please update the docker images?

@algorithmx commented on GitHub (Sep 11, 2024): Can you please update the docker images?
Author
Owner

@racerxdl commented on GitHub (Sep 11, 2024):

@algorithmx working now. Thanks :D

@racerxdl commented on GitHub (Sep 11, 2024): @algorithmx working now. Thanks :D
Author
Owner

@tigflanker commented on GitHub (Sep 11, 2024):

Same issue. 0.8.0
Can not use qwen2-embedding model in Ollama

[ollama] Error: Session.request() got an unexpected keyword argument 'options'


working now.
By modify text_embedding.py in docker-api-1

@tigflanker commented on GitHub (Sep 11, 2024): Same issue. 0.8.0 Can not use qwen2-embedding model in Ollama [ollama] Error: Session.request() got an unexpected keyword argument 'options' -------------------- working now. By modify [text_embedding.py](https://github.com/langgenius/dify/blob/2a3d8c25bc4104f1da65bf045bb732fd9551725a/api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py#L87) in docker-api-1
Author
Owner

@GlitCher50 commented on GitHub (Sep 12, 2024):

Tried updating the docker images still the same. Is the docker images being updated with this fix?

  • Removed the images from docker desktop
  • Did "docker compose pull"
  • Then tried with force-recreate "docker compose up --force-recreate --build -d"

Still not working.

@GlitCher50 commented on GitHub (Sep 12, 2024): Tried updating the docker images still the same. Is the docker images being updated with this fix? - Removed the images from docker desktop - Did "docker compose pull" - Then tried with force-recreate "docker compose up --force-recreate --build -d" Still not working.
Author
Owner

@AAEE86 commented on GitHub (Sep 12, 2024):

@GlitCher50 docker image has not been updated.

@AAEE86 commented on GitHub (Sep 12, 2024): @GlitCher50 docker image has not been updated.
Author
Owner

@racerxdl commented on GitHub (Sep 12, 2024):

I changed to main tag to avoid issues with caching (because there is cache on dockerhub as well for images).

@racerxdl commented on GitHub (Sep 12, 2024): I changed to `main` tag to avoid issues with caching (because there is cache on dockerhub as well for images).
Author
Owner

@kksmi commented on GitHub (Sep 12, 2024):

Tried updating the docker images still the same. Is the docker images being updated with this fix?

  • Removed the images from docker desktop
  • Did "docker compose pull"
  • Then tried with force-recreate "docker compose up --force-recreate --build -d"

Still not working.

You should start it after pull, then modify text_embedding.py in the folder corresponding to the docker-worker-1 and docker-api-1 respectively, remove options, and after that don't start it via command, start it in docker desktop.

@kksmi commented on GitHub (Sep 12, 2024): > Tried updating the docker images still the same. Is the docker images being updated with this fix? > > * Removed the images from docker desktop > * Did "docker compose pull" > * Then tried with force-recreate "docker compose up --force-recreate --build -d" > > Still not working. You should start it after pull, then modify text_embedding.py in the folder corresponding to the docker-worker-1 and docker-api-1 respectively, remove options, and after that don't start it via command, start it in docker desktop.
Author
Owner

@ther3zz commented on GitHub (Sep 12, 2024):

I changed to main tag to avoid issues with caching (because there is cache on dockerhub as well for images).

I changed to main tag to avoid issues with caching (because there is cache on dockerhub as well for images).

I changed to main tag to avoid issues with caching (because there is cache on dockerhub as well for images).

Thanks, this corrected it for me!

The docs on the website has the versions hardcoded and I failed to notice that before you mentioned :main

@ther3zz commented on GitHub (Sep 12, 2024): > I changed to `main` tag to avoid issues with caching (because there is cache on dockerhub as well for images). > I changed to `main` tag to avoid issues with caching (because there is cache on dockerhub as well for images). > I changed to `main` tag to avoid issues with caching (because there is cache on dockerhub as well for images). Thanks, this corrected it for me! The docs on the website has the versions hardcoded and I failed to notice that before you mentioned :main
Author
Owner

@julianShi commented on GitHub (Dec 25, 2024):

There is a typo on https://github.com/langgenius/dify/blame/main/api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py#L68

The url should be api/embeddings.

@julianShi commented on GitHub (Dec 25, 2024): There is a typo on https://github.com/langgenius/dify/blame/main/api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py#L68 The url should be `api/embeddings`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5517