jarvis-ai-assistant 0.3.0__py3-none-any.whl → 0.3.1__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 CHANGED
@@ -1,4 +1,4 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """Jarvis AI Assistant"""
3
3
 
4
- __version__ = "0.3.0"
4
+ __version__ = "0.3.1"
@@ -34,6 +34,7 @@ from jarvis.jarvis_utils.config import (
34
34
  get_thinking_model_name,
35
35
  get_thinking_platform_name,
36
36
  is_execute_tool_confirm,
37
+ is_force_save_memory,
37
38
  is_use_analysis,
38
39
  is_use_methodology,
39
40
  )
@@ -115,6 +116,7 @@ class Agent:
115
116
  multiline_inputer: Optional[Callable[[str], str]] = None,
116
117
  use_methodology: Optional[bool] = None,
117
118
  use_analysis: Optional[bool] = None,
119
+ force_save_memory: Optional[bool] = None,
118
120
  files: List[str] = [],
119
121
  ):
120
122
  """初始化Jarvis Agent实例
@@ -134,6 +136,7 @@ class Agent:
134
136
  multiline_inputer: 多行输入处理器
135
137
  use_methodology: 是否使用方法论
136
138
  use_analysis: 是否使用任务分析
139
+ force_save_memory: 是否强制保存记忆
137
140
  """
138
141
  # 基础属性初始化
139
142
  self.files = files
@@ -161,6 +164,7 @@ class Agent:
161
164
  execute_tool_confirm,
162
165
  summary_prompt,
163
166
  model_group,
167
+ force_save_memory,
164
168
  )
165
169
 
166
170
  # 初始化管理器
@@ -186,9 +190,7 @@ class Agent:
186
190
 
187
191
  self.model = PlatformRegistry().create_platform(platform_name)
188
192
  if self.model is None:
189
- PrettyOutput.print(
190
- f"平台 {platform_name} 不存在,将使用普通模型", OutputType.WARNING
191
- )
193
+ PrettyOutput.print(f"平台 {platform_name} 不存在,将使用普通模型", OutputType.WARNING)
192
194
  self.model = PlatformRegistry().get_normal_platform()
193
195
 
194
196
  if model_name:
@@ -227,6 +229,7 @@ class Agent:
227
229
  execute_tool_confirm: Optional[bool],
228
230
  summary_prompt: Optional[str],
229
231
  model_group: Optional[str],
232
+ force_save_memory: Optional[bool],
230
233
  ):
231
234
  """初始化配置选项"""
232
235
  # 如果有上传文件,自动禁用方法论
@@ -254,6 +257,12 @@ class Agent:
254
257
 
255
258
  self.max_token_count = get_max_token_count(model_group)
256
259
 
260
+ self.force_save_memory = (
261
+ force_save_memory
262
+ if force_save_memory is not None
263
+ else is_force_save_memory()
264
+ )
265
+
257
266
  def _setup_system_prompt(self):
258
267
  """设置系统提示词"""
259
268
  action_prompt = self.get_tool_usage_prompt()
@@ -440,9 +449,10 @@ class Agent:
440
449
  当上下文长度超过最大值时使用
441
450
  """
442
451
  # 在清理历史之前,提示用户保存重要记忆
443
- print("📌 对话历史即将被总结和清理,请先保存重要信息...")
444
- self.memory_manager.prompt_memory_save()
445
-
452
+ if self.force_save_memory:
453
+ print("📌 对话历史即将被总结和清理,请先保存重要信息...")
454
+ self.memory_manager.prompt_memory_save()
455
+
446
456
  if self._should_use_file_upload():
447
457
  return self._handle_history_with_file_upload()
448
458
  else:
@@ -504,10 +514,10 @@ class Agent:
504
514
  self.task_analyzer.analysis_task(satisfaction_feedback)
505
515
  else:
506
516
  # 如果没有开启分析,也提示用户是否有值得记忆的信息
507
- self.memory_manager.prompt_memory_save()
517
+ if self.force_save_memory:
518
+ self.memory_manager.prompt_memory_save()
508
519
 
509
520
  if self.need_summary:
510
-
511
521
  print("📄 正在生成总结...")
512
522
  self.session.prompt = self.summary_prompt
513
523
  if not self.model:
@@ -679,9 +689,7 @@ class Agent:
679
689
  返回:
680
690
  str: "continue" 或 "complete"
681
691
  """
