jarvis-ai-assistant 0.1.23__tar.gz → 0.1.25__tar.gz

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 (56) hide show
  1. {jarvis_ai_assistant-0.1.23/src/jarvis_ai_assistant.egg-info → jarvis_ai_assistant-0.1.25}/PKG-INFO +1 -1
  2. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/pyproject.toml +1 -1
  3. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/setup.py +1 -1
  4. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/__init__.py +1 -1
  5. jarvis_ai_assistant-0.1.25/src/jarvis/__pycache__/__init__.cpython-313.pyc +0 -0
  6. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/__pycache__/agent.cpython-313.pyc +0 -0
  7. jarvis_ai_assistant-0.1.25/src/jarvis/__pycache__/main.cpython-313.pyc +0 -0
  8. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/__pycache__/utils.cpython-313.pyc +0 -0
  9. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/agent.py +13 -3
  10. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/main.py +4 -17
  11. jarvis_ai_assistant-0.1.25/src/jarvis/models/__pycache__/kimi.cpython-313.pyc +0 -0
  12. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/models/kimi.py +83 -3
  13. jarvis_ai_assistant-0.1.25/src/jarvis/tools/__pycache__/base.cpython-313.pyc +0 -0
  14. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/__pycache__/sub_agent.cpython-313.pyc +0 -0
  15. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/base.py +3 -3
  16. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/utils.py +1 -1
  17. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25/src/jarvis_ai_assistant.egg-info}/PKG-INFO +1 -1
  18. jarvis_ai_assistant-0.1.23/src/jarvis/__pycache__/__init__.cpython-313.pyc +0 -0
  19. jarvis_ai_assistant-0.1.23/src/jarvis/__pycache__/main.cpython-313.pyc +0 -0
  20. jarvis_ai_assistant-0.1.23/src/jarvis/models/__pycache__/kimi.cpython-313.pyc +0 -0
  21. jarvis_ai_assistant-0.1.23/src/jarvis/tools/__pycache__/base.cpython-313.pyc +0 -0
  22. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/LICENSE +0 -0
  23. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/MANIFEST.in +0 -0
  24. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/README.md +0 -0
  25. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/setup.cfg +0 -0
  26. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/__pycache__/models.cpython-313.pyc +0 -0
  27. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/__pycache__/tools.cpython-313.pyc +0 -0
  28. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/__pycache__/zte_llm.cpython-313.pyc +0 -0
  29. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/models/__init__.py +0 -0
  30. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/models/__pycache__/__init__.cpython-313.pyc +0 -0
  31. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/models/__pycache__/base.cpython-313.pyc +0 -0
  32. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/models/base.py +0 -0
  33. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/__init__.py +0 -0
  34. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/__pycache__/__init__.cpython-313.pyc +0 -0
  35. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/__pycache__/bing_search.cpython-313.pyc +0 -0
  36. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/__pycache__/calculator.cpython-313.pyc +0 -0
  37. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/__pycache__/calculator_tool.cpython-313.pyc +0 -0
  38. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/__pycache__/file_ops.cpython-313.pyc +0 -0
  39. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/__pycache__/generator.cpython-313.pyc +0 -0
  40. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/__pycache__/python_script.cpython-313.pyc +0 -0
  41. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/__pycache__/rag.cpython-313.pyc +0 -0
  42. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/__pycache__/search.cpython-313.pyc +0 -0
  43. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/__pycache__/shell.cpython-313.pyc +0 -0
  44. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/__pycache__/user_confirmation.cpython-313.pyc +0 -0
  45. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/__pycache__/user_input.cpython-313.pyc +0 -0
  46. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/__pycache__/user_interaction.cpython-313.pyc +0 -0
  47. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/__pycache__/webpage.cpython-313.pyc +0 -0
  48. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/file_ops.py +0 -0
  49. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/generator.py +0 -0
  50. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/shell.py +0 -0
  51. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis/tools/sub_agent.py +0 -0
  52. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis_ai_assistant.egg-info/SOURCES.txt +0 -0
  53. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis_ai_assistant.egg-info/dependency_links.txt +0 -0
  54. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis_ai_assistant.egg-info/entry_points.txt +0 -0
  55. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis_ai_assistant.egg-info/requires.txt +0 -0
  56. {jarvis_ai_assistant-0.1.23 → jarvis_ai_assistant-0.1.25}/src/jarvis_ai_assistant.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: jarvis-ai-assistant
3
- Version: 0.1.23
3
+ Version: 0.1.25
4
4
  Summary: Jarvis: An AI assistant that uses tools to interact with the system
