jarvis-ai-assistant 0.1.126__py3-none-any.whl → 0.1.129__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 (42) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/jarvis_agent/__init__.py +108 -95
  3. jarvis/jarvis_agent/main.py +77 -0
  4. jarvis/jarvis_code_agent/builtin_input_handler.py +43 -0
  5. jarvis/jarvis_code_agent/code_agent.py +17 -81
  6. jarvis/jarvis_code_agent/file_input_handler.py +88 -0
  7. jarvis/jarvis_code_agent/patch.py +142 -114
  8. jarvis/jarvis_code_agent/shell_input_handler.py +8 -2
  9. jarvis/jarvis_codebase/main.py +240 -213
  10. jarvis/jarvis_dev/main.py +4 -3
  11. jarvis/jarvis_multi_agent/__init__.py +51 -40
  12. jarvis/jarvis_platform/base.py +6 -5
  13. jarvis/jarvis_platform_manager/main.py +1 -1
  14. jarvis/jarvis_rag/main.py +250 -186
  15. jarvis/jarvis_smart_shell/main.py +0 -1
  16. jarvis/jarvis_tools/ask_codebase.py +4 -3
  17. jarvis/jarvis_tools/chdir.py +22 -22
  18. jarvis/jarvis_tools/code_review.py +38 -33
  19. jarvis/jarvis_tools/execute_shell.py +0 -3
  20. jarvis/jarvis_tools/file_operation.py +56 -55
  21. jarvis/jarvis_tools/git_commiter.py +60 -50
  22. jarvis/jarvis_tools/read_code.py +143 -0
  23. jarvis/jarvis_tools/read_webpage.py +50 -30
  24. jarvis/jarvis_tools/registry.py +4 -21
  25. jarvis/jarvis_tools/search_web.py +61 -36
  26. jarvis/jarvis_tools/tool_generator.py +78 -36
  27. jarvis/jarvis_utils/__init__.py +17 -17
  28. jarvis/jarvis_utils/config.py +87 -51
  29. jarvis/jarvis_utils/embedding.py +49 -48
  30. jarvis/jarvis_utils/git_utils.py +34 -34
  31. jarvis/jarvis_utils/globals.py +26 -26
  32. jarvis/jarvis_utils/input.py +61 -45
  33. jarvis/jarvis_utils/methodology.py +94 -76
  34. jarvis/jarvis_utils/output.py +63 -62
  35. jarvis/jarvis_utils/utils.py +2 -2
  36. {jarvis_ai_assistant-0.1.126.dist-info → jarvis_ai_assistant-0.1.129.dist-info}/METADATA +1 -1
  37. jarvis_ai_assistant-0.1.129.dist-info/RECORD +78 -0
  38. {jarvis_ai_assistant-0.1.126.dist-info → jarvis_ai_assistant-0.1.129.dist-info}/entry_points.txt +2 -0
  39. jarvis_ai_assistant-0.1.126.dist-info/RECORD +0 -74
  40. {jarvis_ai_assistant-0.1.126.dist-info → jarvis_ai_assistant-0.1.129.dist-info}/LICENSE +0 -0
  41. {jarvis_ai_assistant-0.1.126.dist-info → jarvis_ai_assistant-0.1.129.dist-info}/WHEEL +0 -0
  42. {jarvis_ai_assistant-0.1.126.dist-info → jarvis_ai_assistant-0.1.129.dist-info}/top_level.txt +0 -0
@@ -5,27 +5,13 @@ 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.input import get_multiline_input
8
9
  from jarvis.jarvis_utils.output import OutputType, PrettyOutput
9
10
 
10
11
 
11
- class AgentConfig:
12
- def __init__(self, **config):
13
- self.system_prompt = config.get('system_prompt', '')
14
- self.name = config.get('name', 'Jarvis')
15
- self.description = config.get('description', '')
16
- self.is_sub_agent = config.get('is_sub_agent', False)
17
- self.output_handler = config.get('output_handler', [])
18
- self.platform = config.get('platform')
19
- self.model_name = config.get('model_name')
20
- self.summary_prompt = config.get('summary_prompt')
21
- self.auto_complete = config.get('auto_complete', False)
22
- self.input_handler = config.get('input_handler')
23
- self.max_context_length = config.get('max_context_length')
24
- self.execute_tool_confirm = config.get('execute_tool_confirm')
25
-
26
12
  class MultiAgent(OutputHandler):
27
- def __init__(self, configs: List[AgentConfig], main_agent_name: str):
28
- self.agents_config = configs
13
+ def __init__(self, agents_config: List[Dict], main_agent_name: str):
14
+ self.agents_config = agents_config
29
15
  self.agents = {}
30
16
  self.init_agents()
31
17
  self.main_agent_name = main_agent_name
@@ -76,7 +62,7 @@ content: |
76
62
  - 根据响应继续任务
77
63
 
78
64
  # 👥 可用智能体
79
- {chr(10).join([f"- {c.name}: {c.description}" for c in self.agents_config])}
65
+ {chr(10).join([f"- {c['name']}: {c.get('description', '')}" for c in self.agents_config])}
80
66
 
81
67
  # ❗ 重要规则
82
68
  1. 每轮只能执行一个操作
@@ -128,29 +114,13 @@ content: |
128
114
  return ret
129
115
 
130
116
  def init_agents(self):
