jarvis-ai-assistant 0.1.207__py3-none-any.whl → 0.1.209__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.
Files changed (42) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/jarvis_agent/__init__.py +63 -103
  3. jarvis/jarvis_agent/edit_file_handler.py +43 -47
  4. jarvis/jarvis_agent/jarvis.py +33 -39
  5. jarvis/jarvis_code_agent/code_agent.py +74 -30
  6. jarvis/jarvis_code_agent/lint.py +6 -6
  7. jarvis/jarvis_code_analysis/code_review.py +164 -175
  8. jarvis/jarvis_data/config_schema.json +0 -25
  9. jarvis/jarvis_git_utils/git_commiter.py +148 -153
  10. jarvis/jarvis_methodology/main.py +70 -81
  11. jarvis/jarvis_platform/base.py +21 -17
  12. jarvis/jarvis_platform/kimi.py +59 -64
  13. jarvis/jarvis_platform/tongyi.py +118 -131
  14. jarvis/jarvis_platform/yuanbao.py +117 -122
  15. jarvis/jarvis_platform_manager/main.py +102 -502
  16. jarvis/jarvis_platform_manager/service.py +432 -0
  17. jarvis/jarvis_smart_shell/main.py +99 -33
  18. jarvis/jarvis_tools/ask_user.py +0 -1
  19. jarvis/jarvis_tools/edit_file.py +64 -55
  20. jarvis/jarvis_tools/file_analyzer.py +17 -28
  21. jarvis/jarvis_tools/read_code.py +80 -81
  22. jarvis/jarvis_utils/builtin_replace_map.py +1 -36
  23. jarvis/jarvis_utils/config.py +13 -48
  24. jarvis/jarvis_utils/embedding.py +6 -51
  25. jarvis/jarvis_utils/git_utils.py +93 -43
  26. jarvis/jarvis_utils/http.py +104 -0
  27. jarvis/jarvis_utils/methodology.py +12 -17
  28. jarvis/jarvis_utils/utils.py +186 -63
  29. {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.209.dist-info}/METADATA +4 -19
  30. {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.209.dist-info}/RECORD +34 -40
  31. {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.209.dist-info}/entry_points.txt +1 -1
  32. jarvis/jarvis_data/huggingface.tar.gz +0 -0
  33. jarvis/jarvis_dev/main.py +0 -1247
  34. jarvis/jarvis_tools/chdir.py +0 -72
  35. jarvis/jarvis_tools/code_plan.py +0 -218
  36. jarvis/jarvis_tools/create_code_agent.py +0 -95
  37. jarvis/jarvis_tools/create_sub_agent.py +0 -82
  38. jarvis/jarvis_tools/file_operation.py +0 -238
  39. jarvis/jarvis_utils/jarvis_history.py +0 -98
  40. {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.209.dist-info}/WHEEL +0 -0
  41. {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.209.dist-info}/licenses/LICENSE +0 -0
  42. {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.209.dist-info}/top_level.txt +0 -0
@@ -7,13 +7,15 @@ import sys
7
7
  import tempfile
8
8
  from typing import Any, Dict, Optional
9
9
 
10
- import yaml
11
- from yaspin import yaspin
10
+ import yaml # type: ignore
12
11
 
13
12
  from jarvis.jarvis_platform.registry import PlatformRegistry
14
13
  from jarvis.jarvis_utils.config import get_git_commit_prompt
15
- from jarvis.jarvis_utils.git_utils import (confirm_add_new_files, find_git_root,
16
- has_uncommitted_changes)
14
+ from jarvis.jarvis_utils.git_utils import (
15
+ confirm_add_new_files,
16
+ find_git_root_and_cd,
17
+ has_uncommitted_changes,
18
+ )
17
19
  from jarvis.jarvis_utils.output import OutputType, PrettyOutput
18
20
  from jarvis.jarvis_utils.tag import ct, ot
19
21
  from jarvis.jarvis_utils.utils import init_env, is_context_overflow
