jarvis-ai-assistant 0.1.13__tar.gz → 0.1.14__tar.gz

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.

Files changed (48) hide show
  1. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/PKG-INFO +2 -1
  2. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/pyproject.toml +2 -1
  3. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/setup.py +2 -1
  4. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/__init__.py +1 -1
  5. jarvis_ai_assistant-0.1.14/src/jarvis/__pycache__/__init__.cpython-313.pyc +0 -0
  6. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/__pycache__/main.cpython-313.pyc +0 -0
  7. jarvis_ai_assistant-0.1.14/src/jarvis/__pycache__/utils.cpython-313.pyc +0 -0
  8. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/main.py +35 -20
  9. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/utils.py +40 -22
  10. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis_ai_assistant.egg-info/PKG-INFO +2 -1
  11. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis_ai_assistant.egg-info/requires.txt +1 -0
  12. jarvis_ai_assistant-0.1.13/src/jarvis/__pycache__/__init__.cpython-313.pyc +0 -0
  13. jarvis_ai_assistant-0.1.13/src/jarvis/__pycache__/utils.cpython-313.pyc +0 -0
  14. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/MANIFEST.in +0 -0
  15. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/README.md +0 -0
  16. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/setup.cfg +0 -0
  17. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/__pycache__/agent.cpython-313.pyc +0 -0
  18. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/__pycache__/models.cpython-313.pyc +0 -0
  19. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/__pycache__/tools.cpython-313.pyc +0 -0
  20. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/__pycache__/zte_llm.cpython-313.pyc +0 -0
  21. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/agent.py +0 -0
  22. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/models/__init__.py +0 -0
  23. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/models/__pycache__/__init__.cpython-313.pyc +0 -0
  24. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/models/__pycache__/base.cpython-313.pyc +0 -0
  25. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/models/__pycache__/kimi.cpython-313.pyc +0 -0
  26. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/models/base.py +0 -0
  27. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/models/kimi.py +0 -0
  28. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/tools/__init__.py +0 -0
  29. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/tools/__pycache__/__init__.cpython-313.pyc +0 -0
  30. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/tools/__pycache__/base.cpython-313.pyc +0 -0
  31. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/tools/__pycache__/bing_search.cpython-313.pyc +0 -0
  32. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/tools/__pycache__/file_ops.cpython-313.pyc +0 -0
  33. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/tools/__pycache__/python_script.cpython-313.pyc +0 -0
  34. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/tools/__pycache__/rag.cpython-313.pyc +0 -0
  35. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/tools/__pycache__/search.cpython-313.pyc +0 -0
  36. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/tools/__pycache__/shell.cpython-313.pyc +0 -0
  37. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/tools/__pycache__/sub_agent.cpython-313.pyc +0 -0
  38. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/tools/__pycache__/user_confirmation.cpython-313.pyc +0 -0
  39. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/tools/__pycache__/user_input.cpython-313.pyc +0 -0
  40. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/tools/__pycache__/user_interaction.cpython-313.pyc +0 -0
  41. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/tools/__pycache__/webpage.cpython-313.pyc +0 -0
  42. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/tools/base.py +0 -0
  43. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/tools/file_ops.py +0 -0
  44. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis/tools/shell.py +0 -0
  45. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis_ai_assistant.egg-info/SOURCES.txt +0 -0
  46. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis_ai_assistant.egg-info/dependency_links.txt +0 -0
  47. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis_ai_assistant.egg-info/entry_points.txt +0 -0
  48. {jarvis_ai_assistant-0.1.13 → jarvis_ai_assistant-0.1.14}/src/jarvis_ai_assistant.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: jarvis-ai-assistant
3
- Version: 0.1.13
3
+ Version: 0.1.14
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
@@ -19,6 +19,7 @@ Description-Content-Type: text/markdown
19
19
  Requires-Dist: requests>=2.25.1
20
20
  Requires-Dist: pyyaml>=5.1
21
21
  Requires-Dist: colorama>=0.4.6
22
+ Requires-Dist: prompt_toolkit>=3.0.0
22
23
  Provides-Extra: dev
23
24
  Requires-Dist: pytest; extra == "dev"
24
25
  Requires-Dist: black; extra == "dev"
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "jarvis-ai-assistant"
7
- version = "0.1.13"
7
+ version = "0.1.14"
8
8
  description = "Jarvis: An AI assistant that uses tools to interact with the system"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Your Name", email = "your.email@example.com" }]
@@ -23,6 +23,7 @@ dependencies = [
23
23
  "requests>=2.25.1",
24
24
  "pyyaml>=5.1",
25
25
  "colorama>=0.4.6",
26
+ "prompt_toolkit>=3.0.0",
26
27
  ]
27
28
  requires-python = ">=3.8"
