jarvis-ai-assistant 0.1.19__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.

Files changed (55) hide show
  1. {jarvis_ai_assistant-0.1.19/src/jarvis_ai_assistant.egg-info → jarvis_ai_assistant-0.1.23}/PKG-INFO +1 -1
  2. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/pyproject.toml +1 -1
  3. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/setup.py +1 -1
  4. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/__init__.py +1 -1
  5. jarvis_ai_assistant-0.1.23/src/jarvis/__pycache__/__init__.cpython-313.pyc +0 -0
  6. jarvis_ai_assistant-0.1.23/src/jarvis/__pycache__/agent.cpython-313.pyc +0 -0
  7. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/agent.py +51 -10
  8. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/base.cpython-313.pyc +0 -0
  9. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/generator.cpython-313.pyc +0 -0
  10. jarvis_ai_assistant-0.1.23/src/jarvis/tools/__pycache__/sub_agent.cpython-313.pyc +0 -0
  11. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/base.py +1 -1
  12. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/generator.py +1 -1
  13. jarvis_ai_assistant-0.1.23/src/jarvis/tools/sub_agent.py +108 -0
  14. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23/src/jarvis_ai_assistant.egg-info}/PKG-INFO +1 -1
  15. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis_ai_assistant.egg-info/SOURCES.txt +1 -0
  16. jarvis_ai_assistant-0.1.19/src/jarvis/__pycache__/__init__.cpython-313.pyc +0 -0
  17. jarvis_ai_assistant-0.1.19/src/jarvis/__pycache__/agent.cpython-313.pyc +0 -0
  18. jarvis_ai_assistant-0.1.19/src/jarvis/tools/__pycache__/sub_agent.cpython-313.pyc +0 -0
  19. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/LICENSE +0 -0
  20. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/MANIFEST.in +0 -0
  21. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/README.md +0 -0
  22. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/setup.cfg +0 -0
  23. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/__pycache__/main.cpython-313.pyc +0 -0
  24. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/__pycache__/models.cpython-313.pyc +0 -0
  25. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/__pycache__/tools.cpython-313.pyc +0 -0
  26. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/__pycache__/utils.cpython-313.pyc +0 -0
  27. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/__pycache__/zte_llm.cpython-313.pyc +0 -0
  28. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/main.py +0 -0
  29. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/models/__init__.py +0 -0
  30. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/models/__pycache__/__init__.cpython-313.pyc +0 -0
  31. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/models/__pycache__/base.cpython-313.pyc +0 -0
  32. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/models/__pycache__/kimi.cpython-313.pyc +0 -0
  33. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/models/base.py +0 -0
  34. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/models/kimi.py +0 -0
  35. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__init__.py +0 -0
  36. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/__init__.cpython-313.pyc +0 -0
  37. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/bing_search.cpython-313.pyc +0 -0
  38. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/calculator.cpython-313.pyc +0 -0
  39. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/calculator_tool.cpython-313.pyc +0 -0
  40. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/file_ops.cpython-313.pyc +0 -0
  41. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/python_script.cpython-313.pyc +0 -0
  42. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/rag.cpython-313.pyc +0 -0
  43. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/search.cpython-313.pyc +0 -0
  44. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/shell.cpython-313.pyc +0 -0
  45. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/user_confirmation.cpython-313.pyc +0 -0
  46. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/user_input.cpython-313.pyc +0 -0
  47. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/user_interaction.cpython-313.pyc +0 -0
  48. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/__pycache__/webpage.cpython-313.pyc +0 -0
  49. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/file_ops.py +0 -0
  50. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/tools/shell.py +0 -0
  51. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis/utils.py +0 -0
  52. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis_ai_assistant.egg-info/dependency_links.txt +0 -0
  53. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis_ai_assistant.egg-info/entry_points.txt +0 -0
  54. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis_ai_assistant.egg-info/requires.txt +0 -0
  55. {jarvis_ai_assistant-0.1.19 → jarvis_ai_assistant-0.1.23}/src/jarvis_ai_assistant.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: jarvis-ai-assistant
3
- Version: 0.1.19
3
+ Version: 0.1.23
4
4
  Summary: Jarvis: An AI assistant that uses tools to interact with the system
5
5
  Home-page: https://github.com/skyfireitdiy/Jarvis
6
6
  Author: skyfire
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "jarvis-ai-assistant"
7
- version = "0.1.19"
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.19",
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",
@@ -1,3 +1,3 @@
1
1
  """Jarvis AI Assistant"""
2
2
 
3
- __version__ = "0.1.19"
3
+ __version__ = "0.1.23"
@@ -11,7 +11,7 @@ import os
11
11
  from datetime import datetime
12
12
 
13
13
  class Agent:
14
- def __init__(self, model: BaseModel, tool_registry: ToolRegistry, name: str = "Jarvis"):
14
+ def __init__(self, model: BaseModel, tool_registry: ToolRegistry, name: str = "Jarvis", is_sub_agent: bool = False):
15
15
  """Initialize Agent with a model, optional tool registry and name
16
16
 
17
17
  Args:
@@ -23,6 +23,7 @@ class Agent:
23
23
  self.model = model
24
24
  self.tool_registry = tool_registry or ToolRegistry(model)
25
25
  self.name = name
26
+ self.is_sub_agent = is_sub_agent
26
27
  self.prompt = ""
27
28
 
28
29
 
@@ -77,7 +78,7 @@ class Agent:
77
78
  except Exception as e:
78
79
  raise Exception(f"{self.name}: 模型调用失败: {str(e)}")
79
80
 
80
- def run(self, user_input: str, file_list: Optional[List[str]] = None, keep_history: bool = False):
81
+ def run(self, user_input: str, file_list: Optional[List[str]] = None, keep_history: bool = False) -> str:
81
82
  """处理用户输入并返回响应,返回任务总结报告
82
83
 
83
84
  Args:
@@ -110,17 +111,20 @@ class Agent:
110
111
  核心能力:
111
112
  1. 使用现有工具完成任务
112
113
  2. 通过 generate_tool 创建新工具扩展功能
113
- 3. 遵循 ReAct (思考-行动-观察) 框架
114
+ 3. 通过 create_sub_agent 创建子代理处理独立任务
115
+ 4. 遵循 ReAct (思考-行动-观察) 框架
114
116
 
115
117
  工作流程:
116
118
  1. 思考
117
119
  - 分析需求和可用工具
118
120
  - 评估是否需要新工具
121
+ - 考虑是否需要拆分子任务
119
122
  - 规划解决方案
120
123
 
121
124
  2. 行动 (如果需要)
122
125
  - 使用现有工具
123
126
  - 创建新工具
127
+ - 创建子代理
124
128
  - 询问更多信息
125
129
 
126
130
  3. 观察
@@ -128,14 +132,25 @@ class Agent:
128
132
  - 分析反馈
129
133
  - 规划下一步
130
134
 
131
- 工具使用格式:
135
+ 任务拆分建议:
136
+ - 当任务包含多个独立步骤时
137
+ - 当子任务需要独立的上下文时
138
+ - 当子任务有明确的完成目标时
139
+ - 当需要并行处理多个任务时
140
+
141
+ 创建子代理时,必须提供尽可能多的上下文信息,以确保其正确工作。
142
+
143
+ 创建子代理示例:
132
144
  <START_TOOL_CALL>
133
- name: tool_name
145
+ name: create_sub_agent
134
146
  arguments:
135
- param1: value1
136
- param2: |
137
- multiline
138
- value
147
+ agent_name: CodeAnalyzer
148
+ task: 分析项目代码质量
149
+ context: |
150
+ 这是一个Python项目
151
+ 使用了Flask框架
152
+ 需要关注性能和安全性
153
+ goal: 生成代码质量分析报告
139
154
  <END_TOOL_CALL>
140
155
 
141
156
  创建新工具示例:
@@ -154,6 +169,16 @@ arguments:
154
169
  required: [param1]
155
170
  <END_TOOL_CALL>
156
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
+
157
182
  严格规则:
158
183
  1. 每次只能执行一个工具
159
184
  2. 等待用户提供执行结果
@@ -203,7 +228,23 @@ arguments:
203
228
 
204
229
  if not user_input:
205
230
  PrettyOutput.section("任务完成", OutputType.SUCCESS)
206
- return
231
+ if self.is_sub_agent:
232
+ # 生成任务总结
233
+ summary_prompt = f"""请对以上任务执行情况生成一个简洁的总结报告,包括:
234
+
235
+ 1. 任务目标: xxxx
236
+ 2. 执行结果: 成功/失败
237
+ 3. 关键信息: 提取执行过程中的重要信息
238
+ 4. 重要发现: 任何值得注意的发现
239
+ 5. 后续建议: 如果有的话
240
+
241
+ 请用简洁的要点形式描述,突出重要信息。
242
+ """
243
+ self.prompt = summary_prompt
244
+ summary = self.model.chat(self.prompt)
245
+ return summary
246
+ else:
247
+ return "Task completed"
207
248
 
208
249
  except Exception as e:
209
250
  PrettyOutput.print(str(e), OutputType.ERROR)
@@ -115,7 +115,7 @@ class ToolRegistry:
115
115
  parameters=tool_instance.parameters,
116
116
  func=tool_instance.execute
117
117
  )
118
- self.output_handler.print(f"已加载工具: {tool_instance.name}", OutputType.INFO)
118
+ self.output_handler.print(f"已加载工具: {tool_instance.name}: {tool_instance.description}", OutputType.INFO)
119
119
  tool_found = True
120
120
 
121
121
  if not tool_found:
@@ -15,7 +15,7 @@ class ModelHandler(Protocol):
15
15
 
16
16
  class ToolGeneratorTool:
17
17
  name = "generate_tool"
18
- description = "生成新的工具代码并自动注册到ToolRegistry"
18
+ description = "生成新的工具代码并自动注册到Jarvis,自动扩充Jarvis的能力"
19
19
  parameters = {
20
20
  "type": "object",
21
21
  "properties": {
@@ -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
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: jarvis-ai-assistant
3
- Version: 0.1.19
3
+ Version: 0.1.23
4
4
  Summary: Jarvis: An AI assistant that uses tools to interact with the system
5
5
  Home-page: https://github.com/skyfireitdiy/Jarvis
6
6
  Author: skyfire
@@ -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