@@ -69,19 +71,19 @@ class GitCommitTool:
69
71
  """Prepare git environment by changing directory and checking for changes"""
70
72
  original_dir = os.getcwd()
71
73
  os.chdir(root_dir)
72
- find_git_root()
74
+ find_git_root_and_cd()
73
75
  if not has_uncommitted_changes():
74
76
  PrettyOutput.print("没有未提交的更改", OutputType.SUCCESS)
75
77
  return None
76
78
  return original_dir
77
79
 
78
- def _stage_changes(self, spinner) -> None:
80
+ def _stage_changes(self) -> None:
79
81
  """Stage all changes for commit"""
80
- spinner.text = "正在添加文件到提交..."
82
+ print("📁 正在添加文件到提交...")
81
83
  subprocess.Popen(
82
84
  ["git", "add", "."], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
83
85
  ).wait()
84
- spinner.write("✅ 添加文件到提交")
86
+ print("✅ 添加文件到提交")
85
87
 
86
88
  def execute(self, args: Dict) -> Dict[str, Any]:
87
89
  """Execute automatic commit process with support for multi-line messages and special characters"""
@@ -102,41 +104,40 @@ class GitCommitTool:
102
104
  if not has_uncommitted_changes():
103
105
  return {"success": True, "stdout": "No changes to commit", "stderr": ""}
104
106
 
105
- with yaspin(text="正在初始化提交流程...", color="cyan") as spinner:
106
- # 添加文件到暂存区
107
- self._stage_changes(spinner)
107
+ print("🚀 正在初始化提交流程...")
108
+ self._stage_changes()
108
109
 