5
5
  Home-page: https://github.com/skyfireitdiy/Jarvis
6
6
  Author: skyfire
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "jarvis-ai-assistant"
7
- version = "0.1.23"
7
+ version = "0.1.25"
8
8
  description = "Jarvis: An AI assistant that uses tools to interact with the system"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Your Name", email = "your.email@example.com" }]
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="jarvis-ai-assistant",
5
- version="0.1.23",
5
+ version="0.1.25",
6
6
  author="skyfire",
7
7
  author_email="skyfireitdiy@hotmail.com",
8
8
  description="An AI assistant that uses various tools to interact with the system",
@@ -1,3 +1,3 @@
1
1
  """Jarvis AI Assistant"""
2
2
 
3
- __version__ = "0.1.23"
3
+ __version__ = "0.1.25"
@@ -11,7 +11,7 @@ import os
11
11
  from datetime import datetime
12
12
 
13
13
  class Agent:
14
- def __init__(self, model: BaseModel, tool_registry: ToolRegistry, name: str = "Jarvis", is_sub_agent: bool = False):
14
+ def __init__(self, model: BaseModel, tool_registry: ToolRegistry, name: str = "Jarvis", is_sub_agent: bool = False, verbose: bool = False):
15
15
  """Initialize Agent with a model, optional tool registry and name
16
16
 
17
17
  Args:
@@ -21,7 +21,7 @@ class Agent:
21
21
  is_sub_agent: 是否为子Agent,默认为False
22
22
  """
23
23
  self.model = model
24
- self.tool_registry = tool_registry or ToolRegistry(model)
24
+ self.tool_registry = tool_registry or ToolRegistry(model, verbose=verbose)
25
25
  self.name = name
26
26
  self.is_sub_agent = is_sub_agent
27
27
  self.prompt = ""
@@ -112,7 +112,8 @@ class Agent:
112
112
  1. 使用现有工具完成任务
113
113
  2. 通过 generate_tool 创建新工具扩展功能
114
114
  3. 通过 create_sub_agent 创建子代理处理独立任务
115
- 4. 遵循 ReAct (思考-行动-观察) 框架
115
+ 4. 访问和理解网页内容(无需使用工具)
116
+ 5. 遵循 ReAct (思考-行动-观察) 框架
116
117
 
117
118
  工作流程:
118
119
  1. 思考
@@ -120,11 +121,13 @@ class Agent:
120
121
  - 评估是否需要新工具
121
122
  - 考虑是否需要拆分子任务
122
123
  - 规划解决方案
124
+ - 确定是否需要访问网页
123
125
 
124
126
  2. 行动 (如果需要)
125
127
  - 使用现有工具
126
128
  - 创建新工具
127
129
  - 创建子代理
130
+ - 访问网页获取信息
128
131
  - 询问更多信息
129
132
 
130
133
  3. 观察
@@ -132,6 +135,13 @@ class Agent:
132
135
  - 分析反馈
133
136
  - 规划下一步
134
137
 
138
+ 网页访问能力:
139
+ - 可以直接访问和阅读网页内容
140
+ - 无需使用额外工具
141
+ - 可以提取和分析网页信息
142
+ - 支持多种网页格式
143
+ - 注意:仅支持公开访问的网页
144
+
135
145
  任务拆分建议:
136
146
  - 当任务包含多个独立步骤时
137
147
  - 当子任务需要独立的上下文时
@@ -58,19 +58,6 @@ def load_tasks() -> dict:
58
58
 
59
59
  return tasks
60
60
 
61
- class NumberValidator(Validator):
62
- def validate(self, document):
63
- text = document.text.strip()
64
- if not text: # Allow empty input
65
- return
66
-
67
- try:
68
- number = int(text)
69
- if number < 0:
70
- raise ValidationError(message='Please enter a non-negative number')
71
- except ValueError:
72
- raise ValidationError(message='Please enter a valid number')
73
-
74
61
  def select_task(tasks: dict) -> str:
75
62
  """Let user select a task from the list or skip. Returns task description if selected."""
76
63
  if not tasks:
@@ -93,7 +80,6 @@ def select_task(tasks: dict) -> str:
93
80
  choice = prompt(
94
81
  "\nSelect a task number (0 to skip): ",
95
82
  completer=number_completer,
96
- validator=NumberValidator(),
97
83
  validate_while_typing=False,
98
84
  enable_history_search=True,
99
85
  ).strip()
