jarvis-ai-assistant 0.1.13__tar.gz → 0.1.16__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.16/LICENSE +21 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/PKG-INFO +24 -1
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/pyproject.toml +2 -1
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/setup.py +2 -1
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/__init__.py +1 -1
- jarvis_ai_assistant-0.1.16/src/jarvis/__pycache__/__init__.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/__pycache__/agent.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/__pycache__/main.cpython-313.pyc +0 -0
- jarvis_ai_assistant-0.1.16/src/jarvis/__pycache__/utils.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/agent.py +61 -52
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/main.py +35 -20
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/models/__pycache__/kimi.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/models/kimi.py +26 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/utils.py +40 -22
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis_ai_assistant.egg-info/PKG-INFO +24 -1
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis_ai_assistant.egg-info/SOURCES.txt +1 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis_ai_assistant.egg-info/requires.txt +1 -0
- jarvis_ai_assistant-0.1.13/src/jarvis/__pycache__/__init__.cpython-313.pyc +0 -0
- jarvis_ai_assistant-0.1.13/src/jarvis/__pycache__/utils.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/MANIFEST.in +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/README.md +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/setup.cfg +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/__pycache__/models.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/__pycache__/tools.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/__pycache__/zte_llm.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/models/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/models/__pycache__/__init__.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/models/__pycache__/base.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/models/base.py +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/tools/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/tools/__pycache__/__init__.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/tools/__pycache__/base.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/tools/__pycache__/bing_search.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/tools/__pycache__/file_ops.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/tools/__pycache__/python_script.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/tools/__pycache__/rag.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/tools/__pycache__/search.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/tools/__pycache__/shell.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/tools/__pycache__/sub_agent.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/tools/__pycache__/user_confirmation.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/tools/__pycache__/user_input.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/tools/__pycache__/user_interaction.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/tools/__pycache__/webpage.cpython-313.pyc +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/tools/base.py +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/tools/file_ops.py +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis/tools/shell.py +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis_ai_assistant.egg-info/dependency_links.txt +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis_ai_assistant.egg-info/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis_ai_assistant.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 skyfire
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: jarvis-ai-assistant
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.16
|
|
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
|
|
7
7
|
Author-email: Your Name <your.email@example.com>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2025 skyfire
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
8
29
|
Project-URL: Homepage, https://github.com/skyfireitdiy/Jarvis
|
|
9
30
|
Keywords: jarvis,ai,assistant,tools,automation
|
|
10
31
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -16,9 +37,11 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
16
37
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
38
|
Requires-Python: >=3.8
|
|
18
39
|
Description-Content-Type: text/markdown
|
|
40
|
+
License-File: LICENSE
|
|
19
41
|
Requires-Dist: requests>=2.25.1
|
|
20
42
|
Requires-Dist: pyyaml>=5.1
|
|
21
43
|
Requires-Dist: colorama>=0.4.6
|
|
44
|
+
Requires-Dist: prompt_toolkit>=3.0.0
|
|
22
45
|
Provides-Extra: dev
|
|
23
46
|
Requires-Dist: pytest; extra == "dev"
|
|
24
47
|
Requires-Dist: black; extra == "dev"
|
|
@@ -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.16"
|
|
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" }]
|
|
@@ -23,6 +23,7 @@ dependencies = [
|
|
|
23
23
|
"requests>=2.25.1",
|
|
24
24
|
"pyyaml>=5.1",
|
|
25
25
|
"colorama>=0.4.6",
|
|
26
|
+
"prompt_toolkit>=3.0.0",
|
|
26
27
|
]
|
|
27
28
|
requires-python = ">=3.8"
|
|
28
29
|
|
|
@@ -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.16",
|
|
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",
|
|
@@ -16,6 +16,7 @@ setup(
|
|
|
16
16
|
"requests>=2.25.1",
|
|
17
17
|
"pyyaml>=5.1",
|
|
18
18
|
"colorama>=0.4.6",
|
|
19
|
+
"prompt_toolkit>=3.0.0",
|
|
19
20
|
],
|
|
20
21
|
entry_points={
|
|
21
22
|
"console_scripts": [
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -87,21 +87,22 @@ class Agent:
|
|
|
87
87
|
Returns:
|
|
88
88
|
str: 任务总结报告
|
|
89
89
|
"""
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
try:
|
|
91
|
+
self.clear_history()
|
|
92
|
+
|
|
93
|
+
if file_list:
|
|
94
|
+
self.model.upload_files(file_list)
|
|
95
|
+
|
|
96
|
+
# 显示任务开始
|
|
97
|
+
PrettyOutput.section(f"开始新任务: {self.name}", OutputType.PLANNING)
|
|
97
98
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
tools_prompt = "可用工具:\n"
|
|
100
|
+
for tool in self.tool_registry.get_all_tools():
|
|
101
|
+
tools_prompt += f"- 名称: {tool['name']}\n"
|
|
102
|
+
tools_prompt += f" 描述: {tool['description']}\n"
|
|
103
|
+
tools_prompt += f" 参数: {tool['parameters']}\n"
|
|
103
104
|
|
|
104
|
-
|
|
105
|
+
self.prompt = f"""你是 {self.name},一个严格遵循 ReAct 框架进行逐步推理和行动的 AI 助手。
|
|
105
106
|
|
|
106
107
|
{tools_prompt}
|
|
107
108
|
|
|
@@ -194,53 +195,61 @@ arguments:
|
|
|
194
195
|
任务:
|
|
195
196
|
{user_input}
|
|
196
197
|
"""
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
while True:
|
|
200
|
-
try:
|
|
201
|
-
# 显示思考状态
|
|
202
|
-
PrettyOutput.print("分析任务...", OutputType.PROGRESS)
|
|
203
|
-
|
|
204
|
-
current_response = self._call_model(self.prompt)
|
|
205
198
|
|
|
199
|
+
while True:
|
|
206
200
|
try:
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if len(result) > 0:
|
|
201
|
+
# 显示思考状态
|
|
202
|
+
PrettyOutput.print("分析任务...", OutputType.PROGRESS)
|
|
203
|
+
|
|
204
|
+
current_response = self._call_model(self.prompt)
|
|
205
|
+
|
|
214
206
|
try:
|
|
215
|
-
|
|
216
|
-
PrettyOutput.print("执行工具调用...", OutputType.PROGRESS)
|
|
217
|
-
tool_result = self.tool_registry.handle_tool_calls(result)
|
|
218
|
-
PrettyOutput.print(tool_result, OutputType.RESULT)
|
|
207
|
+
result = Agent.extract_tool_calls(current_response)
|
|
219
208
|
except Exception as e:
|
|
220
|
-
PrettyOutput.print(str(e), OutputType.ERROR)
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
209
|
+
PrettyOutput.print(f"工具调用错误: {str(e)}", OutputType.ERROR)
|
|
210
|
+
self.prompt = f"工具调用错误: {str(e)}"
|
|
211
|
+
continue
|
|
212
|
+
|
|
213
|
+
if len(result) > 0:
|
|
214
|
+
try:
|
|
215
|
+
# 显示工具调用
|
|
216
|
+
PrettyOutput.print("执行工具调用...", OutputType.PROGRESS)
|
|
217
|
+
tool_result = self.tool_registry.handle_tool_calls(result)
|
|
218
|
+
PrettyOutput.print(tool_result, OutputType.RESULT)
|
|
219
|
+
except Exception as e:
|
|
220
|
+
PrettyOutput.print(str(e), OutputType.ERROR)
|
|
221
|
+
tool_result = f"Tool call failed: {str(e)}"
|
|
222
|
+
|
|
223
|
+
self.prompt = tool_result
|
|
224
|
+
continue
|
|
225
|
+
|
|
226
|
+
# 获取用户输入
|
|
227
|
+
user_input = get_multiline_input(f"{self.name}: 您可以继续输入,或输入空行结束当前任务")
|
|
228
|
+
if user_input == "__interrupt__":
|
|
229
|
+
PrettyOutput.print("任务已取消", OutputType.WARNING)
|
|
230
|
+
return "Task cancelled by user"
|
|
231
|
+
if user_input:
|
|
232
|
+
self.prompt = user_input
|
|
233
|
+
continue
|
|
234
|
+
|
|
235
|
+
if not user_input:
|
|
236
236
|
PrettyOutput.section("任务完成", OutputType.SUCCESS)
|
|
237
237
|
return
|
|
238
|
-
|
|
239
238
|
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
except Exception as e:
|
|
240
|
+
PrettyOutput.print(str(e), OutputType.ERROR)
|
|
241
|
+
return f"Task failed: {str(e)}"
|
|
242
|
+
|
|
243
|
+
except Exception as e:
|
|
244
|
+
PrettyOutput.print(str(e), OutputType.ERROR)
|
|
245
|
+
return f"Task failed: {str(e)}"
|
|
246
|
+
|
|
247
|
+
finally:
|
|
248
|
+
# 确保在所有情况下都删除会话
|
|
249
|
+
try:
|
|
250
|
+
self.model.delete_chat()
|
|
242
251
|
except Exception as e:
|
|
243
|
-
PrettyOutput.print(str(e), OutputType.ERROR)
|
|
252
|
+
PrettyOutput.print(f"清理会话时发生错误: {str(e)}", OutputType.ERROR)
|
|
244
253
|
|
|
245
254
|
def clear_history(self):
|
|
246
255
|
"""清除对话历史,只保留系统提示"""
|
|
@@ -17,28 +17,43 @@ from jarvis.utils import PrettyOutput, OutputType, get_multiline_input, load_env
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def load_tasks() -> dict:
|
|
20
|
-
"""Load tasks from .jarvis
|
|
21
|
-
|
|
22
|
-
return {}
|
|
20
|
+
"""Load tasks from .jarvis files in user home and current directory."""
|
|
21
|
+
tasks = {}
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return {}
|
|
31
|
-
|
|
32
|
-
# Validate format and convert all values to strings
|
|
33
|
-
validated_tasks = {}
|
|
34
|
-
for name, desc in tasks.items():
|
|
35
|
-
if desc: # Ensure description is not empty
|
|
36
|
-
validated_tasks[str(name)] = str(desc)
|
|
23
|
+
# 检查用户目录下的 .jarvis
|
|
24
|
+
user_jarvis = os.path.expanduser("~/.jarvis")
|
|
25
|
+
if os.path.exists(user_jarvis):
|
|
26
|
+
try:
|
|
27
|
+
with open(user_jarvis, "r", encoding="utf-8") as f:
|
|
28
|
+
user_tasks = yaml.safe_load(f)
|
|
37
29
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
if isinstance(user_tasks, dict):
|
|
31
|
+
# 验证并添加用户目录的任务
|
|
32
|
+
for name, desc in user_tasks.items():
|
|
33
|
+
if desc: # 确保描述不为空
|
|
34
|
+
tasks[str(name)] = str(desc)
|
|
35
|
+
else:
|
|
36
|
+
PrettyOutput.print("Warning: ~/.jarvis file should contain a dictionary of task_name: task_description", OutputType.ERROR)
|
|
37
|
+
except Exception as e:
|
|
38
|
+
PrettyOutput.print(f"Error loading ~/.jarvis file: {str(e)}", OutputType.ERROR)
|
|
39
|
+
|
|
40
|
+
# 检查当前目录下的 .jarvis
|
|
41
|
+
if os.path.exists(".jarvis"):
|
|
42
|
+
try:
|
|
43
|
+
with open(".jarvis", "r", encoding="utf-8") as f:
|
|
44
|
+
local_tasks = yaml.safe_load(f)
|
|
45
|
+
|
|
46
|
+
if isinstance(local_tasks, dict):
|
|
47
|
+
# 验证并添加当前目录的任务,如果有重名则覆盖用户目录的任务
|
|
48
|
+
for name, desc in local_tasks.items():
|
|
49
|
+
if desc: # 确保描述不为空
|
|
50
|
+
tasks[str(name)] = str(desc)
|
|
51
|
+
else:
|
|
52
|
+
PrettyOutput.print("Warning: .jarvis file should contain a dictionary of task_name: task_description", OutputType.ERROR)
|
|
53
|
+
except Exception as e:
|
|
54
|
+
PrettyOutput.print(f"Error loading .jarvis file: {str(e)}", OutputType.ERROR)
|
|
55
|
+
|
|
56
|
+
return tasks
|
|
42
57
|
|
|
43
58
|
def select_task(tasks: dict) -> str:
|
|
44
59
|
"""Let user select a task from the list or skip. Returns task description if selected."""
|
|
Binary file
|
|
@@ -246,8 +246,34 @@ class KimiModel(BaseModel):
|
|
|
246
246
|
except Exception as e:
|
|
247
247
|
raise Exception(f"Chat failed: {str(e)}")
|
|
248
248
|
|
|
249
|
+
def delete_chat(self) -> bool:
|
|
250
|
+
"""删除当前会话"""
|
|
251
|
+
if not self.chat_id:
|
|
252
|
+
return True # 如果没有会话ID,视为删除成功
|
|
253
|
+
|
|
254
|
+
url = f"https://kimi.moonshot.cn/api/chat/{self.chat_id}"
|
|
255
|
+
headers = {
|
|
256
|
+
'Authorization': self.auth_header,
|
|
257
|
+
'Content-Type': 'application/json'
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
try:
|
|
261
|
+
response = requests.delete(url, headers=headers)
|
|
262
|
+
if response.status_code == 200:
|
|
263
|
+
PrettyOutput.print("会话已删除", OutputType.SUCCESS)
|
|
264
|
+
self.chat_id = "" # 清除会话ID
|
|
265
|
+
return True
|
|
266
|
+
else:
|
|
267
|
+
PrettyOutput.print(f"删除会话失败: HTTP {response.status_code}", OutputType.ERROR)
|
|
268
|
+
return False
|
|
269
|
+
except Exception as e:
|
|
270
|
+
PrettyOutput.print(f"删除会话时发生错误: {str(e)}", OutputType.ERROR)
|
|
271
|
+
return False
|
|
272
|
+
|
|
249
273
|
def reset(self):
|
|
250
274
|
"""重置对话"""
|
|
275
|
+
if self.chat_id:
|
|
276
|
+
self.delete_chat() # 删除现有会话
|
|
251
277
|
self.chat_id = ""
|
|
252
278
|
self.uploaded_files = []
|
|
253
279
|
self.first_chat = True # 重置first_chat标记
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
import sys
|
|
3
3
|
import time
|
|
4
|
+
import os
|
|
4
5
|
from typing import Dict, Optional
|
|
5
6
|
from enum import Enum
|
|
6
7
|
from datetime import datetime
|
|
7
8
|
import colorama
|
|
8
|
-
from colorama import Fore, Style
|
|
9
|
-
import
|
|
9
|
+
from colorama import Fore, Style as ColoramaStyle
|
|
10
|
+
from prompt_toolkit import PromptSession
|
|
11
|
+
from prompt_toolkit.styles import Style as PromptStyle
|
|
12
|
+
from prompt_toolkit.formatted_text import FormattedText
|
|
10
13
|
|
|
11
14
|
# 初始化colorama
|
|
12
15
|
colorama.init()
|
|
@@ -84,10 +87,10 @@ class PrettyOutput:
|
|
|
84
87
|
prefix = PrettyOutput.PREFIXES.get(output_type, "")
|
|
85
88
|
|
|
86
89
|
# 添加时间戳 - 使用白色
|
|
87
|
-
time_str = f"{Fore.WHITE}[{datetime.now().strftime('%H:%M:%S')}]{
|
|
90
|
+
time_str = f"{Fore.WHITE}[{datetime.now().strftime('%H:%M:%S')}]{ColoramaStyle.RESET_ALL} " if timestamp else ""
|
|
88
91
|
|
|
89
92
|
# 格式化输出
|
|
90
|
-
formatted_text = f"{time_str}{color}{icon} {prefix}: {text}{
|
|
93
|
+
formatted_text = f"{time_str}{color}{icon} {prefix}: {text}{ColoramaStyle.RESET_ALL}"
|
|
91
94
|
|
|
92
95
|
return formatted_text
|
|
93
96
|
|
|
@@ -101,15 +104,15 @@ class PrettyOutput:
|
|
|
101
104
|
"""打印带分隔线的段落标题"""
|
|
102
105
|
width = 60
|
|
103
106
|
color = PrettyOutput.COLORS.get(output_type, "")
|
|
104
|
-
print(f"\n{color}" + "=" * width + f"{
|
|
107
|
+
print(f"\n{color}" + "=" * width + f"{ColoramaStyle.RESET_ALL}")
|
|
105
108
|
PrettyOutput.print(title.center(width - 10), output_type, timestamp=False)
|
|
106
|
-
print(f"{color}" + "=" * width + f"{
|
|
109
|
+
print(f"{color}" + "=" * width + f"{ColoramaStyle.RESET_ALL}\n")
|
|
107
110
|
|
|
108
111
|
@staticmethod
|
|
109
112
|
def print_stream(text: str, output_type: OutputType):
|
|
110
113
|
"""打印流式输出,不换行"""
|
|
111
114
|
color = PrettyOutput.COLORS.get(output_type, "")
|
|
112
|
-
sys.stdout.write(f"{color}{text}{
|
|
115
|
+
sys.stdout.write(f"{color}{text}{ColoramaStyle.RESET_ALL}")
|
|
113
116
|
sys.stdout.flush()
|
|
114
117
|
|
|
115
118
|
@staticmethod
|
|
@@ -119,29 +122,44 @@ class PrettyOutput:
|
|
|
119
122
|
sys.stdout.flush()
|
|
120
123
|
|
|
121
124
|
def get_multiline_input(tip: str) -> str:
|
|
122
|
-
"""
|
|
125
|
+
"""获取多行输入,支持方向键、历史记录等功能"""
|
|
123
126
|
PrettyOutput.print(tip + "\n", OutputType.INFO)
|
|
124
|
-
lines = []
|
|
125
127
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
# 创建输入会话,启用历史记录
|
|
129
|
+
session = PromptSession(history=None) # 使用默认历史记录
|
|
130
|
+
|
|
131
|
+
# 定义提示符样式
|
|
132
|
+
style = PromptStyle.from_dict({
|
|
133
|
+
'prompt': 'ansicyan',
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
lines = []
|
|
137
|
+
try:
|
|
138
|
+
while True:
|
|
139
|
+
# 设置提示符
|
|
140
|
+
prompt = FormattedText([
|
|
141
|
+
('class:prompt', '... ' if lines else '>>> ')
|
|
142
|
+
])
|
|
131
143
|
|
|
132
|
-
|
|
144
|
+
# 获取输入
|
|
145
|
+
line = session.prompt(
|
|
146
|
+
prompt,
|
|
147
|
+
style=style,
|
|
148
|
+
).strip()
|
|
149
|
+
|
|
150
|
+
# 空行处理
|
|
133
151
|
if not line:
|
|
134
|
-
if not lines: #
|
|
152
|
+
if not lines: # 第一行就输入空行
|
|
135
153
|
return ""
|
|
136
|
-
break
|
|
137
|
-
|
|
154
|
+
break # 结束多行输入
|
|
155
|
+
|
|
138
156
|
lines.append(line)
|
|
139
157
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
158
|
+
except KeyboardInterrupt:
|
|
159
|
+
PrettyOutput.print("\n输入已取消", OutputType.ERROR)
|
|
160
|
+
return "__interrupt__"
|
|
143
161
|
|
|
144
|
-
return "\n".join(lines)
|
|
162
|
+
return "\n".join(lines)
|
|
145
163
|
|
|
146
164
|
def load_env_from_file():
|
|
147
165
|
"""从~/.jarvis_env加载环境变量"""
|
{jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.16}/src/jarvis_ai_assistant.egg-info/PKG-INFO
RENAMED
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: jarvis-ai-assistant
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.16
|
|
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
|
|
7
7
|
Author-email: Your Name <your.email@example.com>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2025 skyfire
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
8
29
|
Project-URL: Homepage, https://github.com/skyfireitdiy/Jarvis
|
|
9
30
|
Keywords: jarvis,ai,assistant,tools,automation
|
|
10
31
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -16,9 +37,11 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
16
37
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
38
|
Requires-Python: >=3.8
|
|
18
39
|
Description-Content-Type: text/markdown
|
|
40
|
+
License-File: LICENSE
|
|
19
41
|
Requires-Dist: requests>=2.25.1
|
|
20
42
|
Requires-Dist: pyyaml>=5.1
|
|
21
43
|
Requires-Dist: colorama>=0.4.6
|
|
44
|
+
Requires-Dist: prompt_toolkit>=3.0.0
|
|
22
45
|
Provides-Extra: dev
|
|
23
46
|
Requires-Dist: pytest; extra == "dev"
|
|
24
47
|
Requires-Dist: black; extra == "dev"
|
|
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
|