109
- # 获取差异
110
- spinner.text = "正在获取代码差异..."
111
- # 获取文件列表
112
- files_cmd = ["git", "diff", "--cached", "--name-only"]
113
- process = subprocess.Popen(
114
- files_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE
115
- )
116
- files_output = process.communicate()[0].decode()
117
- files = [f.strip() for f in files_output.split("\n") if f.strip()]
118
- file_count = len(files)
119
-
120
- # 获取完整差异
121
- process = subprocess.Popen(
122
- ["git", "diff", "--cached", "--exit-code"],
123
- stdout=subprocess.PIPE,
124
- stderr=subprocess.PIPE,
125
- )
126
- diff = process.communicate()[0].decode(errors="ignore")
127
- spinner.write(f"✅ 获取差异 ({file_count} 个文件)")
128
- try:
129
- temp_diff_file_path = None
130
- # 生成提交信息
131
- spinner.text = "正在生成提交消息..."
132
-
133
- # 准备提示信息
134
- custom_prompt = get_git_commit_prompt()
135
- base_prompt = (
136
- custom_prompt
137
- if custom_prompt
138
- else f"""根据代码差异生成提交信息:
139
- 提交信息应使用中文书写
110
+ # 获取差异
111
+ print("📊 正在获取代码差异...")
112
+ # 获取文件列表
113
+ files_cmd = ["git", "diff", "--cached", "--name-only"]
114
+ process = subprocess.Popen(
115
+ files_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE
116
+ )
117
+ files_output = process.communicate()[0].decode()
118
+ files = [f.strip() for f in files_output.split("\n") if f.strip()]
119
+ file_count = len(files)
120
+
121
+ # 获取完整差异
122
+ process = subprocess.Popen(
123
+ ["git", "diff", "--cached", "--exit-code"],
124
+ stdout=subprocess.PIPE,
125
+ stderr=subprocess.PIPE,
126
+ )
127
+ diff = process.communicate()[0].decode(errors="ignore")
128
+ print(f"✅ 获取差异 ({file_count} 个文件)")
129
+ try:
130
+ temp_diff_file_path = None
131
+ # 生成提交信息
132
+ print("✨ 正在生成提交消息...")
133
+
134
+ # 准备提示信息
135
+ custom_prompt = get_git_commit_prompt()
136
+ base_prompt = (
137
+ custom_prompt
138
+ if custom_prompt
139
+ else f"""根据代码差异生成提交信息:
140
+ 提交信息应使用中文书写
140
141
  # 格式模板
141
142
  必须使用以下格式:
142
143
 
@@ -152,131 +153,125 @@ class GitCommitTool:
152
153
  5. 详细描述部分应解释"是什么"和"为什么",而非"如何"
153
154
  6. 仅输出提交信息,不要输出其他内容
154
155
  """
155
- )
156
- base_prompt += f"""
156
+ )
157
+ base_prompt += f"""
157
158
  # 输出格式
158
159
  {ot("COMMIT_MESSAGE")}
159
160
  commit信息
160
161
  {ct("COMMIT_MESSAGE")}
161
- """
162
-
163
- # 获取模型并尝试上传文件
164
- platform = PlatformRegistry().get_normal_platform()
165
- upload_success = False
166
-
167
- # Check if content is too large
168
- is_large_content = is_context_overflow(diff)
169
-
170
- if is_large_content:
171
- if not platform.support_upload_files():
172
- spinner.text = "差异文件太大,无法处理"
173
- spinner.fail("❌")
174
- return {
175
- "success": False,
176
- "stdout": "",
177
- "stderr": "错误:差异文件太大,无法处理",
178
- }
179
- spinner.text = "正在上传代码差异文件..."
180
- with spinner.hidden():
181
- # 创建临时文件并写入差异内容
182
- with tempfile.NamedTemporaryFile(
183
- mode="w", suffix=".diff", delete=False
184
- ) as temp_diff_file:
185
- temp_diff_file_path = temp_diff_file.name
186
- temp_diff_file.write(diff)
187
- temp_diff_file.flush()
188
- spinner.write(f"✅ 差异内容已写入临时文件")
189
- upload_success = platform.upload_files(
190
- [temp_diff_file_path]
191
- )
192
- if upload_success:
193
- spinner.write(" 成功上传代码差异文件")
194
- else:
195
- spinner.text = "上传代码差异文件失败"
196
- spinner.fail("❌")
197
- return {
198
- "success": False,
199
- "stdout": "",
200
- "stderr": "错误:上传代码差异文件失败",
201
- }
202
- # 根据上传状态准备完整的提示
203
- if is_large_content:
204
- # 尝试生成提交信息
205
- spinner.text = "正在生成提交消息..."
206
- # 使用上传的文件
207
- prompt = (
208
- base_prompt
209
- + f"""
162
+ """
163
+
164
+ # 获取模型并尝试上传文件
165
+ platform = PlatformRegistry().get_normal_platform()
166
+ upload_success = False
167
+
168
+ # Check if content is too large
169
+ is_large_content = is_context_overflow(diff)
170
+
171
+ if is_large_content:
172
+ if not platform.support_upload_files():
173
+ print("❌ 差异文件太大,无法处理")
174
+ return {
175
+ "success": False,
176
+ "stdout": "",
177
+ "stderr": "错误:差异文件太大,无法处理",
178
+ }
179
+ print("📤 正在上传代码差异文件...")
180
+ # 创建临时文件并写入差异内容
181
+ with tempfile.NamedTemporaryFile(
182
+ mode="w", suffix=".diff", delete=False
183
+ ) as temp_diff_file:
184
+ temp_diff_file_path = temp_diff_file.name
185
+ temp_diff_file.write(diff)
186
+ temp_diff_file.flush()
187
+ print(f"✅ 差异内容已写入临时文件")
188
+ upload_success = platform.upload_files([temp_diff_file_path])
189
+ if upload_success:
190
+ print("✅ 成功上传代码差异文件")
191
+ else:
192
+ print("❌ 上传代码差异文件失败")
193
+ return {
194
+ "success": False,
195
+ "stdout": "",
196
+ "stderr": "错误:上传代码差异文件失败",
197
+ }
198
+ # 根据上传状态准备完整的提示
199
+ if is_large_content:
200
+ # 尝试生成提交信息
201
+ print(" 正在生成提交消息...")
202
+ # 使用上传的文件
203
+ prompt = (
204
+ base_prompt
205
+ + f"""
210
206
  # 变更概述
211
207
  - 变更文件数量: {file_count} 个文件
212
208
  - 已上传包含完整代码差异的文件
213
209
 
214
210
  请详细分析已上传的代码差异文件,生成符合上述格式的提交信息。
215
211
  """
216
- )
217
- commit_message = platform.chat_until_success(prompt)
218
- else:
219
- prompt = (
220
- base_prompt
221
- + f"""
212
+ )
213
+ commit_message = platform.chat_until_success(prompt)
214
+ else:
215
+ prompt = (
216
+ base_prompt
217
+ + f"""
222
218
  # 分析材料
223
219
  {diff}
224
220
  """
225
- )
226
- commit_message = platform.chat_until_success(prompt)
227
-
228
- while True:
229
- # 只在特定情况下重新获取commit_message
230
- if (
231
- not upload_success
232
- and not is_large_content
233
- and not commit_message
234
- ):
235
- commit_message = platform.chat_until_success(prompt)
236
- extracted_message = self._extract_commit_message(commit_message)
237
- # 如果成功提取,就跳出循环
238
- if extracted_message:
239
- commit_message = extracted_message
240
- # 应用prefix和suffix
241
- if prefix:
242
- commit_message = f"{prefix} {commit_message}"
243
- if suffix:
244
- commit_message = f"{commit_message}\n{suffix}"
245
- break
246
- prompt = f"""格式错误,请按照以下格式重新生成提交信息:
247
- {ot("COMMIT_MESSAGE")}
248
- commit信息
249
- {ct("COMMIT_MESSAGE")}
250
- """
251
- commit_message = platform.chat_until_success(prompt)
252
- spinner.write("✅ 生成提交消息")
253
-
254
- # 执行提交
255
- spinner.text = "正在准备提交..."
256
- with tempfile.NamedTemporaryFile(mode="w", delete=True) as tmp_file:
257
- tmp_file.write(commit_message)
258
- tmp_file.flush()
259
- spinner.text = "正在执行提交..."
260
- commit_cmd = ["git", "commit", "-F", tmp_file.name]
261
- subprocess.Popen(
262
- commit_cmd,
263
- stdout=subprocess.DEVNULL,
264
- stderr=subprocess.DEVNULL,
265
- ).wait()
266
- spinner.write("✅ 提交")
267
-
268
- commit_hash = self._get_last_commit_hash()
269
- spinner.text = "完成提交"
270
- spinner.ok("✅")
271
- finally:
272
- # 清理临时差异文件
273
- if temp_diff_file_path is not None and os.path.exists(
274
- temp_diff_file_path
221
+ )
222
+ commit_message = platform.chat_until_success(prompt)
223
+
224
+ while True:
225
+ # 只在特定情况下重新获取commit_message
226
+ if (
227
+ not upload_success
228
+ and not is_large_content
229
+ and not commit_message
275
230
  ):
276
- try:
277
- os.unlink(temp_diff_file_path)
278
- except Exception as e:
279
- spinner.write(f"⚠️ 无法删除临时文件: {str(e)}")
231
+ commit_message = platform.chat_until_success(prompt)
232
+ extracted_message = self._extract_commit_message(commit_message)
233
+ # 如果成功提取,就跳出循环
234
+ if extracted_message:
235
+ commit_message = extracted_message
236
+ # 应用prefix和suffix
237
+ if prefix:
238
+ commit_message = f"{prefix} {commit_message}"
239
+ if suffix:
240
+ commit_message = f"{commit_message}\n{suffix}"
241
+ break
242
+ prompt = f"""格式错误,请按照以下格式重新生成提交信息:
243
+ {ot("COMMIT_MESSAGE")}
244
+ commit信息
245
+ {ct("COMMIT_MESSAGE")}
246
+ """
247
+ commit_message = platform.chat_until_success(prompt)
248
+ print("✅ 生成提交消息")
249
+
250
+ # 执行提交
251
+ print("⚙️ 正在准备提交...")
252
+ with tempfile.NamedTemporaryFile(mode="w", delete=True) as tmp_file:
253
+ tmp_file.write(commit_message)
254
+ tmp_file.flush()
255
+ print("💾 正在执行提交...")
256
+ commit_cmd = ["git", "commit", "-F", tmp_file.name]
257
+ subprocess.Popen(
258
+ commit_cmd,
259
+ stdout=subprocess.DEVNULL,
260
+ stderr=subprocess.DEVNULL,
261
+ ).wait()
262
+ print("✅ 提交")
263
+
264
+ commit_hash = self._get_last_commit_hash()
265
+ print("✅ 完成提交")
266
+ finally:
267
+ # 清理临时差异文件
268
+ if temp_diff_file_path is not None and os.path.exists(
269
+ temp_diff_file_path
270
+ ):
271
+ try:
272
+ os.unlink(temp_diff_file_path)
273
+ except Exception as e:
274
+ print(f"⚠️ 无法删除临时文件: {str(e)}")
280
275
 
281
276
  PrettyOutput.print(
282
277
  f"提交哈希: {commit_hash}\n提交消息: {commit_message}",
@@ -14,11 +14,12 @@ import json
14
14
  import os
15
15
 
16
16
  import yaml # type: ignore
17
- from yaspin import yaspin # type: ignore
18
17
 
19
18
  from jarvis.jarvis_platform.registry import PlatformRegistry
20
- from jarvis.jarvis_utils.methodology import (_get_methodology_directory,
21
- _load_all_methodologies)
19
+ from jarvis.jarvis_utils.methodology import (
20
+ _get_methodology_directory,
21
+ _load_all_methodologies,
22
+ )
22
23
  from jarvis.jarvis_utils.output import OutputType, PrettyOutput
23
24
 
24
25
 
@@ -128,46 +129,40 @@ def extract_methodology(input_file):
128
129
  """
129
130
 
130
131
  # 调用大模型平台提取方法论
131
- with yaspin(text="正在提取方法论...", color="yellow") as spinner:
132
- try:
133
- response = platform.chat_until_success(prompt)
134
- except Exception as e:
135
- spinner.text = "提取失败"
136
- spinner.fail("")
137
- PrettyOutput.print(f"提取方法论失败: {str(e)}", OutputType.ERROR)
138
- return
139
-
140
- # 提取YAML部分
141
- methodologies_start = response.find("<methodologies>") + len(
142
- "<methodologies>"
132
+ print("📥 正在提取方法论...")
133
+ try:
134
+ response = platform.chat_until_success(prompt)
135
+ except Exception as e:
136
+ print("❌ 提取失败")
137
+ PrettyOutput.print(f"提取方法论失败: {str(e)}", OutputType.ERROR)
138
+ return
139
+
140
+ # 提取YAML部分
141
+ methodologies_start = response.find("<methodologies>") + len("<methodologies>")
142
+ methodologies_end = response.find("</methodologies>")
143
+ if methodologies_start == -1 or methodologies_end == -1:
144
+ print("❌ 响应格式无效")
145
+ PrettyOutput.print(
146
+ "大模型未返回有效的<methodologies>格式", OutputType.ERROR
143
147
  )
144
- methodologies_end = response.find("</methodologies>")
145
- if methodologies_start == -1 or methodologies_end == -1:
146
- spinner.text = "响应格式无效"
147
- spinner.fail("❌")
148
- PrettyOutput.print(
149
- "大模型未返回有效的<methodologies>格式", OutputType.ERROR
150
- )
151
- return
152
-
153
- yaml_content = response[methodologies_start:methodologies_end].strip()
154
-
155
- try:
156
- data = yaml.safe_load(yaml_content)
157
- extracted_methodologies = {
158
- item["problem_type"]: item["content"] for item in data
159
- }
160
- except (yaml.YAMLError, KeyError, TypeError) as e:
161
- spinner.text = "YAML解析失败"
162
- spinner.fail("❌")
163
- PrettyOutput.print(f"YAML解析错误: {str(e)}", OutputType.ERROR)
164
- return
165
-
166
- if not extracted_methodologies:
167
- spinner.text = "未提取到有效方法论"
168
- spinner.fail("❌")
169
- return
170
- spinner.ok("✅")
148
+ return
149
+
150
+ yaml_content = response[methodologies_start:methodologies_end].strip()
151
+
152
+ try:
153
+ data = yaml.safe_load(yaml_content)
154
+ extracted_methodologies = {
155
+ item["problem_type"]: item["content"] for item in data
156
+ }
157
+ except (yaml.YAMLError, KeyError, TypeError) as e:
158
+ print("❌ YAML解析失败")
159
+ PrettyOutput.print(f"YAML解析错误: {str(e)}", OutputType.ERROR)
160
+ return
161
+
162
+ if not extracted_methodologies:
163
+ print("❌ 未提取到有效方法论")
164
+ return
165
+ print("✅ 提取到有效方法论")
171
166
 
172
167
  # 加载现有方法论
173
168
  existing_methodologies = _load_all_methodologies()
@@ -233,46 +228,40 @@ def extract_methodology_from_url(url):
233
228
  6. 内容字段使用|保留多行格式
234
229
  """
235
230
  # 调用大模型平台提取方法论
236
- with yaspin(text="正在从URL提取方法论...", color="yellow") as spinner:
237
- try:
238
- response = platform.chat_until_success(prompt)
239
- except Exception as e:
240
- spinner.text = "提取失败"
241
- spinner.fail("")
242
- PrettyOutput.print(f"提取方法论失败: {str(e)}", OutputType.ERROR)
243
- return
244
-
245
- # 提取YAML部分
246
- methodologies_start = response.find("<methodologies>") + len(
247
- "<methodologies>"
231
+ print("📥 正在从URL提取方法论...")
232
+ try:
233
+ response = platform.chat_until_success(prompt)
234
+ except Exception as e:
235
+ print("❌ 提取失败")
236
+ PrettyOutput.print(f"提取方法论失败: {str(e)}", OutputType.ERROR)
237
+ return
238
+
239
+ # 提取YAML部分
240
+ methodologies_start = response.find("<methodologies>") + len("<methodologies>")
241
+ methodologies_end = response.find("</methodologies>")
242
+ if methodologies_start == -1 or methodologies_end == -1:
243
+ print("❌ 响应格式无效")
244
+ PrettyOutput.print(
245
+ "大模型未返回有效的<methodologies>格式", OutputType.ERROR
248
246
  )
249
- methodologies_end = response.find("</methodologies>")
250
- if methodologies_start == -1 or methodologies_end == -1:
251
- spinner.text = "响应格式无效"
252
- spinner.fail("❌")
253
- PrettyOutput.print(
254
- "大模型未返回有效的<methodologies>格式", OutputType.ERROR
255
- )
256
- return
257
-
258
- yaml_content = response[methodologies_start:methodologies_end].strip()
259
-
260
- try:
261
- data = yaml.safe_load(yaml_content)
262
- extracted_methodologies = {
263
- item["problem_type"]: item["content"] for item in data
264
- }
265
- except (yaml.YAMLError, KeyError, TypeError) as e:
266
- spinner.text = "YAML解析失败"
267
- spinner.fail("❌")
268
- PrettyOutput.print(f"YAML解析错误: {str(e)}", OutputType.ERROR)
269
- return
270
-
271
- if not extracted_methodologies:
272
- spinner.text = "未提取到有效方法论"
273
- spinner.fail("❌")
274
- return
275
- spinner.ok("✅")
247
+ return
248
+
249
+ yaml_content = response[methodologies_start:methodologies_end].strip()
250
+
251
+ try:
252
+ data = yaml.safe_load(yaml_content)
253
+ extracted_methodologies = {
254
+ item["problem_type"]: item["content"] for item in data
255
+ }
256
+ except (yaml.YAMLError, KeyError, TypeError) as e:
257
+ print("❌ YAML解析失败")
258
+ PrettyOutput.print(f"YAML解析错误: {str(e)}", OutputType.ERROR)
259
+ return
260
+
261
+ if not extracted_methodologies:
262
+ print("❌ 未提取到有效方法论")
263
+ return
264
+ print("✅ 提取到有效方法论")
276
265
 
277
266
  # 加载现有方法论
278
267
  existing_methodologies = _load_all_methodologies()
@@ -3,19 +3,21 @@ import re
3
3
  from abc import ABC, abstractmethod
4
4
  from typing import Generator, List, Tuple
5
5
 
6
- from rich import box # type: ignore
7
- from rich.live import Live # type: ignore
8
- from rich.panel import Panel # type: ignore
9
- from rich.text import Text # type: ignore
10
-
11
- from jarvis.jarvis_utils.config import (get_max_input_token_count,
12
- get_pretty_output, is_print_prompt)
6
+ from rich import box # type: ignore
7
+ from rich.live import Live # type: ignore
8
+ from rich.panel import Panel # type: ignore
9
+ from rich.text import Text # type: ignore
10
+
11
+ from jarvis.jarvis_utils.config import (
12
+ get_max_input_token_count,
13
+ get_pretty_output,
14
+ is_print_prompt,
15
+ )
13
16
  from jarvis.jarvis_utils.embedding import split_text_into_chunks
14
17
  from jarvis.jarvis_utils.globals import set_in_chat
15
18
  from jarvis.jarvis_utils.output import OutputType, PrettyOutput
16
19
  from jarvis.jarvis_utils.tag import ct, ot
17
- from jarvis.jarvis_utils.utils import (get_context_token_count, while_success,
18
- while_true)
20
+ from jarvis.jarvis_utils.utils import get_context_token_count, while_success, while_true
19
21
 
20
22
 
21
23
  class BasePlatform(ABC):
@@ -64,7 +66,7 @@ class BasePlatform(ABC):
64
66
  max_chunk_size = get_max_input_token_count() - 1024 # 留出一些余量
65
67
  min_chunk_size = get_max_input_token_count() - 2048
66
68
  inputs = split_text_into_chunks(message, max_chunk_size, min_chunk_size)
67
- print("正在提交长上下文...")
69
+ print("📤 正在提交长上下文...")
68
70
  prefix_prompt = f"""
69
71
  我将分多次提供大量内容,在我明确告诉你内容已经全部提供完毕之前,每次仅需要输出"已收到",明白请输出"开始接收输入"。
70
72
  """
@@ -76,10 +78,11 @@ class BasePlatform(ABC):
76
78
  submit_count += 1
77
79
  length += len(input)
78
80
  print(
79
- f"正在提交第{submit_count}部分(共{len(inputs)}部分({length}/{len(message)}))"
81
+ f"📤 正在提交第{submit_count}部分(共{len(inputs)}部分({length}/{len(message)}))"
80
82
  )
81
-
82
- response += "\n" + while_true(
83
+
84
+ response += "\n"
85
+ for trunk in while_true(
83
86
  lambda: while_success(
84
87
  lambda: self.chat(
85
88
  f"<part_content>{input}</part_content>\n\n请返回<已收到>,不需要返回其他任何内容"
@@ -87,12 +90,13 @@ class BasePlatform(ABC):
87
90
  5,
88
91
  ),
89
92
  5,
90
- )
91
-
93
+ ):
94
+ response += trunk
95
+
92
96
  print(
93
- f"提交第{submit_count}部分完成,当前进度:{length}/{len(message)}"
97
+ f"📤 提交第{submit_count}部分完成,当前进度:{length}/{len(message)}"
94
98
  )
95
- print("提交完成")
99
+ print("提交完成")
96
100
  response += "\n" + while_true(
97
101
  lambda: while_success(
98
102
  lambda: self._chat("内容已经全部提供完毕,请根据内容继续"), 5