|
@@ -39,6 +39,7 @@ from core.tools.entities.tool_entities import (
|
|
from core.tools.tool.dataset_retriever_tool import DatasetRetrieverTool
|
|
from core.tools.tool.dataset_retriever_tool import DatasetRetrieverTool
|
|
from core.tools.tool.tool import Tool
|
|
from core.tools.tool.tool import Tool
|
|
from core.tools.tool_manager import ToolManager
|
|
from core.tools.tool_manager import ToolManager
|
|
|
|
+from core.tools.utils.tool_parameter_converter import ToolParameterConverter
|
|
from extensions.ext_database import db
|
|
from extensions.ext_database import db
|
|
from models.model import Conversation, Message, MessageAgentThought
|
|
from models.model import Conversation, Message, MessageAgentThought
|
|
from models.tools import ToolConversationVariables
|
|
from models.tools import ToolConversationVariables
|
|
@@ -186,21 +187,11 @@ class BaseAgentRunner(AppRunner):
|
|
if parameter.form != ToolParameter.ToolParameterForm.LLM:
|
|
if parameter.form != ToolParameter.ToolParameterForm.LLM:
|
|
continue
|
|
continue
|
|
|
|
|
|
- parameter_type = 'string'
|
|
+ parameter_type = ToolParameterConverter.get_parameter_type(parameter.type)
|
|
enum = []
|
|
enum = []
|
|
- if parameter.type == ToolParameter.ToolParameterType.STRING:
|
|
+ if parameter.type == ToolParameter.ToolParameterType.SELECT:
|
|
- parameter_type = 'string'
|
|
+ enum = [option.value for option in parameter.options]
|
|
- elif parameter.type == ToolParameter.ToolParameterType.BOOLEAN:
|
|
+
|
|
- parameter_type = 'boolean'
|
|
|
|
- elif parameter.type == ToolParameter.ToolParameterType.NUMBER:
|
|
|
|
- parameter_type = 'number'
|
|
|
|
- elif parameter.type == ToolParameter.ToolParameterType.SELECT:
|
|
|
|
- for option in parameter.options:
|
|
|
|
- enum.append(option.value)
|
|
|
|
- parameter_type = 'string'
|
|
|
|
- else:
|
|
|
|
- raise ValueError(f"parameter type {parameter.type} is not supported")
|
|
|
|
-
|
|
|
|
message_tool.parameters['properties'][parameter.name] = {
|
|
message_tool.parameters['properties'][parameter.name] = {
|
|
"type": parameter_type,
|
|
"type": parameter_type,
|
|
"description": parameter.llm_description or '',
|
|
"description": parameter.llm_description or '',
|
|
@@ -281,20 +272,10 @@ class BaseAgentRunner(AppRunner):
|
|
if parameter.form != ToolParameter.ToolParameterForm.LLM:
|
|
if parameter.form != ToolParameter.ToolParameterForm.LLM:
|
|
continue
|
|
continue
|
|
|
|
|
|
- parameter_type = 'string'
|
|
+ parameter_type = ToolParameterConverter.get_parameter_type(parameter.type)
|
|
enum = []
|
|
enum = []
|
|
- if parameter.type == ToolParameter.ToolParameterType.STRING:
|
|
+ if parameter.type == ToolParameter.ToolParameterType.SELECT:
|
|
- parameter_type = 'string'
|
|
+ enum = [option.value for option in parameter.options]
|
|
- elif parameter.type == ToolParameter.ToolParameterType.BOOLEAN:
|
|
|
|
- parameter_type = 'boolean'
|
|
|
|
- elif parameter.type == ToolParameter.ToolParameterType.NUMBER:
|
|
|
|
- parameter_type = 'number'
|
|
|
|
- elif parameter.type == ToolParameter.ToolParameterType.SELECT:
|
|
|
|
- for option in parameter.options:
|
|
|
|
- enum.append(option.value)
|
|
|
|
- parameter_type = 'string'
|
|
|
|
- else:
|
|
|
|
- raise ValueError(f"parameter type {parameter.type} is not supported")
|
|
|
|
|
|
|
|
prompt_tool.parameters['properties'][parameter.name] = {
|
|
prompt_tool.parameters['properties'][parameter.name] = {
|
|
"type": parameter_type,
|
|
"type": parameter_type,
|