jarvis-ai-assistant 0.1.124__py3-none-any.whl → 0.1.126__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.

Files changed (70) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/jarvis_agent/__init__.py +134 -136
  3. jarvis/jarvis_code_agent/code_agent.py +198 -52
  4. jarvis/jarvis_code_agent/file_select.py +6 -19
  5. jarvis/jarvis_code_agent/patch.py +183 -312
  6. jarvis/jarvis_code_agent/shell_input_handler.py +22 -0
  7. jarvis/jarvis_codebase/main.py +89 -86
  8. jarvis/jarvis_dev/main.py +695 -715
  9. jarvis/jarvis_git_squash/__init__.py +0 -0
  10. jarvis/jarvis_git_squash/main.py +81 -0
  11. jarvis/jarvis_lsp/base.py +0 -12
  12. jarvis/jarvis_lsp/cpp.py +1 -10
  13. jarvis/jarvis_lsp/go.py +1 -10
  14. jarvis/jarvis_lsp/python.py +0 -28
  15. jarvis/jarvis_lsp/registry.py +2 -3
  16. jarvis/jarvis_lsp/rust.py +1 -10
  17. jarvis/jarvis_multi_agent/__init__.py +53 -53
  18. jarvis/jarvis_platform/ai8.py +2 -1
  19. jarvis/jarvis_platform/base.py +19 -24
  20. jarvis/jarvis_platform/kimi.py +2 -3
  21. jarvis/jarvis_platform/ollama.py +3 -1
  22. jarvis/jarvis_platform/openai.py +1 -1
  23. jarvis/jarvis_platform/oyi.py +2 -1
  24. jarvis/jarvis_platform/registry.py +2 -1
  25. jarvis/jarvis_platform_manager/main.py +4 -6
  26. jarvis/jarvis_platform_manager/openai_test.py +0 -1
  27. jarvis/jarvis_rag/main.py +5 -2
  28. jarvis/jarvis_smart_shell/main.py +9 -4
  29. jarvis/jarvis_tools/ask_codebase.py +18 -13
  30. jarvis/jarvis_tools/ask_user.py +5 -4
  31. jarvis/jarvis_tools/base.py +22 -8
  32. jarvis/jarvis_tools/chdir.py +8 -9
  33. jarvis/jarvis_tools/code_review.py +19 -20
  34. jarvis/jarvis_tools/create_code_agent.py +6 -6
  35. jarvis/jarvis_tools/create_sub_agent.py +9 -9
  36. jarvis/jarvis_tools/execute_shell.py +55 -20
  37. jarvis/jarvis_tools/execute_shell_script.py +7 -7
  38. jarvis/jarvis_tools/file_operation.py +39 -10
  39. jarvis/jarvis_tools/git_commiter.py +20 -17
  40. jarvis/jarvis_tools/lsp_find_definition.py +8 -8
  41. jarvis/jarvis_tools/lsp_find_references.py +1 -1
  42. jarvis/jarvis_tools/lsp_get_diagnostics.py +19 -11
  43. jarvis/jarvis_tools/lsp_get_document_symbols.py +1 -1
  44. jarvis/jarvis_tools/lsp_prepare_rename.py +8 -8
  45. jarvis/jarvis_tools/methodology.py +10 -7
  46. jarvis/jarvis_tools/rag.py +27 -20
  47. jarvis/jarvis_tools/read_webpage.py +4 -3
  48. jarvis/jarvis_tools/registry.py +143 -140
  49. jarvis/jarvis_tools/{search.py → search_web.py} +10 -7
  50. jarvis/jarvis_tools/select_code_files.py +4 -4
  51. jarvis/jarvis_tools/tool_generator.py +33 -34
  52. jarvis/jarvis_utils/__init__.py +19 -982
  53. jarvis/jarvis_utils/config.py +138 -0
  54. jarvis/jarvis_utils/embedding.py +201 -0
  55. jarvis/jarvis_utils/git_utils.py +120 -0
  56. jarvis/jarvis_utils/globals.py +82 -0
  57. jarvis/jarvis_utils/input.py +161 -0
  58. jarvis/jarvis_utils/methodology.py +128 -0
  59. jarvis/jarvis_utils/output.py +235 -0
  60. jarvis/jarvis_utils/utils.py +150 -0
  61. jarvis_ai_assistant-0.1.126.dist-info/METADATA +305 -0
  62. jarvis_ai_assistant-0.1.126.dist-info/RECORD +74 -0
  63. {jarvis_ai_assistant-0.1.124.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/WHEEL +1 -1
  64. {jarvis_ai_assistant-0.1.124.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/entry_points.txt +1 -0
  65. jarvis/jarvis_tools/lsp_validate_edit.py +0 -141
  66. jarvis/jarvis_tools/read_code.py +0 -191
  67. jarvis_ai_assistant-0.1.124.dist-info/METADATA +0 -460
  68. jarvis_ai_assistant-0.1.124.dist-info/RECORD +0 -65
  69. {jarvis_ai_assistant-0.1.124.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/LICENSE +0 -0
  70. {jarvis_ai_assistant-0.1.124.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/top_level.txt +0 -0
File without changes
@@ -0,0 +1,81 @@
1
+ import sys
2
+ import argparse
3
+ from typing import Dict, Any
4
+ from jarvis.jarvis_tools.git_commiter import GitCommitTool
5
+ import subprocess
6
+
7
+ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
8
+ from jarvis.jarvis_utils.utils import init_env, user_confirm
9
+ class GitSquashTool:
10
+ name = "git_squash_agent"
11
+ description = "Squash commits interactively using a base commit hash"
12
+
13
+ def _confirm_squash(self) -> bool:
14
+ """Prompt user for confirmation to squash commits"""
15
+ return user_confirm("是否确认压缩提交?", default=True)
16
+
17
+ def _reset_to_commit(self, commit_hash: str) -> bool:
18
+ """Perform soft reset to specified commit hash"""
19
+ try:
20
+ subprocess.Popen(
21
+ ["git", "reset", "--soft", commit_hash],
22
+ stdout=subprocess.DEVNULL,
23
+ stderr=subprocess.DEVNULL
24
+ ).wait()
25
+ return True
26
+ except Exception:
27
+ return False
28
+
29
+ def execute(self, args: Dict) -> Dict[str, Any]:
30
+ """Execute the squash operation"""
31
+ try:
32
+ if not self._confirm_squash():
33
+ return {
34
+ "success": False,
35
+ "stdout": "Operation cancelled",
36
+ "stderr": ""
37
+ }
38
+
39
+ if not self._reset_to_commit(args['commit_hash']):
40
+ return {
41
+ "success": False,
42
+ "stdout": "",
43
+ "stderr": "Failed to reset to specified commit"
44
+ }
45
+
46
+ # Use existing GitCommitTool for new commit
47
+ commit_tool = GitCommitTool()
48
+ result = commit_tool.execute({"lang": args.get('lang', 'Chinese')})
49
+
50
+ return {
51
+ "success": result['success'],
52
+ "stdout": result['stdout'],
53
+ "stderr": result['stderr']
54
+ }
55
+
56
+ except Exception as e:
57
+ return {
58
+ "success": False,
59
+ "stdout": "",
60
+ "stderr": f"Squash failed: {str(e)}"
61
+ }
62
+ def main():
63
+ init_env()
64
+ parser = argparse.ArgumentParser(description='Git squash tool')
65
+ parser.add_argument('commit_hash', type=str, help='Base commit hash to squash from')
66
+ parser.add_argument('--lang', type=str, default='Chinese', help='Language for commit messages')
67
+ args = parser.parse_args()
68
+
69
+ tool = GitSquashTool()
70
+ result = tool.execute({
71
+ 'commit_hash': args.commit_hash,
72
+ 'lang': args.lang
73
+ })
74
+
75
+ if not result['success']:
76
+ PrettyOutput.print(result['stderr'], OutputType.ERROR)
77
+ sys.exit(1)
78
+
79
+ PrettyOutput.print(result['stdout'], OutputType.SUCCESS)
80
+ if __name__ == "__main__":
81
+ sys.exit(main())
jarvis/jarvis_lsp/base.py CHANGED
@@ -125,18 +125,6 @@ class BaseLSP(ABC):
125
125
  """
126
126
  return None
127
127
 
128
- @abstractmethod
129
- def validate_edit(self, file_path: str, edit: Dict[str, Any]) -> bool:
130
- """Validate if proposed edit is syntactically correct.
131
-
132
- Args:
133
- file_path: Path to the file
134
- edit: Edit operation in LSP format
135
-
136
- Returns:
137
- bool: True if edit is valid
138
- """
139
- return False
140
128
 
141
129
  def shutdown(self):
142
130
  """Shutdown LSP server cleanly."""
jarvis/jarvis_lsp/cpp.py CHANGED
@@ -4,7 +4,7 @@ import subprocess
4
4
  from typing import List, Dict, Optional, Tuple, Any
5
5
  import json
6
6
  from jarvis.jarvis_lsp.base import BaseLSP
7
- from jarvis.jarvis_utils import PrettyOutput, OutputType
7
+ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
8
8
 
9
9
  class CPPLSP(BaseLSP):
10
10
  """C++ LSP implementation using clangd."""
@@ -114,15 +114,6 @@ class CPPLSP(BaseLSP):
114
114
  })
115
115
  return result
116
116
 
117
- def validate_edit(self, file_path: str, edit: Dict[str, Any]) -> bool:
118
- # Send workspace/willRenameFiles request to check validity
119
- result = self._send_request("workspace/willRenameFiles", {
120
- "files": [{
121
- "oldUri": f"file://{file_path}",
122
- "newUri": f"file://{file_path}.tmp"
123
- }]
124
- })
125
- return bool(result)
126
117
 
127
118
  def shutdown(self):
128
119
  if self.clangd_process:
jarvis/jarvis_lsp/go.py CHANGED
@@ -4,7 +4,7 @@ import subprocess
4
4
  from typing import List, Dict, Optional, Tuple, Any
5
5
  import json
6
6
  from jarvis.jarvis_lsp.base import BaseLSP
7
- from jarvis.jarvis_utils import PrettyOutput, OutputType
7
+ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
8
8
 
9
9
  class GoLSP(BaseLSP):
10
10
  """Go LSP implementation using gopls."""
@@ -120,15 +120,6 @@ class GoLSP(BaseLSP):
120
120
  })
121
121
  return result
122
122
 
123
- def validate_edit(self, file_path: str, edit: Dict[str, Any]) -> bool:
124
- # Send workspace/willRenameFiles request to check validity
125
- result = self._send_request("workspace/willRenameFiles", {
126
- "files": [{
127
- "oldUri": f"file://{file_path}",
128
- "newUri": f"file://{file_path}.tmp"
129
- }]
130
- })
131
- return bool(result)
132
123
 
133
124
  def shutdown(self):
134
125
  if self.gopls_process:
@@ -100,34 +100,6 @@ class PythonLSP(BaseLSP):
100
100
  return None
101
101
  return None
102
102
 
103
- def validate_edit(self, file_path: str, edit: Dict[str, Any]) -> bool:
104
- try:
105
- # Simple syntax check of the edited content
106
- content = ""
107
- with open(file_path, 'r') as f:
108
- content = f.read()
109
-
110
- # Apply edit
111
- start = edit["range"]["start"]
112
- end = edit["range"]["end"]
113
- new_text = edit["newText"]
114
-
115
- lines = content.splitlines(True)
116
- before = "".join(lines[:start["line"]])
117
- after = "".join(lines[end["line"] + 1:])
118
- current_line = lines[start["line"]]
119
-
120
- edited_line = (current_line[:start["character"]] +
121
- new_text +
122
- current_line[end["character"]:])
123
-
124
- new_content = before + edited_line + after
125
-
126
- # Check if new content is valid Python
127
- jedi.Script(code=new_content)
128
- return True
129
- except Exception:
130
- return False
131
103
 
132
104
  def shutdown(self):
133
105
  self.script_cache.clear()
@@ -5,7 +5,7 @@ import re
5
5
  import sys
6
6
  from typing import Dict, Type, Optional, List
7
7
  from jarvis.jarvis_lsp.base import BaseLSP
8
- from jarvis.jarvis_utils import PrettyOutput, OutputType
8
+ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
9
9
 
10
10
  REQUIRED_METHODS = [
11
11
  ('initialize', ['workspace_path']),
@@ -14,7 +14,6 @@ REQUIRED_METHODS = [
14
14
  ('get_document_symbols', ['file_path']),
15
15
  ('get_diagnostics', ['file_path']),
16
16
  ('prepare_rename', ['file_path', 'position']),
17
- ('validate_edit', ['file_path', 'edit']),
18
17
  ('shutdown', [])
19
18
  ]
20
19
 
@@ -189,7 +188,7 @@ def main():
189
188
  PrettyOutput.print(f"没有 LSP 支持的语言: {args.language}", OutputType.WARNING)
190
189
  return 1
191
190
 
192
- if not lsp.initialize(os.path.dirname(os.path.abspath(args.file))):
191
+ if not lsp.initialize(os.path.abspath(os.getcwd())):
193
192
  PrettyOutput.print("LSP 初始化失败", OutputType.WARNING)
194
193
  return 1
195
194
 
jarvis/jarvis_lsp/rust.py CHANGED
@@ -4,7 +4,7 @@ import subprocess
4
4
  from typing import List, Dict, Optional, Tuple, Any
5
5
  import json
6
6
  from jarvis.jarvis_lsp.base import BaseLSP
7
- from jarvis.jarvis_utils import PrettyOutput, OutputType
7
+ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
8
8
 
9
9
  class RustLSP(BaseLSP):
10
10
  """Rust LSP implementation using rust-analyzer."""
@@ -122,15 +122,6 @@ class RustLSP(BaseLSP):
122
122
  })
123
123
  return result
124
124
 
125
- def validate_edit(self, file_path: str, edit: Dict[str, Any]) -> bool:
126
- # Send workspace/willRenameFiles request to check validity
127
- result = self._send_request("workspace/willRenameFiles", {
128
- "files": [{
129
- "oldUri": f"file://{file_path}",
130
- "newUri": f"file://{file_path}.tmp"
131
- }]
132
- })
133
- return bool(result)
134
125
 
135
126
  def shutdown(self):
136
127
  if self.analyzer_process:
@@ -5,7 +5,7 @@ import yaml
5
5
 
6
6
  from jarvis.jarvis_agent import Agent
7
7
  from jarvis.jarvis_agent.output_handler import OutputHandler
8
- from jarvis.jarvis_utils import OutputType, PrettyOutput
8
+ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
9
9
 
10
10
 
11
11
  class AgentConfig:
@@ -32,65 +32,65 @@ class MultiAgent(OutputHandler):
32
32
 
33
33
  def prompt(self) -> str:
34
34
  return f"""
35
- # 🤖 Message Handling System
36
- You are part of a multi-agent system that communicates through structured messages.
37
-
38
- # 🎯 Core Rules
39
- ## Critical Action Rules
40
- - Execute ONLY ONE action per turn:
41
- - Either use ONE tool (file_operation, ask_user, etc.)
42
- - OR send ONE message to another agent
43
- - NEVER combine both in same turn
44
-
45
- ## Message Flow Control
46
- - Wait for response after sending message
47
- - Process response before next action
48
- - Never send multiple messages at once
49
- - Never combine messages with tool calls
50
-
51
- # 📝 Message Format
35
+ # 🤖 多智能体消息处理系统
36
+ 您是多智能体系统的一部分,通过结构化消息进行通信。
37
+
38
+ # 🎯 核心规则
39
+ ## 关键操作规则
40
+ - 每轮只能执行一个操作:
41
+ - 要么使用一个工具(文件操作、询问用户等)
42
+ - 要么发送一条消息给其他智能体
43
+ - 切勿在同一轮中同时进行这两种操作
44
+
45
+ ## 消息流控制
46
+ - 发送消息后等待响应
47
+ - 处理响应后再进行下一步操作
48
+ - 切勿同时发送多条消息
49
+ - 切勿将消息与工具调用混合使用
50
+
51
+ # 📝 消息格式
52
52
  ```
53
53
  <SEND_MESSAGE>
54
- to: agent_name # Target agent name
54
+ to: 智能体名称 # 目标智能体名称
55
55
  content: |
56
- message_content # Message content
57
- use multiple lines # If needed
58
- with proper indentation
56
+ 消息内容 # 消息内容
57
+ 可使用多行 # 如果需要
58
+ 保持正确的缩进
59
59
  </SEND_MESSAGE>
60
60
  ```
61
61
 
62
- # 🔄 Action Sequence
63
- 1. Choose Most Important Action
64
- - Evaluate priority
65
- - Select ONE action
66
- - Execute action
62
+ # 🔄 操作顺序
63
+ 1. 选择最重要的操作
64
+ - 评估优先级
65
+ - 选择一个操作
66
+ - 执行该操作
67
67
 
68
- 2. Wait for Response
69
- - Process result/response
70
- - Plan next action
71
- - Wait for next turn
68
+ 2. 等待响应
69
+ - 处理结果/响应
70
+ - 计划下一步操作
71
+ - 等待下一轮
72
72
 
73
- 3. Handle Responses
74
- - Process incoming messages
75
- - Reply to sender when needed
76
- - Continue task based on response
73
+ 3. 处理响应
74
+ - 处理收到的消息
75
+ - 需要时回复发送者
76
+ - 根据响应继续任务
77
77
 
78
- # 👥 Available Agents
78
+ # 👥 可用智能体
79
79
  {chr(10).join([f"- {c.name}: {c.description}" for c in self.agents_config])}
80
80
 
81
- # ❗ Important Rules
82
- 1. ONE action per turn only
83
- 2. Wait for responses
84
- 3. Process before next action
85
- 4. Reply to messages
86
- 5. Forward task if needed
87
-
88
- # 💡 Tips
89
- - First action will be executed
90
- - Additional actions will be ignored
91
- - Always process responses first
92
- - Send message to continue task if needed
93
- - Handle and reply to received messages
81
+ # ❗ 重要规则
82
+ 1. 每轮只能执行一个操作
83
+ 2. 等待响应
84
+ 3. 处理后再进行下一步
85
+ 4. 回复消息
86
+ 5. 需要时转发任务
87
+
88
+ # 💡 提示
89
+ - 第一个操作将被执行
90
+ - 额外的操作将被忽略
91
+ - 总是先处理响应
92
+ - 需要时发送消息以继续任务
93
+ - 处理并回复收到的消息
94
94
  """
95
95
 
96
96
  def can_handle(self, response: str) -> bool:
@@ -161,10 +161,10 @@ from: {last_agent}
161
161
  content: {msg['content']}
162
162
  """
163
163
  if msg['to'] not in self.agents:
164
- PrettyOutput.print(f"没有找到{msg['to']},重试...", OutputType.WARNING)
165
- msg = self.agents[last_agent].run(f"The agent {msg['to']} is not found, agent list: {self.agents.keys()}")
164
+ PrettyOutput.print(f"未找到智能体 {msg['to']},正在重试...", OutputType.WARNING)
165
+ msg = self.agents[last_agent].run(f"未找到智能体 {msg['to']},可用智能体列表: {self.agents.keys()}")
166
166
  continue
167
- PrettyOutput.print(f"{last_agent} 发送消息给 {msg['to']}...", OutputType.INFO)
167
+ PrettyOutput.print(f"{last_agent} 正在向 {msg['to']} 发送消息...", OutputType.INFO)
168
168
  last_agent = self.agents[msg['to']].name
169
169
  msg = self.agents[msg['to']].run(prompt)
170
- return ""
170
+ return ""
@@ -1,11 +1,12 @@
1
1
  import os
2
2
  from typing import Dict, List, Tuple
3
3
  from jarvis.jarvis_platform.base import BasePlatform
4
- from jarvis.jarvis_utils import PrettyOutput, OutputType
5
4
  import requests
6
5
  import json
7
6
  import base64
8
7
 
8
+ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
9
+
9
10
  class AI8Model(BasePlatform):
10
11
  """AI8 model implementation"""
11
12
 
@@ -1,10 +1,8 @@
1
1
  from abc import ABC, abstractmethod
2
2
  import re
3
3
  from typing import Dict, List, Tuple
4
-
5
- from jarvis.jarvis_utils import OutputType, PrettyOutput, while_success, while_true
6
- from yaspin import yaspin
7
- from yaspin.spinners import Spinners
4
+ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
5
+ from jarvis.jarvis_utils.utils import get_context_token_count, while_success, while_true
8
6
 
9
7
 
10
8
  class BasePlatform(ABC):
@@ -34,27 +32,24 @@ class BasePlatform(ABC):
34
32
  start_time = time.time()
35
33
  response = self.chat(message)
36
34
 
37
- # Calculate statistics
38
- if not self.suppress_output:
39
- end_time = time.time()
40
- duration = end_time - start_time
41
- char_count = len(response)
42
-
43
- # Calculate token count and tokens per second
44
- try:
45
- from jarvis.jarvis_utils import get_context_token_count
46
- token_count = get_context_token_count(response)
47
- tokens_per_second = token_count / duration if duration > 0 else 0
48
- except Exception as e:
49
- PrettyOutput.print(f"Tokenization failed: {str(e)}", OutputType.WARNING)
50
- token_count = 0
51
- tokens_per_second = 0
35
+ end_time = time.time()
36
+ duration = end_time - start_time
37
+ char_count = len(response)
38
+
39
+ # Calculate token count and tokens per second
40
+ try:
41
+ token_count = get_context_token_count(response)
42
+ tokens_per_second = token_count / duration if duration > 0 else 0
43
+ except Exception as e:
44
+ PrettyOutput.print(f"Tokenization failed: {str(e)}", OutputType.WARNING)
45
+ token_count = 0
46
+ tokens_per_second = 0
52
47
 
53
- # Print statistics
54
- PrettyOutput.print(
55
- f"对话完成 - 耗时: {duration:.2f}秒, 输出字符数: {char_count}, 输出Token数量: {token_count}, 每秒Token数量: {tokens_per_second:.2f}",
56
- OutputType.INFO,
57
- )
48
+ # Print statistics
49
+ PrettyOutput.print(
50
+ f"对话完成 - 耗时: {duration:.2f}秒, 输出字符数: {char_count}, 输出Token数量: {token_count}, 每秒Token数量: {tokens_per_second:.2f}",
51
+ OutputType.INFO,
52
+ )
58
53
 
59
54
  # Keep original think tag handling
60
55
  response = re.sub(r'<think>.*?</think>', '', response, flags=re.DOTALL)
@@ -5,9 +5,8 @@ import os
5
5
  import mimetypes
6
6
  import time
7
7
  from jarvis.jarvis_platform.base import BasePlatform
8
- from jarvis.jarvis_utils import PrettyOutput, OutputType
9
- from jarvis.jarvis_utils import while_success
10
-
8
+ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
9
+ from jarvis.jarvis_utils.utils import while_success
11
10
  class KimiModel(BasePlatform):
12
11
  """Kimi model implementation"""
13
12
 
@@ -1,10 +1,12 @@
1
1
  import requests
2
2
  from typing import List, Dict, Tuple
3
3
  from jarvis.jarvis_platform.base import BasePlatform
4
- from jarvis.jarvis_utils import OutputType, PrettyOutput, get_single_line_input
5
4
  import os
6
5
  import json
7
6
 
7
+ from jarvis.jarvis_utils.input import get_single_line_input
8
+ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
9
+
8
10
  class OllamaPlatform(BasePlatform):
9
11
  """Ollama platform implementation"""
10
12
 
@@ -2,7 +2,7 @@ from typing import Dict, List, Tuple
2
2
  import os
3
3
  from openai import OpenAI
4
4
  from jarvis.jarvis_platform.base import BasePlatform
5
- from jarvis.jarvis_utils import PrettyOutput, OutputType
5
+ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
6
6
 
7
7
  class OpenAIModel(BasePlatform):
8
8
  platform_name = "openai"
@@ -2,10 +2,11 @@ import mimetypes
2
2
  import os
3
3
  from typing import Dict, List, Tuple
4
4
  from jarvis.jarvis_platform.base import BasePlatform
5
- from jarvis.jarvis_utils import PrettyOutput, OutputType
6
5
  import requests
7
6
  import json
8
7
 
8
+ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
9
+
9
10
  class OyiModel(BasePlatform):
10
11
  """Oyi model implementation"""
11
12
 
@@ -4,7 +4,8 @@ import os
4
4
  import sys
5
5
  from typing import Dict, Type, Optional, List
6
6
  from jarvis.jarvis_platform.base import BasePlatform
7
- from jarvis.jarvis_utils import PrettyOutput, OutputType, get_cheap_model_name, get_cheap_platform_name, get_codegen_model_name, get_codegen_platform_name, get_normal_model_name, get_normal_platform_name, get_thinking_model_name, get_thinking_platform_name
7
+ from jarvis.jarvis_utils.config import get_cheap_model_name, get_cheap_platform_name, get_codegen_model_name, get_codegen_platform_name, get_normal_model_name, get_normal_platform_name, get_thinking_model_name, get_thinking_platform_name
8
+ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
8
9
 
9
10
  REQUIRED_METHODS = [
10
11
  ('chat', ['message']), # 方法名和参数列表
@@ -1,18 +1,16 @@
1
1
  from jarvis.jarvis_platform.registry import PlatformRegistry
2
- from jarvis.jarvis_utils import PrettyOutput, OutputType, init_env, get_multiline_input
3
2
  import asyncio
4
3
  from fastapi import FastAPI, HTTPException
5
4
  from fastapi.responses import StreamingResponse
6
5
  from pydantic import BaseModel, Field
7
6
  from typing import List, Dict, Any, Optional
8
7
  import uvicorn
9
- import io
10
- from contextlib import redirect_stdout
11
- import json
12
- import os
13
- from datetime import datetime
14
8
  from fastapi.middleware.cors import CORSMiddleware
15
9
 
10
+ from jarvis.jarvis_utils.input import get_multiline_input
11
+ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
12
+ from jarvis.jarvis_utils.utils import init_env
13
+
16
14
  def list_platforms():
17
15
  """List all supported platforms and models"""
18
16
  registry = PlatformRegistry.get_global_platform_registry()
@@ -4,7 +4,6 @@ Test script for Jarvis OpenAI-compatible API service.
4
4
  """
5
5
 
6
6
  import argparse
7
- import os
8
7
  import sys
9
8
  from openai import OpenAI
10
9
 
jarvis/jarvis_rag/main.py CHANGED
@@ -3,8 +3,6 @@ import numpy as np
3
3
  import faiss
4
4
  from typing import List, Tuple, Optional, Dict
5
5
  import pickle
6
- from jarvis.jarvis_utils import OutputType, PrettyOutput, get_context_token_count, get_embedding, get_embedding_batch, get_file_md5, get_max_token_count, get_max_paragraph_length, get_min_paragraph_length, get_thread_count, init_gpu_config, load_embedding_model
7
- from jarvis.jarvis_utils import init_env
8
6
  from dataclasses import dataclass
9
7
  from tqdm import tqdm
10
8
  import fitz # PyMuPDF for PDF files
@@ -15,6 +13,11 @@ import lzma # 添加 lzma 导入
15
13
  from threading import Lock
16
14
  import hashlib
17
15
 
16
+ from jarvis.jarvis_utils.config import get_max_paragraph_length, get_max_token_count, get_min_paragraph_length, get_thread_count
17
+ from jarvis.jarvis_utils.embedding import get_context_token_count, get_embedding, get_embedding_batch, load_embedding_model
18
+ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
19
+ from jarvis.jarvis_utils.utils import get_file_md5, init_env, init_gpu_config
20
+
18
21
  @dataclass
19
22
  class Document:
20
23
  """Document class, for storing document content and metadata"""
@@ -4,11 +4,14 @@ import os
4
4
  import sys
5
5
  import readline
6
6
  from typing import Optional
7
- from yaspin import yaspin # type: ignore
8
- from yaspin.spinners import Spinners # type: ignore
7
+
8
+ from yaspin import yaspin
9
9
 
10
10
  from jarvis.jarvis_platform.registry import PlatformRegistry
11
- from jarvis.jarvis_utils import PrettyOutput, OutputType, get_multiline_input, get_shell_name, init_env
11
+ from jarvis.jarvis_utils.config import get_shell_name
12
+ from jarvis.jarvis_utils.input import get_multiline_input
13
+ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
14
+ from jarvis.jarvis_utils.utils import init_env
12
15
 
13
16
  def execute_command(command: str) -> None:
14
17
  """Show command and allow user to edit, then execute, Ctrl+C to cancel"""
@@ -95,7 +98,9 @@ Output: find . -name "*.py"
95
98
  prefix = f"Current path: {current_path}\n"
96
99
  prefix += f"Current shell: {shell}\n"
97
100
 
98
- result = model.chat_until_success(prefix + request)
101
+ with yaspin(text="正在生成命令...", color="cyan") as spinner:
102
+ result = model.chat_until_success(prefix + request)
103
+ spinner.ok("✅ 命令生成成功")
99
104
 
100
105
  # 提取命令
101
106
  if result and isinstance(result, str):