pygpt-net 2.6.0.post2__py3-none-any.whl → 2.6.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pygpt_net/CHANGELOG.txt +8 -0
- pygpt_net/__init__.py +3 -3
- pygpt_net/app.py +27 -9
- pygpt_net/controller/chat/response.py +10 -4
- pygpt_net/controller/chat/stream.py +40 -2
- pygpt_net/controller/model/editor.py +45 -4
- pygpt_net/controller/plugins/plugins.py +25 -0
- pygpt_net/controller/presets/editor.py +100 -100
- pygpt_net/controller/presets/experts.py +20 -1
- pygpt_net/controller/presets/presets.py +5 -4
- pygpt_net/controller/ui/mode.py +17 -66
- pygpt_net/core/agents/provider.py +2 -1
- pygpt_net/core/agents/runner.py +123 -9
- pygpt_net/core/agents/runners/helpers.py +3 -2
- pygpt_net/core/agents/runners/llama_workflow.py +176 -22
- pygpt_net/core/agents/runners/loop.py +22 -13
- pygpt_net/core/experts/experts.py +19 -25
- pygpt_net/core/idx/chat.py +24 -34
- pygpt_net/core/idx/response.py +5 -2
- pygpt_net/core/locale/locale.py +73 -45
- pygpt_net/core/render/web/body.py +152 -207
- pygpt_net/core/render/web/renderer.py +4 -2
- pygpt_net/data/config/config.json +3 -3
- pygpt_net/data/config/models.json +3 -3
- pygpt_net/data/locale/locale.de.ini +12 -8
- pygpt_net/data/locale/locale.en.ini +12 -8
- pygpt_net/data/locale/locale.es.ini +12 -8
- pygpt_net/data/locale/locale.fr.ini +12 -8
- pygpt_net/data/locale/locale.it.ini +12 -8
- pygpt_net/data/locale/locale.pl.ini +12 -8
- pygpt_net/data/locale/locale.uk.ini +12 -8
- pygpt_net/data/locale/locale.zh.ini +12 -8
- pygpt_net/item/ctx.py +2 -1
- pygpt_net/plugin/base/plugin.py +35 -3
- pygpt_net/plugin/bitbucket/__init__.py +12 -0
- pygpt_net/plugin/bitbucket/config.py +267 -0
- pygpt_net/plugin/bitbucket/plugin.py +125 -0
- pygpt_net/plugin/bitbucket/worker.py +569 -0
- pygpt_net/plugin/cmd_files/worker.py +19 -16
- pygpt_net/plugin/facebook/__init__.py +12 -0
- pygpt_net/plugin/facebook/config.py +359 -0
- pygpt_net/plugin/facebook/plugin.py +114 -0
- pygpt_net/plugin/facebook/worker.py +698 -0
- pygpt_net/plugin/github/__init__.py +12 -0
- pygpt_net/plugin/github/config.py +441 -0
- pygpt_net/plugin/github/plugin.py +124 -0
- pygpt_net/plugin/github/worker.py +674 -0
- pygpt_net/plugin/google/__init__.py +12 -0
- pygpt_net/plugin/google/config.py +367 -0
- pygpt_net/plugin/google/plugin.py +126 -0
- pygpt_net/plugin/google/worker.py +826 -0
- pygpt_net/plugin/slack/__init__.py +12 -0
- pygpt_net/plugin/slack/config.py +349 -0
- pygpt_net/plugin/slack/plugin.py +116 -0
- pygpt_net/plugin/slack/worker.py +639 -0
- pygpt_net/plugin/telegram/__init__.py +12 -0
- pygpt_net/plugin/telegram/config.py +308 -0
- pygpt_net/plugin/telegram/plugin.py +118 -0
- pygpt_net/plugin/telegram/worker.py +563 -0
- pygpt_net/plugin/twitter/__init__.py +12 -0
- pygpt_net/plugin/twitter/config.py +491 -0
- pygpt_net/plugin/twitter/plugin.py +126 -0
- pygpt_net/plugin/twitter/worker.py +837 -0
- pygpt_net/provider/agents/base.py +4 -1
- pygpt_net/provider/agents/llama_index/codeact_workflow.py +95 -0
- pygpt_net/provider/agents/llama_index/legacy/__init__.py +0 -0
- pygpt_net/provider/agents/llama_index/{openai.py → legacy/openai.py} +2 -2
- pygpt_net/provider/agents/llama_index/{openai_assistant.py → legacy/openai_assistant.py} +37 -5
- pygpt_net/provider/agents/llama_index/{planner.py → legacy/planner.py} +3 -3
- pygpt_net/provider/agents/llama_index/{react.py → legacy/react.py} +3 -3
- pygpt_net/provider/agents/llama_index/openai_workflow.py +52 -0
- pygpt_net/provider/agents/llama_index/planner_workflow.py +115 -0
- pygpt_net/provider/agents/llama_index/react_workflow.py +6 -4
- pygpt_net/provider/agents/llama_index/workflow/__init__.py +0 -0
- pygpt_net/provider/agents/llama_index/{codeact_agent_custom.py → workflow/codeact.py} +124 -8
- pygpt_net/provider/agents/llama_index/workflow/events.py +24 -0
- pygpt_net/provider/agents/llama_index/workflow/openai.py +634 -0
- pygpt_net/provider/agents/llama_index/workflow/planner.py +601 -0
- pygpt_net/provider/agents/openai/agent.py +1 -0
- pygpt_net/provider/agents/openai/agent_b2b.py +2 -0
- pygpt_net/provider/agents/openai/agent_planner.py +1 -0
- pygpt_net/provider/agents/openai/agent_with_experts.py +1 -0
- pygpt_net/provider/agents/openai/agent_with_experts_feedback.py +1 -0
- pygpt_net/provider/agents/openai/agent_with_feedback.py +1 -0
- pygpt_net/provider/agents/openai/evolve.py +1 -0
- pygpt_net/provider/core/preset/patch.py +11 -17
- pygpt_net/ui/base/config_dialog.py +4 -0
- pygpt_net/ui/dialog/preset.py +34 -77
- pygpt_net/ui/layout/toolbox/presets.py +2 -2
- pygpt_net/ui/main.py +3 -1
- pygpt_net/ui/widget/lists/experts.py +3 -2
- {pygpt_net-2.6.0.post2.dist-info → pygpt_net-2.6.2.dist-info}/METADATA +155 -4
- {pygpt_net-2.6.0.post2.dist-info → pygpt_net-2.6.2.dist-info}/RECORD +96 -62
- pygpt_net/data/config/presets/agent_react_workflow.json +0 -34
- pygpt_net/provider/agents/llama_index/code_act.py +0 -58
- {pygpt_net-2.6.0.post2.dist-info → pygpt_net-2.6.2.dist-info}/LICENSE +0 -0
- {pygpt_net-2.6.0.post2.dist-info → pygpt_net-2.6.2.dist-info}/WHEEL +0 -0
- {pygpt_net-2.6.0.post2.dist-info → pygpt_net-2.6.2.dist-info}/entry_points.txt +0 -0
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
|
7
7
|
# MIT License #
|
|
8
8
|
# Created By : Marcin Szczygliński #
|
|
9
|
-
# Updated Date: 2025.08.
|
|
9
|
+
# Updated Date: 2025.08.14 03:00:00 #
|
|
10
10
|
# ================================================== #
|
|
11
11
|
|
|
12
12
|
from typing import Dict, Any, Tuple
|
|
@@ -85,6 +85,9 @@ class BaseAgent:
|
|
|
85
85
|
:param key: Option key
|
|
86
86
|
:return: Option value
|
|
87
87
|
"""
|
|
88
|
+
if preset is None:
|
|
89
|
+
print("No preset provided, returning default option value")
|
|
90
|
+
return None
|
|
88
91
|
extra = preset.extra
|
|
89
92
|
if not isinstance(extra, dict) or self.id not in extra:
|
|
90
93
|
return self.get_default(section, key)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# ================================================== #
|
|
4
|
+
# This file is a part of PYGPT package #
|
|
5
|
+
# Website: https://pygpt.net #
|
|
6
|
+
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
|
7
|
+
# MIT License #
|
|
8
|
+
# Created By : Marcin Szczygliński #
|
|
9
|
+
# Updated Date: 2025.08.14 03:00:00 #
|
|
10
|
+
# ================================================== #
|
|
11
|
+
|
|
12
|
+
from typing import Dict, Any
|
|
13
|
+
|
|
14
|
+
from pygpt_net.core.bridge import BridgeContext
|
|
15
|
+
from pygpt_net.core.types import (
|
|
16
|
+
AGENT_MODE_WORKFLOW,
|
|
17
|
+
AGENT_TYPE_LLAMA,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
from .workflow.codeact import DEFAULT_CODE_ACT_PROMPT
|
|
21
|
+
from ..base import BaseAgent
|
|
22
|
+
|
|
23
|
+
class CodeActAgent(BaseAgent):
|
|
24
|
+
|
|
25
|
+
def __init__(self, *args, **kwargs):
|
|
26
|
+
super(CodeActAgent, self).__init__(*args, **kwargs)
|
|
27
|
+
self.id = "code_act"
|
|
28
|
+
self.type = AGENT_TYPE_LLAMA
|
|
29
|
+
self.mode = AGENT_MODE_WORKFLOW
|
|
30
|
+
self.name = "CodeAct"
|
|
31
|
+
|
|
32
|
+
def get_agent(self, window, kwargs: Dict[str, Any]):
|
|
33
|
+
"""
|
|
34
|
+
Return Agent provider instance
|
|
35
|
+
|
|
36
|
+
:param window: window instance
|
|
37
|
+
:param kwargs: keyword arguments
|
|
38
|
+
:return: Agent provider instance
|
|
39
|
+
"""
|
|
40
|
+
# from llama_index.core.agent.workflow import CodeActAgent as Agent
|
|
41
|
+
from .workflow.codeact import CodeActAgent as Agent # <-- custom version with tools
|
|
42
|
+
|
|
43
|
+
context = kwargs.get("context", BridgeContext())
|
|
44
|
+
tools = kwargs.get("plugin_tools", {})
|
|
45
|
+
specs = kwargs.get("plugin_specs", [])
|
|
46
|
+
retriever_tool = kwargs.get("retriever_tools", None)
|
|
47
|
+
workdir = kwargs.get("workdir", "/data")
|
|
48
|
+
llm = kwargs.get("llm", None)
|
|
49
|
+
preset = context.preset
|
|
50
|
+
system_prompt = self.get_option(preset, "additional", "prompt")
|
|
51
|
+
code_prompt = self.get_option(preset, "base", "prompt")
|
|
52
|
+
if not code_prompt:
|
|
53
|
+
code_prompt = DEFAULT_CODE_ACT_PROMPT # use default prompt if not set
|
|
54
|
+
kwargs = {
|
|
55
|
+
"code_execute_fn": window.core.agents.tools.code_execute_fn.execute,
|
|
56
|
+
"plugin_tool_fn": window.core.agents.tools.tool_exec,
|
|
57
|
+
"plugin_tools": tools,
|
|
58
|
+
"plugin_specs": specs,
|
|
59
|
+
"tool_retriever": retriever_tool,
|
|
60
|
+
"llm": llm,
|
|
61
|
+
"system_prompt": system_prompt, # additional
|
|
62
|
+
"code_act_system_prompt": code_prompt.replace("{workdir}", workdir),
|
|
63
|
+
}
|
|
64
|
+
return Agent(**kwargs)
|
|
65
|
+
|
|
66
|
+
def get_options(self) -> Dict[str, Any]:
|
|
67
|
+
"""
|
|
68
|
+
Return Agent options
|
|
69
|
+
|
|
70
|
+
:return: dict of options
|
|
71
|
+
"""
|
|
72
|
+
return {
|
|
73
|
+
"base": {
|
|
74
|
+
"label": "Base prompt",
|
|
75
|
+
"options": {
|
|
76
|
+
"prompt": {
|
|
77
|
+
"type": "textarea",
|
|
78
|
+
"label": "Prompt",
|
|
79
|
+
"description": "Code execute prompt (initial)",
|
|
80
|
+
"default": DEFAULT_CODE_ACT_PROMPT,
|
|
81
|
+
},
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"additional": {
|
|
85
|
+
"label": "Additional prompt",
|
|
86
|
+
"options": {
|
|
87
|
+
"prompt": {
|
|
88
|
+
"type": "textarea",
|
|
89
|
+
"label": "Prompt",
|
|
90
|
+
"description": "Additional prompt for agent (will be added to the base prompt)",
|
|
91
|
+
"default": "",
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
}
|
|
File without changes
|
|
@@ -16,12 +16,12 @@ from pygpt_net.core.types import (
|
|
|
16
16
|
AGENT_TYPE_LLAMA,
|
|
17
17
|
)
|
|
18
18
|
|
|
19
|
-
from
|
|
19
|
+
from ...base import BaseAgent
|
|
20
20
|
|
|
21
21
|
class OpenAIAgent(BaseAgent):
|
|
22
22
|
def __init__(self, *args, **kwargs):
|
|
23
23
|
super(OpenAIAgent, self).__init__(*args, **kwargs)
|
|
24
|
-
self.id = "
|
|
24
|
+
self.id = "openai_legacy"
|
|
25
25
|
self.type = AGENT_TYPE_LLAMA
|
|
26
26
|
self.mode = AGENT_MODE_STEP
|
|
27
27
|
self.name = "OpenAI"
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
|
7
7
|
# MIT License #
|
|
8
8
|
# Created By : Marcin Szczygliński #
|
|
9
|
-
# Updated Date: 2025.08.
|
|
9
|
+
# Updated Date: 2025.08.14 13:00:00 #
|
|
10
10
|
# ================================================== #
|
|
11
11
|
|
|
12
12
|
from typing import Dict, Any
|
|
@@ -17,7 +17,7 @@ from pygpt_net.core.types import (
|
|
|
17
17
|
)
|
|
18
18
|
from pygpt_net.core.bridge.context import BridgeContext
|
|
19
19
|
|
|
20
|
-
from
|
|
20
|
+
from ...base import BaseAgent
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
class OpenAIAssistantAgent(BaseAgent):
|
|
@@ -26,7 +26,7 @@ class OpenAIAssistantAgent(BaseAgent):
|
|
|
26
26
|
self.id = "openai_assistant"
|
|
27
27
|
self.type = AGENT_TYPE_LLAMA
|
|
28
28
|
self.mode = AGENT_MODE_ASSISTANT
|
|
29
|
-
self.name = "OpenAI Assistant"
|
|
29
|
+
self.name = "OpenAI Assistant (Legacy)"
|
|
30
30
|
|
|
31
31
|
def get_agent(self, window, kwargs: Dict[str, Any]):
|
|
32
32
|
"""
|
|
@@ -39,10 +39,11 @@ class OpenAIAssistantAgent(BaseAgent):
|
|
|
39
39
|
from llama_index.agent.openai import OpenAIAssistantAgent as Agent
|
|
40
40
|
|
|
41
41
|
context = kwargs.get("context", BridgeContext())
|
|
42
|
+
preset = context.preset
|
|
42
43
|
tools = kwargs.get("tools", [])
|
|
43
44
|
verbose = kwargs.get("verbose", False)
|
|
44
45
|
model = context.model
|
|
45
|
-
system_prompt =
|
|
46
|
+
system_prompt = self.get_option(preset, "base", "prompt")
|
|
46
47
|
ctx = context.ctx
|
|
47
48
|
thread_id = None
|
|
48
49
|
assistant_id = None
|
|
@@ -61,7 +62,7 @@ class OpenAIAssistantAgent(BaseAgent):
|
|
|
61
62
|
thread_id = ctx.meta.thread
|
|
62
63
|
|
|
63
64
|
# get assistant_id from preset
|
|
64
|
-
preset_assistant_id =
|
|
65
|
+
preset_assistant_id = self.get_option(preset, "base", "assistant_id")
|
|
65
66
|
if (preset_assistant_id is not None
|
|
66
67
|
and preset_assistant_id != ""):
|
|
67
68
|
assistant_id = preset_assistant_id # override assistant_id from ctx
|
|
@@ -82,3 +83,34 @@ class OpenAIAssistantAgent(BaseAgent):
|
|
|
82
83
|
kwargs["openai_tools"] = [{"type": "code_interpreter"}, {"type": "file_search"}]
|
|
83
84
|
kwargs["model"] = model.id
|
|
84
85
|
return Agent.from_new(**kwargs)
|
|
86
|
+
|
|
87
|
+
def get_options(self) -> Dict[str, Any]:
|
|
88
|
+
"""
|
|
89
|
+
Return Agent options
|
|
90
|
+
|
|
91
|
+
:return: dict of options
|
|
92
|
+
"""
|
|
93
|
+
return {
|
|
94
|
+
"base": {
|
|
95
|
+
"label": "Base prompt",
|
|
96
|
+
"options": {
|
|
97
|
+
"prompt": {
|
|
98
|
+
"type": "textarea",
|
|
99
|
+
"label": "Prompt",
|
|
100
|
+
"description": "Base prompt",
|
|
101
|
+
"default": "",
|
|
102
|
+
},
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"assistant": {
|
|
106
|
+
"label": "Assistant config",
|
|
107
|
+
"options": {
|
|
108
|
+
"assistant_id": {
|
|
109
|
+
"type": "text",
|
|
110
|
+
"label": "Assistant ID",
|
|
111
|
+
"description": "OpenAI Assistant ID, asst_abcd1234...",
|
|
112
|
+
"default": "",
|
|
113
|
+
},
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
}
|
|
@@ -16,15 +16,15 @@ from pygpt_net.core.types import (
|
|
|
16
16
|
AGENT_TYPE_LLAMA,
|
|
17
17
|
)
|
|
18
18
|
|
|
19
|
-
from
|
|
19
|
+
from ...base import BaseAgent
|
|
20
20
|
|
|
21
21
|
class PlannerAgent(BaseAgent):
|
|
22
22
|
def __init__(self, *args, **kwargs):
|
|
23
23
|
super(PlannerAgent, self).__init__(*args, **kwargs)
|
|
24
|
-
self.id = "
|
|
24
|
+
self.id = "planner_legacy"
|
|
25
25
|
self.type = AGENT_TYPE_LLAMA
|
|
26
26
|
self.mode = AGENT_MODE_PLAN
|
|
27
|
-
self.name = "Planner (
|
|
27
|
+
self.name = "Planner (Legacy)"
|
|
28
28
|
|
|
29
29
|
def get_agent(self, window, kwargs: Dict[str, Any]):
|
|
30
30
|
"""
|
|
@@ -19,15 +19,15 @@ from pygpt_net.core.types import (
|
|
|
19
19
|
AGENT_MODE_STEP,
|
|
20
20
|
)
|
|
21
21
|
|
|
22
|
-
from
|
|
22
|
+
from ...base import BaseAgent
|
|
23
23
|
|
|
24
24
|
class ReactAgent(BaseAgent):
|
|
25
25
|
def __init__(self, *args, **kwargs):
|
|
26
26
|
super(ReactAgent, self).__init__(*args, **kwargs)
|
|
27
|
-
self.id = "
|
|
27
|
+
self.id = "react_legacy"
|
|
28
28
|
self.type = AGENT_TYPE_LLAMA
|
|
29
29
|
self.mode = AGENT_MODE_STEP
|
|
30
|
-
self.name = "ReAct"
|
|
30
|
+
self.name = "ReAct (Legacy)"
|
|
31
31
|
|
|
32
32
|
def get_agent(self, window, kwargs: Dict[str, Any]):
|
|
33
33
|
"""
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# ================================================== #
|
|
4
|
+
# This file is a part of PYGPT package #
|
|
5
|
+
# Website: https://pygpt.net #
|
|
6
|
+
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
|
7
|
+
# MIT License #
|
|
8
|
+
# Created By : Marcin Szczygliński #
|
|
9
|
+
# Updated Date: 2025.08.14 03:00:00 #
|
|
10
|
+
# ================================================== #
|
|
11
|
+
|
|
12
|
+
from typing import Dict, Any, List
|
|
13
|
+
|
|
14
|
+
from pygpt_net.core.types import (
|
|
15
|
+
AGENT_TYPE_LLAMA,
|
|
16
|
+
AGENT_MODE_WORKFLOW,
|
|
17
|
+
)
|
|
18
|
+
from llama_index.core.llms.llm import LLM
|
|
19
|
+
from llama_index.core.tools.types import BaseTool
|
|
20
|
+
|
|
21
|
+
from ..base import BaseAgent
|
|
22
|
+
|
|
23
|
+
class OpenAIAgent(BaseAgent):
|
|
24
|
+
def __init__(self, *args, **kwargs):
|
|
25
|
+
super(OpenAIAgent, self).__init__(*args, **kwargs)
|
|
26
|
+
self.id = "openai"
|
|
27
|
+
self.type = AGENT_TYPE_LLAMA
|
|
28
|
+
self.mode = AGENT_MODE_WORKFLOW
|
|
29
|
+
self.name = "FunctionAgent" # previous name: OpenAI
|
|
30
|
+
|
|
31
|
+
def get_agent(self, window, kwargs: Dict[str, Any]):
|
|
32
|
+
"""
|
|
33
|
+
Get agent instance
|
|
34
|
+
|
|
35
|
+
:param window: Window instance
|
|
36
|
+
:param kwargs: Agent parameters
|
|
37
|
+
:return: PlannerWorkflow instance
|
|
38
|
+
"""
|
|
39
|
+
from .workflow.openai import OpenAIWorkflowAgent
|
|
40
|
+
|
|
41
|
+
tools: List[BaseTool] = kwargs.get("tools", []) or []
|
|
42
|
+
llm: LLM = kwargs.get("llm", None)
|
|
43
|
+
verbose: bool = kwargs.get("verbose", False)
|
|
44
|
+
system_prompt: str = kwargs.get("system_prompt", None)
|
|
45
|
+
max_steps: int = kwargs.get("max_steps", 12)
|
|
46
|
+
|
|
47
|
+
return OpenAIWorkflowAgent(
|
|
48
|
+
tools=tools,
|
|
49
|
+
llm=llm,
|
|
50
|
+
system_prompt=system_prompt,
|
|
51
|
+
verbose=verbose,
|
|
52
|
+
)
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# ================================================== #
|
|
4
|
+
# This file is a part of PYGPT package #
|
|
5
|
+
# Website: https://pygpt.net #
|
|
6
|
+
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
|
7
|
+
# MIT License #
|
|
8
|
+
# Created By : Marcin Szczygliński #
|
|
9
|
+
# Updated Date: 2025.08.14 03:00:00 #
|
|
10
|
+
# ================================================== #
|
|
11
|
+
|
|
12
|
+
from typing import Dict, Any, List
|
|
13
|
+
|
|
14
|
+
from pygpt_net.core.bridge import BridgeContext
|
|
15
|
+
from pygpt_net.core.types import (
|
|
16
|
+
AGENT_TYPE_LLAMA,
|
|
17
|
+
AGENT_MODE_WORKFLOW,
|
|
18
|
+
)
|
|
19
|
+
from llama_index.core.llms.llm import LLM
|
|
20
|
+
from llama_index.core.tools.types import BaseTool
|
|
21
|
+
|
|
22
|
+
from .workflow.planner import (
|
|
23
|
+
DEFAULT_INITIAL_PLAN_PROMPT,
|
|
24
|
+
DEFAULT_PLAN_REFINE_PROMPT,
|
|
25
|
+
DEFAULT_EXECUTE_PROMPT
|
|
26
|
+
)
|
|
27
|
+
from ..base import BaseAgent
|
|
28
|
+
|
|
29
|
+
class PlannerAgent(BaseAgent):
|
|
30
|
+
def __init__(self, *args, **kwargs):
|
|
31
|
+
super(PlannerAgent, self).__init__(*args, **kwargs)
|
|
32
|
+
self.id = "planner"
|
|
33
|
+
self.type = AGENT_TYPE_LLAMA
|
|
34
|
+
self.mode = AGENT_MODE_WORKFLOW
|
|
35
|
+
self.name = "Planner"
|
|
36
|
+
|
|
37
|
+
def get_agent(self, window, kwargs: Dict[str, Any]):
|
|
38
|
+
"""
|
|
39
|
+
Get agent instance
|
|
40
|
+
|
|
41
|
+
:param window: Window instance
|
|
42
|
+
:param kwargs: Agent parameters
|
|
43
|
+
:return: PlannerWorkflow instance
|
|
44
|
+
"""
|
|
45
|
+
from .workflow.planner import PlannerWorkflow
|
|
46
|
+
|
|
47
|
+
context = kwargs.get("context", BridgeContext())
|
|
48
|
+
preset = context.preset
|
|
49
|
+
tools: List[BaseTool] = kwargs.get("tools", []) or []
|
|
50
|
+
llm: LLM = kwargs.get("llm", None)
|
|
51
|
+
verbose: bool = kwargs.get("verbose", False)
|
|
52
|
+
max_steps: int = kwargs.get("max_steps", 12)
|
|
53
|
+
|
|
54
|
+
# get prompts from options or use defaults
|
|
55
|
+
prompt_step = self.get_option(preset, "step", "prompt")
|
|
56
|
+
prompt_plan_initial = self.get_option(preset, "plan", "prompt")
|
|
57
|
+
prompt_plan_refine = self.get_option(preset, "plan_refine", "prompt")
|
|
58
|
+
if not prompt_step:
|
|
59
|
+
prompt_step = DEFAULT_EXECUTE_PROMPT
|
|
60
|
+
if not prompt_plan_initial:
|
|
61
|
+
prompt_plan_initial = DEFAULT_INITIAL_PLAN_PROMPT
|
|
62
|
+
if not prompt_plan_refine:
|
|
63
|
+
prompt_plan_refine = DEFAULT_PLAN_REFINE_PROMPT
|
|
64
|
+
|
|
65
|
+
return PlannerWorkflow(
|
|
66
|
+
tools=tools,
|
|
67
|
+
llm=llm,
|
|
68
|
+
verbose=verbose,
|
|
69
|
+
max_steps=max_steps,
|
|
70
|
+
system_prompt=prompt_step,
|
|
71
|
+
initial_plan_prompt= prompt_plan_initial,
|
|
72
|
+
plan_refine_prompt= prompt_plan_refine,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
def get_options(self) -> Dict[str, Any]:
|
|
76
|
+
"""
|
|
77
|
+
Return Agent options
|
|
78
|
+
|
|
79
|
+
:return: dict of options
|
|
80
|
+
"""
|
|
81
|
+
return {
|
|
82
|
+
"step": {
|
|
83
|
+
"label": "Execute prompt",
|
|
84
|
+
"options": {
|
|
85
|
+
"prompt": {
|
|
86
|
+
"type": "textarea",
|
|
87
|
+
"label": "Prompt",
|
|
88
|
+
"description": "Steps execute prompt",
|
|
89
|
+
"default": DEFAULT_EXECUTE_PROMPT,
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"plan": {
|
|
94
|
+
"label": "Planner (initial))",
|
|
95
|
+
"options": {
|
|
96
|
+
"prompt": {
|
|
97
|
+
"type": "textarea",
|
|
98
|
+
"label": "Prompt",
|
|
99
|
+
"description": "Initial plan prompt",
|
|
100
|
+
"default": DEFAULT_INITIAL_PLAN_PROMPT,
|
|
101
|
+
},
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"plan_refine": {
|
|
105
|
+
"label": "Planner (refine)",
|
|
106
|
+
"options": {
|
|
107
|
+
"prompt": {
|
|
108
|
+
"type": "textarea",
|
|
109
|
+
"label": "Prompt",
|
|
110
|
+
"description": "Plan refine prompt",
|
|
111
|
+
"default": DEFAULT_PLAN_REFINE_PROMPT,
|
|
112
|
+
},
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
|
7
7
|
# MIT License #
|
|
8
8
|
# Created By : Marcin Szczygliński #
|
|
9
|
-
# Updated Date: 2025.08.
|
|
9
|
+
# Updated Date: 2025.08.14 03:00:00 #
|
|
10
10
|
# ================================================== #
|
|
11
11
|
|
|
12
12
|
from typing import Dict, Any
|
|
@@ -23,10 +23,10 @@ from ..base import BaseAgent
|
|
|
23
23
|
class ReactWorkflowAgent(BaseAgent):
|
|
24
24
|
def __init__(self, *args, **kwargs):
|
|
25
25
|
super(ReactWorkflowAgent, self).__init__(*args, **kwargs)
|
|
26
|
-
self.id = "
|
|
26
|
+
self.id = "react"
|
|
27
27
|
self.type = AGENT_TYPE_LLAMA
|
|
28
28
|
self.mode = AGENT_MODE_WORKFLOW
|
|
29
|
-
self.name = "ReAct
|
|
29
|
+
self.name = "ReAct"
|
|
30
30
|
|
|
31
31
|
def get_agent(self, window, kwargs: Dict[str, Any]):
|
|
32
32
|
"""
|
|
@@ -36,7 +36,6 @@ class ReactWorkflowAgent(BaseAgent):
|
|
|
36
36
|
:param kwargs: keyword arguments
|
|
37
37
|
:return: Agent provider instance
|
|
38
38
|
"""
|
|
39
|
-
|
|
40
39
|
from llama_index.core.agent.workflow import ReActAgent as Agent
|
|
41
40
|
|
|
42
41
|
tools = kwargs.get("tools", [])
|
|
@@ -44,6 +43,7 @@ class ReactWorkflowAgent(BaseAgent):
|
|
|
44
43
|
llm = kwargs.get("llm", None)
|
|
45
44
|
chat_history = kwargs.get("chat_history", [])
|
|
46
45
|
max_iterations = kwargs.get("max_iterations", 10)
|
|
46
|
+
system_prompt = kwargs.get("system_prompt", None)
|
|
47
47
|
|
|
48
48
|
"""
|
|
49
49
|
# TODO: multimodal support
|
|
@@ -62,10 +62,12 @@ class ReactWorkflowAgent(BaseAgent):
|
|
|
62
62
|
)
|
|
63
63
|
return step_engine.as_agent()
|
|
64
64
|
"""
|
|
65
|
+
# system prompt for ReAct agent is added to messages
|
|
65
66
|
return Agent(
|
|
66
67
|
tools=tools,
|
|
67
68
|
llm=llm,
|
|
68
69
|
chat_history=chat_history,
|
|
69
70
|
max_iterations=max_iterations,
|
|
71
|
+
system_prompt=system_prompt,
|
|
70
72
|
verbose=verbose,
|
|
71
73
|
)
|
|
File without changes
|