28
29
 
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="jarvis-ai-assistant",
5
- version="0.1.13",
5
+ version="0.1.14",
6
6
  author="skyfire",
7
7
  author_email="skyfireitdiy@hotmail.com",
8
8
  description="An AI assistant that uses various tools to interact with the system",
@@ -16,6 +16,7 @@ setup(
16
16
  "requests>=2.25.1",
17
17
  "pyyaml>=5.1",
18
18
  "colorama>=0.4.6",
19
+ "prompt_toolkit>=3.0.0",
19
20
  ],
20
21
  entry_points={
21
22
  "console_scripts": [
@@ -1,3 +1,3 @@
1
1
  """Jarvis AI Assistant"""
2
2
 
3
- __version__ = "0.1.13"
3
+ __version__ = "0.1.14"
@@ -17,28 +17,43 @@ from jarvis.utils import PrettyOutput, OutputType, get_multiline_input, load_env
17
17
 
18
18
 
19
19
  def load_tasks() -> dict:
20
- """Load tasks from .jarvis file if it exists."""
21
- if not os.path.exists(".jarvis"):
22
- return {}
20
+ """Load tasks from .jarvis files in user home and current directory."""
21
+ tasks = {}
23
22
 
24
- try:
25
- with open(".jarvis", "r", encoding="utf-8") as f:
26
- tasks = yaml.safe_load(f)
27
-
28
- if not isinstance(tasks, dict):
29
- PrettyOutput.print("Warning: .jarvis file should contain a dictionary of task_name: task_description", OutputType.ERROR)
30
- return {}
31
-
32
- # Validate format and convert all values to strings
33
- validated_tasks = {}
34
- for name, desc in tasks.items():
35
- if desc: # Ensure description is not empty
36
- validated_tasks[str(name)] = str(desc)
23
+ # 检查用户目录下的 .jarvis
24
+ user_jarvis = os.path.expanduser("~/.jarvis")
25
+ if os.path.exists(user_jarvis):
26
+ try:
27
+ with open(user_jarvis, "r", encoding="utf-8") as f:
28
+ user_tasks = yaml.safe_load(f)
37
29
 
38
- return validated_tasks
39
- except Exception as e:
40
- PrettyOutput.print(f"Error loading .jarvis file: {str(e)}", OutputType.ERROR)
41
- return {}
30
+ if isinstance(user_tasks, dict):
31
+ # 验证并添加用户目录的任务
32
+ for name, desc in user_tasks.items():
33
+ if desc: # 确保描述不为空
34
+ tasks[str(name)] = str(desc)
35
+ else:
36
+ PrettyOutput.print("Warning: ~/.jarvis file should contain a dictionary of task_name: task_description", OutputType.ERROR)
37
+ except Exception as e:
38
+ PrettyOutput.print(f"Error loading ~/.jarvis file: {str(e)}", OutputType.ERROR)
39
+
40
+ # 检查当前目录下的 .jarvis
41
+ if os.path.exists(".jarvis"):
42
+ try:
43
+ with open(".jarvis", "r", encoding="utf-8") as f:
44
+ local_tasks = yaml.safe_load(f)
45
+
46
+ if isinstance(local_tasks, dict):
47
+ # 验证并添加当前目录的任务,如果有重名则覆盖用户目录的任务
48
+ for name, desc in local_tasks.items():
49
+ if desc: # 确保描述不为空
50
+ tasks[str(name)] = str(desc)
51
+ else:
52
+ PrettyOutput.print("Warning: .jarvis file should contain a dictionary of task_name: task_description", OutputType.ERROR)
53
+ except Exception as e:
54
+ PrettyOutput.print(f"Error loading .jarvis file: {str(e)}", OutputType.ERROR)
55
+
56
+ return tasks
42
57
 
43
58
  def select_task(tasks: dict) -> str:
44
59
  """Let user select a task from the list or skip. Returns task description if selected."""
@@ -1,12 +1,15 @@
1
1
  from pathlib import Path
2
2
  import sys
3
3
  import time
4
+ import os
4
5
  from typing import Dict, Optional
5
6
  from enum import Enum
6
7
  from datetime import datetime
7
8
  import colorama
8
- from colorama import Fore, Style
9
- import os
9
+ from colorama import Fore, Style as ColoramaStyle
10
+ from prompt_toolkit import PromptSession
11
+ from prompt_toolkit.styles import Style as PromptStyle
12
+ from prompt_toolkit.formatted_text import FormattedText
10
13
 
11
14
  # 初始化colorama
12
15
  colorama.init()
@@ -84,10 +87,10 @@ class PrettyOutput:
84
87
  prefix = PrettyOutput.PREFIXES.get(output_type, "")
85
88
 
86
89
  # 添加时间戳 - 使用白色
87
- time_str = f"{Fore.WHITE}[{datetime.now().strftime('%H:%M:%S')}]{Style.RESET_ALL} " if timestamp else ""
90
+ time_str = f"{Fore.WHITE}[{datetime.now().strftime('%H:%M:%S')}]{ColoramaStyle.RESET_ALL} " if timestamp else ""
88
91
 
89
92
  # 格式化输出
90
- formatted_text = f"{time_str}{color}{icon} {prefix}: {text}{Style.RESET_ALL}"
93
+ formatted_text = f"{time_str}{color}{icon} {prefix}: {text}{ColoramaStyle.RESET_ALL}"
91
94
 
92
95
  return formatted_text
93
96
 
@@ -101,15 +104,15 @@ class PrettyOutput:
101
104
  """打印带分隔线的段落标题"""
102
105
  width = 60
103
106
  color = PrettyOutput.COLORS.get(output_type, "")
104
- print(f"\n{color}" + "=" * width + f"{Style.RESET_ALL}")
107
+ print(f"\n{color}" + "=" * width + f"{ColoramaStyle.RESET_ALL}")
105
108
  PrettyOutput.print(title.center(width - 10), output_type, timestamp=False)
106
- print(f"{color}" + "=" * width + f"{Style.RESET_ALL}\n")
109
+ print(f"{color}" + "=" * width + f"{ColoramaStyle.RESET_ALL}\n")
107
110
 
108
111
  @staticmethod
109
112
  def print_stream(text: str, output_type: OutputType):
110
113
  """打印流式输出,不换行"""
111
114
  color = PrettyOutput.COLORS.get(output_type, "")
112
- sys.stdout.write(f"{color}{text}{Style.RESET_ALL}")
115
+ sys.stdout.write(f"{color}{text}{ColoramaStyle.RESET_ALL}")
113
116
  sys.stdout.flush()
114
117
 
115
118
  @staticmethod
@@ -119,29 +122,44 @@ class PrettyOutput:
119
122
  sys.stdout.flush()
120
123
 
121
124
  def get_multiline_input(tip: str) -> str:
122
- """获取多行输入"""
125
+ """获取多行输入,支持方向键、历史记录等功能"""
123
126
  PrettyOutput.print(tip + "\n", OutputType.INFO)
124
- lines = []
125
127
 
126
- while True:
127
- try:
128
- prompt = "... " if lines else ">>> "
129
- sys.stdout.write(f"{Fore.GREEN}{prompt}{Style.RESET_ALL}")
130
- sys.stdout.flush()
128
+ # 创建输入会话,启用历史记录
129
+ session = PromptSession(history=None) # 使用默认历史记录
130
+
131
+ # 定义提示符样式
132
+ style = PromptStyle.from_dict({
133
+ 'prompt': 'ansicyan',
134
+ })
135
+
136
+ lines = []
137
+ try:
138
+ while True:
139
+ # 设置提示符
140
+ prompt = FormattedText([
141
+ ('class:prompt', '... ' if lines else '>>> ')
142
+ ])
131
143
 
132
- line = input().strip()
144
+ # 获取输入
145
+ line = session.prompt(
146
+ prompt,
147
+ style=style,
148
+ ).strip()
149
+
150
+ # 空行处理
133
151
  if not line:
134
- if not lines: # 如果是第一行就输入空行
152
+ if not lines: # 第一行就输入空行
135
153
  return ""
136
- break
137
-
154
+ break # 结束多行输入
155
+
138
156
  lines.append(line)
139
157
 
140
- except KeyboardInterrupt:
141
- PrettyOutput.print("\n输入已取消", OutputType.ERROR)
142
- return "__interrupt__"
158
+ except KeyboardInterrupt:
159
+ PrettyOutput.print("\n输入已取消", OutputType.ERROR)
160
+ return "__interrupt__"
143
161
 
144
- return "\n".join(lines).strip()
162
+ return "\n".join(lines)
145
163
 
146
164
  def load_env_from_file():
147
165
  """从~/.jarvis_env加载环境变量"""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: jarvis-ai-assistant
3
- Version: 0.1.13
3
+ Version: 0.1.14
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
@@ -19,6 +19,7 @@ Description-Content-Type: text/markdown
19
19
  Requires-Dist: requests>=2.25.1
20
20
  Requires-Dist: pyyaml>=5.1
21
21
  Requires-Dist: colorama>=0.4.6
22
+ Requires-Dist: prompt_toolkit>=3.0.0
22
23
  Provides-Extra: dev
23
24
  Requires-Dist: pytest; extra == "dev"
24
25
  Requires-Dist: black; extra == "dev"
@@ -1,6 +1,7 @@
1
1
  requests>=2.25.1
2
2
  pyyaml>=5.1
3
3
  colorama>=0.4.6
4
+ prompt_toolkit>=3.0.0
4
5
 
5
6
  [dev]
6
7
  pytest