jarvis-ai-assistant 0.1.189__py3-none-any.whl → 0.1.191__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 +11 -39
- jarvis/jarvis_agent/jarvis.py +0 -2
- jarvis/jarvis_git_utils/git_commiter.py +1 -0
- jarvis/jarvis_platform/base.py +11 -6
- jarvis/jarvis_platform/human.py +1 -1
- jarvis/jarvis_platform/kimi.py +1 -1
- jarvis/jarvis_platform/openai.py +1 -1
- jarvis/jarvis_platform/registry.py +1 -1
- jarvis/jarvis_platform/tongyi.py +1 -1
- jarvis/jarvis_platform/yuanbao.py +1 -1
- jarvis/jarvis_platform_manager/main.py +283 -125
- jarvis/jarvis_smart_shell/main.py +1 -1
- jarvis/jarvis_tools/file_analyzer.py +1 -1
- jarvis/jarvis_tools/generate_new_tool.py +88 -40
- jarvis/jarvis_tools/registry.py +5 -3
- jarvis/jarvis_utils/globals.py +45 -0
- jarvis/jarvis_utils/utils.py +16 -0
- {jarvis_ai_assistant-0.1.189.dist-info → jarvis_ai_assistant-0.1.191.dist-info}/METADATA +62 -3
- {jarvis_ai_assistant-0.1.189.dist-info → jarvis_ai_assistant-0.1.191.dist-info}/RECORD +24 -24
- {jarvis_ai_assistant-0.1.189.dist-info → jarvis_ai_assistant-0.1.191.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.189.dist-info → jarvis_ai_assistant-0.1.191.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.189.dist-info → jarvis_ai_assistant-0.1.191.dist-info}/licenses/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.189.dist-info → jarvis_ai_assistant-0.1.191.dist-info}/top_level.txt +0 -0
jarvis/__init__.py
CHANGED
jarvis/jarvis_agent/__init__.py
CHANGED
@@ -19,8 +19,8 @@ from jarvis.jarvis_utils.config import (get_max_token_count,
|
|
19
19
|
is_execute_tool_confirm,
|
20
20
|
is_use_analysis, is_use_methodology)
|
21
21
|
from jarvis.jarvis_utils.embedding import get_context_token_count
|
22
|
-
from jarvis.jarvis_utils.globals import (delete_agent, make_agent_name,
|
23
|
-
set_agent)
|
22
|
+
from jarvis.jarvis_utils.globals import (delete_agent, get_interrupt, make_agent_name,
|
23
|
+
set_agent, set_interrupt)
|
24
24
|
from jarvis.jarvis_utils.input import get_multiline_input
|
25
25
|
from jarvis.jarvis_utils.methodology import (load_methodology,
|
26
26
|
upload_methodology)
|
@@ -319,7 +319,7 @@ class Agent:
|
|
319
319
|
</actions>
|
320
320
|
"""
|
321
321
|
|
322
|
-
self.model.
|
322
|
+
self.model.set_system_prompt(
|
323
323
|
f"""
|
324
324
|
{self.system_prompt}
|
325
325
|
|
@@ -371,40 +371,6 @@ class Agent:
|
|
371
371
|
return handler
|
372
372
|
return None
|
373
373
|
|
374
|
-
def make_default_addon_prompt(self, need_complete: bool) -> str:
|
375
|
-
"""生成附加提示。
|
376
|
-
|
377
|
-
参数:
|
378
|
-
need_complete: 是否需要完成任务
|
379
|
-
|
380
|
-
"""
|
381
|
-
# 结构化系统指令
|
382
|
-
action_handlers = ", ".join([handler.name() for handler in self.output_handler])
|
383
|
-
|
384
|
-
# 任务完成提示
|
385
|
-
complete_prompt = (
|
386
|
-
f"- 输出{ot('!!!COMPLETE!!!')}"
|
387
|
-
if need_complete and self.auto_complete
|
388
|
-
else ""
|
389
|
-
)
|
390
|
-
|
391
|
-
addon_prompt = f"""
|
392
|
-
<system_prompt>
|
393
|
-
请判断是否已经完成任务,如果已经完成:
|
394
|
-
- 直接输出完成原因,不需要再有新的操作,不要输出{ot("TOOL_CALL")}标签
|
395
|
-
{complete_prompt}
|
396
|
-
如果没有完成,请进行下一步操作:
|
397
|
-
- 仅包含一个操作
|
398
|
-
- 如果信息不明确,请请求用户补充
|
399
|
-
- 如果执行过程中连续失败5次,请使用ask_user询问用户操作
|
400
|
-
- 操作列表:{action_handlers}
|
401
|
-
</system_prompt>
|
402
|
-
|
403
|
-
请继续。
|
404
|
-
"""
|
405
|
-
|
406
|
-
return addon_prompt
|
407
|
-
|
408
374
|
def _call_model(self, message: str, need_complete: bool = False) -> str:
|
409
375
|
"""调用AI模型并实现重试逻辑
|
410
376
|
|
@@ -429,8 +395,6 @@ class Agent:
|
|
429
395
|
if self.addon_prompt:
|
430
396
|
message += f"\n\n{self.addon_prompt}"
|
431
397
|
self.addon_prompt = ""
|
432
|
-
else:
|
433
|
-
message += f"\n\n{self.make_default_addon_prompt(need_complete)}"
|
434
398
|
|
435
399
|
# 累加对话长度
|
436
400
|
self.conversation_length += get_context_token_count(message)
|
@@ -812,6 +776,14 @@ arguments:
|
|
812
776
|
if self.after_tool_call_cb:
|
813
777
|
self.after_tool_call_cb(self)
|
814
778
|
|
779
|
+
if get_interrupt():
|
780
|
+
set_interrupt(False)
|
781
|
+
user_input = self.multiline_inputer(
|
782
|
+
f"模型交互期间被中断,请输入用户干预信息:"
|
783
|
+
)
|
784
|
+
if user_input:
|
785
|
+
self.prompt += f"\n\n用户干预信息:{user_input}"
|
786
|
+
|
815
787
|
if self.prompt or self.addon_prompt:
|
816
788
|
continue
|
817
789
|
|
jarvis/jarvis_agent/jarvis.py
CHANGED
@@ -77,6 +77,7 @@ class GitCommitTool:
|
|
77
77
|
def execute(self, args: Dict) -> Dict[str, Any]:
|
78
78
|
"""Execute automatic commit process with support for multi-line messages and special characters"""
|
79
79
|
try:
|
80
|
+
original_dir = os.getcwd()
|
80
81
|
root_dir = args.get("root_dir", ".")
|
81
82
|
prefix = args.get("prefix", "")
|
82
83
|
suffix = args.get("suffix", "")
|
jarvis/jarvis_platform/base.py
CHANGED
@@ -12,6 +12,7 @@ from yaspin import yaspin
|
|
12
12
|
from jarvis.jarvis_utils.config import (get_max_input_token_count,
|
13
13
|
get_pretty_output, is_print_prompt)
|
14
14
|
from jarvis.jarvis_utils.embedding import split_text_into_chunks
|
15
|
+
from jarvis.jarvis_utils.globals import set_in_chat
|
15
16
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
16
17
|
from jarvis.jarvis_utils.tag import ct, ot
|
17
18
|
from jarvis.jarvis_utils.utils import (get_context_token_count,
|
@@ -128,10 +129,14 @@ class BasePlatform(ABC):
|
|
128
129
|
|
129
130
|
def chat_until_success(self, message: str) -> str:
|
130
131
|
"""Chat with model until successful response"""
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
132
|
+
try:
|
133
|
+
set_in_chat(True)
|
134
|
+
if not self.suppress_output and is_print_prompt():
|
135
|
+
PrettyOutput.print(f"{message}", OutputType.USER)
|
136
|
+
result: str = while_true(lambda: while_success(lambda: self._chat(message), 5), 5)
|
137
|
+
return result
|
138
|
+
finally:
|
139
|
+
set_in_chat(False)
|
135
140
|
|
136
141
|
@abstractmethod
|
137
142
|
def name(self) -> str:
|
@@ -144,9 +149,9 @@ class BasePlatform(ABC):
|
|
144
149
|
raise NotImplementedError("delete_chat is not implemented")
|
145
150
|
|
146
151
|
@abstractmethod
|
147
|
-
def
|
152
|
+
def set_system_prompt(self, message: str):
|
148
153
|
"""Set system message"""
|
149
|
-
raise NotImplementedError("
|
154
|
+
raise NotImplementedError("set_system_prompt is not implemented")
|
150
155
|
|
151
156
|
@abstractmethod
|
152
157
|
def get_model_list(self) -> List[Tuple[str, str]]:
|
jarvis/jarvis_platform/human.py
CHANGED
jarvis/jarvis_platform/kimi.py
CHANGED
jarvis/jarvis_platform/openai.py
CHANGED
@@ -16,7 +16,7 @@ REQUIRED_METHODS = [
|
|
16
16
|
('chat', ['message']), # 方法名和参数列表
|
17
17
|
('name', []),
|
18
18
|
('delete_chat', []),
|
19
|
-
('
|
19
|
+
('set_system_prompt', ['message']),
|
20
20
|
('set_model_name', ['model_name']),
|
21
21
|
('get_model_list', []),
|
22
22
|
('upload_files', ['file_list']),
|
jarvis/jarvis_platform/tongyi.py
CHANGED
@@ -493,7 +493,7 @@ class TongyiPlatform(BasePlatform):
|
|
493
493
|
PrettyOutput.print(f"Error deleting chat: {str(e)}", OutputType.ERROR)
|
494
494
|
return False
|
495
495
|
|
496
|
-
def
|
496
|
+
def set_system_prompt(self, message: str):
|
497
497
|
"""Set system message
|
498
498
|
|
499
499
|
Args:
|
@@ -45,7 +45,7 @@ class YuanbaoPlatform(BasePlatform):
|
|
45
45
|
self.model_name = "deep_seek_v3" # 默认模型名称,使用下划线保持一致
|
46
46
|
self.multimedia = []
|
47
47
|
|
48
|
-
def
|
48
|
+
def set_system_prompt(self, message: str):
|
49
49
|
"""设置系统消息"""
|
50
50
|
self.system_message = message
|
51
51
|
|