OpenAI gpt-4.1 error #29

Open
opened 2026-02-22 17:16:17 -05:00 by yindo · 1 comment
Owner

Originally created by @throrio on GitHub (Apr 15, 2025).

Dify 1.2
Plugin OpenAI Model 0.0.18

All is correct with gpt-4o in chatbot
When i try to use 4.1 in same chatbot, i always cathed error:

2025-04-15 20:19:28,703.703 ERROR [Thread-267 (_generate_worker)] [app_generator.py:246] - Unknown Error when generating

Traceback (most recent call last):

File "/app/api/core/app/apps/chat/app_generator.py", line 226, in _generate_worker

runner.run(

File "/app/api/core/app/apps/chat/app_runner.py", line 69, in run

self.get_pre_calculate_rest_tokens(

File "/app/api/core/app/apps/base_app_runner.py", line 90, 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":"NotImplementedError","message":"get_num_tokens_from_messages() is not presently implemented for model cl100k_base.See https://platform.openai.com/docs/advanced-usage/managing-tokens for for information on how messages are converted to tokens."}

2025-04-15 20:19:28,735.735 ERROR [Dummy-268] [base_app_generate_response_converter.py:123] - {"args":{},"error_type":"NotImplementedError","message":"get_num_tokens_from_messages() is not presently implemented for model cl100k_base.See https://platform.openai.com/docs/advanced-usage/managing-tokens for for information on how messages are converted to tokens."}

Originally created by @throrio on GitHub (Apr 15, 2025). Dify 1.2 Plugin OpenAI Model 0.0.18 All is correct with gpt-4o in chatbot When i try to use 4.1 in same chatbot, i always cathed error: 2025-04-15 20:19:28,703.703 ERROR [Thread-267 (_generate_worker)] [app_generator.py:246] - Unknown Error when generating Traceback (most recent call last): File "/app/api/core/app/apps/chat/app_generator.py", line 226, in _generate_worker runner.run( File "/app/api/core/app/apps/chat/app_runner.py", line 69, in run self.get_pre_calculate_rest_tokens( File "/app/api/core/app/apps/base_app_runner.py", line 90, 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":"NotImplementedError","message":"get_num_tokens_from_messages() is not presently implemented for model cl100k_base.See https://platform.openai.com/docs/advanced-usage/managing-tokens for for information on how messages are converted to tokens."} 2025-04-15 20:19:28,735.735 ERROR [Dummy-268] [base_app_generate_response_converter.py:123] - {"args":{},"error_type":"NotImplementedError","message":"get_num_tokens_from_messages() is not presently implemented for model cl100k_base.See https://platform.openai.com/docs/advanced-usage/managing-tokens for for information on how messages are converted to tokens."}
Author
Owner

@kurokobo commented on GitHub (Apr 15, 2025):

Duplicated: https://github.com/langgenius/dify-official-plugins/issues/721

@kurokobo commented on GitHub (Apr 15, 2025): Duplicated: https://github.com/langgenius/dify-official-plugins/issues/721
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-plugins#29