jarvis-ai-assistant 0.3.30__py3-none-any.whl → 0.7.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.
- jarvis/__init__.py +1 -1
- jarvis/jarvis_agent/__init__.py +458 -152
- jarvis/jarvis_agent/agent_manager.py +17 -13
- jarvis/jarvis_agent/builtin_input_handler.py +2 -6
- jarvis/jarvis_agent/config_editor.py +2 -7
- jarvis/jarvis_agent/event_bus.py +82 -12
- jarvis/jarvis_agent/file_context_handler.py +329 -0
- jarvis/jarvis_agent/file_methodology_manager.py +3 -4
- jarvis/jarvis_agent/jarvis.py +628 -55
- jarvis/jarvis_agent/language_extractors/__init__.py +57 -0
- jarvis/jarvis_agent/language_extractors/c_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/cpp_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/go_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/java_extractor.py +84 -0
- jarvis/jarvis_agent/language_extractors/javascript_extractor.py +79 -0
- jarvis/jarvis_agent/language_extractors/python_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/rust_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/typescript_extractor.py +84 -0
- jarvis/jarvis_agent/language_support_info.py +486 -0
- jarvis/jarvis_agent/main.py +34 -10
- jarvis/jarvis_agent/memory_manager.py +7 -16
- jarvis/jarvis_agent/methodology_share_manager.py +10 -16
- jarvis/jarvis_agent/prompt_manager.py +1 -1
- jarvis/jarvis_agent/prompts.py +193 -171
- jarvis/jarvis_agent/protocols.py +8 -12
- jarvis/jarvis_agent/run_loop.py +105 -9
- jarvis/jarvis_agent/session_manager.py +2 -3
- jarvis/jarvis_agent/share_manager.py +20 -22
- jarvis/jarvis_agent/shell_input_handler.py +1 -2
- jarvis/jarvis_agent/stdio_redirect.py +295 -0
- jarvis/jarvis_agent/task_analyzer.py +31 -6
- jarvis/jarvis_agent/task_manager.py +11 -27
- jarvis/jarvis_agent/tool_executor.py +2 -3
- jarvis/jarvis_agent/tool_share_manager.py +12 -24
- jarvis/jarvis_agent/utils.py +5 -1
- jarvis/jarvis_agent/web_bridge.py +189 -0
- jarvis/jarvis_agent/web_output_sink.py +53 -0
- jarvis/jarvis_agent/web_server.py +786 -0
- jarvis/jarvis_c2rust/__init__.py +26 -0
- jarvis/jarvis_c2rust/cli.py +575 -0
- jarvis/jarvis_c2rust/collector.py +250 -0
- jarvis/jarvis_c2rust/constants.py +26 -0
- jarvis/jarvis_c2rust/library_replacer.py +1254 -0
- jarvis/jarvis_c2rust/llm_module_agent.py +1272 -0
- jarvis/jarvis_c2rust/loaders.py +207 -0
- jarvis/jarvis_c2rust/models.py +28 -0
- jarvis/jarvis_c2rust/optimizer.py +2157 -0
- jarvis/jarvis_c2rust/scanner.py +1681 -0
- jarvis/jarvis_c2rust/transpiler.py +2983 -0
- jarvis/jarvis_c2rust/utils.py +385 -0
- jarvis/jarvis_code_agent/build_validation_config.py +132 -0
- jarvis/jarvis_code_agent/code_agent.py +1371 -220
- jarvis/jarvis_code_agent/code_analyzer/__init__.py +65 -0
- jarvis/jarvis_code_agent/code_analyzer/base_language.py +74 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/__init__.py +44 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/base.py +106 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/cmake.py +74 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/detector.py +125 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/fallback.py +72 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/go.py +70 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/java_gradle.py +53 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/java_maven.py +47 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/makefile.py +61 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/nodejs.py +110 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/python.py +154 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/rust.py +110 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/validator.py +153 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator.py +43 -0
- jarvis/jarvis_code_agent/code_analyzer/context_manager.py +648 -0
- jarvis/jarvis_code_agent/code_analyzer/context_recommender.py +18 -0
- jarvis/jarvis_code_agent/code_analyzer/dependency_analyzer.py +132 -0
- jarvis/jarvis_code_agent/code_analyzer/file_ignore.py +330 -0
- jarvis/jarvis_code_agent/code_analyzer/impact_analyzer.py +781 -0
- jarvis/jarvis_code_agent/code_analyzer/language_registry.py +185 -0
- jarvis/jarvis_code_agent/code_analyzer/language_support.py +110 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/__init__.py +49 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/c_cpp_language.py +299 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/go_language.py +215 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/java_language.py +212 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/javascript_language.py +254 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/python_language.py +269 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/rust_language.py +281 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/typescript_language.py +280 -0
- jarvis/jarvis_code_agent/code_analyzer/llm_context_recommender.py +605 -0
- jarvis/jarvis_code_agent/code_analyzer/structured_code.py +556 -0
- jarvis/jarvis_code_agent/code_analyzer/symbol_extractor.py +252 -0
- jarvis/jarvis_code_agent/code_analyzer/tree_sitter_extractor.py +58 -0
- jarvis/jarvis_code_agent/lint.py +501 -8
- jarvis/jarvis_code_agent/utils.py +141 -0
- jarvis/jarvis_code_analysis/code_review.py +493 -584
- jarvis/jarvis_data/config_schema.json +128 -12
- jarvis/jarvis_git_squash/main.py +4 -5
- jarvis/jarvis_git_utils/git_commiter.py +82 -75
- jarvis/jarvis_mcp/sse_mcp_client.py +22 -29
- jarvis/jarvis_mcp/stdio_mcp_client.py +12 -13
- jarvis/jarvis_mcp/streamable_mcp_client.py +15 -14
- jarvis/jarvis_memory_organizer/memory_organizer.py +55 -74
- jarvis/jarvis_methodology/main.py +32 -48
- jarvis/jarvis_multi_agent/__init__.py +287 -55
- jarvis/jarvis_multi_agent/main.py +36 -4
- jarvis/jarvis_platform/base.py +524 -202
- jarvis/jarvis_platform/human.py +7 -8
- jarvis/jarvis_platform/kimi.py +30 -36
- jarvis/jarvis_platform/openai.py +88 -25
- jarvis/jarvis_platform/registry.py +26 -10
- jarvis/jarvis_platform/tongyi.py +24 -25
- jarvis/jarvis_platform/yuanbao.py +32 -43
- jarvis/jarvis_platform_manager/main.py +66 -77
- jarvis/jarvis_platform_manager/service.py +8 -13
- jarvis/jarvis_rag/cli.py +53 -55
- jarvis/jarvis_rag/embedding_manager.py +13 -18
- jarvis/jarvis_rag/llm_interface.py +8 -9
- jarvis/jarvis_rag/query_rewriter.py +10 -21
- jarvis/jarvis_rag/rag_pipeline.py +24 -27
- jarvis/jarvis_rag/reranker.py +4 -5
- jarvis/jarvis_rag/retriever.py +28 -30
- jarvis/jarvis_sec/__init__.py +305 -0
- jarvis/jarvis_sec/agents.py +143 -0
- jarvis/jarvis_sec/analysis.py +276 -0
- jarvis/jarvis_sec/checkers/__init__.py +32 -0
- jarvis/jarvis_sec/checkers/c_checker.py +2680 -0
- jarvis/jarvis_sec/checkers/rust_checker.py +1108 -0
- jarvis/jarvis_sec/cli.py +139 -0
- jarvis/jarvis_sec/clustering.py +1439 -0
- jarvis/jarvis_sec/file_manager.py +427 -0
- jarvis/jarvis_sec/parsers.py +73 -0
- jarvis/jarvis_sec/prompts.py +268 -0
- jarvis/jarvis_sec/report.py +336 -0
- jarvis/jarvis_sec/review.py +453 -0
- jarvis/jarvis_sec/status.py +264 -0
- jarvis/jarvis_sec/types.py +20 -0
- jarvis/jarvis_sec/utils.py +499 -0
- jarvis/jarvis_sec/verification.py +848 -0
- jarvis/jarvis_sec/workflow.py +226 -0
- jarvis/jarvis_smart_shell/main.py +38 -87
- jarvis/jarvis_stats/cli.py +2 -2
- jarvis/jarvis_stats/stats.py +8 -8
- jarvis/jarvis_stats/storage.py +15 -21
- jarvis/jarvis_stats/visualizer.py +1 -1
- jarvis/jarvis_tools/clear_memory.py +3 -20
- jarvis/jarvis_tools/cli/main.py +21 -23
- jarvis/jarvis_tools/edit_file.py +1019 -132
- jarvis/jarvis_tools/execute_script.py +83 -25
- jarvis/jarvis_tools/file_analyzer.py +6 -9
- jarvis/jarvis_tools/generate_new_tool.py +14 -21
- jarvis/jarvis_tools/lsp_client.py +1552 -0
- jarvis/jarvis_tools/methodology.py +2 -3
- jarvis/jarvis_tools/read_code.py +1736 -35
- jarvis/jarvis_tools/read_symbols.py +140 -0
- jarvis/jarvis_tools/read_webpage.py +12 -13
- jarvis/jarvis_tools/registry.py +427 -200
- jarvis/jarvis_tools/retrieve_memory.py +20 -19
- jarvis/jarvis_tools/rewrite_file.py +72 -158
- jarvis/jarvis_tools/save_memory.py +3 -15
- jarvis/jarvis_tools/search_web.py +18 -18
- jarvis/jarvis_tools/sub_agent.py +36 -43
- jarvis/jarvis_tools/sub_code_agent.py +25 -26
- jarvis/jarvis_tools/virtual_tty.py +55 -33
- jarvis/jarvis_utils/clipboard.py +7 -10
- jarvis/jarvis_utils/config.py +232 -45
- jarvis/jarvis_utils/embedding.py +8 -5
- jarvis/jarvis_utils/fzf.py +8 -8
- jarvis/jarvis_utils/git_utils.py +225 -36
- jarvis/jarvis_utils/globals.py +3 -3
- jarvis/jarvis_utils/http.py +1 -1
- jarvis/jarvis_utils/input.py +99 -48
- jarvis/jarvis_utils/jsonnet_compat.py +465 -0
- jarvis/jarvis_utils/methodology.py +52 -48
- jarvis/jarvis_utils/utils.py +819 -491
- jarvis_ai_assistant-0.7.6.dist-info/METADATA +600 -0
- jarvis_ai_assistant-0.7.6.dist-info/RECORD +218 -0
- {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/entry_points.txt +4 -0
- jarvis/jarvis_agent/config.py +0 -92
- jarvis/jarvis_agent/edit_file_handler.py +0 -296
- jarvis/jarvis_platform/ai8.py +0 -332
- jarvis/jarvis_tools/ask_user.py +0 -54
- jarvis_ai_assistant-0.3.30.dist-info/METADATA +0 -381
- jarvis_ai_assistant-0.3.30.dist-info/RECORD +0 -137
- {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/licenses/LICENSE +0 -0
- {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/top_level.txt +0 -0
|
@@ -15,7 +15,6 @@ from jarvis.jarvis_utils.config import (
|
|
|
15
15
|
|
|
16
16
|
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
17
17
|
from jarvis.jarvis_utils.input import get_multiline_input, get_single_line_input
|
|
18
|
-
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
19
18
|
from jarvis.jarvis_utils.utils import init_env
|
|
20
19
|
from jarvis.jarvis_platform_manager.service import start_service
|
|
21
20
|
from jarvis.jarvis_utils.fzf import fzf_select
|
|
@@ -33,7 +32,7 @@ def list_platforms(
|
|
|
33
32
|
registry = PlatformRegistry.get_global_platform_registry()
|
|
34
33
|
platform_names = [platform] if platform else registry.get_available_platforms()
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
print("✅ Supported platforms and models")
|
|
37
36
|
|
|
38
37
|
for platform_name in platform_names:
|
|
39
38
|
try:
|
|
@@ -46,7 +45,7 @@ def list_platforms(
|
|
|
46
45
|
models = platform_instance.get_model_list()
|
|
47
46
|
|
|
48
47
|
# Print platform name
|
|
49
|
-
|
|
48
|
+
print(f"✅ {platform_name}")
|
|
50
49
|
|
|
51
50
|
output = ""
|
|
52
51
|
# Print model list
|
|
@@ -56,12 +55,12 @@ def list_platforms(
|
|
|
56
55
|
output += f" • {model_name} - {description}\n"
|
|
57
56
|
else:
|
|
58
57
|
output += f" • {model_name}\n"
|
|
59
|
-
|
|
58
|
+
print(f"✅ {output}")
|
|
60
59
|
else:
|
|
61
|
-
|
|
60
|
+
print("⚠️ • 没有可用的模型信息")
|
|
62
61
|
|
|
63
62
|
except Exception:
|
|
64
|
-
|
|
63
|
+
print(f"⚠️ 创建 {platform_name} 平台失败")
|
|
65
64
|
|
|
66
65
|
|
|
67
66
|
def chat_with_model(
|
|
@@ -84,7 +83,7 @@ def chat_with_model(
|
|
|
84
83
|
platform.set_model_name(model_name)
|
|
85
84
|
|
|
86
85
|
if not platform:
|
|
87
|
-
|
|
86
|
+
print(f"⚠️ 创建平台 {platform_name} 失败")
|
|
88
87
|
return
|
|
89
88
|
|
|
90
89
|
try:
|
|
@@ -93,14 +92,11 @@ def chat_with_model(
|
|
|
93
92
|
if system_prompt:
|
|
94
93
|
platform.set_system_prompt(system_prompt)
|
|
95
94
|
platform.set_suppress_output(False)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
PrettyOutput.print(
|
|
100
|
-
"可用命令: /bye - 退出, /clear - 清除会话, /upload - 上传文件, "
|
|
95
|
+
print(f"✅ 连接到 {platform_name} 平台 {model_name} 模型")
|
|
96
|
+
print(
|
|
97
|
+
"ℹ️ 可用命令: /bye - 退出, /clear - 清除会话, /upload - 上传文件, "
|
|
101
98
|
"/shell - 执行命令, /save - 保存对话, /saveall - 保存所有对话, "
|
|
102
|
-
"/save_session - 保存会话状态, /load_session - 加载会话状态"
|
|
103
|
-
OutputType.INFO,
|
|
99
|
+
"/save_session - 保存会话状态, /load_session - 加载会话状态"
|
|
104
100
|
)
|
|
105
101
|
|
|
106
102
|
# Start conversation loop
|
|
@@ -110,12 +106,12 @@ def chat_with_model(
|
|
|
110
106
|
|
|
111
107
|
# Check if input is cancelled
|
|
112
108
|
if user_input.strip() == "/bye":
|
|
113
|
-
|
|
109
|
+
print("✅ 再见!")
|
|
114
110
|
break
|
|
115
111
|
|
|
116
112
|
# Check if input is empty
|
|
117
113
|
if not user_input.strip():
|
|
118
|
-
|
|
114
|
+
print("ℹ️ 检测到空输入,退出聊天")
|
|
119
115
|
break
|
|
120
116
|
|
|
121
117
|
# Parse command and arguments
|
|
@@ -130,9 +126,9 @@ def chat_with_model(
|
|
|
130
126
|
platform.reset() # type: ignore[no-untyped-call] # type: ignore[no-untyped-call] # type: ignore[no-untyped-call]
|
|
131
127
|
platform.set_model_name(model_name) # Reinitialize session
|
|
132
128
|
conversation_history = [] # 重置对话记录
|
|
133
|
-
|
|
129
|
+
print("✅ 会话已清除")
|
|
134
130
|
except Exception as exc:
|
|
135
|
-
|
|
131
|
+
print(f"❌ 清除会话失败: {str(exc)}")
|
|
136
132
|
continue
|
|
137
133
|
|
|
138
134
|
# Check if it is an upload command
|
|
@@ -140,9 +136,8 @@ def chat_with_model(
|
|
|
140
136
|
try:
|
|
141
137
|
file_path = args
|
|
142
138
|
if not file_path:
|
|
143
|
-
|
|
144
|
-
'请指定要上传的文件路径,例如: /upload /path/to/file 或 /upload "/path/with spaces/file"'
|
|
145
|
-
OutputType.WARNING,
|
|
139
|
+
print(
|
|
140
|
+
'⚠️ 请指定要上传的文件路径,例如: /upload /path/to/file 或 /upload "/path/with spaces/file"'
|
|
146
141
|
)
|
|
147
142
|
continue
|
|
148
143
|
|
|
@@ -153,16 +148,16 @@ def chat_with_model(
|
|
|
153
148
|
file_path = file_path[1:-1]
|
|
154
149
|
|
|
155
150
|
if not platform.support_upload_files():
|
|
156
|
-
|
|
151
|
+
print("❌ 平台不支持上传文件")
|
|
157
152
|
continue
|
|
158
153
|
|
|
159
|
-
|
|
154
|
+
print(f"ℹ️ 正在上传文件: {file_path}")
|
|
160
155
|
if platform.upload_files([file_path]):
|
|
161
|
-
|
|
156
|
+
print("✅ 文件上传成功")
|
|
162
157
|
else:
|
|
163
|
-
|
|
158
|
+
print("❌ 文件上传失败")
|
|
164
159
|
except Exception as exc:
|
|
165
|
-
|
|
160
|
+
print(f"❌ 上传文件失败: {str(exc)}")
|
|
166
161
|
continue
|
|
167
162
|
|
|
168
163
|
# Check if it is a save command
|
|
@@ -170,9 +165,8 @@ def chat_with_model(
|
|
|
170
165
|
try:
|
|
171
166
|
file_path = args
|
|
172
167
|
if not file_path:
|
|
173
|
-
|
|
174
|
-
"请指定保存文件名,例如: /save last_message.txt"
|
|
175
|
-
OutputType.WARNING,
|
|
168
|
+
print(
|
|
169
|
+
"⚠️ 请指定保存文件名,例如: /save last_message.txt"
|
|
176
170
|
)
|
|
177
171
|
continue
|
|
178
172
|
|
|
@@ -187,13 +181,13 @@ def chat_with_model(
|
|
|
187
181
|
with open(file_path, "w", encoding="utf-8") as file_obj:
|
|
188
182
|
last_entry = conversation_history[-1]
|
|
189
183
|
file_obj.write(f"{last_entry['content']}\n")
|
|
190
|
-
|
|
191
|
-
f"最后一条消息内容已保存到 {file_path}"
|
|
184
|
+
print(
|
|
185
|
+
f"✅ 最后一条消息内容已保存到 {file_path}"
|
|
192
186
|
)
|
|
193
187
|
else:
|
|
194
|
-
|
|
188
|
+
print("⚠️ 没有可保存的消息")
|
|
195
189
|
except Exception as exc:
|
|
196
|
-
|
|
190
|
+
print(f"❌ 保存消息失败: {str(exc)}")
|
|
197
191
|
continue
|
|
198
192
|
|
|
199
193
|
# Check if it is a saveall command
|
|
@@ -201,9 +195,8 @@ def chat_with_model(
|
|
|
201
195
|
try:
|
|
202
196
|
file_path = args
|
|
203
197
|
if not file_path:
|
|
204
|
-
|
|
205
|
-
"请指定保存文件名,例如: /saveall all_conversations.txt"
|
|
206
|
-
OutputType.WARNING,
|
|
198
|
+
print(
|
|
199
|
+
"⚠️ 请指定保存文件名,例如: /saveall all_conversations.txt"
|
|
207
200
|
)
|
|
208
201
|
continue
|
|
209
202
|
|
|
@@ -218,12 +211,12 @@ def chat_with_model(
|
|
|
218
211
|
for entry in conversation_history:
|
|
219
212
|
file_obj.write(f"{entry['role']}: {entry['content']}\n\n")
|
|
220
213
|
|
|
221
|
-
|
|
222
|
-
f"所有对话已保存到 {file_path}"
|
|
214
|
+
print(
|
|
215
|
+
f"✅ 所有对话已保存到 {file_path}"
|
|
223
216
|
)
|
|
224
217
|
except Exception as exc:
|
|
225
|
-
|
|
226
|
-
f"保存所有对话失败: {str(exc)}"
|
|
218
|
+
print(
|
|
219
|
+
f"❌ 保存所有对话失败: {str(exc)}"
|
|
227
220
|
)
|
|
228
221
|
continue
|
|
229
222
|
|
|
@@ -232,9 +225,8 @@ def chat_with_model(
|
|
|
232
225
|
try:
|
|
233
226
|
file_path = args
|
|
234
227
|
if not file_path:
|
|
235
|
-
|
|
236
|
-
"请指定保存会话的文件名,例如: /save_session session.json"
|
|
237
|
-
OutputType.WARNING,
|
|
228
|
+
print(
|
|
229
|
+
"⚠️ 请指定保存会话的文件名,例如: /save_session session.json"
|
|
238
230
|
)
|
|
239
231
|
continue
|
|
240
232
|
|
|
@@ -245,13 +237,13 @@ def chat_with_model(
|
|
|
245
237
|
file_path = file_path[1:-1]
|
|
246
238
|
|
|
247
239
|
if platform.save(file_path):
|
|
248
|
-
|
|
249
|
-
f"会话已保存到 {file_path}"
|
|
240
|
+
print(
|
|
241
|
+
f"✅ 会话已保存到 {file_path}"
|
|
250
242
|
)
|
|
251
243
|
else:
|
|
252
|
-
|
|
244
|
+
print("❌ 保存会话失败")
|
|
253
245
|
except Exception as exc:
|
|
254
|
-
|
|
246
|
+
print(f"❌ 保存会话失败: {str(exc)}")
|
|
255
247
|
continue
|
|
256
248
|
|
|
257
249
|
# Check if it is a load_session command
|
|
@@ -259,9 +251,8 @@ def chat_with_model(
|
|
|
259
251
|
try:
|
|
260
252
|
file_path = args
|
|
261
253
|
if not file_path:
|
|
262
|
-
|
|
263
|
-
"请指定加载会话的文件名,例如: /load_session session.json"
|
|
264
|
-
OutputType.WARNING,
|
|
254
|
+
print(
|
|
255
|
+
"⚠️ 请指定加载会话的文件名,例如: /load_session session.json"
|
|
265
256
|
)
|
|
266
257
|
continue
|
|
267
258
|
|
|
@@ -273,13 +264,13 @@ def chat_with_model(
|
|
|
273
264
|
|
|
274
265
|
if platform.restore(file_path):
|
|
275
266
|
conversation_history = [] # Clear local history after loading
|
|
276
|
-
|
|
277
|
-
f"会话已从 {file_path} 加载"
|
|
267
|
+
print(
|
|
268
|
+
f"✅ 会话已从 {file_path} 加载"
|
|
278
269
|
)
|
|
279
270
|
else:
|
|
280
|
-
|
|
271
|
+
print("❌ 加载会话失败")
|
|
281
272
|
except Exception as exc:
|
|
282
|
-
|
|
273
|
+
print(f"❌ 加载会话失败: {str(exc)}")
|
|
283
274
|
continue
|
|
284
275
|
|
|
285
276
|
# Check if it is a shell command
|
|
@@ -287,22 +278,21 @@ def chat_with_model(
|
|
|
287
278
|
try:
|
|
288
279
|
shell_command = args
|
|
289
280
|
if not shell_command:
|
|
290
|
-
|
|
291
|
-
"请指定要执行的shell命令,例如: /shell ls -l"
|
|
292
|
-
OutputType.WARNING,
|
|
281
|
+
print(
|
|
282
|
+
"⚠️ 请指定要执行的shell命令,例如: /shell ls -l"
|
|
293
283
|
)
|
|
294
284
|
continue
|
|
295
285
|
|
|
296
|
-
|
|
286
|
+
print(f"ℹ️ 执行命令: {shell_command}")
|
|
297
287
|
return_code = os.system(shell_command)
|
|
298
288
|
if return_code == 0:
|
|
299
|
-
|
|
289
|
+
print("✅ 命令执行完成")
|
|
300
290
|
else:
|
|
301
|
-
|
|
302
|
-
f"命令执行失败(返回码: {return_code})"
|
|
291
|
+
print(
|
|
292
|
+
f"❌ 命令执行失败(返回码: {return_code})"
|
|
303
293
|
)
|
|
304
294
|
except Exception as exc:
|
|
305
|
-
|
|
295
|
+
print(f"❌ 执行命令失败: {str(exc)}")
|
|
306
296
|
continue
|
|
307
297
|
|
|
308
298
|
try:
|
|
@@ -312,19 +302,19 @@ def chat_with_model(
|
|
|
312
302
|
# Send to model and get reply
|
|
313
303
|
response = platform.chat_until_success(user_input)
|
|
314
304
|
if not response:
|
|
315
|
-
|
|
305
|
+
print("⚠️ 没有有效的回复")
|
|
316
306
|
else:
|
|
317
307
|
conversation_history.append(
|
|
318
308
|
{"role": "assistant", "content": response}
|
|
319
309
|
) # 记录模型回复
|
|
320
310
|
|
|
321
311
|
except Exception as exc:
|
|
322
|
-
|
|
312
|
+
print(f"❌ 聊天失败: {str(exc)}")
|
|
323
313
|
|
|
324
314
|
except typer.Exit:
|
|
325
315
|
raise
|
|
326
316
|
except Exception as exc:
|
|
327
|
-
|
|
317
|
+
print(f"❌ 初始化会话失败: {str(exc)}")
|
|
328
318
|
sys.exit(1)
|
|
329
319
|
finally:
|
|
330
320
|
# Clean up resources
|
|
@@ -345,9 +335,8 @@ def validate_platform_model(platform: Optional[str], model: Optional[str]) -> bo
|
|
|
345
335
|
bool: 如果平台和模型有效返回True,否则返回False。
|
|
346
336
|
"""
|
|
347
337
|
if not platform or not model:
|
|
348
|
-
|
|
349
|
-
"请指定平台和模型。使用 'jarvis info' 查看可用平台和模型。"
|
|
350
|
-
OutputType.WARNING,
|
|
338
|
+
print(
|
|
339
|
+
"⚠️ 请指定平台和模型。使用 'jarvis info' 查看可用平台和模型。"
|
|
351
340
|
)
|
|
352
341
|
return False
|
|
353
342
|
return True
|
|
@@ -404,7 +393,7 @@ def load_role_config(config_path: str) -> Dict[str, Any]:
|
|
|
404
393
|
import yaml
|
|
405
394
|
|
|
406
395
|
if not os.path.exists(config_path):
|
|
407
|
-
|
|
396
|
+
print(f"❌ 角色配置文件 {config_path} 不存在")
|
|
408
397
|
return {}
|
|
409
398
|
|
|
410
399
|
with open(config_path, "r", encoding="utf-8", errors="ignore") as file_obj:
|
|
@@ -412,7 +401,7 @@ def load_role_config(config_path: str) -> Dict[str, Any]:
|
|
|
412
401
|
config = yaml.safe_load(file_obj)
|
|
413
402
|
return config if config else {}
|
|
414
403
|
except yaml.YAMLError as exc:
|
|
415
|
-
|
|
404
|
+
print(f"❌ 角色配置文件解析失败: {str(exc)}")
|
|
416
405
|
return {}
|
|
417
406
|
|
|
418
407
|
|
|
@@ -439,18 +428,18 @@ def role_command(
|
|
|
439
428
|
config_path = os.path.expanduser(config_file)
|
|
440
429
|
config = load_role_config(config_path)
|
|
441
430
|
if not config or "roles" not in config:
|
|
442
|
-
|
|
431
|
+
print("❌ 无效的角色配置文件")
|
|
443
432
|
return
|
|
444
433
|
|
|
445
434
|
# 显示可选角色列表
|
|
446
|
-
|
|
435
|
+
print("✅ 可用角色")
|
|
447
436
|
output_str = "\n".join(
|
|
448
437
|
[
|
|
449
438
|
f"{i}. {role['name']} - {role.get('description', '')}"
|
|
450
439
|
for i, role in enumerate(config["roles"], 1)
|
|
451
440
|
]
|
|
452
441
|
)
|
|
453
|
-
|
|
442
|
+
print(f"ℹ️ {output_str}")
|
|
454
443
|
|
|
455
444
|
# 让用户选择角色(优先 fzf,回退编号输入)
|
|
456
445
|
selected_role = None # type: ignore[var-annotated]
|
|
@@ -471,13 +460,13 @@ def role_command(
|
|
|
471
460
|
if selected_role is None:
|
|
472
461
|
raw_choice = get_single_line_input("请选择角色(输入编号,直接回车退出): ")
|
|
473
462
|
if not raw_choice.strip():
|
|
474
|
-
|
|
463
|
+
print("ℹ️ 已取消,退出程序")
|
|
475
464
|
raise typer.Exit(code=0)
|
|
476
465
|
try:
|
|
477
466
|
choice = int(raw_choice)
|
|
478
467
|
selected_role = config["roles"][choice - 1]
|
|
479
468
|
except (ValueError, IndexError):
|
|
480
|
-
|
|
469
|
+
print("❌ 无效的选择")
|
|
481
470
|
return
|
|
482
471
|
|
|
483
472
|
|
|
@@ -509,13 +498,13 @@ def role_command(
|
|
|
509
498
|
system_prompt = selected_role.get("system_prompt", "")
|
|
510
499
|
|
|
511
500
|
# 开始对话
|
|
512
|
-
|
|
501
|
+
print(f"✅ 已选择角色: {selected_role['name']}")
|
|
513
502
|
chat_with_model(platform_name, model_name, system_prompt)
|
|
514
503
|
|
|
515
504
|
|
|
516
505
|
def main() -> None:
|
|
517
506
|
"""Jarvis平台管理器的主入口点。"""
|
|
518
|
-
init_env(
|
|
507
|
+
init_env()
|
|
519
508
|
app()
|
|
520
509
|
|
|
521
510
|
|
|
@@ -20,7 +20,6 @@ from pydantic import BaseModel, Field
|
|
|
20
20
|
from starlette.responses import JSONResponse, Response
|
|
21
21
|
|
|
22
22
|
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
23
|
-
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
24
23
|
|
|
25
24
|
|
|
26
25
|
class ChatMessage(BaseModel):
|
|
@@ -97,15 +96,12 @@ def start_service(
|
|
|
97
96
|
|
|
98
97
|
registry = PlatformRegistry.get_global_platform_registry()
|
|
99
98
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
)
|
|
103
|
-
PrettyOutput.print("This server provides an OpenAI-compatible API", OutputType.INFO)
|
|
99
|
+
print(f"✅ Starting Jarvis API server on {host}:{port}")
|
|
100
|
+
print("ℹ️ 本服务提供与 OpenAI 兼容的 API")
|
|
104
101
|
|
|
105
102
|
if default_platform and default_model:
|
|
106
|
-
|
|
107
|
-
f"Default platform: {default_platform}, model: {default_model}"
|
|
108
|
-
OutputType.INFO,
|
|
103
|
+
print(
|
|
104
|
+
f"ℹ️ Default platform: {default_platform}, model: {default_model}"
|
|
109
105
|
)
|
|
110
106
|
|
|
111
107
|
# Platform and model cache
|
|
@@ -151,7 +147,7 @@ def start_service(
|
|
|
151
147
|
if response:
|
|
152
148
|
f.write(f"\nResponse:\n{response}\n")
|
|
153
149
|
|
|
154
|
-
|
|
150
|
+
print(f"ℹ️ 会话已记录到 {log_file}")
|
|
155
151
|
|
|
156
152
|
@app.get("/v1/models")
|
|
157
153
|
async def list_models() -> Dict[str, Any]:
|
|
@@ -176,9 +172,8 @@ def start_service(
|
|
|
176
172
|
}
|
|
177
173
|
)
|
|
178
174
|
except Exception as exc:
|
|
179
|
-
|
|
180
|
-
f"Error getting models for {default_platform}: {str(exc)}"
|
|
181
|
-
OutputType.ERROR,
|
|
175
|
+
print(
|
|
176
|
+
f"❌ Error getting models for {default_platform}: {str(exc)}"
|
|
182
177
|
)
|
|
183
178
|
|
|
184
179
|
# Return model list
|
|
@@ -344,7 +339,7 @@ def start_service(
|
|
|
344
339
|
|
|
345
340
|
if isinstance(item, dict) and "__error__" in item:
|
|
346
341
|
error_msg = f"Error during streaming: {item['__error__']}"
|
|
347
|
-
|
|
342
|
+
print(f"❌ {error_msg}")
|
|
348
343
|
|
|
349
344
|
# Send error information in the stream
|
|
350
345
|
error_chunk = {
|