jarvis-ai-assistant 0.1.185__py3-none-any.whl → 0.1.187__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 +5 -7
- jarvis/jarvis_agent/jarvis.py +2 -1
- jarvis/jarvis_agent/main.py +8 -6
- jarvis/jarvis_tools/edit_file.py +1 -1
- jarvis/jarvis_utils/utils.py +19 -18
- {jarvis_ai_assistant-0.1.185.dist-info → jarvis_ai_assistant-0.1.187.dist-info}/METADATA +1 -1
- {jarvis_ai_assistant-0.1.185.dist-info → jarvis_ai_assistant-0.1.187.dist-info}/RECORD +12 -12
- {jarvis_ai_assistant-0.1.185.dist-info → jarvis_ai_assistant-0.1.187.dist-info}/WHEEL +1 -1
- {jarvis_ai_assistant-0.1.185.dist-info → jarvis_ai_assistant-0.1.187.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.185.dist-info → jarvis_ai_assistant-0.1.187.dist-info}/licenses/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.185.dist-info → jarvis_ai_assistant-0.1.187.dist-info}/top_level.txt +0 -0
jarvis/__init__.py
CHANGED
jarvis/jarvis_agent/__init__.py
CHANGED
@@ -436,7 +436,9 @@ class Agent:
|
|
436
436
|
if self.conversation_length > self.max_token_count:
|
437
437
|
message = self._summarize_and_clear_history() + "\n\n" + message
|
438
438
|
self.conversation_length += get_context_token_count(message)
|
439
|
-
|
439
|
+
response = self.model.chat_until_success(message) # type: ignore
|
440
|
+
self.conversation_length += get_context_token_count(response)
|
441
|
+
return response
|
440
442
|
|
441
443
|
def _summarize_and_clear_history(self) -> str:
|
442
444
|
"""总结当前对话并清理历史记录
|
@@ -780,27 +782,23 @@ arguments:
|
|
780
782
|
# 如果有上传文件,先上传文件
|
781
783
|
if self.files and isinstance(self.model, BasePlatform) and hasattr(self.model, "upload_files"):
|
782
784
|
self.model.upload_files(self.files)
|
783
|
-
self.prompt = f"{user_input}
|
785
|
+
self.prompt = f"{user_input}"
|
784
786
|
|
785
787
|
# 如果启用方法论且没有上传文件,上传方法论
|
786
788
|
elif self.use_methodology:
|
787
789
|
platform = self.model if hasattr(self.model, "upload_files") else None
|
788
790
|
if platform and upload_methodology(platform):
|
789
|
-
self.prompt = f"{user_input}
|
791
|
+
self.prompt = f"{user_input}"
|
790
792
|
else:
|
791
793
|
# 上传失败则回退到本地加载
|
792
794
|
self.prompt = f"{user_input}\n\n以下是历史类似问题的执行经验,可参考:\n{load_methodology(user_input, self.get_tool_registry())}"
|
793
795
|
|
794
796
|
self.first = False
|
795
797
|
|
796
|
-
self.conversation_length = get_context_token_count(self.prompt)
|
797
798
|
while True:
|
798
799
|
try:
|
799
800
|
current_response = self._call_model(self.prompt, True)
|
800
801
|
self.prompt = ""
|
801
|
-
self.conversation_length += get_context_token_count(
|
802
|
-
current_response
|
803
|
-
)
|
804
802
|
|
805
803
|
need_return, self.prompt = self._call_tools(current_response)
|
806
804
|
|
jarvis/jarvis_agent/jarvis.py
CHANGED
@@ -105,12 +105,13 @@ def _select_task(tasks: Dict[str, str]) -> str:
|
|
105
105
|
def main() -> None:
|
106
106
|
|
107
107
|
|
108
|
-
init_env("欢迎使用 Jarvis AI 助手,您的智能助理已准备就绪!")
|
109
108
|
parser = argparse.ArgumentParser(description='Jarvis AI assistant')
|
110
109
|
parser.add_argument('-p', '--platform', type=str, help='Platform to use')
|
111
110
|
parser.add_argument('-m', '--model', type=str, help='Model to use')
|
112
111
|
parser.add_argument('-t', '--task', type=str, help='Directly input task content from command line')
|
112
|
+
parser.add_argument('-f', '--config', type=str, help='Path to custom config file')
|
113
113
|
args = parser.parse_args()
|
114
|
+
init_env("欢迎使用 Jarvis AI 助手,您的智能助理已准备就绪!", config_file=args.config)
|
114
115
|
|
115
116
|
try:
|
116
117
|
agent = Agent(
|
jarvis/jarvis_agent/main.py
CHANGED
@@ -33,19 +33,21 @@ def load_config(config_path: str) -> dict:
|
|
33
33
|
|
34
34
|
def main():
|
35
35
|
"""Main entry point for Jarvis agent"""
|
36
|
-
# Initialize environment
|
37
|
-
init_env("欢迎使用 Jarvis AI 助手,您的智能助理已准备就绪!")
|
38
|
-
|
39
36
|
# Set up argument parser
|
40
37
|
parser = argparse.ArgumentParser(description='Jarvis AI assistant')
|
41
|
-
parser.add_argument('-
|
42
|
-
help='Path to
|
38
|
+
parser.add_argument('-f', '--config', type=str, required=False,
|
39
|
+
help='Path to agent config file')
|
40
|
+
parser.add_argument('-c', '--agent_definition', type=str,
|
41
|
+
help='Path to agent definition file')
|
43
42
|
parser.add_argument('-t', '--task', type=str,
|
44
43
|
help='Initial task to execute')
|
45
44
|
args = parser.parse_args()
|
46
45
|
|
46
|
+
# Initialize environment
|
47
|
+
init_env("欢迎使用 Jarvis AI 助手,您的智能助理已准备就绪!", config_file=args.config)
|
48
|
+
|
47
49
|
# Load configuration
|
48
|
-
config = load_config(args.
|
50
|
+
config = load_config(args.agent_definition) if args.agent_definition else {}
|
49
51
|
|
50
52
|
# Create and run agent
|
51
53
|
try:
|
jarvis/jarvis_tools/edit_file.py
CHANGED
jarvis/jarvis_utils/utils.py
CHANGED
@@ -5,7 +5,7 @@ import subprocess
|
|
5
5
|
import tarfile
|
6
6
|
import time
|
7
7
|
from pathlib import Path
|
8
|
-
from typing import Any, Callable, Dict
|
8
|
+
from typing import Any, Callable, Dict, Optional
|
9
9
|
|
10
10
|
import yaml
|
11
11
|
|
@@ -17,7 +17,7 @@ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
17
17
|
|
18
18
|
|
19
19
|
|
20
|
-
def init_env(welcome_str: str) -> None:
|
20
|
+
def init_env(welcome_str: str, config_file: Optional[str] = None) -> None:
|
21
21
|
"""初始化环境变量从jarvis_data/env文件
|
22
22
|
功能:
|
23
23
|
1. 创建不存在的jarvis_data目录
|
@@ -25,6 +25,10 @@ def init_env(welcome_str: str) -> None:
|
|
25
25
|
3. 处理文件读取异常
|
26
26
|
4. 检查git仓库状态并在落后时更新
|
27
27
|
5. 统计当前命令使用次数
|
28
|
+
|
29
|
+
参数:
|
30
|
+
welcome_str: 欢迎信息字符串
|
31
|
+
config_file: 配置文件路径,默认为None(使用~/.jarvis/config.yaml)
|
28
32
|
"""
|
29
33
|
count_cmd_usage()
|
30
34
|
|
@@ -43,35 +47,32 @@ def init_env(welcome_str: str) -> None:
|
|
43
47
|
if welcome_str:
|
44
48
|
PrettyOutput.print_gradient_text(jarvis_ascii_art, (0, 120, 255), (0, 255, 200))
|
45
49
|
|
46
|
-
|
47
|
-
config_file = jarvis_dir / "config.yaml"
|
50
|
+
config_file_path = Path(config_file) if config_file is not None else Path(os.path.expanduser("~/.jarvis/config.yaml"))
|
48
51
|
|
49
|
-
#
|
50
|
-
if not
|
51
|
-
|
52
|
+
# 加载配置文件
|
53
|
+
if not config_file_path.exists():
|
54
|
+
old_config_file = config_file_path.parent / "env"
|
55
|
+
if old_config_file.exists():# 旧的配置文件存在
|
56
|
+
_read_old_config_file(old_config_file)
|
57
|
+
else:
|
58
|
+
_read_config_file(config_file_path.parent, config_file_path)
|
52
59
|
|
60
|
+
# 现在获取最终的数据目录(可能被配置文件修改)
|
61
|
+
data_dir = Path(get_data_dir())
|
53
62
|
script_dir = Path(os.path.dirname(os.path.dirname(__file__)))
|
54
63
|
hf_archive = script_dir / "jarvis_data" / "huggingface.tar.gz"
|
55
64
|
|
56
65
|
|
57
66
|
# 检查并解压huggingface模型
|
58
|
-
hf_dir =
|
67
|
+
hf_dir = data_dir / "huggingface" / "hub"
|
59
68
|
if not hf_dir.exists() and hf_archive.exists():
|
60
69
|
try:
|
61
70
|
PrettyOutput.print("正在解压HuggingFace模型...", OutputType.INFO)
|
62
71
|
with tarfile.open(hf_archive, "r:gz") as tar:
|
63
|
-
tar.extractall(path=
|
72
|
+
tar.extractall(path=data_dir)
|
64
73
|
PrettyOutput.print("HuggingFace模型解压完成", OutputType.SUCCESS)
|
65
74
|
except Exception as e:
|
66
|
-
PrettyOutput.print(f"解压HuggingFace模型失败: {e}", OutputType.ERROR)
|
67
|
-
|
68
|
-
|
69
|
-
if not config_file.exists():
|
70
|
-
old_config_file = jarvis_dir / "env"
|
71
|
-
if old_config_file.exists():# 旧的配置文件存在
|
72
|
-
_read_old_config_file(old_config_file)
|
73
|
-
else:
|
74
|
-
_read_config_file(jarvis_dir, config_file)
|
75
|
+
PrettyOutput.print(f"解压HuggingFace模型失败: {e}", OutputType.ERROR)
|
75
76
|
|
76
77
|
# 检查是否是git仓库并更新
|
77
78
|
from jarvis.jarvis_utils.git_utils import check_and_update_git_repo
|
@@ -1,9 +1,9 @@
|
|
1
|
-
jarvis/__init__.py,sha256=
|
2
|
-
jarvis/jarvis_agent/__init__.py,sha256=
|
1
|
+
jarvis/__init__.py,sha256=asOF79piCkaX_uxiI4Oz9X7T0At-IuYPfb0XQlJZ6k8,74
|
2
|
+
jarvis/jarvis_agent/__init__.py,sha256=GBlsKYlZUpBekI7mTYFqAsmjXhlxMbIAoHkBpNjwt7M,30611
|
3
3
|
jarvis/jarvis_agent/builtin_input_handler.py,sha256=f4DaEHPakXcAbgykFP-tiOQP6fh_yGFlZx_h91_j2tQ,1529
|
4
4
|
jarvis/jarvis_agent/file_input_handler.py,sha256=7u8pXWD7F9mmiJkr9XO83mhFu40FSRoYQm55DbZHgQo,4203
|
5
|
-
jarvis/jarvis_agent/jarvis.py,sha256=
|
6
|
-
jarvis/jarvis_agent/main.py,sha256=
|
5
|
+
jarvis/jarvis_agent/jarvis.py,sha256=gOZfTwVlG-GZxPjgCoSiIcFsl4RwwfPA0CGUjE5J7oU,6249
|
6
|
+
jarvis/jarvis_agent/main.py,sha256=hgyf0QDESx88GlqYfGelxJ5HCpYOpm3FlcDXc-5jtjE,2852
|
7
7
|
jarvis/jarvis_agent/output_handler.py,sha256=7qori-RGrQmdiFepoEe3oPPKJIvRt90l_JDmvCoa4zA,1219
|
8
8
|
jarvis/jarvis_agent/shell_input_handler.py,sha256=pi3AtPKrkKc6K9e99S1djKXQ_XrxtP6FrSWebQmRT6E,1261
|
9
9
|
jarvis/jarvis_code_agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -65,7 +65,7 @@ jarvis/jarvis_tools/chdir.py,sha256=DNKVFrWqu6t_sZ2ipv99s6802QR4cSGlqKlmaI--arE,
|
|
65
65
|
jarvis/jarvis_tools/code_plan.py,sha256=gWR0lzY62x2PxWKoMRBqW6jq7zQuO8vhpjC4TcHSYjk,7685
|
66
66
|
jarvis/jarvis_tools/create_code_agent.py,sha256=-nHfo5O5pDIG5IX3w1ClQafGvGcdI2_w75-KGrD-gUQ,3458
|
67
67
|
jarvis/jarvis_tools/create_sub_agent.py,sha256=lyFrrg4V0yXULmU3vldwGp_euZjwZzJcRU6mJ20zejY,3023
|
68
|
-
jarvis/jarvis_tools/edit_file.py,sha256=
|
68
|
+
jarvis/jarvis_tools/edit_file.py,sha256=o8Arp2-779m8GLVtocS4kfVbAjoBb87nND2fy3bzbV0,17347
|
69
69
|
jarvis/jarvis_tools/execute_script.py,sha256=IA1SkcnwBB9PKG2voBNx5N9GXL303OC7OOtdqRfqWOk,6428
|
70
70
|
jarvis/jarvis_tools/file_analyzer.py,sha256=7ILHkUFm8pPZn1y_s4uT0kaWHP-EmlHnpkovDdA1yRE,4872
|
71
71
|
jarvis/jarvis_tools/file_operation.py,sha256=WloC1-oPJLwgICu4WBc9f7XA8N_Ggl73QQ5CxM2XTlE,9464
|
@@ -90,10 +90,10 @@ jarvis/jarvis_utils/input.py,sha256=FkLW7MXL8awQUghFLQnW1r5F1wV8K3EZeVPwHFRHJTo,
|
|
90
90
|
jarvis/jarvis_utils/methodology.py,sha256=A8pE8ZqNHvGKaDO4TFtg7Oz-hAXPBcQfhmSPWMr6vdg,8629
|
91
91
|
jarvis/jarvis_utils/output.py,sha256=QboL42GtG_dnvd1O64sl8o72mEBhXNRADPXQMXgDE7Q,9661
|
92
92
|
jarvis/jarvis_utils/tag.py,sha256=YJHmuedLb7_AiqvKQetHr4R1FxyzIh7HN0RRkWMmYbU,429
|
93
|
-
jarvis/jarvis_utils/utils.py,sha256=
|
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.
|
99
|
-
jarvis_ai_assistant-0.1.
|
93
|
+
jarvis/jarvis_utils/utils.py,sha256=dTFIN6EV48BuC4VOyvcVcj4P0tsWysc9ennbMRhLJjk,10960
|
94
|
+
jarvis_ai_assistant-0.1.187.dist-info/licenses/LICENSE,sha256=AGgVgQmTqFvaztRtCAXsAMryUymB18gZif7_l2e1XOg,1063
|
95
|
+
jarvis_ai_assistant-0.1.187.dist-info/METADATA,sha256=lbhXX4AEUFxgJOFe_c2Sz40dB98YotFgNHHnhtB4WU4,15923
|
96
|
+
jarvis_ai_assistant-0.1.187.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
97
|
+
jarvis_ai_assistant-0.1.187.dist-info/entry_points.txt,sha256=Gy3DOP1PYLMK0GCj4rrP_9lkOyBQ39EK_lKGUSwn41E,869
|
98
|
+
jarvis_ai_assistant-0.1.187.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
|
99
|
+
jarvis_ai_assistant-0.1.187.dist-info/RECORD,,
|
{jarvis_ai_assistant-0.1.185.dist-info → jarvis_ai_assistant-0.1.187.dist-info}/entry_points.txt
RENAMED
File without changes
|
{jarvis_ai_assistant-0.1.185.dist-info → jarvis_ai_assistant-0.1.187.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
{jarvis_ai_assistant-0.1.185.dist-info → jarvis_ai_assistant-0.1.187.dist-info}/top_level.txt
RENAMED
File without changes
|