mirror of https://github.com/langgenius/dify.git
fix: tool
This commit is contained in:
parent
dc53362506
commit
ede65eca4d
|
|
@ -3,7 +3,6 @@ from typing import Literal, Optional, Union
|
|||
from pydantic import BaseModel, validator
|
||||
|
||||
from core.workflow.entities.base_node_data_entities import BaseNodeData
|
||||
from core.workflow.entities.variable_entities import VariableSelector
|
||||
|
||||
ToolParameterValue = Union[str, int, float, bool]
|
||||
|
||||
|
|
@ -16,8 +15,10 @@ class ToolEntity(BaseModel):
|
|||
tool_configurations: dict[str, ToolParameterValue]
|
||||
|
||||
class ToolNodeData(BaseNodeData, ToolEntity):
|
||||
class ToolInput(VariableSelector):
|
||||
class ToolInput(BaseModel):
|
||||
variable: str
|
||||
variable_type: Literal['selector', 'static']
|
||||
value_selector: Optional[list[str]]
|
||||
value: Optional[str]
|
||||
|
||||
@validator('value')
|
||||
|
|
@ -25,6 +26,12 @@ class ToolNodeData(BaseNodeData, ToolEntity):
|
|||
if values['variable_type'] == 'static' and value is None:
|
||||
raise ValueError('value is required for static variable')
|
||||
return value
|
||||
|
||||
@validator('value_selector')
|
||||
def check_value_selector(cls, value_selector, values, **kwargs):
|
||||
if values['variable_type'] == 'selector' and value_selector is None:
|
||||
raise ValueError('value_selector is required for selector variable')
|
||||
return value_selector
|
||||
|
||||
"""
|
||||
Tool Node Schema
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class ToolNode(BaseNode):
|
|||
return NodeRunResult(
|
||||
status=WorkflowNodeExecutionStatus.FAILED,
|
||||
inputs=parameters,
|
||||
error=f'Failed to invoke tool: {str(e)}'
|
||||
error=f'Failed to invoke tool: {str(e)}',
|
||||
)
|
||||
|
||||
# convert tool messages
|
||||
|
|
@ -56,6 +56,7 @@ class ToolNode(BaseNode):
|
|||
'text': plain_text,
|
||||
'files': files
|
||||
},
|
||||
inputs=parameters
|
||||
)
|
||||
|
||||
def _generate_parameters(self, variable_pool: VariablePool, node_data: ToolNodeData) -> dict:
|
||||
|
|
|
|||
Loading…
Reference in New Issue