jarvis-ai-assistant 0.1.35__tar.gz → 0.1.36__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {jarvis_ai_assistant-0.1.35/src/jarvis_ai_assistant.egg-info → jarvis_ai_assistant-0.1.36}/PKG-INFO +1 -1
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/pyproject.toml +1 -1
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/setup.py +1 -1
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/__init__.py +1 -1
- jarvis_ai_assistant-0.1.36/src/jarvis/__pycache__/__init__.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/__pycache__/agent.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/agent.py +11 -10
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/models/__pycache__/ai8.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/models/__pycache__/oyi.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/models/ai8.py +1 -1
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/models/oyi.py +1 -1
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/__pycache__/methodology.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/__pycache__/registry.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/methodology.py +16 -16
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/registry.py +1 -1
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36/src/jarvis_ai_assistant.egg-info}/PKG-INFO +1 -1
- jarvis_ai_assistant-0.1.35/src/jarvis/__pycache__/__init__.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/MANIFEST.in +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/README.md +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/setup.cfg +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/__pycache__/main.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/__pycache__/models.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/__pycache__/tools.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/__pycache__/utils.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/__pycache__/zte_llm.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/main.py +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/models/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/models/__pycache__/__init__.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/models/__pycache__/base.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/models/__pycache__/kimi.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/models/__pycache__/openai.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/models/__pycache__/registry.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/models/base.py +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/models/kimi.py +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/models/openai.py +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/models/registry.py +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/__pycache__/__init__.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/__pycache__/base.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/__pycache__/bing_search.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/__pycache__/calculator.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/__pycache__/calculator_tool.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/__pycache__/file_ops.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/__pycache__/generator.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/__pycache__/python_script.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/__pycache__/rag.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/__pycache__/search.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/__pycache__/shell.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/__pycache__/sub_agent.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/__pycache__/user_confirmation.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/__pycache__/user_input.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/__pycache__/user_interaction.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/__pycache__/webpage.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/base.py +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/file_ops.py +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/generator.py +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/shell.py +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/tools/sub_agent.py +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis/utils.py +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis_ai_assistant.egg-info/SOURCES.txt +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis_ai_assistant.egg-info/dependency_links.txt +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis_ai_assistant.egg-info/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/src/jarvis_ai_assistant.egg-info/requires.txt +0 -0
- {jarvis_ai_assistant-0.1.35 → jarvis_ai_assistant-0.1.36}/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.36"
|
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.36",
|
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
|
@@ -88,14 +88,15 @@ class Agent:
|
|
88
88
|
|
89
89
|
|
90
90
|
def _load_methodology(self) -> str:
|
91
|
-
"""
|
91
|
+
"""加载经验总结"""
|
92
92
|
user_jarvis_methodology = os.path.expanduser("~/.jarvis_methodology")
|
93
93
|
ret = ""
|
94
94
|
if os.path.exists(user_jarvis_methodology):
|
95
95
|
with open(user_jarvis_methodology, "r", encoding="utf-8") as f:
|
96
96
|
data = yaml.safe_load(f)
|
97
97
|
for k, v in data.items():
|
98
|
-
ret += f"问题类型: \n{k}\n
|
98
|
+
ret += f"问题类型: \n{k}\n经验总结: \n{v}\n\n"
|
99
|
+
PrettyOutput.print(f"从 {user_jarvis_methodology} 加载经验总结: {', '.join(data.keys())}", OutputType.INFO)
|
99
100
|
return ret
|
100
101
|
|
101
102
|
def run(self, user_input: str, file_list: Optional[List[str]] = None, keep_history: bool = False) -> str:
|
@@ -115,12 +116,12 @@ class Agent:
|
|
115
116
|
if file_list:
|
116
117
|
self.model.upload_files(file_list)
|
117
118
|
|
118
|
-
#
|
119
|
+
# 加载经验总结
|
119
120
|
methodology = self._load_methodology()
|
120
121
|
|
121
122
|
methodology_prompt = ""
|
122
123
|
if methodology:
|
123
|
-
methodology_prompt = f"""
|
124
|
+
methodology_prompt = f"""这是以往处理问题的标准经验总结,如果当前任务与此类似,可参考:
|
124
125
|
{methodology}
|
125
126
|
|
126
127
|
"""
|
@@ -145,11 +146,11 @@ class Agent:
|
|
145
146
|
6. 制定行动计划:根据目前可以使用的工具制定行动计划
|
146
147
|
7. 执行行动计划:每步执行一个步骤,最多使用一个工具(工具执行完成后,等待工具结果再执行下一步)
|
147
148
|
8. 监控与调整:如果执行结果与预期不符,则反思并调整行动计划,迭代之前的步骤
|
148
|
-
9.
|
149
|
+
9. 更新经验总结(如有必要):任务完成后总结执行过程中的经验教训,生成同类问题的通用经验总结,使用经验总结工具进行更新或者添加
|
149
150
|
|
150
151
|
-------------------------------------------------------------
|
151
152
|
|
152
|
-
|
153
|
+
经验总结模板:
|
153
154
|
1. 问题重述
|
154
155
|
2. 最优解决方案
|
155
156
|
3. 最优方案执行步骤(失败的行动不需要体现)
|
@@ -223,7 +224,7 @@ arguments:
|
|
223
224
|
|
224
225
|
if not user_input:
|
225
226
|
while True:
|
226
|
-
choice = prompt("
|
227
|
+
choice = prompt("是否需要手动为此任务生成经验总结以提升Jarvis对类似任务的处理能力?(y/n), 回车跳过: ")
|
227
228
|
if choice == "y":
|
228
229
|
self._make_methodology()
|
229
230
|
break
|
@@ -273,9 +274,9 @@ arguments:
|
|
273
274
|
self.model.reset()
|
274
275
|
|
275
276
|
def _make_methodology(self):
|
276
|
-
"""
|
277
|
-
current_response = self._call_model("""
|
278
|
-
|
277
|
+
"""生成经验总结"""
|
278
|
+
current_response = self._call_model("""请根据之前的对话内容,判断是否有必要更新、添加、删除现有经验总结,如果有,使用methodology工具进行管理。
|
279
|
+
经验总结模板:
|
279
280
|
1. 问题重述
|
280
281
|
2. 最优解决方案
|
281
282
|
3. 最优方案执行步骤(失败的行动不需要体现)
|
Binary file
|
Binary file
|
@@ -59,7 +59,7 @@ class AI8Model(BaseModel):
|
|
59
59
|
PrettyOutput.print("ERNIE-3.5-128K", OutputType.INFO)
|
60
60
|
|
61
61
|
|
62
|
-
PrettyOutput.print("使用AI8_MODEL
|
62
|
+
PrettyOutput.print("使用AI8_MODEL环境变量配置模型", OutputType.SUCCESS)
|
63
63
|
|
64
64
|
self.system_message = ""
|
65
65
|
self.conversation = None
|
@@ -39,7 +39,7 @@ class OyiModel(BaseModel):
|
|
39
39
|
PrettyOutput.print("generalv3.5", OutputType.INFO)
|
40
40
|
PrettyOutput.print("gemini-pro", OutputType.INFO)
|
41
41
|
PrettyOutput.print("llama3-70b-8192", OutputType.INFO)
|
42
|
-
PrettyOutput.print("使用OYI_MODEL
|
42
|
+
PrettyOutput.print("使用OYI_MODEL环境变量配置模型", OutputType.SUCCESS)
|
43
43
|
|
44
44
|
|
45
45
|
self.messages = []
|
Binary file
|
Binary file
|
@@ -8,7 +8,7 @@ class MethodologyTool:
|
|
8
8
|
"""经验管理工具"""
|
9
9
|
|
10
10
|
name = "methodology"
|
11
|
-
description = "
|
11
|
+
description = "管理问题处理经验总结,支持添加、更新、删除操作"
|
12
12
|
parameters = {
|
13
13
|
"type": "object",
|
14
14
|
"properties": {
|
@@ -23,7 +23,7 @@ class MethodologyTool:
|
|
23
23
|
},
|
24
24
|
"content": {
|
25
25
|
"type": "string",
|
26
|
-
"description": "
|
26
|
+
"description": "经验总结内容 (update/add 时必需)",
|
27
27
|
"optional": True
|
28
28
|
}
|
29
29
|
},
|
@@ -36,39 +36,39 @@ class MethodologyTool:
|
|
36
36
|
self._ensure_file_exists()
|
37
37
|
|
38
38
|
def _ensure_file_exists(self):
|
39
|
-
"""
|
39
|
+
"""确保经验总结文件存在"""
|
40
40
|
if not os.path.exists(self.methodology_file):
|
41
41
|
try:
|
42
42
|
with open(self.methodology_file, 'w', encoding='utf-8') as f:
|
43
43
|
yaml.safe_dump({}, f, allow_unicode=True)
|
44
44
|
except Exception as e:
|
45
|
-
PrettyOutput.print(f"
|
45
|
+
PrettyOutput.print(f"创建经验总结文件失败: {str(e)}", OutputType.ERROR)
|
46
46
|
|
47
47
|
def _load_methodologies(self) -> Dict:
|
48
|
-
"""
|
48
|
+
"""加载所有经验总结"""
|
49
49
|
try:
|
50
50
|
with open(self.methodology_file, 'r', encoding='utf-8') as f:
|
51
51
|
return yaml.safe_load(f) or {}
|
52
52
|
except Exception as e:
|
53
|
-
PrettyOutput.print(f"
|
53
|
+
PrettyOutput.print(f"加载经验总结失败: {str(e)}", OutputType.ERROR)
|
54
54
|
return {}
|
55
55
|
|
56
56
|
def _save_methodologies(self, methodologies: Dict):
|
57
|
-
"""
|
57
|
+
"""保存所有经验总结"""
|
58
58
|
try:
|
59
59
|
with open(self.methodology_file, 'w', encoding='utf-8') as f:
|
60
60
|
yaml.safe_dump(methodologies, f, allow_unicode=True)
|
61
61
|
except Exception as e:
|
62
|
-
PrettyOutput.print(f"
|
62
|
+
PrettyOutput.print(f"保存经验总结失败: {str(e)}", OutputType.ERROR)
|
63
63
|
|
64
64
|
def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
|
65
|
-
"""
|
65
|
+
"""执行经验总结管理操作
|
66
66
|
|
67
67
|
Args:
|
68
68
|
args: 包含操作参数的字典
|
69
69
|
- operation: 操作类型 (delete/update/add)
|
70
70
|
- problem_type: 问题类型
|
71
|
-
- content:
|
71
|
+
- content: 经验总结内容 (update/add 时必需)
|
72
72
|
|
73
73
|
Returns:
|
74
74
|
Dict[str, Any]: 包含执行结果的字典
|
@@ -92,19 +92,19 @@ class MethodologyTool:
|
|
92
92
|
self._save_methodologies(methodologies)
|
93
93
|
return {
|
94
94
|
"success": True,
|
95
|
-
"stdout": f"已删除问题类型 '{problem_type}'
|
95
|
+
"stdout": f"已删除问题类型 '{problem_type}' 的经验总结"
|
96
96
|
}
|
97
97
|
else:
|
98
98
|
return {
|
99
99
|
"success": False,
|
100
|
-
"error": f"未找到问题类型 '{problem_type}'
|
100
|
+
"error": f"未找到问题类型 '{problem_type}' 的经验总结"
|
101
101
|
}
|
102
102
|
|
103
103
|
elif operation in ["update", "add"]:
|
104
104
|
if not content:
|
105
105
|
return {
|
106
106
|
"success": False,
|
107
|
-
"error": "
|
107
|
+
"error": "需要提供经验总结内容"
|
108
108
|
}
|
109
109
|
|
110
110
|
methodologies[problem_type] = content
|
@@ -113,7 +113,7 @@ class MethodologyTool:
|
|
113
113
|
action = "更新" if problem_type in methodologies else "添加"
|
114
114
|
return {
|
115
115
|
"success": True,
|
116
|
-
"stdout": f"已{action}问题类型 '{problem_type}'
|
116
|
+
"stdout": f"已{action}问题类型 '{problem_type}' 的经验总结"
|
117
117
|
}
|
118
118
|
|
119
119
|
else:
|
@@ -129,13 +129,13 @@ class MethodologyTool:
|
|
129
129
|
}
|
130
130
|
|
131
131
|
def get_methodology(self, problem_type: str) -> Optional[str]:
|
132
|
-
"""
|
132
|
+
"""获取指定问题类型的经验总结
|
133
133
|
|
134
134
|
Args:
|
135
135
|
problem_type: 问题类型
|
136
136
|
|
137
137
|
Returns:
|
138
|
-
Optional[str]:
|
138
|
+
Optional[str]: 经验总结内容,如果不存在则返回 None
|
139
139
|
"""
|
140
140
|
methodologies = self._load_methodologies()
|
141
141
|
return methodologies.get(problem_type)
|
@@ -99,7 +99,7 @@ class ToolRegistry:
|
|
99
99
|
parameters=tool_instance.parameters,
|
100
100
|
func=tool_instance.execute
|
101
101
|
)
|
102
|
-
PrettyOutput.print(f"
|
102
|
+
PrettyOutput.print(f"从 {file_path} 加载工具: {tool_instance.name}: {tool_instance.description}", OutputType.INFO)
|
103
103
|
tool_found = True
|
104
104
|
|
105
105
|
if not tool_found:
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|