dify icon indicating copy to clipboard operation
dify copied to clipboard

After the plug-in is migrated and installed after the upgrade 1.0.0 is completed, error 404 is reported in the model call log

Open auxpd opened this issue 11 months ago • 6 comments

Self Checks

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

Dify version

1.0.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Calling the model normally in the chat assistant (Anthropic) ,I tried reinstalling the module again and the problem was not resolved

✔️ Expected Behavior

After migration, the model can be used normally (agent、chat bot)

❌ Actual Behavior

Now the page response ends directly, and the background log gives an error:

2025-03-06 06:20:25.196 ERROR [Thread-89 (_generate_worker)] [app_generator.py:243] - Unknown Error when generating
Traceback (most recent call last):
  File "/app/api/core/app/apps/chat/app_generator.py", line 223, in _generate_worker
    runner.run(
  File "/app/api/core/app/apps/chat/app_runner.py", line 58, in run
    self.get_pre_calculate_rest_tokens(
  File "/app/api/core/app/apps/base_app_runner.py", line 86, in get_pre_calculate_rest_tokens
    prompt_tokens = model_instance.get_llm_num_tokens(prompt_messages)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/core/model_manager.py", line 195, in get_llm_num_tokens
    self._round_robin_invoke(
  File "/app/api/core/model_manager.py", line 370, in _round_robin_invoke
    return function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/core/model_runtime/model_providers/__base/large_language_model.py", line 299, in get_num_tokens
    return plugin_model_manager.get_llm_num_tokens(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/core/plugin/manager/model.py", line 231, in get_llm_num_tokens
    for resp in response:
                ^^^^^^^^
  File "/app/api/core/plugin/manager/base.py", line 189, in _request_with_plugin_daemon_response_stream
    self._handle_plugin_daemon_error(error.error_type, error.message)
  File "/app/api/core/plugin/manager/base.py", line 221, in _handle_plugin_daemon_error
    raise PluginInvokeError(description=message)
core.plugin.manager.exc.PluginInvokeError: PluginInvokeError: {"args":{},"error_type":"NotFoundError","message":"404 page not found"}
2025-03-06 06:20:25.200 DEBUG [Dummy-88] [based_generate_task_pipeline.py:45] - error: PluginInvokeError: {"args":{},"error_type":"NotFoundError","message":"404 page not found"}
2025-03-06 06:20:25.210 ERROR [Dummy-88] [base_app_generate_response_converter.py:123] - {"args":{},"error_type":"NotFoundError","message":"404 page not found"}

auxpd avatar Mar 06 '25 06:03 auxpd

To resolve the 404 error in the model call log after migrating and installing the plug-in in Dify version 1.0.0 on a self-hosted Docker setup, you should:

  1. Upgrade the Gemini Plugin: Ensure that the Gemini plugin is updated to its latest version. Check for updates in the plugin interface and click the update button if a new version is available.

  2. Modify Nginx Configuration: Update the Nginx configuration to ensure correct routing. Add the following configuration to the dify/docker/nginx/conf.d/default.conf.template file:

    # Add specific location block for /explore path
    location /explore {
        proxy_pass http://web:3000;
        include proxy.conf;
    }
    
    location ^~ /e/ {
        proxy_pass http://plugin_daemon:5002;
        include proxy.conf;
    }
    

This configuration helps route '/explore' requests to the web service, which should resolve the 404 error [1][2].

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 Mar 06 '25 06:03 dosubot[bot]

Yes I have all of these configurations in dify/docker/nginx/conf.d/default.conf.template: location /v1 { proxy_pass http://api:5001; include proxy.conf; }

location /files {
  proxy_pass http://api:5001;
  include proxy.conf;
}

location /explore {
  proxy_pass http://web:3000;
  include proxy.conf;
}

location /e/ {
  proxy_pass http://plugin_daemon:5002;
  proxy_set_header Dify-Hook-Url $scheme://$host$request_uri;
  include proxy.conf;
}

location / {
  proxy_pass http://web:3000;
  include proxy.conf;

But there are also errors

auxpd avatar Mar 09 '25 02:03 auxpd

At the moment, it seems that the Anthropic series model has this problem

auxpd avatar Mar 09 '25 07:03 auxpd

I have same issues now.

skikkh avatar Mar 23 '25 17:03 skikkh

1.try logout and login again 2.I fixed the issue by commenting out the get_llm_num_tokens section of the Anthropic plugin's code. It seems the problem was caused by the third-party API I'm using not properly integrating with Anthropic's get_llm_num_tokens API.

bikeread avatar Mar 25 '25 16:03 bikeread

Hi, @auxpd. I'm Dosu, and I'm helping the Dify team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • A 404 error occurred in the model call log after upgrading to version 1.0.0 and installing a plugin.
  • You confirmed that the suggested configurations were already in place and noted the issue was specific to the Anthropic series model.
  • @bikeread resolved the issue by commenting out a section of the Anthropic plugin's code related to the get_llm_num_tokens API.

Next Steps:

  • Please let us know if this issue is still relevant to the latest version of the Dify repository by commenting on this issue.
  • If there is no further activity, this issue will be automatically closed in 15 days.

Thank you for your understanding and contribution!

dosubot[bot] avatar Apr 25 '25 16:04 dosubot[bot]