Closed HuMian10 closed 2 hours ago
@HuMian10 Hello there! 👋 I'm here to help you with bug fixes, answer questions, and guide you on how to contribute. Let's tackle this issue together!
To resolve the error "Tool.fork_tool_runtime() got an unexpected keyword argument 'meta'" in Dify version 0.8.2, you need to modify the _validate_credentials
method in the GoogleProvider
class. The fork_tool_runtime
method does not accept a meta
keyword argument. Instead, you should pass the credentials within a runtime
dictionary to the fork_tool_runtime
method.
Here is the corrected code:
from core.tools.entities.tool_entities import ToolInvokeMessage, ToolProviderType
from core.tools.tool.tool import Tool
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
from core.tools.errors import ToolProviderCredentialValidationError
from core.tools.provider.builtin.google.tools.google_search import GoogleSearchTool
from typing import Any, Dict
class GoogleProvider(BuiltinToolProviderController):
def _validate_credentials(self, credentials: Dict[str, Any]) -> None:
try:
# 1. Here you need to instantiate a GoogleSearchTool with GoogleSearchTool(), it will automatically load the yaml configuration of GoogleSearchTool, but at this time it does not have credential information inside
# 2. Then you need to use the fork_tool_runtime method to pass the current credential information to GoogleSearchTool
# 3. Finally, invoke it, the parameters need to be passed according to the parameter rules configured in the yaml of GoogleSearchTool
GoogleSearchTool().fork_tool_runtime(
runtime={
"credentials": credentials,
}
).invoke(
user_id='',
tool_parameters={
"query": "test",
"result_type": "link"
},
)
except Exception as e:
raise ToolProviderCredentialValidationError(str(e))
This change should resolve the error by correctly passing the credentials within a runtime
dictionary to the fork_tool_runtime
method [1][2].
To continue talking to Dosu, mention @dosu.
Self Checks
Dify version
0.8.2
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
After defining a Google search tool using the official docs "Quick Tool Intergration", it is not possible to save API parameters
✔️ Expected Behavior
Provide some modification suggestions
❌ Actual Behavior
No response