@@ -121,6 +107,7 @@ def main():
121
107
  parser = argparse.ArgumentParser(description='Jarvis AI Assistant')
122
108
  parser.add_argument('-f', '--files', nargs='*', help='List of files to process')
123
109
  parser.add_argument('--keep-history', action='store_true', help='Keep chat history (do not delete chat session)')
110
+ parser.add_argument('-v', '--verbose', action='store_true', help='Show detailed search and reference information')
124
111
  args = parser.parse_args()
125
112
 
126
113
  load_env_from_file()
@@ -149,10 +136,10 @@ def main():
149
136
  PrettyOutput.print("\n设置完成后重新运行 Jarvis。", OutputType.INFO, timestamp=False)
150
137
  return 1
151
138
 
152
- model = KimiModel(kimi_api_key)
139
+ model = KimiModel(kimi_api_key, verbose=args.verbose)
153
140
 
154
- tool_registry = ToolRegistry()
155
- agent = Agent(model, tool_registry)
141
+ tool_registry = ToolRegistry(verbose=args.verbose)
142
+ agent = Agent(model, tool_registry, verbose=args.verbose)
156
143
 
157
144
  # 欢迎信息
158
145
  PrettyOutput.print(f"Jarvis 已初始化 - With Kimi", OutputType.SYSTEM)
@@ -10,7 +10,7 @@ import time
10
10
  class KimiModel(BaseModel):
11
11
  """Kimi模型实现"""
12
12
 
13
- def __init__(self, api_key: str = None):
13
+ def __init__(self, api_key: Optional[str] = None, verbose: bool = False):
14
14
  """
15
15
  初始化Kimi模型
16
16
  Args:
@@ -23,6 +23,7 @@ class KimiModel(BaseModel):
23
23
  self.chat_id = ""
24
24
  self.uploaded_files = [] # 存储已上传文件的信息
25
25
  self.first_chat = True # 添加标记,用于判断是否是第一次对话
26
+ self.verbose = verbose # 添加verbose属性
26
27
 
27
28
  def _create_chat(self) -> bool:
28
29
  """创建新的对话会话"""
@@ -41,7 +42,7 @@ class KimiModel(BaseModel):
41
42
  self.chat_id = response.json()["id"]
42
43
  return True
43
44
  except Exception as e:
44
- PrettyOutput.print(f"Failed to create chat: {e}", OutputType.ERROR)
45
+ PrettyOutput.print(f"Failed to create chat: {e}: Response: {response.text}", OutputType.ERROR)
45
46
  return False
46
47
 
47
48
  def _get_presigned_url(self, filename: str) -> Dict:
@@ -221,6 +222,10 @@ class KimiModel(BaseModel):
221
222
  response = requests.post(url, headers=headers, json=payload, stream=True)
222
223
  full_response = ""
223
224
 
225
+ # 收集搜索和引用结果
226
+ search_results = []
227
+ ref_sources = []
228
+
224
229
  PrettyOutput.print("接收响应...", OutputType.PROGRESS)
225
230
  for line in response.iter_lines():
226
231
  if not line:
@@ -232,15 +237,90 @@ class KimiModel(BaseModel):
232
237
 
233
238
  try:
234
239
  data = json.loads(line[6:])
235
- if data.get("event") == "cmpl":
240
+ event = data.get("event")
241
+
242
+ if event == "cmpl":
243
+ # 处理补全文本
236
244
  text = data.get("text", "")
237
245
  if text:
238
246
  PrettyOutput.print_stream(text, OutputType.SYSTEM)
239
247
  full_response += text
248
+
249
+ elif event == "search_plus":
250
+ # 收集搜索结果
251
+ msg = data.get("msg", {})
252
+ if msg.get("type") == "get_res":
253
+ search_results.append({
254
+ "date": msg.get("date", ""),
255
+ "site_name": msg.get("site_name", ""),
256
+ "snippet": msg.get("snippet", ""),
257
+ "title": msg.get("title", ""),
258
+ "type": msg.get("type", ""),
259
+ "url": msg.get("url", "")
260
+ })
261
+
262
+ elif event == "ref_docs":
263
+ # 收集引用来源
264
+ ref_cards = data.get("ref_cards", [])
265
+ for card in ref_cards:
266
+ ref_sources.append({
267
+ "idx_s": card.get("idx_s", ""),
268
+ "idx_z": card.get("idx_z", ""),
269
+ "ref_id": card.get("ref_id", ""),
270
+ "url": card.get("url", ""),
271
+ "title": card.get("title", ""),
272
+ "abstract": card.get("abstract", ""),
273
+ "source": card.get("source_label", ""),
274
+ "rag_segments": card.get("rag_segments", []),
275
+ "origin": card.get("origin", {})
276
+ })
277
+
240
278
  except json.JSONDecodeError:
241
279
  continue
242
280
 
243
281
  PrettyOutput.print_stream_end()
282
+
283
+ # 只在verbose模式下显示搜索和引用信息
284
+ if self.verbose:
285
+ # 显示搜索结果摘要
286
+ if search_results:
287
+ PrettyOutput.print("\n搜索结果:", OutputType.INFO)
288
+ for result in search_results:
289
+ PrettyOutput.print(f"- {result['title']}", OutputType.INFO)
290
+ if result['date']:
291
+ PrettyOutput.print(f" 日期: {result['date']}", OutputType.INFO)
292
+ PrettyOutput.print(f" 来源: {result['site_name']}", OutputType.INFO)
293
+ if result['snippet']:
294
+ PrettyOutput.print(f" 摘要: {result['snippet']}", OutputType.INFO)
295
+ PrettyOutput.print(f" 链接: {result['url']}", OutputType.INFO)
296
+ PrettyOutput.print("", OutputType.INFO)
297
+
298
+ # 显示引用来源
299
+ if ref_sources:
300
+ PrettyOutput.print("\n引用来源:", OutputType.INFO)
301
+ for source in ref_sources:
302
+ PrettyOutput.print(f"- [{source['ref_id']}] {source['title']} ({source['source']})", OutputType.INFO)
303
+ PrettyOutput.print(f" 链接: {source['url']}", OutputType.INFO)
304
+ if source['abstract']:
305
+ PrettyOutput.print(f" 摘要: {source['abstract']}", OutputType.INFO)
306
+
307
+ # 显示相关段落
308
+ if source['rag_segments']:
309
+ PrettyOutput.print(" 相关段落:", OutputType.INFO)
310
+ for segment in source['rag_segments']:
311
+ text = segment.get('text', '').replace('\n', ' ').strip()
312
+ if text:
313
+ PrettyOutput.print(f" - {text}", OutputType.INFO)
314
+
315
+ # 显示原文引用
316
+ origin = source['origin']
317
+ if origin:
318
+ text = origin.get('text', '')
319
+ if text:
320
+ PrettyOutput.print(f" 原文: {text}", OutputType.INFO)
321
+
322
+ PrettyOutput.print("", OutputType.INFO)
323
+
244
324
  return full_response
245
325
 
246
326
  except Exception as e:
@@ -30,7 +30,7 @@ class Tool:
30
30
  return self.func(arguments)
31
31
 
32
32
  class ToolRegistry:
33
- def __init__(self, output_handler=None):
33
+ def __init__(self, output_handler=None, verbose=False):
34
34
  """初始化工具注册器
