jarvis-ai-assistant 0.1.196__py3-none-any.whl → 0.1.198__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 +1 -1
- jarvis/jarvis_agent/__init__.py +34 -7
- jarvis/jarvis_utils/jarvis_history.py +9 -7
- {jarvis_ai_assistant-0.1.196.dist-info → jarvis_ai_assistant-0.1.198.dist-info}/METADATA +2 -2
- {jarvis_ai_assistant-0.1.196.dist-info → jarvis_ai_assistant-0.1.198.dist-info}/RECORD +9 -9
- {jarvis_ai_assistant-0.1.196.dist-info → jarvis_ai_assistant-0.1.198.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.196.dist-info → jarvis_ai_assistant-0.1.198.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.196.dist-info → jarvis_ai_assistant-0.1.198.dist-info}/licenses/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.196.dist-info → jarvis_ai_assistant-0.1.198.dist-info}/top_level.txt +0 -0
jarvis/__init__.py
CHANGED
jarvis/jarvis_agent/__init__.py
CHANGED
@@ -473,13 +473,25 @@ class Agent:
|
|
473
473
|
注意:
|
474
474
|
当上下文长度超过最大值时使用
|
475
475
|
"""
|
476
|
-
|
477
|
-
|
476
|
+
need_summary = True
|
477
|
+
tmp_file_name = ""
|
478
|
+
try:
|
479
|
+
if self.model and self.model.support_upload_files():
|
480
|
+
need_summary = False
|
481
|
+
if need_summary:
|
482
|
+
summary = self.generate_summary()
|
483
|
+
else:
|
484
|
+
import tempfile
|
485
|
+
tmp_file = tempfile.NamedTemporaryFile(delete=False)
|
486
|
+
tmp_file_name = tmp_file.name
|
487
|
+
self.history.save_history(tmp_file_name)
|
488
|
+
self.clear_history() # type: ignore
|
478
489
|
|
479
|
-
|
480
|
-
|
490
|
+
if need_summary:
|
491
|
+
if not summary:
|
492
|
+
return ""
|
481
493
|
|
482
|
-
|
494
|
+
return f"""
|
483
495
|
以下是之前对话的关键信息总结:
|
484
496
|
|
485
497
|
<content>
|
@@ -487,7 +499,15 @@ class Agent:
|
|
487
499
|
</content>
|
488
500
|
|
489
501
|
请基于以上信息继续完成任务。请注意,这是之前对话的摘要,上下文长度已超过限制而被重置。请直接继续任务,无需重复已完成的步骤。如有需要,可以询问用户以获取更多信息。
|
490
|
-
"""
|
502
|
+
"""
|
503
|
+
else:
|
504
|
+
if self.model and self.model.upload_files([tmp_file_name]):
|
505
|
+
return "上传的文件是历史对话信息,请基于历史对话信息继续完成任务。"
|
506
|
+
else:
|
507
|
+
return ""
|
508
|
+
finally:
|
509
|
+
if tmp_file_name:
|
510
|
+
os.remove(tmp_file_name)
|
491
511
|
|
492
512
|
def _call_tools(self, response: str) -> Tuple[bool, Any]:
|
493
513
|
"""调用工具执行响应
|
@@ -848,7 +868,7 @@ arguments:
|
|
848
868
|
import tempfile
|
849
869
|
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
850
870
|
history_md = str(Path(tempfile.gettempdir())/f"{self.name}_history_{timestamp}.md")
|
851
|
-
self.history.export_history_to_markdown(
|
871
|
+
self.history.export_history_to_markdown(self.history_dir, history_md, max_files=self.history_count)
|
852
872
|
self.files.append(history_md)
|
853
873
|
|
854
874
|
# 如果有上传文件,先上传文件
|
@@ -862,9 +882,16 @@ arguments:
|
|
862
882
|
for handler in self.input_handler:
|
863
883
|
msg, _ = handler(msg, self)
|
864
884
|
self.prompt = f"{self.prompt}\n\n以下是历史类似问题的执行经验,可参考:\n{load_methodology(msg, self.get_tool_registry())}"
|
885
|
+
else:
|
886
|
+
if self.files:
|
887
|
+
self.prompt = f"{self.prompt}\n\n上传的文件包含历史对话信息和方法论文件,可以从中获取一些经验信息。"
|
888
|
+
else:
|
889
|
+
self.prompt = f"{self.prompt}\n\n上传的文件包含历史对话信息,可以从中获取一些经验信息。"
|
865
890
|
elif self.files:
|
866
891
|
if not self.model.upload_files(self.files):
|
867
892
|
PrettyOutput.print("文件上传失败,将忽略文件列表", OutputType.WARNING)
|
893
|
+
else:
|
894
|
+
self.prompt = f"{self.prompt}\n\n上传的文件包含历史对话信息,可以从中获取一些经验信息。"
|
868
895
|
else:
|
869
896
|
if self.files:
|
870
897
|
PrettyOutput.print("不支持上传文件,将忽略文件列表", OutputType.WARNING)
|
@@ -23,23 +23,25 @@ class JarvisHistory:
|
|
23
23
|
raise RuntimeError("Recording not started. Call start_record first.")
|
24
24
|
self.records.append({"role": role, "message": msg})
|
25
25
|
|
26
|
-
def
|
26
|
+
def save_history(self, filename: str) -> None:
|
27
27
|
"""Save recorded messages to YAML file"""
|
28
|
-
if not self.current_file:
|
29
|
-
raise RuntimeError("No recording session to stop.")
|
30
28
|
|
31
29
|
# Skip saving if records is empty
|
32
30
|
if not self.records:
|
33
|
-
self.current_file = None
|
34
|
-
self.records = []
|
35
31
|
return
|
36
32
|
|
37
33
|
# Ensure directory exists
|
38
|
-
os.makedirs(os.path.dirname(
|
34
|
+
os.makedirs(os.path.dirname(filename), exist_ok=True)
|
39
35
|
|
40
|
-
with open(
|
36
|
+
with open(filename, "w") as f:
|
41
37
|
yaml.safe_dump({"conversation": self.records}, f, allow_unicode=True)
|
42
38
|
|
39
|
+
def stop_record(self) -> None:
|
40
|
+
"""Stop recording session and save messages"""
|
41
|
+
if not self.current_file:
|
42
|
+
raise RuntimeError("No recording session to stop.")
|
43
|
+
|
44
|
+
self.save_history(self.current_file)
|
43
45
|
self.current_file = None
|
44
46
|
self.records = []
|
45
47
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: jarvis-ai-assistant
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.198
|
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
|
@@ -538,7 +538,7 @@ OPENAI_API_BASE: https://api.openai.com/v1
|
|
538
538
|
| `JARVIS_PRINT_PROMPT` | false | 是否打印提示 |
|
539
539
|
| `JARVIS_USE_METHODOLOGY` | true | 是否启用方法论功能 |
|
540
540
|
| `JARVIS_USE_ANALYSIS` | true | 是否启用任务分析功能 |
|
541
|
-
| `
|
541
|
+
| `JARVIS_USE_HISTORY_COUNT` | 0 | 使用N次历史记录作为上下文记忆 |
|
542
542
|
| `JARVIS_DATA_PATH` | ~/.jarvis | Jarvis数据存储目录路径 |
|
543
543
|
|
544
544
|
## 🛠️ 工具说明 <a id="tools"></a>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
jarvis/__init__.py,sha256=
|
2
|
-
jarvis/jarvis_agent/__init__.py,sha256=
|
1
|
+
jarvis/__init__.py,sha256=Ir1_uW7TcquoBOm25uhvdYhSDr2TWwS0R_QGOUXidP0,75
|
2
|
+
jarvis/jarvis_agent/__init__.py,sha256=3CfmmDU9ccEtJmRAtY86cdBm6NUYWatAsbgQFjs0t6M,33880
|
3
3
|
jarvis/jarvis_agent/builtin_input_handler.py,sha256=4CCEtVLRBIpkhDUKd54VcX1JFCIWCvDqDh4B1H-eSn0,2187
|
4
4
|
jarvis/jarvis_agent/jarvis.py,sha256=GH2zi8eXNpW8twiY3LKDEZgGmFC5geB0jlkwFrm7hOQ,6279
|
5
5
|
jarvis/jarvis_agent/main.py,sha256=c6bQe-8LXvW2-NBn9Rn_yPYdrwnkJ8KQaSFY2cPvkxw,2775
|
@@ -85,14 +85,14 @@ jarvis/jarvis_utils/file_processors.py,sha256=XiM248SHS7lLgQDCbORVFWqinbVDUawYxW
|
|
85
85
|
jarvis/jarvis_utils/git_utils.py,sha256=F1558EbJ3dRl12DMwmT24XjkC8XqddBjhpWxLgyI0aI,15688
|
86
86
|
jarvis/jarvis_utils/globals.py,sha256=9NTMfCVd0jvtloOv14-KE6clhcVStFmyN9jWxLmQ5so,3369
|
87
87
|
jarvis/jarvis_utils/input.py,sha256=WOs9hYSiZE3ao5K-UJmC7KyZByYnC1opHGJTUZm7DVo,7884
|
88
|
-
jarvis/jarvis_utils/jarvis_history.py,sha256=
|
88
|
+
jarvis/jarvis_utils/jarvis_history.py,sha256=Td6cmze9Oc5-Ewz0l9RKYeSg_-fbEu9ZhyEueHEMcLY,3664
|
89
89
|
jarvis/jarvis_utils/methodology.py,sha256=MhPrMxMqElyAn54BDfpQdUqrRr7IbSlrLvAI39LCgTM,8487
|
90
90
|
jarvis/jarvis_utils/output.py,sha256=PRCgudPOB8gMEP3u-g0FGD2c6tBgJhLXUMqNPglfjV8,10813
|
91
91
|
jarvis/jarvis_utils/tag.py,sha256=f211opbbbTcSyzCDwuIK_oCnKhXPNK-RknYyGzY1yD0,431
|
92
92
|
jarvis/jarvis_utils/utils.py,sha256=55kIbFXPFEd6770mdy2fZDh96XH0rIFJw2w3rYhE2Cc,11895
|
93
|
-
jarvis_ai_assistant-0.1.
|
94
|
-
jarvis_ai_assistant-0.1.
|
95
|
-
jarvis_ai_assistant-0.1.
|
96
|
-
jarvis_ai_assistant-0.1.
|
97
|
-
jarvis_ai_assistant-0.1.
|
98
|
-
jarvis_ai_assistant-0.1.
|
93
|
+
jarvis_ai_assistant-0.1.198.dist-info/licenses/LICENSE,sha256=AGgVgQmTqFvaztRtCAXsAMryUymB18gZif7_l2e1XOg,1063
|
94
|
+
jarvis_ai_assistant-0.1.198.dist-info/METADATA,sha256=DuyATtZZbn9V7qS0YtIBAfsp1a9bBfkL9Agp21YUeWk,20215
|
95
|
+
jarvis_ai_assistant-0.1.198.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
96
|
+
jarvis_ai_assistant-0.1.198.dist-info/entry_points.txt,sha256=Gy3DOP1PYLMK0GCj4rrP_9lkOyBQ39EK_lKGUSwn41E,869
|
97
|
+
jarvis_ai_assistant-0.1.198.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
|
98
|
+
jarvis_ai_assistant-0.1.198.dist-info/RECORD,,
|
File without changes
|
{jarvis_ai_assistant-0.1.196.dist-info → jarvis_ai_assistant-0.1.198.dist-info}/entry_points.txt
RENAMED
File without changes
|
{jarvis_ai_assistant-0.1.196.dist-info → jarvis_ai_assistant-0.1.198.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
{jarvis_ai_assistant-0.1.196.dist-info → jarvis_ai_assistant-0.1.198.dist-info}/top_level.txt
RENAMED
File without changes
|