682
- user_input = self.multiline_inputer(
683
- f"{self.name}: 请输入,或输入空行来结束当前任务:"
684
- )
692
+ user_input = self.multiline_inputer(f"{self.name}: 请输入,或输入空行来结束当前任务:")
685
693
 
686
694
  if user_input:
687
695
  self.session.prompt = user_input
@@ -116,18 +116,12 @@ class MemoryManager:
116
116
  memory_prompts += (
117
117
  "\n - 如果有关键信息需要记忆,请调用save_memory工具进行记忆:"
118
118
  )
119
- memory_prompts += (
120
- "\n * project_long_term: 保存与当前项目相关的长期信息"
121
- )
122
- memory_prompts += (
123
- "\n * global_long_term: 保存通用的信息、用户喜好、知识、方法等"
124
- )
125
- memory_prompts += "\n * short_term: 保存当前任务相关的临时信息"
119
+ memory_prompts += "\n * project_long_term: 保存与当前项目相关的长期信息(如:架构决策、关键配置、特定实现)"
120
+ memory_prompts += "\n * global_long_term: 保存通用的信息、用户喜好、知识、方法等(如:常用命令、个人偏好、解决方案)"
121
+ memory_prompts += "\n * short_term: 保存当前任务相关的临时信息(如:当前处理的文件、用户中间需求)"
126
122
 
127
123
  # 如果有retrieve_memory工具,添加相关提示
128
124
  if "retrieve_memory" in tool_names:
129
- memory_prompts += (
130
- "\n - 如果需要检索相关记忆信息,请调用retrieve_memory工具"
131
- )
125
+ memory_prompts += "\n - 如果需要获取上下文或寻找解决方案,请调用retrieve_memory工具检索相关记忆"
132
126
 
133
127
  return memory_prompts
@@ -245,6 +245,11 @@
245
245
  "description": "是否启用静态代码分析",
246
246
  "default": true
247
247
  },
248
+ "JARVIS_FORCE_SAVE_MEMORY": {
249
+ "type": "boolean",
250
+ "description": "是否强制保存记忆",
251
+ "default": true
252
+ },
248
253
  "JARVIS_TOOL_GROUP": {
249
254
  "type": "string",
250
255
  "description": "选择一个预定义的工具配置组",
@@ -391,10 +396,6 @@
391
396
  "type": "string",
392
397
  "description": "AI8 API Key"
393
398
  },