35
35
 
36
36
  Args:
@@ -38,7 +38,7 @@ class ToolRegistry:
38
38
  """
39
39
  self.tools: Dict[str, Tool] = {}
40
40
  self.output_handler = output_handler or PrettyOutput
41
-
41
+ self.verbose = verbose
42
42
  # 加载内置工具和外部工具
43
43
  self._load_builtin_tools()
44
44
  self._load_external_tools()
@@ -106,7 +106,7 @@ class ToolRegistry:
106
106
  hasattr(item, 'parameters')):
107
107
 
108
108
  # 实例化工具类,传入模型和输出处理器
109
- tool_instance = item(model=KimiModel(), register=self, output_handler=self.output_handler)
109
+ tool_instance = item(model=KimiModel(verbose=self.verbose), register=self, output_handler=self.output_handler)
110
110
 
111
111
  # 注册工具
112
112
  self.register_tool(
@@ -95,7 +95,7 @@ class PrettyOutput:
95
95
  return formatted_text
96
96
 
97
97
  @staticmethod
98
- def print(text: str, output_type: OutputType, timestamp: bool = True):
98
+ def print(text: str, output_type: OutputType, timestamp: bool = False):
99
99
  """打印格式化的输出"""
100
100
  print(PrettyOutput.format(text, output_type, timestamp))
101
101
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: jarvis-ai-assistant
3
- Version: 0.1.23
3
+ Version: 0.1.25
4
4
  Summary: Jarvis: An AI assistant that uses tools to interact with the system
5
5
  Home-page: https://github.com/skyfireitdiy/Jarvis
6
6
  Author: skyfire