jarvis-ai-assistant 0.1.22__tar.gz → 0.1.23__tar.gz
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.
Potentially problematic release.
This version of jarvis-ai-assistant might be problematic. Click here for more details.
- {jarvis_ai_assistant-0.1.22/src/jarvis_ai_assistant.egg-info → jarvis_ai_assistant-0.1.23}/PKG-INFO +1 -1
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/pyproject.toml +1 -1
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/setup.py +1 -1
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/__init__.py +1 -1
- jarvis_ai_assistant-0.1.23/src/jarvis/__pycache__/__init__.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/__pycache__/agent.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/agent.py +31 -7
- jarvis_ai_assistant-0.1.23/src/jarvis/tools/__pycache__/sub_agent.cpython-313.pyc +0 -0
- jarvis_ai_assistant-0.1.23/src/jarvis/tools/sub_agent.py +108 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23/src/jarvis_ai_assistant.egg-info}/PKG-INFO +1 -1
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis_ai_assistant.egg-info/SOURCES.txt +1 -0
- jarvis_ai_assistant-0.1.22/src/jarvis/__pycache__/__init__.cpython-313.pyc +0 -0
- jarvis_ai_assistant-0.1.22/src/jarvis/tools/__pycache__/sub_agent.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/MANIFEST.in +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/README.md +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/setup.cfg +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/__pycache__/main.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/__pycache__/models.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/__pycache__/tools.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/__pycache__/utils.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/__pycache__/zte_llm.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/main.py +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/models/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/models/__pycache__/__init__.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/models/__pycache__/base.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/models/__pycache__/kimi.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/models/base.py +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/models/kimi.py +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/__init__.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/base.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/bing_search.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/calculator.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/calculator_tool.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/file_ops.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/generator.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/python_script.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/rag.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/search.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/shell.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/user_confirmation.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/user_input.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/user_interaction.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/webpage.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/base.py +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/file_ops.py +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/generator.py +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/shell.py +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis/utils.py +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis_ai_assistant.egg-info/dependency_links.txt +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis_ai_assistant.egg-info/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis_ai_assistant.egg-info/requires.txt +0 -0
- {jarvis_ai_assistant-0.1.22 → jarvis_ai_assistant-0.1.23}/src/jarvis_ai_assistant.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "jarvis-ai-assistant"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.23"
|
|
8
8
|
description = "Jarvis: An AI assistant that uses tools to interact with the system"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{ name = "Your Name", email = "your.email@example.com" }]
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name="jarvis-ai-assistant",
|
|
5
|
-
version="0.1.
|
|
5
|
+
version="0.1.23",
|
|
6
6
|
author="skyfire",
|
|
7
7
|
author_email="skyfireitdiy@hotmail.com",
|
|
8
8
|
description="An AI assistant that uses various tools to interact with the system",
|
|
Binary file
|
|
@@ -111,17 +111,20 @@ class Agent:
|
|
|
111
111
|
核心能力:
|
|
112
112
|
1. 使用现有工具完成任务
|
|
113
113
|
2. 通过 generate_tool 创建新工具扩展功能
|
|
114
|
-
3.
|
|
114
|
+
3. 通过 create_sub_agent 创建子代理处理独立任务
|
|
115
|
+
4. 遵循 ReAct (思考-行动-观察) 框架
|
|
115
116
|
|
|
116
117
|
工作流程:
|
|
117
118
|
1. 思考
|
|
118
119
|
- 分析需求和可用工具
|
|
119
120
|
- 评估是否需要新工具
|
|
121
|
+
- 考虑是否需要拆分子任务
|
|
120
122
|
- 规划解决方案
|
|
121
123
|
|
|
122
124
|
2. 行动 (如果需要)
|
|
123
125
|
- 使用现有工具
|
|
124
126
|
- 创建新工具
|
|
127
|
+
- 创建子代理
|
|
125
128
|
- 询问更多信息
|
|
126
129
|
|
|
127
130
|
3. 观察
|
|
@@ -129,14 +132,25 @@ class Agent:
|
|
|
129
132
|
- 分析反馈
|
|
130
133
|
- 规划下一步
|
|
131
134
|
|
|
132
|
-
|
|
135
|
+
任务拆分建议:
|
|
136
|
+
- 当任务包含多个独立步骤时
|
|
137
|
+
- 当子任务需要独立的上下文时
|
|
138
|
+
- 当子任务有明确的完成目标时
|
|
139
|
+
- 当需要并行处理多个任务时
|
|
140
|
+
|
|
141
|
+
创建子代理时,必须提供尽可能多的上下文信息,以确保其正确工作。
|
|
142
|
+
|
|
143
|
+
创建子代理示例:
|
|
133
144
|
<START_TOOL_CALL>
|
|
134
|
-
name:
|
|
145
|
+
name: create_sub_agent
|
|
135
146
|
arguments:
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
147
|
+
agent_name: CodeAnalyzer
|
|
148
|
+
task: 分析项目代码质量
|
|
149
|
+
context: |
|
|
150
|
+
这是一个Python项目
|
|
151
|
+
使用了Flask框架
|
|
152
|
+
需要关注性能和安全性
|
|
153
|
+
goal: 生成代码质量分析报告
|
|
140
154
|
<END_TOOL_CALL>
|
|
141
155
|
|
|
142
156
|
创建新工具示例:
|
|
@@ -155,6 +169,16 @@ arguments:
|
|
|
155
169
|
required: [param1]
|
|
156
170
|
<END_TOOL_CALL>
|
|
157
171
|
|
|
172
|
+
工具使用格式:
|
|
173
|
+
<START_TOOL_CALL>
|
|
174
|
+
name: tool_name
|
|
175
|
+
arguments:
|
|
176
|
+
param1: value1
|
|
177
|
+
param2: |
|
|
178
|
+
multiline
|
|
179
|
+
value
|
|
180
|
+
<END_TOOL_CALL>
|
|
181
|
+
|
|
158
182
|
严格规则:
|
|
159
183
|
1. 每次只能执行一个工具
|
|
160
184
|
2. 等待用户提供执行结果
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
from typing import Dict, Any, Protocol, Optional
|
|
2
|
+
from enum import Enum
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
# 添加项目根目录到 Python 路径
|
|
8
|
+
project_root = Path(__file__).parent.parent.parent
|
|
9
|
+
if str(project_root) not in sys.path:
|
|
10
|
+
sys.path.append(str(project_root))
|
|
11
|
+
|
|
12
|
+
from jarvis.agent import Agent
|
|
13
|
+
from jarvis.utils import OutputType
|
|
14
|
+
|
|
15
|
+
class OutputHandler(Protocol):
|
|
16
|
+
def print(self, text: str, output_type: OutputType) -> None: ...
|
|
17
|
+
|
|
18
|
+
class ModelHandler(Protocol):
|
|
19
|
+
def chat(self, message: str) -> str: ...
|
|
20
|
+
|
|
21
|
+
class SubAgentTool:
|
|
22
|
+
name = "create_sub_agent"
|
|
23
|
+
description = "创建一个子代理来处理特定任务,子代理会生成任务总结报告"
|
|
24
|
+
parameters = {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"properties": {
|
|
27
|
+
"agent_name": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "子代理的名称"
|
|
30
|
+
},
|
|
31
|
+
"task": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "需要完成的具体任务"
|
|
34
|
+
},
|
|
35
|
+
"context": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "任务相关的上下文信息",
|
|
38
|
+
"default": ""
|
|
39
|
+
},
|
|
40
|
+
"goal": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"description": "任务的完成目标",
|
|
43
|
+
"default": ""
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"required": ["agent_name", "task", "context", "goal"]
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
def __init__(self, **kwargs):
|
|
50
|
+
"""初始化子代理工具
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
model: 模型处理器
|
|
54
|
+
output_handler: 输出处理器
|
|
55
|
+
register: 工具注册器
|
|
56
|
+
"""
|
|
57
|
+
self.model = kwargs.get('model')
|
|
58
|
+
if not self.model:
|
|
59
|
+
raise Exception("Model is required for SubAgentTool")
|
|
60
|
+
self.output = kwargs.get('output_handler')
|
|
61
|
+
self.register = kwargs.get('register')
|
|
62
|
+
|
|
63
|
+
def _print(self, text: str, output_type: OutputType = OutputType.INFO):
|
|
64
|
+
"""输出信息"""
|
|
65
|
+
if self.output:
|
|
66
|
+
self.output.print(text, output_type)
|
|
67
|
+
|
|
68
|
+
def execute(self, args: Dict) -> Dict[str, Any]:
|
|
69
|
+
"""创建并运行子代理"""
|
|
70
|
+
try:
|
|
71
|
+
agent_name = args["agent_name"]
|
|
72
|
+
task = args["task"]
|
|
73
|
+
context = args.get("context", "")
|
|
74
|
+
goal = args.get("goal", "")
|
|
75
|
+
|
|
76
|
+
self._print(f"创建子代理: {agent_name}")
|
|
77
|
+
|
|
78
|
+
# 构建任务描述
|
|
79
|
+
task_description = task
|
|
80
|
+
if context:
|
|
81
|
+
task_description = f"上下文信息:\n{context}\n\n任务:\n{task}"
|
|
82
|
+
if goal:
|
|
83
|
+
task_description += f"\n\n完成目标:\n{goal}"
|
|
84
|
+
|
|
85
|
+
# 创建子代理
|
|
86
|
+
sub_agent = Agent(
|
|
87
|
+
name=agent_name,
|
|
88
|
+
model=self.model,
|
|
89
|
+
tool_registry=self.register,
|
|
90
|
+
is_sub_agent=True
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
# 运行子代理
|
|
94
|
+
self._print(f"子代理开始执行任务...")
|
|
95
|
+
result = sub_agent.run(task_description)
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
"success": True,
|
|
99
|
+
"stdout": f"子代理任务完成\n\n{result}",
|
|
100
|
+
"stderr": ""
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
except Exception as e:
|
|
104
|
+
self._print(str(e), OutputType.ERROR)
|
|
105
|
+
return {
|
|
106
|
+
"success": False,
|
|
107
|
+
"error": f"子代理执行失败: {str(e)}"
|
|
108
|
+
}
|
|
@@ -25,6 +25,7 @@ src/jarvis/tools/base.py
|
|
|
25
25
|
src/jarvis/tools/file_ops.py
|
|
26
26
|
src/jarvis/tools/generator.py
|
|
27
27
|
src/jarvis/tools/shell.py
|
|
28
|
+
src/jarvis/tools/sub_agent.py
|
|
28
29
|
src/jarvis/tools/__pycache__/__init__.cpython-313.pyc
|
|
29
30
|
src/jarvis/tools/__pycache__/base.cpython-313.pyc
|
|
30
31
|
src/jarvis/tools/__pycache__/bing_search.cpython-313.pyc
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|