jarvis-ai-assistant 0.1.46__py3-none-any.whl → 0.1.48__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.
- jarvis/__init__.py +1 -1
- jarvis/agent.py +32 -47
- jarvis/main.py +35 -51
- jarvis/models/__init__.py +1 -1
- jarvis/models/ai8.py +58 -88
- jarvis/models/base.py +6 -6
- jarvis/models/kimi.py +80 -171
- jarvis/models/openai.py +23 -43
- jarvis/models/oyi.py +91 -113
- jarvis/models/registry.py +44 -63
- jarvis/tools/__init__.py +1 -1
- jarvis/tools/base.py +2 -2
- jarvis/tools/file_ops.py +15 -19
- jarvis/tools/generator.py +12 -15
- jarvis/tools/methodology.py +20 -20
- jarvis/tools/registry.py +30 -44
- jarvis/tools/shell.py +11 -12
- jarvis/tools/sub_agent.py +2 -1
- jarvis/utils.py +27 -47
- {jarvis_ai_assistant-0.1.46.dist-info → jarvis_ai_assistant-0.1.48.dist-info}/METADATA +1 -1
- jarvis_ai_assistant-0.1.48.dist-info/RECORD +25 -0
- jarvis_ai_assistant-0.1.46.dist-info/RECORD +0 -25
- {jarvis_ai_assistant-0.1.46.dist-info → jarvis_ai_assistant-0.1.48.dist-info}/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.46.dist-info → jarvis_ai_assistant-0.1.48.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.46.dist-info → jarvis_ai_assistant-0.1.48.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.46.dist-info → jarvis_ai_assistant-0.1.48.dist-info}/top_level.txt +0 -0
jarvis/utils.py
CHANGED
@@ -13,25 +13,23 @@ from prompt_toolkit.formatted_text import FormattedText
|
|
13
13
|
# 初始化colorama
|
14
14
|
colorama.init()
|
15
15
|
|
16
|
-
|
17
16
|
class OutputType(Enum):
|
18
17
|
SYSTEM = "system" # AI助手消息
|
19
18
|
CODE = "code" # 代码相关
|
20
19
|
RESULT = "result" # 工具执行结果
|
21
20
|
ERROR = "error" # 错误信息
|
22
21
|
INFO = "info" # 系统提示
|
23
|
-
PLANNING = "planning"
|
24
|
-
PROGRESS = "progress"
|
22
|
+
PLANNING = "planning" # 任务规划
|
23
|
+
PROGRESS = "progress" # 执行进度
|
25
24
|
SUCCESS = "success" # 成功信息
|
26
25
|
WARNING = "warning" # 警告信息
|
27
26
|
DEBUG = "debug" # 调试信息
|
28
27
|
USER = "user" # 用户输入
|
29
28
|
TOOL = "tool" # 工具调用
|
30
29
|
|
31
|
-
|
32
30
|
class PrettyOutput:
|
33
31
|
"""美化输出类"""
|
34
|
-
|
32
|
+
|
35
33
|
# 颜色方案 - 只使用前景色
|
36
34
|
COLORS = {
|
37
35
|
OutputType.SYSTEM: Fore.CYAN, # 青色 - AI助手
|
@@ -39,7 +37,7 @@ class PrettyOutput:
|
|
39
37
|
OutputType.RESULT: Fore.BLUE, # 蓝色 - 结果
|
40
38
|
OutputType.ERROR: Fore.RED, # 红色 - 错误
|
41
39
|
OutputType.INFO: Fore.YELLOW, # 黄色 - 提示
|
42
|
-
OutputType.PLANNING: Fore.MAGENTA,
|
40
|
+
OutputType.PLANNING: Fore.MAGENTA, # 紫色 - 规划
|
43
41
|
OutputType.PROGRESS: Fore.WHITE, # 白色 - 进度
|
44
42
|
OutputType.SUCCESS: Fore.GREEN, # 绿色 - 成功
|
45
43
|
OutputType.WARNING: Fore.YELLOW, # 黄色 - 警告
|
@@ -47,7 +45,7 @@ class PrettyOutput:
|
|
47
45
|
OutputType.USER: Fore.GREEN, # 绿色 - 用户
|
48
46
|
OutputType.TOOL: Fore.YELLOW, # 黄色 - 工具
|
49
47
|
}
|
50
|
-
|
48
|
+
|
51
49
|
# 图标方案
|
52
50
|
ICONS = {
|
53
51
|
OutputType.SYSTEM: "🤖", # 机器人 - AI助手
|
@@ -63,7 +61,7 @@ class PrettyOutput:
|
|
63
61
|
OutputType.USER: "👤", # 用户 - 用户
|
64
62
|
OutputType.TOOL: "🔧", # 扳手 - 工具
|
65
63
|
}
|
66
|
-
|
64
|
+
|
67
65
|
# 前缀方案
|
68
66
|
PREFIXES = {
|
69
67
|
OutputType.SYSTEM: "Assistant",
|
@@ -81,20 +79,18 @@ class PrettyOutput:
|
|
81
79
|
}
|
82
80
|
|
83
81
|
@staticmethod
|
84
|
-
def format(text: str, output_type: OutputType,
|
85
|
-
timestamp: bool = True) -> str:
|
82
|
+
def format(text: str, output_type: OutputType, timestamp: bool = True) -> str:
|
86
83
|
"""格式化输出文本"""
|
87
84
|
color = PrettyOutput.COLORS.get(output_type, "")
|
88
85
|
icon = PrettyOutput.ICONS.get(output_type, "")
|
89
86
|
prefix = PrettyOutput.PREFIXES.get(output_type, "")
|
90
|
-
|
87
|
+
|
91
88
|
# 添加时间戳 - 使用白色
|
92
89
|
time_str = f"{Fore.WHITE}[{datetime.now().strftime('%H:%M:%S')}]{ColoramaStyle.RESET_ALL} " if timestamp else ""
|
93
|
-
|
90
|
+
|
94
91
|
# 格式化输出
|
95
|
-
formatted_text = f"{time_str}{color}{icon} {prefix}: {text}{
|
96
|
-
|
97
|
-
|
92
|
+
formatted_text = f"{time_str}{color}{icon} {prefix}: {text}{ColoramaStyle.RESET_ALL}"
|
93
|
+
|
98
94
|
return formatted_text
|
99
95
|
|
100
96
|
@staticmethod
|
@@ -103,10 +99,7 @@ class PrettyOutput:
|
|
103
99
|
print(PrettyOutput.format(text, output_type, timestamp))
|
104
100
|
if output_type == OutputType.ERROR:
|
105
101
|
import traceback
|
106
|
-
PrettyOutput.print(
|
107
|
-
f"错误追踪: {
|
108
|
-
traceback.format_exc()}",
|
109
|
-
OutputType.INFO)
|
102
|
+
PrettyOutput.print(f"错误追踪: {traceback.format_exc()}", OutputType.INFO)
|
110
103
|
|
111
104
|
@staticmethod
|
112
105
|
def section(title: str, output_type: OutputType = OutputType.INFO):
|
@@ -114,11 +107,7 @@ class PrettyOutput:
|
|
114
107
|
width = 60
|
115
108
|
color = PrettyOutput.COLORS.get(output_type, "")
|
116
109
|
print(f"\n{color}" + "=" * width + f"{ColoramaStyle.RESET_ALL}")
|
117
|
-
PrettyOutput.print(
|
118
|
-
title.center(
|
119
|
-
width - 10),
|
120
|
-
output_type,
|
121
|
-
timestamp=False)
|
110
|
+
PrettyOutput.print(title.center(width - 10), output_type, timestamp=False)
|
122
111
|
print(f"{color}" + "=" * width + f"{ColoramaStyle.RESET_ALL}\n")
|
123
112
|
|
124
113
|
@staticmethod
|
@@ -134,19 +123,18 @@ class PrettyOutput:
|
|
134
123
|
sys.stdout.write("\n")
|
135
124
|
sys.stdout.flush()
|
136
125
|
|
137
|
-
|
138
126
|
def get_multiline_input(tip: str) -> str:
|
139
127
|
"""获取多行输入,支持方向键、历史记录等功能"""
|
140
128
|
PrettyOutput.print(tip + "\n", OutputType.INFO)
|
141
|
-
|
129
|
+
|
142
130
|
# 创建输入会话,启用历史记录
|
143
131
|
session = PromptSession(history=None) # 使用默认历史记录
|
144
|
-
|
132
|
+
|
145
133
|
# 定义提示符样式
|
146
134
|
style = PromptStyle.from_dict({
|
147
135
|
'prompt': 'ansicyan',
|
148
136
|
})
|
149
|
-
|
137
|
+
|
150
138
|
lines = []
|
151
139
|
try:
|
152
140
|
while True:
|
@@ -154,32 +142,31 @@ def get_multiline_input(tip: str) -> str:
|
|
154
142
|
prompt = FormattedText([
|
155
143
|
('class:prompt', '... ' if lines else '>>> ')
|
156
144
|
])
|
157
|
-
|
145
|
+
|
158
146
|
# 获取输入
|
159
147
|
line = session.prompt(
|
160
148
|
prompt,
|
161
149
|
style=style,
|
162
150
|
).strip()
|
163
|
-
|
151
|
+
|
164
152
|
# 空行处理
|
165
153
|
if not line:
|
166
154
|
if not lines: # 第一行就输入空行
|
167
155
|
return ""
|
168
156
|
break # 结束多行输入
|
169
|
-
|
157
|
+
|
170
158
|
lines.append(line)
|
171
|
-
|
159
|
+
|
172
160
|
except KeyboardInterrupt:
|
173
161
|
PrettyOutput.print("\n输入已取消", OutputType.ERROR)
|
174
162
|
return "__interrupt__"
|
175
|
-
|
163
|
+
|
176
164
|
return "\n".join(lines)
|
177
165
|
|
178
|
-
|
179
166
|
def load_env_from_file():
|
180
167
|
"""从~/.jarvis_env加载环境变量"""
|
181
168
|
env_file = Path.home() / ".jarvis_env"
|
182
|
-
|
169
|
+
|
183
170
|
if env_file.exists():
|
184
171
|
try:
|
185
172
|
with open(env_file, "r", encoding="utf-8") as f:
|
@@ -188,29 +175,22 @@ def load_env_from_file():
|
|
188
175
|
if line and not line.startswith("#"):
|
189
176
|
try:
|
190
177
|
key, value = line.split("=", 1)
|
191
|
-
os.environ[key.strip()] = value.strip().strip(
|
192
|
-
"'").strip('"')
|
178
|
+
os.environ[key.strip()] = value.strip().strip("'").strip('"')
|
193
179
|
except ValueError:
|
194
180
|
continue
|
195
181
|
except Exception as e:
|
196
|
-
PrettyOutput.print(
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
182
|
+
PrettyOutput.print(f"Warning: Failed to read ~/.jarvis_env: {e}", OutputType.WARNING)
|
183
|
+
|
184
|
+
|
201
185
|
def while_success(func, sleep_time: float = 0.1):
|
202
186
|
while True:
|
203
187
|
try:
|
204
188
|
return func()
|
205
189
|
except Exception as e:
|
206
|
-
PrettyOutput.print(
|
207
|
-
f"执行失败: {
|
208
|
-
str(e)}, {sleep_time}s后重试...",
|
209
|
-
OutputType.ERROR)
|
190
|
+
PrettyOutput.print(f"执行失败: {str(e)}, {sleep_time}s后重试...", OutputType.ERROR)
|
210
191
|
time.sleep(sleep_time)
|
211
192
|
continue
|
212
193
|
|
213
|
-
|
214
194
|
def while_true(func, sleep_time: float = 0.1):
|
215
195
|
"""循环执行函数,直到函数返回True"""
|
216
196
|
while True:
|
@@ -0,0 +1,25 @@
|
|
1
|
+
jarvis/__init__.py,sha256=5Kd0blvGwS59SYMJr_z-vMkb9qnFktJZho8oQ1uSNOw,50
|
2
|
+
jarvis/agent.py,sha256=5GmC9iAOerTR4JoxzrfgLSspoz6qRm1E6xEIWLTR2OI,12222
|
3
|
+
jarvis/main.py,sha256=VIqMYnqNrmVcnO5YC-Tc-ATVBt8IlqIcXHjZvHmyCFs,6272
|
4
|
+
jarvis/utils.py,sha256=JlkuC9RtspXH2VWDmj9nR0vnb8ie1gIsKc4vC7WRco8,7321
|
5
|
+
jarvis/models/__init__.py,sha256=mrOt67nselz_H1gX9wdAO4y2DY5WPXzABqJbr5Des8k,63
|
6
|
+
jarvis/models/ai8.py,sha256=9i7n_-TPbvq0AaRILs9ERQ7Vy5tDyoibXkiPsJvwQio,12520
|
7
|
+
jarvis/models/base.py,sha256=eeNJJbv9ikPVTtV_E7mgW8LZzVgjQ-OzxlHF6slYrHw,1237
|
8
|
+
jarvis/models/kimi.py,sha256=N0bPQ1ugx0RwjR96jLchmOPvCmws-fXyA0mnOAdo2k4,17161
|
9
|
+
jarvis/models/openai.py,sha256=pB7AaZuorHlmudTPaUnEbFOyl51Fy6uhU9KQBm98Ov8,4156
|
10
|
+
jarvis/models/oyi.py,sha256=4_sppGOLS3rucBHinhzjLhSh_6rJKIgLu9h6trHIOGM,14900
|
11
|
+
jarvis/models/registry.py,sha256=iVBjN9ImEvGHcz8WR-z8pPMJQZI907o_nccVOFANhak,7951
|
12
|
+
jarvis/tools/__init__.py,sha256=Kj1bKj34lwRDKMKHLOrLyQElf2lHbqA2tDgP359eaDo,71
|
13
|
+
jarvis/tools/base.py,sha256=EGRGbdfbLXDLwtyoWdvp9rlxNX7bzc20t0Vc2VkwIEY,652
|
14
|
+
jarvis/tools/file_ops.py,sha256=h8g0eT9UvlJf4kt0DLXvdSsjcPj7x19lxWdDApeDfpg,3842
|
15
|
+
jarvis/tools/generator.py,sha256=vVP3eN5cCDpRXf_fn0skETkPXAW1XZFWx9pt2_ahK48,5999
|
16
|
+
jarvis/tools/methodology.py,sha256=G3cOaHTMujGZBhDLhQEqyCV2NISizO3MXRuho1KfI6Y,5223
|
17
|
+
jarvis/tools/registry.py,sha256=NbH7A4A2lyN2IoyZGFwa5Ghed2dpzbJWCAd1Dg95WBI,7183
|
18
|
+
jarvis/tools/shell.py,sha256=UPKshPyOaUwTngresUw-ot1jHjQIb4wCY5nkJqa38lU,2520
|
19
|
+
jarvis/tools/sub_agent.py,sha256=rEtAmSVY2ZjFOZEKr5m5wpACOQIiM9Zr_3dT92FhXYU,2621
|
20
|
+
jarvis_ai_assistant-0.1.48.dist-info/LICENSE,sha256=AGgVgQmTqFvaztRtCAXsAMryUymB18gZif7_l2e1XOg,1063
|
21
|
+
jarvis_ai_assistant-0.1.48.dist-info/METADATA,sha256=aa15iAnYAREOwcLJP3tTpjdC5JAmXzouiqXIwKrO83g,10015
|
22
|
+
jarvis_ai_assistant-0.1.48.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
23
|
+
jarvis_ai_assistant-0.1.48.dist-info/entry_points.txt,sha256=iKu7OMfew9dtfGhW71gIMTg4wvafuPqKb4wyQOnMAGU,44
|
24
|
+
jarvis_ai_assistant-0.1.48.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
|
25
|
+
jarvis_ai_assistant-0.1.48.dist-info/RECORD,,
|
@@ -1,25 +0,0 @@
|
|
1
|
-
jarvis/__init__.py,sha256=HiOdrOkDAfqQOFrFVCKd96C_U-XMAI6wE1pX3GjE8Yk,50
|
2
|
-
jarvis/agent.py,sha256=omq58Bo4u-oEwpOuHnZTTE_3JeXG5Ow-1bhhJt6RlBs,12339
|
3
|
-
jarvis/main.py,sha256=Zd1aoq7EXNZMZrZl6n-2OB8UIC202sIPcQEJGuJJkpE,6087
|
4
|
-
jarvis/utils.py,sha256=CQo_V7qA_oGVvR4RrbfL9cd98lXzbE9tp1EB9S0ppIc,7469
|
5
|
-
jarvis/models/__init__.py,sha256=8uX1dj3YLL-i2Q5AIz1V0GtrROb6BJmRRRzxrexj-aE,59
|
6
|
-
jarvis/models/ai8.py,sha256=LEgtAZ7SZj94RoUuNlclXes_u-eh_vx5pxZ8kwSQG78,12658
|
7
|
-
jarvis/models/base.py,sha256=Drotowk47m3s30BPYspEL1MZlo2MyCaLev0v-oaqszY,1211
|
8
|
-
jarvis/models/kimi.py,sha256=ghL1g2iq9jnUNBB1flyV2wd0JKs7i7q0CpKr2-6kF3U,18570
|
9
|
-
jarvis/models/openai.py,sha256=vh_4J7imSlqWi0J8xBrVhv6mpPXj6UqvD_xVlKayiXg,4330
|
10
|
-
jarvis/models/oyi.py,sha256=pi4wD-TMz2Q6olkwQ5Vw5GCPKwL-KyTR8SNbrXiXvuo,14513
|
11
|
-
jarvis/models/registry.py,sha256=RgzbCLJM6-FlQYuhaXnEmQASshur3FR5u0z3UBJtBgQ,8137
|
12
|
-
jarvis/tools/__init__.py,sha256=ZXnUzaenBd2yX6xRI7T7tOjG7Hv2PjzcMva455VStgA,70
|
13
|
-
jarvis/tools/base.py,sha256=UnYlIpkKLAZDVxLyIZy2imHLSqF5xQXAVg5sKrQgTFw,668
|
14
|
-
jarvis/tools/file_ops.py,sha256=tuyeEg9gGcUBXiCL6WwO5IVtl2TRaNRJn1VYBkquFTs,3756
|
15
|
-
jarvis/tools/generator.py,sha256=fKTx6KbCPZAo2LZixWV51uZZWwVSj_UmDo1b8Lq5Y-c,5945
|
16
|
-
jarvis/tools/methodology.py,sha256=hpejF0ElrrMaCg90WBOrVRvCekfYkyiiQbAH13kC1ys,4995
|
17
|
-
jarvis/tools/registry.py,sha256=eMRW0geKeNsaYhGBQB73bbRBkQMGUDORWy69rmjs3Hk,7201
|
18
|
-
jarvis/tools/shell.py,sha256=NixHMaM2yF4XcDXxsgD3tAtdO1rZ3PxS_0_LlzjCpd8,2457
|
19
|
-
jarvis/tools/sub_agent.py,sha256=m0H6dWIeI0VeK2cNETfI0uqWxlot8f70mW4o9aBMXYo,2620
|
20
|
-
jarvis_ai_assistant-0.1.46.dist-info/LICENSE,sha256=AGgVgQmTqFvaztRtCAXsAMryUymB18gZif7_l2e1XOg,1063
|
21
|
-
jarvis_ai_assistant-0.1.46.dist-info/METADATA,sha256=DLFgc6On2RrSRKOtXgFuefCkMuxgsya7ZvWP0TmcJO0,10015
|
22
|
-
jarvis_ai_assistant-0.1.46.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
23
|
-
jarvis_ai_assistant-0.1.46.dist-info/entry_points.txt,sha256=iKu7OMfew9dtfGhW71gIMTg4wvafuPqKb4wyQOnMAGU,44
|
24
|
-
jarvis_ai_assistant-0.1.46.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
|
25
|
-
jarvis_ai_assistant-0.1.46.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{jarvis_ai_assistant-0.1.46.dist-info → jarvis_ai_assistant-0.1.48.dist-info}/entry_points.txt
RENAMED
File without changes
|
File without changes
|