Merge 769c23a882
into a30945312a
This commit is contained in:
commit
be3fd4fb4f
@ -2,6 +2,7 @@ import json
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from collections.abc import Generator, Mapping, Sequence
|
from collections.abc import Generator, Mapping, Sequence
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
from configs import dify_config
|
||||||
|
|
||||||
from core.agent.base_agent_runner import BaseAgentRunner
|
from core.agent.base_agent_runner import BaseAgentRunner
|
||||||
from core.agent.entities import AgentScratchpadUnit
|
from core.agent.entities import AgentScratchpadUnit
|
||||||
@ -63,7 +64,7 @@ class CotAgentRunner(BaseAgentRunner, ABC):
|
|||||||
self._instruction = self._fill_in_inputs_from_external_data_tools(instruction, inputs)
|
self._instruction = self._fill_in_inputs_from_external_data_tools(instruction, inputs)
|
||||||
|
|
||||||
iteration_step = 1
|
iteration_step = 1
|
||||||
max_iteration_steps = min(app_config.agent.max_iteration if app_config.agent else 5, 5) + 1
|
max_iteration_steps = min(app_config.agent.max_iteration if app_config.agent else dify_config.AGENT_SETTING_MAX_ITERATION, dify_config.AGENT_SETTING_MAX_ITERATION) + 1
|
||||||
|
|
||||||
# convert tools into ModelRuntime Tool format
|
# convert tools into ModelRuntime Tool format
|
||||||
tool_instances, prompt_messages_tools = self._init_prompt_tools()
|
tool_instances, prompt_messages_tools = self._init_prompt_tools()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
from configs import dify_config
|
||||||
from enum import StrEnum
|
from enum import StrEnum
|
||||||
from typing import Any, Optional, Union
|
from typing import Any, Optional, Union
|
||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
from core.tools.entities.tool_entities import ToolInvokeMessage, ToolProviderType
|
from core.tools.entities.tool_entities import ToolInvokeMessage, ToolProviderType
|
||||||
@ -82,7 +82,7 @@ class AgentEntity(BaseModel):
|
|||||||
strategy: Strategy
|
strategy: Strategy
|
||||||
prompt: Optional[AgentPromptEntity] = None
|
prompt: Optional[AgentPromptEntity] = None
|
||||||
tools: Optional[list[AgentToolEntity]] = None
|
tools: Optional[list[AgentToolEntity]] = None
|
||||||
max_iteration: int = 5
|
max_iteration: int = dify_config.AGENT_SETTING_MAX_ITERATION
|
||||||
|
|
||||||
|
|
||||||
class AgentInvokeMessage(ToolInvokeMessage):
|
class AgentInvokeMessage(ToolInvokeMessage):
|
||||||
|
@ -3,6 +3,7 @@ import logging
|
|||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from typing import Any, Optional, Union
|
from typing import Any, Optional, Union
|
||||||
|
from configs import dify_config
|
||||||
|
|
||||||
from core.agent.base_agent_runner import BaseAgentRunner
|
from core.agent.base_agent_runner import BaseAgentRunner
|
||||||
from core.app.apps.base_app_queue_manager import PublishFrom
|
from core.app.apps.base_app_queue_manager import PublishFrom
|
||||||
@ -49,7 +50,7 @@ class FunctionCallAgentRunner(BaseAgentRunner):
|
|||||||
assert app_config.agent
|
assert app_config.agent
|
||||||
|
|
||||||
iteration_step = 1
|
iteration_step = 1
|
||||||
max_iteration_steps = min(app_config.agent.max_iteration, 5) + 1
|
max_iteration_steps = min(app_config.agent.max_iteration, dify_config.AGENT_SETTING_MAX_ITERATION) + 1
|
||||||
|
|
||||||
# continue to run until there is not any tool call
|
# continue to run until there is not any tool call
|
||||||
function_call_state = True
|
function_call_state = True
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
from configs import dify_config
|
||||||
|
|
||||||
from core.agent.entities import AgentEntity, AgentPromptEntity, AgentToolEntity
|
from core.agent.entities import AgentEntity, AgentPromptEntity, AgentToolEntity
|
||||||
from core.agent.prompt.template import REACT_PROMPT_TEMPLATES
|
from core.agent.prompt.template import REACT_PROMPT_TEMPLATES
|
||||||
@ -75,7 +76,7 @@ class AgentConfigManager:
|
|||||||
strategy=strategy,
|
strategy=strategy,
|
||||||
prompt=agent_prompt_entity,
|
prompt=agent_prompt_entity,
|
||||||
tools=agent_tools,
|
tools=agent_tools,
|
||||||
max_iteration=agent_dict.get("max_iteration", 5),
|
max_iteration=agent_dict.get("max_iteration", dify_config.AGENT_SETTING_MAX_ITERATION),
|
||||||
)
|
)
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
@ -21,7 +21,7 @@ type Props = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const maxIterationsMin = 1
|
const maxIterationsMin = 1
|
||||||
const maxIterationsMax = 5
|
const maxIterationsMax = process.env.AGENT_SETTING_MAX_ITERATION
|
||||||
|
|
||||||
const AgentSetting: FC<Props> = ({
|
const AgentSetting: FC<Props> = ({
|
||||||
isChatModel,
|
isChatModel,
|
||||||
|
@ -173,7 +173,7 @@ export const MAX_TOOLS_NUM = maxToolsNum
|
|||||||
|
|
||||||
export const DEFAULT_AGENT_SETTING = {
|
export const DEFAULT_AGENT_SETTING = {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
max_iteration: 5,
|
max_iteration: process.env.AGENT_SETTING_MAX_ITERATION || 5,
|
||||||
strategy: AgentStrategy.functionCall,
|
strategy: AgentStrategy.functionCall,
|
||||||
tools: [],
|
tools: [],
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user