Merge 769c23a882
into a30945312a
This commit is contained in:
commit
be3fd4fb4f
@ -2,6 +2,7 @@ import json
|
||||
from abc import ABC, abstractmethod
|
||||
from collections.abc import Generator, Mapping, Sequence
|
||||
from typing import Any, Optional
|
||||
from configs import dify_config
|
||||
|
||||
from core.agent.base_agent_runner import BaseAgentRunner
|
||||
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)
|
||||
|
||||
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
|
||||
tool_instances, prompt_messages_tools = self._init_prompt_tools()
|
||||
|
@ -1,6 +1,6 @@
|
||||
from configs import dify_config
|
||||
from enum import StrEnum
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from core.tools.entities.tool_entities import ToolInvokeMessage, ToolProviderType
|
||||
@ -82,7 +82,7 @@ class AgentEntity(BaseModel):
|
||||
strategy: Strategy
|
||||
prompt: Optional[AgentPromptEntity] = None
|
||||
tools: Optional[list[AgentToolEntity]] = None
|
||||
max_iteration: int = 5
|
||||
max_iteration: int = dify_config.AGENT_SETTING_MAX_ITERATION
|
||||
|
||||
|
||||
class AgentInvokeMessage(ToolInvokeMessage):
|
||||
|
@ -3,6 +3,7 @@ import logging
|
||||
from collections.abc import Generator
|
||||
from copy import deepcopy
|
||||
from typing import Any, Optional, Union
|
||||
from configs import dify_config
|
||||
|
||||
from core.agent.base_agent_runner import BaseAgentRunner
|
||||
from core.app.apps.base_app_queue_manager import PublishFrom
|
||||
@ -49,7 +50,7 @@ class FunctionCallAgentRunner(BaseAgentRunner):
|
||||
assert app_config.agent
|
||||
|
||||
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
|
||||
function_call_state = True
|
||||
|
@ -1,4 +1,5 @@
|
||||
from typing import Optional
|
||||
from configs import dify_config
|
||||
|
||||
from core.agent.entities import AgentEntity, AgentPromptEntity, AgentToolEntity
|
||||
from core.agent.prompt.template import REACT_PROMPT_TEMPLATES
|
||||
@ -75,7 +76,7 @@ class AgentConfigManager:
|
||||
strategy=strategy,
|
||||
prompt=agent_prompt_entity,
|
||||
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
|
||||
|
@ -21,7 +21,7 @@ type Props = {
|
||||
}
|
||||
|
||||
const maxIterationsMin = 1
|
||||
const maxIterationsMax = 5
|
||||
const maxIterationsMax = process.env.AGENT_SETTING_MAX_ITERATION
|
||||
|
||||
const AgentSetting: FC<Props> = ({
|
||||
isChatModel,
|
||||
|
@ -173,7 +173,7 @@ export const MAX_TOOLS_NUM = maxToolsNum
|
||||
|
||||
export const DEFAULT_AGENT_SETTING = {
|
||||
enabled: false,
|
||||
max_iteration: 5,
|
||||
max_iteration: process.env.AGENT_SETTING_MAX_ITERATION || 5,
|
||||
strategy: AgentStrategy.functionCall,
|
||||
tools: [],
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user