agent functioncall got PluginInvokeError about : Input should be a valid dictionary or instance of AIModelEntity
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
1、Register custom tools
openapi: 3.0.0
info:
title: API服务
description: API 接口
version: 1.0.0
servers:
- url: http://10.9.9.9:8000
description: 本地开发服务器
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
schemas:
CustomerBase:
type: object
properties:
customer_id:
type: string
name:
type: string
email:
type: string
phone:
type: string
CustomerDetail:
allOf:
- $ref: '#/components/schemas/CustomerBase'
- type: object
properties:
purchase_history:
type: array
items:
type: object
properties:
date:
type: string
format: date
product:
type: string
amount:
type: number
preferences:
type: object
properties:
favorite_category:
type: string
Error:
type: object
properties:
detail:
type: string
paths:
/customers:
get:
summary: 获取客户列表
operationId: listCustomers
tags:
- customers
security:
- BearerAuth: []
responses:
'200':
description: 成功获取客户列表
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/CustomerBase'
'401':
description: 未授权访问
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/customers/{customer_id}:
get:
summary: 获取客户详细信息
operationId: getCustomerDetail
tags:
- customers
security:
- BearerAuth: []
parameters:
- name: customer_id
in: path
required: true
schema:
type: string
responses:
'200':
description: 成功获取客户详细信息
content:
application/json:
schema:
$ref: '#/components/schemas/CustomerDetail'
'404':
description: 客户未找到
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
2、Add an agent node, and the strategy is Functioncall
3、The agent encounters an execution error.
Run failed: Failed to transform agent message: PluginInvokeError: {"args":{},"error_type":"ValidationError","message":"1 validation error for FunctionCallingParams\nmodel.entity\n Input should be a valid dictionary or instance of AIModelEntity [type=model_type, input_value=None, input_type=NoneType]\n For further information visit [https://errors.pydantic.dev/2.8/v/model_type"}](https://errors.pydantic.dev/2.8/v/model_type%22%7D)
model input:
{
"model": {
"provider": "langgenius/xinference/xinference",
"model": "qwen2.5-32B-instruct",
"model_type": "llm",
"mode": "chat",
"completion_params": {},
"type": "model-selector"
},
"tools": [
{
"provider_name": "45481b09-60bb-4892-a4b5-36b642c9bc9a",
"type": "api",
"tool_name": "listCustomers",
"tool_label": "listCustomers",
"settings": {},
"parameters": {},
"enabled": true,
"extra": {
"description": ""
}
},
{
"provider_name": "45481b09-60bb-4892-a4b5-36b642c9bc9a",
"type": "api",
"tool_name": "getCustomerDetail",
"tool_label": "getCustomerDetail",
"settings": {},
"parameters": {
"customer_id": null
},
"enabled": true,
"extra": {
"description": ""
}
},
{
"provider_name": "45481b09-60bb-4892-a4b5-36b642c9bc9a",
"type": "api",
"tool_name": "getCustomerPreferences",
"tool_label": "getCustomerPreferences",
"settings": {},
"parameters": {
"customer_id": null
},
"enabled": true,
"extra": {
"description": ""
}
}
],
"instruction": "尝试使用工具列表中的工具,解决用户问题",
"query": "查询张三的信息"
}
✔️ Expected Behavior
No response
❌ Actual Behavior
No response
The PluginInvokeError you're encountering during the agent function call in Dify can be caused by several issues. Here are some common causes and potential solutions:
-
InvokeRateLimitError: Ensure that you are not exceeding the rate limits set for the plugin. Check if there are any rate limit configurations that need adjustment.
-
InvokeAuthorizationError: Verify that the authorization credentials (e.g., API keys, tokens) are correctly configured and valid. Ensure that the BearerAuth scheme is properly set up in your OpenAPI specification.
-
InvokeBadRequestError: Double-check the request parameters being sent to the plugin. Ensure that they match the expected schema and data types defined in your OpenAPI specification.
-
InvokeConnectionError: Confirm that the server URL specified in your OpenAPI specification is correct and that the server is reachable. Check for any network issues that might be causing connection problems.
-
InvokeServerUnavailableError: Ensure that the server hosting the API is up and running. Check server logs for any issues that might be causing it to be unavailable.
-
CredentialsValidateFailedError: Make sure that the credentials used for authentication are correct and have the necessary permissions to access the API.
These errors are typically handled in the _handle_plugin_daemon_error function in the api/core/plugin/manager/base.py file of the Dify codebase [1].
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
+1
@crazywoola @zxhlyh Do you have any suggestions?
I just upgraded dify to v1.0.1, but this issue still hasn't been resolved.
Run failed: Failed to transform agent message: PluginInvokeError: {"args":{},"error_type":"ValidationError","message":"1 validation error for FunctionCallingParams\nmodel.entity\n Input should be a valid dictionary or instance of AIModelEntity [type=model_type, input_value=None, input_type=NoneType]\n For further information visit https://errors.pydantic.dev/2.8/v/model_type"}
I just upgraded dify to v1.0.1, but this issue still hasn't been resolved.
Run failed: Failed to transform agent message: PluginInvokeError: {"args":{},"error_type":"ValidationError","message":"1 validation error for FunctionCallingParams\nmodel.entity\n Input should be a valid dictionary or instance of AIModelEntity [type=model_type, input_value=None, input_type=NoneType]\n For further information visit https://errors.pydantic.dev/2.8/v/model_type"}
same error
same error +1
Any model launched by Xinference will report this issue. Most online models work fine. It has been troubling for a very long time.
+1
After debugging, it was determined that the error requires modifying the dependency code within the plugin.
Modify the __init__.py file in the directory volumes/plugin_daemon/cwd/langgenius/agent-0.0.9@f16916b704a20067317dbe9030f62aa28f0832021a3ef6d4ce699504074c5e13/.venv/lib64/python3.12/site-packages/dify_plugin/interfaces/agent, and set the default value of entity in the AgentModelConfig class to None.
Before modification:
class AgentModelConfig(LLMModelConfig):
entity: AIModelEntity
After modification:
class AgentModelConfig(LLMModelConfig):
entity: Optional[AIModelEntity] = Field(default=None)
To restart the docker-plugin_daemon-1 container after modifying the code, you can use the following command:
docker restart docker-plugin_daemon-1
Verification result:
Thanks for @HamaWhiteGG For Xinference, Also need to modify: /app/storage/cwd/langgenius/xinference-0.0.2@04dee9c8396689421df7537f73ebb4b26efbcb7e0b9c32b7f09236e84bb97b3c/models/llm/llm.py
1、Do not use: helper.dump_model
2、Enable stream function call