jarvis-ai-assistant 0.1.75__py3-none-any.whl → 0.1.76__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.
Potentially problematic release.
This version of jarvis-ai-assistant might be problematic. Click here for more details.
- jarvis/__init__.py +1 -1
- jarvis/agent.py +47 -8
- {jarvis_ai_assistant-0.1.75.dist-info → jarvis_ai_assistant-0.1.76.dist-info}/METADATA +1 -1
- {jarvis_ai_assistant-0.1.75.dist-info → jarvis_ai_assistant-0.1.76.dist-info}/RECORD +8 -8
- {jarvis_ai_assistant-0.1.75.dist-info → jarvis_ai_assistant-0.1.76.dist-info}/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.75.dist-info → jarvis_ai_assistant-0.1.76.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.75.dist-info → jarvis_ai_assistant-0.1.76.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.75.dist-info → jarvis_ai_assistant-0.1.76.dist-info}/top_level.txt +0 -0
jarvis/__init__.py
CHANGED
jarvis/agent.py
CHANGED
|
@@ -140,6 +140,7 @@ class Agent:
|
|
|
140
140
|
|
|
141
141
|
def _load_methodology(self, user_input: str) -> Dict[str, str]:
|
|
142
142
|
"""加载方法论并构建向量索引"""
|
|
143
|
+
PrettyOutput.print("加载方法论...", OutputType.PLANNING)
|
|
143
144
|
user_jarvis_methodology = os.path.expanduser("~/.jarvis_methodology")
|
|
144
145
|
if not os.path.exists(user_jarvis_methodology):
|
|
145
146
|
return {}
|
|
@@ -290,6 +291,38 @@ class Agent:
|
|
|
290
291
|
self.prompt = summary_prompt
|
|
291
292
|
return self._call_model(self.prompt)
|
|
292
293
|
|
|
294
|
+
def choose_tools(self, user_input: str) -> List[Dict]:
|
|
295
|
+
"""根据用户输入选择工具"""
|
|
296
|
+
PrettyOutput.print("选择工具...", OutputType.PLANNING)
|
|
297
|
+
tools = self.tool_registry.get_all_tools()
|
|
298
|
+
prompt = f"""你是一个工具选择专家,请根据用户输入选择合适的工具,返回可能使用到的工具的名称。以下是可用工具:
|
|
299
|
+
"""
|
|
300
|
+
for tool in tools:
|
|
301
|
+
prompt += f"- {tool['name']}: {tool['description']}\n"
|
|
302
|
+
prompt += f"用户输入: {user_input}\n"
|
|
303
|
+
prompt += f"请返回可能使用到的工具的名称,如果无法确定,请返回空列表。"
|
|
304
|
+
prompt += f"返回的格式为:\n"
|
|
305
|
+
prompt += f"<TOOL_CHOICE_START>\n"
|
|
306
|
+
prompt += f"tool_name1\n"
|
|
307
|
+
prompt += f"tool_name2\n"
|
|
308
|
+
prompt += f"<TOOL_CHOICE_END>\n"
|
|
309
|
+
model = PlatformRegistry.get_global_platform()
|
|
310
|
+
model.set_suppress_output(True)
|
|
311
|
+
try:
|
|
312
|
+
response = model.chat(prompt)
|
|
313
|
+
response = response.replace("<TOOL_CHOICE_START>", "").replace("<TOOL_CHOICE_END>", "")
|
|
314
|
+
tools_name = response.split("\n")
|
|
315
|
+
choosed_tools = []
|
|
316
|
+
for tool_name in tools_name:
|
|
317
|
+
for tool in tools:
|
|
318
|
+
if tool['name'] == tool_name:
|
|
319
|
+
choosed_tools.append(tool)
|
|
320
|
+
break
|
|
321
|
+
return choosed_tools
|
|
322
|
+
except Exception as e:
|
|
323
|
+
PrettyOutput.print(f"工具选择失败: {str(e)}", OutputType.ERROR)
|
|
324
|
+
return []
|
|
325
|
+
|
|
293
326
|
def run(self, user_input: str, file_list: Optional[List[str]] = None, keep_history: bool = False) -> str:
|
|
294
327
|
"""处理用户输入并返回响应,返回任务总结报告
|
|
295
328
|
|
|
@@ -302,6 +335,7 @@ class Agent:
|
|
|
302
335
|
str: 任务总结报告
|
|
303
336
|
"""
|
|
304
337
|
try:
|
|
338
|
+
PrettyOutput.section("准备环境", OutputType.PLANNING)
|
|
305
339
|
if file_list:
|
|
306
340
|
self.model.upload_files(file_list)
|
|
307
341
|
|
|
@@ -313,18 +347,23 @@ class Agent:
|
|
|
313
347
|
{methodology}
|
|
314
348
|
|
|
315
349
|
"""
|
|
350
|
+
tools_prompt = ""
|
|
351
|
+
|
|
352
|
+
# 选择工具
|
|
353
|
+
tools = self.choose_tools(user_input)
|
|
354
|
+
if tools:
|
|
355
|
+
tools_prompt += "可用工具:\n"
|
|
356
|
+
for tool in tools:
|
|
357
|
+
PrettyOutput.print(f"选择工具: {tool['name']}", OutputType.INFO)
|
|
358
|
+
tools_prompt += f"- 名称: {tool['name']}\n"
|
|
359
|
+
tools_prompt += f" 描述: {tool['description']}\n"
|
|
360
|
+
tools_prompt += f" 参数: {tool['parameters']}\n"
|
|
316
361
|
|
|
317
|
-
self.clear_history()
|
|
318
|
-
self.conversation_turns = 0
|
|
319
|
-
|
|
320
362
|
# 显示任务开始
|
|
321
363
|
PrettyOutput.section(f"开始新任务: {self.name}", OutputType.PLANNING)
|
|
322
364
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
tools_prompt += f"- 名称: {tool['name']}\n"
|
|
326
|
-
tools_prompt += f" 描述: {tool['description']}\n"
|
|
327
|
-
tools_prompt += f" 参数: {tool['parameters']}\n"
|
|
365
|
+
self.clear_history()
|
|
366
|
+
self.conversation_turns = 0
|
|
328
367
|
|
|
329
368
|
self.model.set_system_message(f"""你是 {self.name},一个问题处理能力强大的 AI 助手。
|
|
330
369
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
jarvis/__init__.py,sha256=
|
|
2
|
-
jarvis/agent.py,sha256=
|
|
1
|
+
jarvis/__init__.py,sha256=mqMOFwEAV4m463m3kW2Lz8KGIkWz1vJScSEYFQi4jsc,50
|
|
2
|
+
jarvis/agent.py,sha256=10YxntRu9CWp-xZt7PmUYbzj_knwGM0QqyRbM4FaKSk,21473
|
|
3
3
|
jarvis/main.py,sha256=7EcSlxa5JFFXBujzKDWdNtwX6axLhFFdJMc2GxTjfdk,6295
|
|
4
4
|
jarvis/utils.py,sha256=vZV8sHj0ggZy4Rb8RxIujQhRWgeNEomhqVl4WXmpq7c,7498
|
|
5
5
|
jarvis/jarvis_codebase/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -25,9 +25,9 @@ jarvis/tools/search.py,sha256=1EqOVvLhg2Csh-i03-XeCrusbyfmH69FZ8khwZt8Tow,6131
|
|
|
25
25
|
jarvis/tools/shell.py,sha256=UPKshPyOaUwTngresUw-ot1jHjQIb4wCY5nkJqa38lU,2520
|
|
26
26
|
jarvis/tools/sub_agent.py,sha256=rEtAmSVY2ZjFOZEKr5m5wpACOQIiM9Zr_3dT92FhXYU,2621
|
|
27
27
|
jarvis/tools/webpage.py,sha256=d3w3Jcjcu1ESciezTkz3n3Zf-rp_l91PrVoDEZnckOo,2391
|
|
28
|
-
jarvis_ai_assistant-0.1.
|
|
29
|
-
jarvis_ai_assistant-0.1.
|
|
30
|
-
jarvis_ai_assistant-0.1.
|
|
31
|
-
jarvis_ai_assistant-0.1.
|
|
32
|
-
jarvis_ai_assistant-0.1.
|
|
33
|
-
jarvis_ai_assistant-0.1.
|
|
28
|
+
jarvis_ai_assistant-0.1.76.dist-info/LICENSE,sha256=AGgVgQmTqFvaztRtCAXsAMryUymB18gZif7_l2e1XOg,1063
|
|
29
|
+
jarvis_ai_assistant-0.1.76.dist-info/METADATA,sha256=X1sBPb59GZyR4UjtnFntEQY4SzIe0q_KOgmYt62hMcU,12399
|
|
30
|
+
jarvis_ai_assistant-0.1.76.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
31
|
+
jarvis_ai_assistant-0.1.76.dist-info/entry_points.txt,sha256=QNUeqmUJd7nHufel2FO7cRttS1uKFfnbIyObv8eVyOY,140
|
|
32
|
+
jarvis_ai_assistant-0.1.76.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
|
|
33
|
+
jarvis_ai_assistant-0.1.76.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{jarvis_ai_assistant-0.1.75.dist-info → jarvis_ai_assistant-0.1.76.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|