394
- "OYI_API_KEY": {
395
- "type": "string",
396
- "description": "Oyi API Key"
397
- },
398
399
  "SHELL": {
399
400
  "type": "string",
400
401
  "description": "系统Shell路径,用于获取当前使用的shell类型",
@@ -195,11 +195,16 @@ def start_service(
195
195
  if "/" in model:
196
196
  platform_name, model_name = model.split("/", 1)
197
197
  else:
198
- # Use default platform and model if not specified
199
- if default_platform and default_model:
200
- platform_name, model_name = default_platform, default_model
198
+ # Use default platform if not specified in the model name
199
+ if default_platform:
200
+ platform_name = default_platform
201
+ model_name = model
201
202
  else:
202
- platform_name, model_name = "oyi", model # Default to OYI platform
203
+ raise HTTPException(
204
+ status_code=400,
205
+ detail="Model name must be in 'platform/model_name' format "
206
+ "or a default platform must be set.",
207
+ )
203
208
 
204
209
  # Get platform instance
205
210
  platform = get_platform_instance(platform_name, model_name)
@@ -31,7 +31,7 @@ class SearchWebTool:
31
31
  """执行网络搜索、抓取内容并总结结果。"""
32
32
  try:
33
33
  PrettyOutput.print("▶️ 使用 DuckDuckGo 开始网页搜索...", OutputType.INFO)
34
- results = list(DDGS().text(query, max_results=50))
34
+ results = list(DDGS().text(query, max_results=50, page=3))
35
35
 
36
36
  if not results:
37
37
  return {
@@ -339,6 +339,16 @@ def is_print_prompt() -> bool:
339
339
  return GLOBAL_CONFIG_DATA.get("JARVIS_PRINT_PROMPT", False) == True
340
340
 
341
341
 
342
+ def is_force_save_memory() -> bool:
343
+ """
344
+ 获取是否强制保存记忆。
345
+
346
+ 返回:
347
+ bool: 如果强制保存记忆则返回True,默认为True
348
+ """
349
+ return GLOBAL_CONFIG_DATA.get("JARVIS_FORCE_SAVE_MEMORY", True) is True
350
+
351
+
342
352
  def is_enable_static_analysis() -> bool:
343
353
  """
344
354
  获取是否启用静态代码分析。
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jarvis-ai-assistant
3
- Version: 0.3.0
3
+ Version: 0.3.1
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
@@ -1,5 +1,5 @@
1
- jarvis/__init__.py,sha256=Arb_r89dPCTZmB-odbagucR7oYRYbfwAPJ4wWImvcxQ,73
2
- jarvis/jarvis_agent/__init__.py,sha256=rOMM99DeDsoO4pI2UT_eT-WRoOgibTb0641EikLzd_U,25397
1
+ jarvis/__init__.py,sha256=XcoTQZ6UV9jwJibx5WyZw3mcC4mymdL1YQyJuL5GUfY,73
2
+ jarvis/jarvis_agent/__init__.py,sha256=2zScM4N6GN4Vv5y_jDmJjTirea8ZGtRMiPf-UaGl0XE,25789
3
3
  jarvis/jarvis_agent/agent_manager.py,sha256=YzpMiF0H2-eyk2kn2o24Bkj3bXsQx7Pv2vfD4gWepo0,2893
4
4
  jarvis/jarvis_agent/builtin_input_handler.py,sha256=Qs4LAr4xdKLBJpQE81YP4CkucAop86ms0iVoKa1nnso,2468
5
5
  jarvis/jarvis_agent/config_editor.py,sha256=Ctk82sO6w2cNW0-_5L7Bomj-hgM4U7WwMc52fwhAJyg,1809
@@ -7,7 +7,7 @@ jarvis/jarvis_agent/edit_file_handler.py,sha256=w-byNJ4TN_SlV3djjfFC7OksySOFGrM8
7
7
  jarvis/jarvis_agent/file_methodology_manager.py,sha256=h2ogMK9mSKjg_n04ITw24m28J_U225bhLNhfwpf9jpU,4383
8
8
  jarvis/jarvis_agent/jarvis.py,sha256=yCXqNVF9S-IX02tNfPTw4WesMuO3F0Ht3Z0u1Srv7VI,3234
9
9
  jarvis/jarvis_agent/main.py,sha256=56pLVy6v-3ZdyPCcWXdRkgbjmYsoIfC7zrA6B7sYivU,3334
10
- jarvis/jarvis_agent/memory_manager.py,sha256=R9NdbQA-EnBSG4kCgEd_XkNCcBnMgGDUeo0HU01zLCc,5194
10
+ jarvis/jarvis_agent/memory_manager.py,sha256=F7HTNzdN1_-cSygnz7zKSJRJvPLUOosqcXQeiW8zG4U,5266
11
11
  jarvis/jarvis_agent/methodology_share_manager.py,sha256=vwWNexluTXSI3qeNP3zJAemOjWW37o_1AlqDR1C8wCI,6910
12
12
  jarvis/jarvis_agent/output_handler.py,sha256=P7oWpXBGFfOsWq7cIhS_z9crkQ19ES7qU5pM92KKjAs,1172
13
13
  jarvis/jarvis_agent/prompt_builder.py,sha256=PH1fPDVa8z_RXkoXHJFNDf8PQjUoLNLYwkh2lC__p40,1705
@@ -44,7 +44,7 @@ jarvis/jarvis_code_analysis/checklists/shell.py,sha256=aRFYhQQvTgbYd-uY5pc8UHIUA
44
44
  jarvis/jarvis_code_analysis/checklists/sql.py,sha256=vR0T6qC7b4dURjJVAd7kSVxyvZEQXPG1Jqc2sNTGp5c,2355
45
45
  jarvis/jarvis_code_analysis/checklists/swift.py,sha256=TPx4I6Gupvs6tSerRKmTSKEPQpOLEbH2Y7LXg1uBgxc,2566
46
46
  jarvis/jarvis_code_analysis/checklists/web.py,sha256=25gGD7pDadZQybNFvALYxWvK0VRjGQb1NVJQElwjyk0,3943
47
- jarvis/jarvis_data/config_schema.json,sha256=YTBUnQsUxqb0JlHZm2OBD6m_m6x5nZVNnxb_PlQB9c4,11369
47
+ jarvis/jarvis_data/config_schema.json,sha256=xri_qfCrs2AJ-fPwvnV4oU7VJpIrUxddffQMoSaHZ2A,11419
48
48
  jarvis/jarvis_data/tiktoken/9b5ad71b2ce5302211f9c61530b329a4922fc6a4,sha256=Ijkht27pm96ZW3_3OFE-7xAPtR0YyTWXoRO8_-hlsqc,1681126
49
49
  jarvis/jarvis_git_squash/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
50
  jarvis/jarvis_git_squash/main.py,sha256=6PECdAbTbrsJBRLK1pXBh4hdJ_LADh-XXSic1xJi97E,2255
@@ -67,7 +67,7 @@ jarvis/jarvis_platform/tongyi.py,sha256=uZP5ceCbHPApimKBqKthP5QynG52C3tMBglIyoBH
67
67
  jarvis/jarvis_platform/yuanbao.py,sha256=mS4aywK9CzgFU6FHh6GUxyY1Ly-NoBtGkBi74Jo_0XM,22921
68
68
  jarvis/jarvis_platform_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
69
69
  jarvis/jarvis_platform_manager/main.py,sha256=VhP0qiLqGPk_nQ_j0xg6H5CSct5ckNBaFqohb82whYs,17490
70
- jarvis/jarvis_platform_manager/service.py,sha256=hQGWQ2qAlzm_C_lNQDuLORQ4rmjR1P1-V3ou7l2Bv0s,13622
70
+ jarvis/jarvis_platform_manager/service.py,sha256=myJYGSUclCEiRTf3JKs4JndwhXJeQj7MQQy4i13jMt0,13767
71
71
  jarvis/jarvis_rag/__init__.py,sha256=HRTXgnQxDuaE9x-e3r6SYqhJ5d4DSI_rrIxy2IGY6qk,320
72
72
  jarvis/jarvis_rag/cache.py,sha256=Tqx_Oe-AhuWlMXHGHUaIuG6OEHoHBVZq7mL3kldtFFU,2723
73
73
  jarvis/jarvis_rag/cli.py,sha256=bIQKibp8swJDyfFBXaiX5C20LHN_2W2knO2I-MQp58c,15620
@@ -99,14 +99,14 @@ jarvis/jarvis_tools/registry.py,sha256=TtZ415LUMfWqfcgn3G5V4e3QLLU2ILNRatkP10U0Y
99
99
  jarvis/jarvis_tools/retrieve_memory.py,sha256=0UBZm4wQTXLTj5WHXR9fjsiIDQh-Z2UINVu8cJ12YYg,9488
100
100
  jarvis/jarvis_tools/rewrite_file.py,sha256=eG_WKg6cVAXmuGwUqlWkcuyay5S8DOzEi8vZCmX3O8w,7255
101
101
  jarvis/jarvis_tools/save_memory.py,sha256=DjeFb38OtK9Y_RpWYHz8vL72JdauXZTlc_Y0FUQBtiM,7486
102
- jarvis/jarvis_tools/search_web.py,sha256=zh6EYLQPIQneoz27Hheh-fifMeMNhrTVldXKMSsMz2Y,5801
102
+ jarvis/jarvis_tools/search_web.py,sha256=kDwC6fy4TFFyok5zFYZ4VCZXyLsbU9jAoxxy26--GIk,5809
103
103
  jarvis/jarvis_tools/virtual_tty.py,sha256=LTsg1PlsPvgaLShUaxpAKwTpyjXRr0l0qSREI7Q-fBc,26349
104
104
  jarvis/jarvis_tools/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
105
105
  jarvis/jarvis_tools/cli/main.py,sha256=GsfZJ4OS4Hvxh0H2XiLkgbzm-ajBsb4c0LyjuIAAatE,7718
106
106
  jarvis/jarvis_utils/__init__.py,sha256=67h0ldisGlh3oK4DAeNEL2Bl_VsI3tSmfclasyVlueM,850
107
107
  jarvis/jarvis_utils/builtin_replace_map.py,sha256=4BurljGuiG_I93EBs7mlFlPm9wYC_4CmdTG5tQWpF6g,1712
108
108
  jarvis/jarvis_utils/clipboard.py,sha256=WgbQIQR2sh7_5ZzeX04eT3zXx_mxQbKyJOZXgGX_TcI,2907
109
- jarvis/jarvis_utils/config.py,sha256=aHPm-E1CrbyOMWMvPRhMKPeuSVDXTlo8Iw7ya-3KWbs,15127
109
+ jarvis/jarvis_utils/config.py,sha256=RSmKvpfB9-cq5PVZPNSirc0qiNtNKw8AUpuz5RKK2vs,15378
110
110
  jarvis/jarvis_utils/embedding.py,sha256=oEOEM2qf16DMYwPsQe6srET9BknyjOdY2ef0jsp3Or8,2714
111
111
  jarvis/jarvis_utils/file_processors.py,sha256=XiM248SHS7lLgQDCbORVFWqinbVDUawYxWDOsLXDxP8,3043
112
112
  jarvis/jarvis_utils/git_utils.py,sha256=FxvmKkGlHWP0bTxzL1KR9fwr_ZYuBhtWX3Tt3JuMYKI,21865
@@ -117,9 +117,9 @@ jarvis/jarvis_utils/methodology.py,sha256=i8-chZtggN3GbhaDzeLV4eBl0DP3I5zctZ-I5H
117
117
  jarvis/jarvis_utils/output.py,sha256=QRLlKObQKT0KuRSeZRqYb7NlTQvsd1oZXZ41WxeWEuU,10894
118
118
  jarvis/jarvis_utils/tag.py,sha256=f211opbbbTcSyzCDwuIK_oCnKhXPNK-RknYyGzY1yD0,431
119
119
  jarvis/jarvis_utils/utils.py,sha256=RwhyPfBGx_x9OKawWUVw6bAbZeI4IlvxBhhYQ_RHpWQ,40847
120
- jarvis_ai_assistant-0.3.0.dist-info/licenses/LICENSE,sha256=AGgVgQmTqFvaztRtCAXsAMryUymB18gZif7_l2e1XOg,1063
121
- jarvis_ai_assistant-0.3.0.dist-info/METADATA,sha256=u-1pW7IUdcBM9TjwR_w4swoBGTV57p6NbL9Vg_RDlso,16807
122
- jarvis_ai_assistant-0.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
123
- jarvis_ai_assistant-0.3.0.dist-info/entry_points.txt,sha256=8cwi1VxZGU5UeSZMFiH-jG6NK95Asjukj5SBLBrGiGo,1257
124
- jarvis_ai_assistant-0.3.0.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
125
- jarvis_ai_assistant-0.3.0.dist-info/RECORD,,
120
+ jarvis_ai_assistant-0.3.1.dist-info/licenses/LICENSE,sha256=AGgVgQmTqFvaztRtCAXsAMryUymB18gZif7_l2e1XOg,1063
121
+ jarvis_ai_assistant-0.3.1.dist-info/METADATA,sha256=4A6JaiqkYbe-sqjWL5vB8MPelkKGP03DulZn-Y-zE3Y,16807
122
+ jarvis_ai_assistant-0.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
123
+ jarvis_ai_assistant-0.3.1.dist-info/entry_points.txt,sha256=8cwi1VxZGU5UeSZMFiH-jG6NK95Asjukj5SBLBrGiGo,1257
124
+ jarvis_ai_assistant-0.3.1.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
125
+ jarvis_ai_assistant-0.3.1.dist-info/RECORD,,