jarvis-ai-assistant 0.1.32__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 +3 -0
- jarvis/__pycache__/__init__.cpython-313.pyc +0 -0
- jarvis/__pycache__/agent.cpython-313.pyc +0 -0
- jarvis/__pycache__/main.cpython-313.pyc +0 -0
- jarvis/__pycache__/models.cpython-313.pyc +0 -0
- jarvis/__pycache__/tools.cpython-313.pyc +0 -0
- jarvis/__pycache__/utils.cpython-313.pyc +0 -0
- jarvis/__pycache__/zte_llm.cpython-313.pyc +0 -0
- jarvis/agent.py +289 -0
- jarvis/main.py +148 -0
- jarvis/models/__init__.py +3 -0
- jarvis/models/__pycache__/__init__.cpython-313.pyc +0 -0
- jarvis/models/__pycache__/base.cpython-313.pyc +0 -0
- jarvis/models/__pycache__/kimi.cpython-313.pyc +0 -0
- jarvis/models/__pycache__/openai.cpython-313.pyc +0 -0
- jarvis/models/__pycache__/oyi.cpython-313.pyc +0 -0
- jarvis/models/__pycache__/registry.cpython-313.pyc +0 -0
- jarvis/models/base.py +39 -0
- jarvis/models/kimi.py +389 -0
- jarvis/models/openai.py +96 -0
- jarvis/models/oyi.py +271 -0
- jarvis/models/registry.py +199 -0
- jarvis/tools/__init__.py +5 -0
- jarvis/tools/__pycache__/__init__.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/base.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/bing_search.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/calculator.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/calculator_tool.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/file_ops.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/generator.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/methodology.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/python_script.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/rag.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/registry.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/search.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/shell.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/sub_agent.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/user_confirmation.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/user_input.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/user_interaction.cpython-313.pyc +0 -0
- jarvis/tools/__pycache__/webpage.cpython-313.pyc +0 -0
- jarvis/tools/base.py +23 -0
- jarvis/tools/file_ops.py +110 -0
- jarvis/tools/generator.py +172 -0
- jarvis/tools/methodology.py +145 -0
- jarvis/tools/registry.py +183 -0
- jarvis/tools/shell.py +78 -0
- jarvis/tools/sub_agent.py +82 -0
- jarvis/utils.py +202 -0
- jarvis_ai_assistant-0.1.32.dist-info/LICENSE +21 -0
- jarvis_ai_assistant-0.1.32.dist-info/METADATA +345 -0
- jarvis_ai_assistant-0.1.32.dist-info/RECORD +55 -0
- jarvis_ai_assistant-0.1.32.dist-info/WHEEL +5 -0
- jarvis_ai_assistant-0.1.32.dist-info/entry_points.txt +2 -0
- jarvis_ai_assistant-0.1.32.dist-info/top_level.txt +1 -0
jarvis/utils.py
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
import sys
|
3
|
+
import time
|
4
|
+
import os
|
5
|
+
from enum import Enum
|
6
|
+
from datetime import datetime
|
7
|
+
import colorama
|
8
|
+
from colorama import Fore, Style as ColoramaStyle
|
9
|
+
from prompt_toolkit import PromptSession
|
10
|
+
from prompt_toolkit.styles import Style as PromptStyle
|
11
|
+
from prompt_toolkit.formatted_text import FormattedText
|
12
|
+
|
13
|
+
# 初始化colorama
|
14
|
+
colorama.init()
|
15
|
+
|
16
|
+
class OutputType(Enum):
|
17
|
+
SYSTEM = "system" # AI助手消息
|
18
|
+
CODE = "code" # 代码相关
|
19
|
+
RESULT = "result" # 工具执行结果
|
20
|
+
ERROR = "error" # 错误信息
|
21
|
+
INFO = "info" # 系统提示
|
22
|
+
PLANNING = "planning" # 任务规划
|
23
|
+
PROGRESS = "progress" # 执行进度
|
24
|
+
SUCCESS = "success" # 成功信息
|
25
|
+
WARNING = "warning" # 警告信息
|
26
|
+
DEBUG = "debug" # 调试信息
|
27
|
+
USER = "user" # 用户输入
|
28
|
+
TOOL = "tool" # 工具调用
|
29
|
+
|
30
|
+
class PrettyOutput:
|
31
|
+
"""美化输出类"""
|
32
|
+
|
33
|
+
# 颜色方案 - 只使用前景色
|
34
|
+
COLORS = {
|
35
|
+
OutputType.SYSTEM: Fore.CYAN, # 青色 - AI助手
|
36
|
+
OutputType.CODE: Fore.GREEN, # 绿色 - 代码
|
37
|
+
OutputType.RESULT: Fore.BLUE, # 蓝色 - 结果
|
38
|
+
OutputType.ERROR: Fore.RED, # 红色 - 错误
|
39
|
+
OutputType.INFO: Fore.YELLOW, # 黄色 - 提示
|
40
|
+
OutputType.PLANNING: Fore.MAGENTA, # 紫色 - 规划
|
41
|
+
OutputType.PROGRESS: Fore.WHITE, # 白色 - 进度
|
42
|
+
OutputType.SUCCESS: Fore.GREEN, # 绿色 - 成功
|
43
|
+
OutputType.WARNING: Fore.YELLOW, # 黄色 - 警告
|
44
|
+
OutputType.DEBUG: Fore.BLUE, # 蓝色 - 调试
|
45
|
+
OutputType.USER: Fore.GREEN, # 绿色 - 用户
|
46
|
+
OutputType.TOOL: Fore.YELLOW, # 黄色 - 工具
|
47
|
+
}
|
48
|
+
|
49
|
+
# 图标方案
|
50
|
+
ICONS = {
|
51
|
+
OutputType.SYSTEM: "🤖", # 机器人 - AI助手
|
52
|
+
OutputType.CODE: "📝", # 记事本 - 代码
|
53
|
+
OutputType.RESULT: "✨", # 闪光 - 结果
|
54
|
+
OutputType.ERROR: "❌", # 错误 - 错误
|
55
|
+
OutputType.INFO: "ℹ️", # 信息 - 提示
|
56
|
+
OutputType.PLANNING: "📋", # 剪贴板 - 规划
|
57
|
+
OutputType.PROGRESS: "⏳", # 沙漏 - 进度
|
58
|
+
OutputType.SUCCESS: "✅", # 勾选 - 成功
|
59
|
+
OutputType.WARNING: "⚠️", # 警告 - 警告
|
60
|
+
OutputType.DEBUG: "🔍", # 放大镜 - 调试
|
61
|
+
OutputType.USER: "👤", # 用户 - 用户
|
62
|
+
OutputType.TOOL: "🔧", # 扳手 - 工具
|
63
|
+
}
|
64
|
+
|
65
|
+
# 前缀方案
|
66
|
+
PREFIXES = {
|
67
|
+
OutputType.SYSTEM: "Assistant",
|
68
|
+
OutputType.CODE: "Code",
|
69
|
+
OutputType.RESULT: "Result",
|
70
|
+
OutputType.ERROR: "Error",
|
71
|
+
OutputType.INFO: "Info",
|
72
|
+
OutputType.PLANNING: "Plan",
|
73
|
+
OutputType.PROGRESS: "Progress",
|
74
|
+
OutputType.SUCCESS: "Success",
|
75
|
+
OutputType.WARNING: "Warning",
|
76
|
+
OutputType.DEBUG: "Debug",
|
77
|
+
OutputType.USER: "User",
|
78
|
+
OutputType.TOOL: "Tool",
|
79
|
+
}
|
80
|
+
|
81
|
+
@staticmethod
|
82
|
+
def format(text: str, output_type: OutputType, timestamp: bool = True) -> str:
|
83
|
+
"""格式化输出文本"""
|
84
|
+
color = PrettyOutput.COLORS.get(output_type, "")
|
85
|
+
icon = PrettyOutput.ICONS.get(output_type, "")
|
86
|
+
prefix = PrettyOutput.PREFIXES.get(output_type, "")
|
87
|
+
|
88
|
+
# 添加时间戳 - 使用白色
|
89
|
+
time_str = f"{Fore.WHITE}[{datetime.now().strftime('%H:%M:%S')}]{ColoramaStyle.RESET_ALL} " if timestamp else ""
|
90
|
+
|
91
|
+
# 格式化输出
|
92
|
+
formatted_text = f"{time_str}{color}{icon} {prefix}: {text}{ColoramaStyle.RESET_ALL}"
|
93
|
+
|
94
|
+
return formatted_text
|
95
|
+
|
96
|
+
@staticmethod
|
97
|
+
def print(text: str, output_type: OutputType, timestamp: bool = False):
|
98
|
+
"""打印格式化的输出"""
|
99
|
+
print(PrettyOutput.format(text, output_type, timestamp))
|
100
|
+
if output_type == OutputType.ERROR:
|
101
|
+
import traceback
|
102
|
+
PrettyOutput.print(f"错误追踪: {traceback.format_exc()}", OutputType.INFO)
|
103
|
+
|
104
|
+
@staticmethod
|
105
|
+
def section(title: str, output_type: OutputType = OutputType.INFO):
|
106
|
+
"""打印带分隔线的段落标题"""
|
107
|
+
width = 60
|
108
|
+
color = PrettyOutput.COLORS.get(output_type, "")
|
109
|
+
print(f"\n{color}" + "=" * width + f"{ColoramaStyle.RESET_ALL}")
|
110
|
+
PrettyOutput.print(title.center(width - 10), output_type, timestamp=False)
|
111
|
+
print(f"{color}" + "=" * width + f"{ColoramaStyle.RESET_ALL}\n")
|
112
|
+
|
113
|
+
@staticmethod
|
114
|
+
def print_stream(text: str):
|
115
|
+
"""打印流式输出,不换行"""
|
116
|
+
color = PrettyOutput.COLORS.get(OutputType.SYSTEM, "")
|
117
|
+
sys.stdout.write(f"{color}{text}{ColoramaStyle.RESET_ALL}")
|
118
|
+
sys.stdout.flush()
|
119
|
+
|
120
|
+
@staticmethod
|
121
|
+
def print_stream_end():
|
122
|
+
"""流式输出结束,打印换行"""
|
123
|
+
sys.stdout.write("\n")
|
124
|
+
sys.stdout.flush()
|
125
|
+
|
126
|
+
def get_multiline_input(tip: str) -> str:
|
127
|
+
"""获取多行输入,支持方向键、历史记录等功能"""
|
128
|
+
PrettyOutput.print(tip + "\n", OutputType.INFO)
|
129
|
+
|
130
|
+
# 创建输入会话,启用历史记录
|
131
|
+
session = PromptSession(history=None) # 使用默认历史记录
|
132
|
+
|
133
|
+
# 定义提示符样式
|
134
|
+
style = PromptStyle.from_dict({
|
135
|
+
'prompt': 'ansicyan',
|
136
|
+
})
|
137
|
+
|
138
|
+
lines = []
|
139
|
+
try:
|
140
|
+
while True:
|
141
|
+
# 设置提示符
|
142
|
+
prompt = FormattedText([
|
143
|
+
('class:prompt', '... ' if lines else '>>> ')
|
144
|
+
])
|
145
|
+
|
146
|
+
# 获取输入
|
147
|
+
line = session.prompt(
|
148
|
+
prompt,
|
149
|
+
style=style,
|
150
|
+
).strip()
|
151
|
+
|
152
|
+
# 空行处理
|
153
|
+
if not line:
|
154
|
+
if not lines: # 第一行就输入空行
|
155
|
+
return ""
|
156
|
+
break # 结束多行输入
|
157
|
+
|
158
|
+
lines.append(line)
|
159
|
+
|
160
|
+
except KeyboardInterrupt:
|
161
|
+
PrettyOutput.print("\n输入已取消", OutputType.ERROR)
|
162
|
+
return "__interrupt__"
|
163
|
+
|
164
|
+
return "\n".join(lines)
|
165
|
+
|
166
|
+
def load_env_from_file():
|
167
|
+
"""从~/.jarvis_env加载环境变量"""
|
168
|
+
env_file = Path.home() / ".jarvis_env"
|
169
|
+
|
170
|
+
if env_file.exists():
|
171
|
+
try:
|
172
|
+
with open(env_file, "r", encoding="utf-8") as f:
|
173
|
+
for line in f:
|
174
|
+
line = line.strip()
|
175
|
+
if line and not line.startswith("#"):
|
176
|
+
try:
|
177
|
+
key, value = line.split("=", 1)
|
178
|
+
os.environ[key.strip()] = value.strip().strip("'").strip('"')
|
179
|
+
except ValueError:
|
180
|
+
continue
|
181
|
+
except Exception as e:
|
182
|
+
PrettyOutput.print(f"Warning: Failed to read ~/.jarvis_env: {e}", OutputType.WARNING)
|
183
|
+
|
184
|
+
|
185
|
+
def while_success(func, sleep_time: float = 0.1):
|
186
|
+
while True:
|
187
|
+
try:
|
188
|
+
return func()
|
189
|
+
except Exception as e:
|
190
|
+
PrettyOutput.print(f"执行失败: {str(e)}, {sleep_time}s后重试...", OutputType.ERROR)
|
191
|
+
time.sleep(sleep_time)
|
192
|
+
continue
|
193
|
+
|
194
|
+
def while_true(func, sleep_time: float = 0.1):
|
195
|
+
"""循环执行函数,直到函数返回True"""
|
196
|
+
while True:
|
197
|
+
ret = func()
|
198
|
+
if ret:
|
199
|
+
break
|
200
|
+
PrettyOutput.print(f"执行失败,{sleep_time}s后重试...", OutputType.WARNING)
|
201
|
+
time.sleep(sleep_time)
|
202
|
+
return ret
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 skyfire
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,345 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: jarvis-ai-assistant
|
3
|
+
Version: 0.1.32
|
4
|
+
Summary: Jarvis: An AI assistant that uses tools to interact with the system
|
5
|
+
Home-page: https://github.com/skyfireitdiy/Jarvis
|
6
|
+
Author: skyfire
|
7
|
+
Author-email: Your Name <your.email@example.com>
|
8
|
+
License: MIT License
|
9
|
+
|
10
|
+
Copyright (c) 2025 skyfire
|
11
|
+
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
14
|
+
in the Software without restriction, including without limitation the rights
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
17
|
+
furnished to do so, subject to the following conditions:
|
18
|
+
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
20
|
+
copies or substantial portions of the Software.
|
21
|
+
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
28
|
+
SOFTWARE.
|
29
|
+
Project-URL: Homepage, https://github.com/skyfireitdiy/Jarvis
|
30
|
+
Keywords: jarvis,ai,assistant,tools,automation
|
31
|
+
Classifier: License :: OSI Approved :: MIT License
|
32
|
+
Classifier: Programming Language :: Python
|
33
|
+
Classifier: Programming Language :: Python :: 3
|
34
|
+
Classifier: Programming Language :: Python :: 3.8
|
35
|
+
Classifier: Programming Language :: Python :: 3.9
|
36
|
+
Classifier: Programming Language :: Python :: 3.10
|
37
|
+
Classifier: Programming Language :: Python :: 3.11
|
38
|
+
Requires-Python: >=3.8
|
39
|
+
Description-Content-Type: text/markdown
|
40
|
+
License-File: LICENSE
|
41
|
+
Requires-Dist: requests>=2.25.1
|
42
|
+
Requires-Dist: pyyaml>=5.1
|
43
|
+
Requires-Dist: colorama>=0.4.6
|
44
|
+
Requires-Dist: prompt_toolkit>=3.0.0
|
45
|
+
Requires-Dist: openai>=1.20.0
|
46
|
+
Provides-Extra: dev
|
47
|
+
Requires-Dist: pytest; extra == "dev"
|
48
|
+
Requires-Dist: black; extra == "dev"
|
49
|
+
Requires-Dist: isort; extra == "dev"
|
50
|
+
Requires-Dist: mypy; extra == "dev"
|
51
|
+
Dynamic: author
|
52
|
+
Dynamic: home-page
|
53
|
+
Dynamic: requires-python
|
54
|
+
|
55
|
+
<div align="center">
|
56
|
+
|
57
|
+
# 🤖 Jarvis AI Assistant
|
58
|
+
|
59
|
+
<p align="center">
|
60
|
+
<img src="docs/images/jarvis-logo.png" alt="Jarvis Logo" width="200"/>
|
61
|
+
</p>
|
62
|
+
|
63
|
+
[](https://www.python.org/downloads/)
|
64
|
+
[](https://opensource.org/licenses/MIT)
|
65
|
+
|
66
|
+
*Your intelligent assistant for development and system interaction*
|
67
|
+
|
68
|
+
[Features](#features) •
|
69
|
+
[Usage](#usage) •
|
70
|
+
[Configuration](#configuration) •
|
71
|
+
[Extending Jarvis](#-extending-jarvis) •
|
72
|
+
[Contributing](#-contributing) •
|
73
|
+
[License](#-license)
|
74
|
+
|
75
|
+
</div>
|
76
|
+
|
77
|
+
---
|
78
|
+
|
79
|
+
## ✨ Features
|
80
|
+
|
81
|
+
### 🧠 Intelligent Agent
|
82
|
+
- Self-improving through experience accumulation
|
83
|
+
- Automatic methodology generation from successful problem-solving
|
84
|
+
- Iterative learning from each interaction
|
85
|
+
- Context-aware problem solving
|
86
|
+
|
87
|
+
### 🛠️ Extensible Architecture
|
88
|
+
- Dynamic tool loading and integration
|
89
|
+
- Custom model support with simple interface
|
90
|
+
- AI-powered tool generation
|
91
|
+
- Hot-reload support for tools and models
|
92
|
+
|
93
|
+
### 💡 Smart Features
|
94
|
+
- Automated methodology management
|
95
|
+
- Problem-specific solution patterns
|
96
|
+
- Continuous capability enhancement
|
97
|
+
- Learning from past interactions
|
98
|
+
|
99
|
+
### 🎨 User Experience
|
100
|
+
- Beautiful console output
|
101
|
+
- Interactive mode
|
102
|
+
- Multi-line input support
|
103
|
+
- Progress indicators
|
104
|
+
- Colored output
|
105
|
+
|
106
|
+
## 🚀 Installation
|
107
|
+
|
108
|
+
```bash
|
109
|
+
pip install jarvis-ai-assistant
|
110
|
+
```
|
111
|
+
|
112
|
+
## 🔧 Configuration
|
113
|
+
|
114
|
+
Create a `.jarvis_env` file in your home directory with your API keys:
|
115
|
+
|
116
|
+
### For Kimi:
|
117
|
+
```bash
|
118
|
+
KIMI_API_KEY=your_kimi_api_key_here
|
119
|
+
```
|
120
|
+
|
121
|
+
### For OpenAI:
|
122
|
+
```bash
|
123
|
+
OPENAI_API_KEY=your_api_key_here
|
124
|
+
OPENAI_API_BASE=your_api_base # Optional, defaults to https://api.deepseek.com
|
125
|
+
OPENAI_MODEL_NAME=your_model_name # Optional, defaults to deepseek-chat
|
126
|
+
```
|
127
|
+
|
128
|
+
## 🎯 Usage
|
129
|
+
|
130
|
+
### Basic Usage
|
131
|
+
```bash
|
132
|
+
jarvis
|
133
|
+
```
|
134
|
+
|
135
|
+
### With Specific Model
|
136
|
+
```bash
|
137
|
+
jarvis -m kimi # Use Kimi model
|
138
|
+
jarvis -m openai # Use OpenAI model
|
139
|
+
```
|
140
|
+
|
141
|
+
### Process Files
|
142
|
+
```bash
|
143
|
+
jarvis -f file1.py file2.py # Process specific files
|
144
|
+
```
|
145
|
+
|
146
|
+
### Keep Chat History
|
147
|
+
```bash
|
148
|
+
jarvis --keep-history # Don't delete chat session after completion
|
149
|
+
```
|
150
|
+
|
151
|
+
## 🛠️ Tools
|
152
|
+
|
153
|
+
### Built-in Tools
|
154
|
+
|
155
|
+
| Tool | Description |
|
156
|
+
|------|-------------|
|
157
|
+
| shell | Execute shell commands |
|
158
|
+
| file | File operations (read/write/append) |
|
159
|
+
| git | Git operations |
|
160
|
+
| methodology | Manage problem-solving methodologies |
|
161
|
+
|
162
|
+
### Tool Locations
|
163
|
+
- Built-in tools: `src/jarvis/tools/`
|
164
|
+
- User tools: `~/.jarvis_tools/`
|
165
|
+
|
166
|
+
### Key Features
|
167
|
+
|
168
|
+
#### 1. Self-Extending Capabilities
|
169
|
+
- AI-powered tool generation
|
170
|
+
- Automatic integration of new tools
|
171
|
+
- Dynamic capability expansion
|
172
|
+
|
173
|
+
#### 2. Methodology Learning
|
174
|
+
- Automatic extraction of problem-solving patterns
|
175
|
+
- Continuous methodology refinement
|
176
|
+
- Experience-based improvement
|
177
|
+
|
178
|
+
#### 3. Adaptive Problem Solving
|
179
|
+
- Context-aware tool selection
|
180
|
+
- Dynamic strategy adjustment
|
181
|
+
- Learning from execution results
|
182
|
+
|
183
|
+
## �� Extending Jarvis
|
184
|
+
|
185
|
+
### Adding New Tools
|
186
|
+
|
187
|
+
Create a new Python file in `~/.jarvis_tools/` or `src/jarvis/tools/`:
|
188
|
+
|
189
|
+
```python
|
190
|
+
from typing import Dict, Any
|
191
|
+
from jarvis.utils import OutputType, PrettyOutput
|
192
|
+
|
193
|
+
class CustomTool:
|
194
|
+
name = "tool_name" # Tool name for invocation
|
195
|
+
description = "Tool description" # Tool purpose
|
196
|
+
parameters = { # JSON Schema for parameters
|
197
|
+
"type": "object",
|
198
|
+
"properties": {
|
199
|
+
"param1": {
|
200
|
+
"type": "string",
|
201
|
+
"description": "Parameter description"
|
202
|
+
}
|
203
|
+
},
|
204
|
+
"required": ["param1"]
|
205
|
+
}
|
206
|
+
|
207
|
+
def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
|
208
|
+
"""Execute tool functionality
|
209
|
+
|
210
|
+
Args:
|
211
|
+
args: Parameters passed to the tool
|
212
|
+
|
213
|
+
Returns:
|
214
|
+
Dict with execution results:
|
215
|
+
{
|
216
|
+
"success": bool,
|
217
|
+
"stdout": str, # On success
|
218
|
+
"stderr": str, # Optional error details
|
219
|
+
"error": str # On failure
|
220
|
+
}
|
221
|
+
"""
|
222
|
+
try:
|
223
|
+
# Implement tool logic here
|
224
|
+
result = "Tool execution result"
|
225
|
+
return {
|
226
|
+
"success": True,
|
227
|
+
"stdout": result
|
228
|
+
}
|
229
|
+
except Exception as e:
|
230
|
+
return {
|
231
|
+
"success": False,
|
232
|
+
"error": str(e)
|
233
|
+
}
|
234
|
+
```
|
235
|
+
|
236
|
+
### Adding New Models
|
237
|
+
|
238
|
+
Create a new Python file in `~/.jarvis_models/`:
|
239
|
+
|
240
|
+
```python
|
241
|
+
from typing import Dict, List
|
242
|
+
from jarvis.models.base import BaseModel
|
243
|
+
from jarvis.utils import PrettyOutput, OutputType
|
244
|
+
|
245
|
+
class CustomModel(BaseModel):
|
246
|
+
"""Custom model implementation"""
|
247
|
+
|
248
|
+
model_name = "custom" # Model identifier
|
249
|
+
|
250
|
+
def __init__(self):
|
251
|
+
"""Initialize model"""
|
252
|
+
# Add your initialization code here
|
253
|
+
self.messages = []
|
254
|
+
self.system_message = ""
|
255
|
+
|
256
|
+
def set_system_message(self, message: str):
|
257
|
+
"""Set system message"""
|
258
|
+
self.system_message = message
|
259
|
+
|
260
|
+
def chat(self, message: str) -> str:
|
261
|
+
"""Execute chat with the model
|
262
|
+
|
263
|
+
Args:
|
264
|
+
message: User input message
|
265
|
+
|
266
|
+
Returns:
|
267
|
+
str: Model response
|
268
|
+
"""
|
269
|
+
try:
|
270
|
+
# Implement chat logic here
|
271
|
+
PrettyOutput.print("发送请求...", OutputType.PROGRESS)
|
272
|
+
|
273
|
+
# Add message to history
|
274
|
+
self.messages.append({"role": "user", "content": message})
|
275
|
+
|
276
|
+
# Get response from your model
|
277
|
+
response = "Model response"
|
278
|
+
|
279
|
+
# Add response to history
|
280
|
+
self.messages.append({"role": "assistant", "content": response})
|
281
|
+
|
282
|
+
return response
|
283
|
+
|
284
|
+
except Exception as e:
|
285
|
+
PrettyOutput.print(f"对话失败: {str(e)}", OutputType.ERROR)
|
286
|
+
raise Exception(f"Chat failed: {str(e)}")
|
287
|
+
|
288
|
+
def name(self) -> str:
|
289
|
+
"""Return model name"""
|
290
|
+
return self.model_name
|
291
|
+
|
292
|
+
def reset(self):
|
293
|
+
"""Reset model state"""
|
294
|
+
self.messages = []
|
295
|
+
if self.system_message:
|
296
|
+
self.messages.append({"role": "system", "content": self.system_message})
|
297
|
+
|
298
|
+
def delete_chat(self) -> bool:
|
299
|
+
"""Delete current chat session"""
|
300
|
+
self.reset()
|
301
|
+
return True
|
302
|
+
```
|
303
|
+
|
304
|
+
### Development Guidelines
|
305
|
+
|
306
|
+
1. **Tool Development**
|
307
|
+
- Use descriptive names and documentation
|
308
|
+
- Define clear parameter schemas
|
309
|
+
- Handle errors gracefully
|
310
|
+
- Return standardized results
|
311
|
+
- Keep tools focused and simple
|
312
|
+
|
313
|
+
2. **Model Development**
|
314
|
+
- Implement all required methods
|
315
|
+
- Handle streaming responses
|
316
|
+
- Manage chat history properly
|
317
|
+
- Use proper error handling
|
318
|
+
- Follow existing model patterns
|
319
|
+
|
320
|
+
3. **Best Practices**
|
321
|
+
- Use PrettyOutput for console output
|
322
|
+
- Document your code
|
323
|
+
- Add type hints
|
324
|
+
- Test thoroughly
|
325
|
+
- Handle edge cases
|
326
|
+
|
327
|
+
## 🤝 Contributing
|
328
|
+
|
329
|
+
1. Fork the repository
|
330
|
+
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
|
331
|
+
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
|
332
|
+
4. Push to the branch (`git push origin feature/AmazingFeature`)
|
333
|
+
5. Open a Pull Request
|
334
|
+
|
335
|
+
## 📄 License
|
336
|
+
|
337
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
338
|
+
|
339
|
+
---
|
340
|
+
|
341
|
+
<div align="center">
|
342
|
+
|
343
|
+
Made with ❤️ by the Jarvis Team
|
344
|
+
|
345
|
+
</div>
|
@@ -0,0 +1,55 @@
|
|
1
|
+
jarvis/__init__.py,sha256=WCzps5uo3WencEBknwjSQ5YjmvxkCFmigbNfF_1D6ts,50
|
2
|
+
jarvis/agent.py,sha256=QR5nwej7LKYg2s9q7lVG1R7C62t8OcJz0PTuIFncDB8,11805
|
3
|
+
jarvis/main.py,sha256=Lh0kMjfa3M692MpSn0T7jiXdR9EZpKDu7GSRPeLv7hk,5553
|
4
|
+
jarvis/utils.py,sha256=JlkuC9RtspXH2VWDmj9nR0vnb8ie1gIsKc4vC7WRco8,7321
|
5
|
+
jarvis/__pycache__/__init__.cpython-313.pyc,sha256=hB9XrD1bAFDQCRPcpo5W6SqRb1VIoPRY4r3V2-hjedo,209
|
6
|
+
jarvis/__pycache__/agent.cpython-313.pyc,sha256=cgbX5L0T16_ZBYw1K3wHGQ8UT7khEn5V7AlOGFkoN68,15200
|
7
|
+
jarvis/__pycache__/main.cpython-313.pyc,sha256=ZZl8WwAJtRj14_v_-mvlvCGUmfd-oJtqAMKv3RiR3lU,7673
|
8
|
+
jarvis/__pycache__/models.cpython-313.pyc,sha256=uWuRIjGrY4YDB3dGW5PGDLWaS03et8g11O725TjY_eU,5960
|
9
|
+
jarvis/__pycache__/tools.cpython-313.pyc,sha256=lAD4LrnnWzNZQmHXGfZ_2l7oskOpr2_2OC-gdFhxQY8,33933
|
10
|
+
jarvis/__pycache__/utils.cpython-313.pyc,sha256=eXXM-V-2ax7qBNxktdUrEIwhAXPQHAlI7gLGewlKOj4,10276
|
11
|
+
jarvis/__pycache__/zte_llm.cpython-313.pyc,sha256=kMm9IGundGmOPqjsgrm9oIaWLDagYGCPRAaE3ipkc-0,5662
|
12
|
+
jarvis/models/__init__.py,sha256=Lqb1NWFIfq7HlZIsJ7eUGyGjdYyaJqOoOf7cG_yo73A,57
|
13
|
+
jarvis/models/base.py,sha256=dNkYPg9ISrHGEpmQLN9kxCDU-kqJAJlm_owdDC302Dk,1132
|
14
|
+
jarvis/models/kimi.py,sha256=iI8mBzUxiyxa_bzDG9uwE3BZtreEUt0EJOIP_l2rSDM,16788
|
15
|
+
jarvis/models/openai.py,sha256=aFpRH6K0YG6suCRGlJLw2JzLh2Ftpn6AYhdnKtMQQlY,3940
|
16
|
+
jarvis/models/oyi.py,sha256=QCFLtrJN3CkHZ1mAudoFH684cx4tZiFUrerr7jtvEI8,10583
|
17
|
+
jarvis/models/registry.py,sha256=ecIo3a0G-pRPw4eg77ozzbGVh6vy93DHF8oAnU2g51w,7511
|
18
|
+
jarvis/models/__pycache__/__init__.cpython-313.pyc,sha256=hD4Uui0EPCTfoPOasTYzIi46Kv_q7OI8m-Lck-nX4zM,220
|
19
|
+
jarvis/models/__pycache__/base.cpython-313.pyc,sha256=9VvOXFPYOrB-2pO2py7dWOVbimODnXQJFLlFbyF7-LI,2207
|
20
|
+
jarvis/models/__pycache__/kimi.cpython-313.pyc,sha256=FGtHoTv747oNY4Lqnwf5BkGYKnevHOlIEDIlbsY7va0,20893
|
21
|
+
jarvis/models/__pycache__/openai.cpython-313.pyc,sha256=CU3KaUA0XcOK55sexF7OxfQ6_jdofABsufmFxm0T3mk,6004
|
22
|
+
jarvis/models/__pycache__/oyi.cpython-313.pyc,sha256=zpmRUcqDewifdvHel7goKuQiyo_6TYvmECoc_akAEkc,11163
|
23
|
+
jarvis/models/__pycache__/registry.cpython-313.pyc,sha256=jUZUyHyfzeQtjCdk2NCZGTsTUsvKyIlnZVDzZY1gLuU,9985
|
24
|
+
jarvis/tools/__init__.py,sha256=Kj1bKj34lwRDKMKHLOrLyQElf2lHbqA2tDgP359eaDo,71
|
25
|
+
jarvis/tools/base.py,sha256=EGRGbdfbLXDLwtyoWdvp9rlxNX7bzc20t0Vc2VkwIEY,652
|
26
|
+
jarvis/tools/file_ops.py,sha256=h8g0eT9UvlJf4kt0DLXvdSsjcPj7x19lxWdDApeDfpg,3842
|
27
|
+
jarvis/tools/generator.py,sha256=qyNdarq5SGEFBjkIlohk13cP5wV9IeQK5qJs7MwGUZg,5740
|
28
|
+
jarvis/tools/methodology.py,sha256=ptYOJR2yX6wHqv8hbvA3QshOYiga1r-c1-WQtaDJpq8,5434
|
29
|
+
jarvis/tools/registry.py,sha256=lSdx1coMf2IFE8hfwCbCgSW83yVRCp0H981kj7c80e0,7167
|
30
|
+
jarvis/tools/shell.py,sha256=UPKshPyOaUwTngresUw-ot1jHjQIb4wCY5nkJqa38lU,2520
|
31
|
+
jarvis/tools/sub_agent.py,sha256=rEtAmSVY2ZjFOZEKr5m5wpACOQIiM9Zr_3dT92FhXYU,2621
|
32
|
+
jarvis/tools/__pycache__/__init__.cpython-313.pyc,sha256=2ezw_ULVg9CJCUdX-RXTgYHLxQBs5X7wWJu1GNAN3ro,231
|
33
|
+
jarvis/tools/__pycache__/base.cpython-313.pyc,sha256=1s8lIsYq0WA9qdmya01N9ZXXVdEdKExTZp60UR6WepE,1422
|
34
|
+
jarvis/tools/__pycache__/bing_search.cpython-313.pyc,sha256=1G_wPbk5wcQYh7H0drLIS2Aw0XOG2ZM8ztgfQaqu3P8,2031
|
35
|
+
jarvis/tools/__pycache__/calculator.cpython-313.pyc,sha256=C_qwTDGm6gc7QNxtPzPZXyStdKEintJVQIt5NMHQ8oY,4205
|
36
|
+
jarvis/tools/__pycache__/calculator_tool.cpython-313.pyc,sha256=PI4LZNDTPdSe3ffWDRovLZ-r-vF8Kl-n6xdGdFWiBpY,4296
|
37
|
+
jarvis/tools/__pycache__/file_ops.cpython-313.pyc,sha256=qfgRIcO7JFsa_FxOOXV-3pNSnlovZDrcIkZ1WN3pOJI,3773
|
38
|
+
jarvis/tools/__pycache__/generator.cpython-313.pyc,sha256=sSO-y6fREIenF4cvFgaAtd0rAu95Epd5VZpjhmOfPRk,6155
|
39
|
+
jarvis/tools/__pycache__/methodology.cpython-313.pyc,sha256=bsSQdQBeEit_hqbkgHOdiilQP3CFC5AUjLu7WF8XGRQ,6318
|
40
|
+
jarvis/tools/__pycache__/python_script.cpython-313.pyc,sha256=8JpryqTovEiTvBlWAK1KjZmPvHUuPc9GT9rTXBEQoJc,6693
|
41
|
+
jarvis/tools/__pycache__/rag.cpython-313.pyc,sha256=JH6-PSZRMKAvTZqCwlRXJGClxYXNMs-vetU0q7hBLz0,6064
|
42
|
+
jarvis/tools/__pycache__/registry.cpython-313.pyc,sha256=TFRMsyO-g0YiQiez-jpi2YwBLzWu89Y6QyuidNB-ojc,9310
|
43
|
+
jarvis/tools/__pycache__/search.cpython-313.pyc,sha256=wLMIkFwT-h4NGHgssytT4xme7sGO6ZhEnex7kjcy0-k,5990
|
44
|
+
jarvis/tools/__pycache__/shell.cpython-313.pyc,sha256=ATt7BraEX6Sd3Ih6etwFpZ8fYczlZn5f0IqdjaqXt6c,3349
|
45
|
+
jarvis/tools/__pycache__/sub_agent.cpython-313.pyc,sha256=ROqk3BEwB_2-ALp6jG3wf18ShUr1lO0bhJjibOn6f3o,2799
|
46
|
+
jarvis/tools/__pycache__/user_confirmation.cpython-313.pyc,sha256=wK3Ev10lHSUSRvoYmi7A0GzxYkzU-C4Wfhs5qW_HBqs,2271
|
47
|
+
jarvis/tools/__pycache__/user_input.cpython-313.pyc,sha256=JjTFOhObKsKF4Pn8KBRuKfV1_Ssj083fjU7Mfc_5z7c,2531
|
48
|
+
jarvis/tools/__pycache__/user_interaction.cpython-313.pyc,sha256=RuVZ-pmiPBDywY3efgXSfohMAciC1avMGPmBK5qlnew,3305
|
49
|
+
jarvis/tools/__pycache__/webpage.cpython-313.pyc,sha256=BjzSfnNzsKCrLETCcWjt32lNDLzwnjqcVGg4JfWd9OM,3008
|
50
|
+
jarvis_ai_assistant-0.1.32.dist-info/LICENSE,sha256=AGgVgQmTqFvaztRtCAXsAMryUymB18gZif7_l2e1XOg,1063
|
51
|
+
jarvis_ai_assistant-0.1.32.dist-info/METADATA,sha256=hUCVm5P7w8ORbGpX2O3puRO1t8R-V3kOoXIbCLFkOG8,9765
|
52
|
+
jarvis_ai_assistant-0.1.32.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
53
|
+
jarvis_ai_assistant-0.1.32.dist-info/entry_points.txt,sha256=iKu7OMfew9dtfGhW71gIMTg4wvafuPqKb4wyQOnMAGU,44
|
54
|
+
jarvis_ai_assistant-0.1.32.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
|
55
|
+
jarvis_ai_assistant-0.1.32.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
jarvis
|