131
- for agent_config in self.agents_config:
132
- agent = Agent(system_prompt=agent_config.system_prompt,
133
- name=agent_config.name,
134
- description=agent_config.description,
135
- model_name=agent_config.model_name,
136
- platform=agent_config.platform,
137
- max_context_length=agent_config.max_context_length,
138
- execute_tool_confirm=agent_config.execute_tool_confirm,
139
- input_handler=agent_config.input_handler,
140
- use_methodology=False,
141
- record_methodology=False,
142
- need_summary=False,
143
- auto_complete=agent_config.auto_complete,
144
- summary_prompt=agent_config.summary_prompt,
145
- is_sub_agent=agent_config.is_sub_agent,
146
- output_handler=[*agent_config.output_handler, self],
147
- )
148
-
149
- self.agents[agent_config.name] = agent
117
+ for config in self.agents_config:
118
+ agent = Agent(**config)
119
+ self.agents[config['name']] = agent
150
120
 
151
- def run(self, user_input: str, file_list: Optional[List[str]] = None) -> str:
121
+ def run(self, user_input: str) -> str:
152
122
  last_agent = self.main_agent_name
153
- msg = self.agents[self.main_agent_name].run(user_input, file_list)
123
+ msg = self.agents[self.main_agent_name].run(user_input)
154
124
  while msg:
155
125
  if isinstance(msg, str):
156
126
  return msg
@@ -167,4 +137,45 @@ content: {msg['content']}
167
137
  PrettyOutput.print(f"{last_agent} 正在向 {msg['to']} 发送消息...", OutputType.INFO)
168
138
  last_agent = self.agents[msg['to']].name
169
139
  msg = self.agents[msg['to']].run(prompt)
170
- return ""
140
+ return ""
141
+
142
+
143
+ def main():
144
+ """从YAML配置文件初始化并运行多智能体系统
145
+
146
+ Returns:
147
+ 最终处理结果
148
+ """
149
+ import argparse
150
+ parser = argparse.ArgumentParser(description="多智能体系统启动器")
151
+ parser.add_argument("--config", "-c", required=True, help="YAML配置文件路径")
152
+ parser.add_argument("--input", "-i", help="用户输入(可选)")
153
+ args = parser.parse_args()
154
+
155
+ try:
156
+ with open(args.config, 'r') as f:
157
+ config_data = yaml.safe_load(f)
158
+
159
+ # 获取agents配置
160
+ agents_config = config_data.get('agents', [])
161
+
162
+ main_agent_name = config_data.get('main_agent', '')
163
+ if not main_agent_name:
164
+ raise ValueError("必须指定main_agent作为主智能体")
165
+
166
+ # 创建并运行多智能体系统
167
+ multi_agent = MultiAgent(agents_config, main_agent_name)
168
+ user_input = args.input if args.input is not None else get_multiline_input("请输入内容(输入空行结束):")
169
+ if user_input == "":
170
+ return
171
+ return multi_agent.run(user_input)
172
+
173
+ except yaml.YAMLError as e:
174
+ raise ValueError(f"YAML配置文件解析错误: {str(e)}")
175
+ except Exception as e:
176
+ raise RuntimeError(f"多智能体系统初始化失败: {str(e)}")
177
+
178
+
179
+ if __name__ == "__main__":
180
+ result = main()
181
+
@@ -10,7 +10,7 @@ class BasePlatform(ABC):
10
10
 
11
11
  def __init__(self):
12
12
  """Initialize model"""
13
- self.suppress_output = False # 添加输出控制标志
13
+ self.suppress_output = True # 添加输出控制标志
14
14
 
15
15
  def __del__(self):
16
16
  """Destroy model"""
@@ -46,10 +46,11 @@ class BasePlatform(ABC):
46
46
  tokens_per_second = 0
47
47
 
48
48
  # Print statistics
49
- PrettyOutput.print(
50
- f"对话完成 - 耗时: {duration:.2f}秒, 输出字符数: {char_count}, 输出Token数量: {token_count}, 每秒Token数量: {tokens_per_second:.2f}",
51
- OutputType.INFO,
52
- )
49
+ if not self.suppress_output:
50
+ PrettyOutput.print(
51
+ f"对话完成 - 耗时: {duration:.2f}秒, 输出字符数: {char_count}, 输出Token数量: {token_count}, 每秒Token数量: {tokens_per_second:.2f}",
52
+ OutputType.INFO,
53
+ )
53
54
 
54
55
  # Keep original think tag handling
55
56
  response = re.sub(r'<think>.*?</think>', '', response, flags=re.DOTALL)
@@ -59,6 +59,7 @@ def chat_with_model(platform_name: str, model_name: str):
59
59
  try:
60
60
  # Set model
61
61
  platform.set_model_name(model_name)
62
+ platform.set_suppress_output(False)
62
63
  PrettyOutput.print(f"连接到 {platform_name} 平台 {model_name} 模型", OutputType.SUCCESS)
63
64
 
64
65
  # Start conversation loop
@@ -209,7 +210,6 @@ def service_command(args):
209
210
  raise HTTPException(status_code=400, detail=f"Platform {platform_name} not found")
210
211
 
211
212
  platform.set_model_name(model_name)
212
- platform.set_suppress_output(True) # Suppress console output in server mode
213
213
  platform_instances[key] = platform
214
214
 
215
215
  return platform_instances[key]