jarvis-ai-assistant 0.1.5__py3-none-any.whl → 0.1.6__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.
Potentially problematic release.
This version of jarvis-ai-assistant might be problematic. Click here for more details.
- jarvis/__init__.py +1 -1
- jarvis/__pycache__/__init__.cpython-313.pyc +0 -0
- jarvis/__pycache__/agent.cpython-313.pyc +0 -0
- jarvis/__pycache__/main.cpython-313.pyc +0 -0
- jarvis/__pycache__/models.cpython-313.pyc +0 -0
- jarvis/__pycache__/utils.cpython-313.pyc +0 -0
- jarvis/__pycache__/zte_llm.cpython-313.pyc +0 -0
- jarvis/agent.py +93 -31
- jarvis/main.py +8 -8
- jarvis/models.py +55 -35
- jarvis/tools/__init__.py +3 -3
- jarvis/tools/__pycache__/__init__.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/base.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/shell.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/sub_agent.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/user_input.cpython-313.pyc +0 -0
- jarvis/tools/base.py +45 -113
- jarvis/tools/shell.py +62 -48
- jarvis/tools/sub_agent.py +82 -20
- jarvis/tools/user_input.py +74 -0
- jarvis/utils.py +101 -65
- jarvis/zte_llm.py +5 -1
- {jarvis_ai_assistant-0.1.5.dist-info → jarvis_ai_assistant-0.1.6.dist-info}/METADATA +1 -1
- jarvis_ai_assistant-0.1.6.dist-info/RECORD +38 -0
- jarvis/.jarvis +0 -1
- jarvis/tools/python_script.py +0 -150
- jarvis_ai_assistant-0.1.5.dist-info/RECORD +0 -38
- {jarvis_ai_assistant-0.1.5.dist-info → jarvis_ai_assistant-0.1.6.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.5.dist-info → jarvis_ai_assistant-0.1.6.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.5.dist-info → jarvis_ai_assistant-0.1.6.dist-info}/top_level.txt +0 -0
jarvis/tools/python_script.py
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import time
|
|
3
|
-
import subprocess
|
|
4
|
-
import sys
|
|
5
|
-
import pkgutil
|
|
6
|
-
from pathlib import Path
|
|
7
|
-
from typing import Dict, Any, Optional
|
|
8
|
-
from ..utils import PrettyOutput, OutputType
|
|
9
|
-
|
|
10
|
-
class PythonScript:
|
|
11
|
-
"""Python脚本管理类"""
|
|
12
|
-
SCRIPTS_DIR = "/tmp/ai_scripts"
|
|
13
|
-
|
|
14
|
-
@classmethod
|
|
15
|
-
def init_scripts_dir(cls):
|
|
16
|
-
"""初始化脚本目录"""
|
|
17
|
-
Path(cls.SCRIPTS_DIR).mkdir(parents=True, exist_ok=True)
|
|
18
|
-
|
|
19
|
-
@classmethod
|
|
20
|
-
def generate_script_path(cls, name: Optional[str] = None) -> str:
|
|
21
|
-
"""生成脚本文件路径"""
|
|
22
|
-
if name:
|
|
23
|
-
safe_name = "".join(c for c in name if c.isalnum() or c in "._- ")
|
|
24
|
-
filename = f"{int(time.time())}_{safe_name}.py"
|
|
25
|
-
else:
|
|
26
|
-
filename = f"{int(time.time())}_script.py"
|
|
27
|
-
return str(Path(cls.SCRIPTS_DIR) / filename)
|
|
28
|
-
|
|
29
|
-
class PythonScriptTool:
|
|
30
|
-
name = "execute_python"
|
|
31
|
-
description = """Execute Python code and return the results.
|
|
32
|
-
Notes:
|
|
33
|
-
1. Use print() to output results
|
|
34
|
-
2. Automatic dependency management
|
|
35
|
-
3. Code saved to temporary file
|
|
36
|
-
"""
|
|
37
|
-
parameters = {
|
|
38
|
-
"type": "object",
|
|
39
|
-
"properties": {
|
|
40
|
-
"code": {
|
|
41
|
-
"type": "string",
|
|
42
|
-
"description": "Python code to execute"
|
|
43
|
-
},
|
|
44
|
-
"dependencies": {
|
|
45
|
-
"type": "array",
|
|
46
|
-
"items": {"type": "string"},
|
|
47
|
-
"description": "Python package dependencies",
|
|
48
|
-
"default": []
|
|
49
|
-
},
|
|
50
|
-
"name": {
|
|
51
|
-
"type": "string",
|
|
52
|
-
"description": "Script name",
|
|
53
|
-
"default": ""
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
"required": ["code"]
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@staticmethod
|
|
60
|
-
def _is_builtin_package(package_name: str) -> bool:
|
|
61
|
-
package_name = package_name.split("==")[0].strip()
|
|
62
|
-
if hasattr(sys.modules, package_name) or package_name in sys.stdlib_module_names:
|
|
63
|
-
return True
|
|
64
|
-
try:
|
|
65
|
-
return pkgutil.find_spec(package_name) is not None
|
|
66
|
-
except Exception:
|
|
67
|
-
return False
|
|
68
|
-
|
|
69
|
-
def execute(self, args: Dict) -> Dict[str, Any]:
|
|
70
|
-
"""执行Python代码"""
|
|
71
|
-
try:
|
|
72
|
-
code = args["code"]
|
|
73
|
-
dependencies = args.get("dependencies", [])
|
|
74
|
-
script_name = args.get("name", "")
|
|
75
|
-
|
|
76
|
-
# 初始化脚本目录
|
|
77
|
-
PythonScript.init_scripts_dir()
|
|
78
|
-
|
|
79
|
-
# 生成脚本路径
|
|
80
|
-
script_path = PythonScript.generate_script_path(script_name)
|
|
81
|
-
|
|
82
|
-
# 安装依赖
|
|
83
|
-
missing_deps = []
|
|
84
|
-
for dep in dependencies:
|
|
85
|
-
if not self._is_builtin_package(dep):
|
|
86
|
-
missing_deps.append(dep)
|
|
87
|
-
|
|
88
|
-
if missing_deps:
|
|
89
|
-
PrettyOutput.print("正在安装依赖...", OutputType.INFO)
|
|
90
|
-
try:
|
|
91
|
-
subprocess.run(
|
|
92
|
-
[sys.executable, "-m", "pip", "install"] + missing_deps,
|
|
93
|
-
check=True,
|
|
94
|
-
capture_output=True,
|
|
95
|
-
text=True
|
|
96
|
-
)
|
|
97
|
-
PrettyOutput.print("依赖安装完成", OutputType.INFO)
|
|
98
|
-
except subprocess.CalledProcessError as e:
|
|
99
|
-
return {
|
|
100
|
-
"success": False,
|
|
101
|
-
"error": f"依赖安装失败: {e.stderr}"
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
# 写入脚本文件
|
|
105
|
-
with open(script_path, 'w', encoding='utf-8') as f:
|
|
106
|
-
f.write(code)
|
|
107
|
-
|
|
108
|
-
# 执行脚本
|
|
109
|
-
PrettyOutput.print(f"执行脚本: {script_path}", OutputType.INFO)
|
|
110
|
-
result = subprocess.run(
|
|
111
|
-
[sys.executable, script_path],
|
|
112
|
-
capture_output=True,
|
|
113
|
-
text=True
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
# 构建输出
|
|
117
|
-
output = []
|
|
118
|
-
|
|
119
|
-
# 添加脚本信息
|
|
120
|
-
output.append(f"脚本路径: {script_path}")
|
|
121
|
-
if dependencies:
|
|
122
|
-
output.append(f"依赖项: {', '.join(dependencies)}")
|
|
123
|
-
output.append("")
|
|
124
|
-
|
|
125
|
-
# 添加执行结果
|
|
126
|
-
if result.stdout:
|
|
127
|
-
output.append("输出:")
|
|
128
|
-
output.append(result.stdout)
|
|
129
|
-
|
|
130
|
-
# 添加错误信息(如果有)
|
|
131
|
-
if result.stderr:
|
|
132
|
-
output.append("错误:")
|
|
133
|
-
output.append(result.stderr)
|
|
134
|
-
|
|
135
|
-
# 添加返回码
|
|
136
|
-
output.append(f"返回码: {result.returncode}")
|
|
137
|
-
|
|
138
|
-
return {
|
|
139
|
-
"success": result.returncode == 0,
|
|
140
|
-
"stdout": "\n".join(output),
|
|
141
|
-
"stderr": result.stderr,
|
|
142
|
-
"return_code": result.returncode,
|
|
143
|
-
"script_path": script_path
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
except Exception as e:
|
|
147
|
-
return {
|
|
148
|
-
"success": False,
|
|
149
|
-
"error": f"执行Python代码失败: {str(e)}"
|
|
150
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
jarvis/.jarvis,sha256=S4ZMmLqlVLHAPmnwHFQ3vYt0gnDFp-KQRH4okBh8Hpw,209
|
|
2
|
-
jarvis/__init__.py,sha256=ArINt8uI8UveWy3H6iPntzn05IR-PEq6P7qb8dzmPjc,49
|
|
3
|
-
jarvis/agent.py,sha256=YdtSBqwGl8xKN9xWIqYcAgxsLmXKyXzLcJ1D-Oie9fE,5536
|
|
4
|
-
jarvis/main.py,sha256=egbfAhkHUGHI5J3j5ZMwb9EgOXE7ikJef-4lqFj0-mA,6063
|
|
5
|
-
jarvis/models.py,sha256=NWXMsgnw6AHkfk22tvmGOjcyVhC74Us-t3T6rUF4R20,4186
|
|
6
|
-
jarvis/utils.py,sha256=-5tugkGABZdi2QXVStVtCQfag9CRTfCsGUvReitmHUM,3816
|
|
7
|
-
jarvis/zte_llm.py,sha256=ygUeGd8WGm0qrnkt5TrCLnaf5ZFZ0tdfwrA7nrByt4g,4504
|
|
8
|
-
jarvis/__pycache__/__init__.cpython-313.pyc,sha256=viNe2ZOgBWfBtJpzh5J0oAhQphAwJi4m2ogxgBgCt6s,208
|
|
9
|
-
jarvis/__pycache__/agent.cpython-313.pyc,sha256=7Ae1sOwF6W2HCGjzDToWdCOYFiS47EUqDZVCz2OxH9Q,7125
|
|
10
|
-
jarvis/__pycache__/main.cpython-313.pyc,sha256=lNKrL5HZQahMGpv5cOVriWZoNOScMWRk_toYD7X-Xeo,7444
|
|
11
|
-
jarvis/__pycache__/models.cpython-313.pyc,sha256=fot2VOV0lgODg4b_WuD-kkq-g7uZGLuZlYXiljlW13U,6350
|
|
12
|
-
jarvis/__pycache__/tools.cpython-313.pyc,sha256=lAD4LrnnWzNZQmHXGfZ_2l7oskOpr2_2OC-gdFhxQY8,33933
|
|
13
|
-
jarvis/__pycache__/utils.cpython-313.pyc,sha256=m9l4R4U1vCG2WkXXNWCTbSASRiS6tWYEWK8pu29EtY4,7175
|
|
14
|
-
jarvis/__pycache__/zte_llm.cpython-313.pyc,sha256=PcS-P2H96EyelWcPleCIcu0lGYYoLrdi9VSZgg2cooA,5340
|
|
15
|
-
jarvis/tools/__init__.py,sha256=NZqKPfIbBxeM5FOrN1ssQQ4S9gVXNCSVXa3ov73AyEk,356
|
|
16
|
-
jarvis/tools/base.py,sha256=I_XIwxb6hCH82qCVPESbDNC93Dj0G3KVSZRXSh6mHIM,6516
|
|
17
|
-
jarvis/tools/file_ops.py,sha256=05Vc4u-NGMjLD15WI52eL_nt_RyYt-Z_cXJnnBepf-c,3781
|
|
18
|
-
jarvis/tools/python_script.py,sha256=_eK8LqNs-Mz50zdcgwbjdd8-qAeOl6kJ_qRDvWawGMw,5006
|
|
19
|
-
jarvis/tools/search.py,sha256=dyJmeP_s2tWv5KQejOl-TuVF12B6SXViiXEyTemD1Wo,1412
|
|
20
|
-
jarvis/tools/shell.py,sha256=VhEqEdoUGIRW6CT6F0YNMAlzJxpHcsKS9hSS0VC3ezw,2644
|
|
21
|
-
jarvis/tools/sub_agent.py,sha256=vC495JBAEMgHbAkHzGlYhIPA5scKekwhy1RViNcwqy8,2683
|
|
22
|
-
jarvis/tools/webpage.py,sha256=UTEomu5j7jbOw8c5az2jsjv5E7LeokWKj1QahvZO7xc,3077
|
|
23
|
-
jarvis/tools/__pycache__/__init__.cpython-313.pyc,sha256=Qng3CpxPy9R_1hTjSSr_qLXHtlI8GneyYX6JHwUtmHE,642
|
|
24
|
-
jarvis/tools/__pycache__/base.cpython-313.pyc,sha256=wXXQs94_MAEuHVhFx80q_IgWBRuo1I4Dc7wz3G9ZMo4,8544
|
|
25
|
-
jarvis/tools/__pycache__/file_ops.cpython-313.pyc,sha256=bawv11xhWSj5wCtW0QeJLI-InhUBUXaSkogq6rZzvTQ,3636
|
|
26
|
-
jarvis/tools/__pycache__/python_script.cpython-313.pyc,sha256=8JpryqTovEiTvBlWAK1KjZmPvHUuPc9GT9rTXBEQoJc,6693
|
|
27
|
-
jarvis/tools/__pycache__/rag.cpython-313.pyc,sha256=JH6-PSZRMKAvTZqCwlRXJGClxYXNMs-vetU0q7hBLz0,6064
|
|
28
|
-
jarvis/tools/__pycache__/search.cpython-313.pyc,sha256=VX9zztOwIsPCkYwev0A0XJGyu4Tr0PQcQkbbqx8vfB0,1870
|
|
29
|
-
jarvis/tools/__pycache__/shell.cpython-313.pyc,sha256=UUciwt3nW3mkHrMI7WvCASQ-YLwVx2N68RzQq97nL74,2972
|
|
30
|
-
jarvis/tools/__pycache__/sub_agent.cpython-313.pyc,sha256=p6vgjqdHW7ZAJYaiDh6F39CMndeA3tutbxXB9cwc6xY,3003
|
|
31
|
-
jarvis/tools/__pycache__/user_confirmation.cpython-313.pyc,sha256=wK3Ev10lHSUSRvoYmi7A0GzxYkzU-C4Wfhs5qW_HBqs,2271
|
|
32
|
-
jarvis/tools/__pycache__/user_interaction.cpython-313.pyc,sha256=RuVZ-pmiPBDywY3efgXSfohMAciC1avMGPmBK5qlnew,3305
|
|
33
|
-
jarvis/tools/__pycache__/webpage.cpython-313.pyc,sha256=VcpkaV8IyOOtebedXjn8ybjr8AglU-3-Cs80yzE4FYo,3628
|
|
34
|
-
jarvis_ai_assistant-0.1.5.dist-info/METADATA,sha256=pZCtN2L3EmGQMvpbxA6vED4RHJIWdJqXC2JnaD0whEw,3690
|
|
35
|
-
jarvis_ai_assistant-0.1.5.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
36
|
-
jarvis_ai_assistant-0.1.5.dist-info/entry_points.txt,sha256=iKu7OMfew9dtfGhW71gIMTg4wvafuPqKb4wyQOnMAGU,44
|
|
37
|
-
jarvis_ai_assistant-0.1.5.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
|
|
38
|
-
jarvis_ai_assistant-0.1.5.dist-info/RECORD,,
|
|
File without changes
|
{jarvis_ai_assistant-0.1.5.dist-info → jarvis_ai_assistant-0.1.6.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|