jarvis-ai-assistant 0.1.41__tar.gz → 0.1.43__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. {jarvis_ai_assistant-0.1.41/src/jarvis_ai_assistant.egg-info → jarvis_ai_assistant-0.1.43}/PKG-INFO +18 -17
  2. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/README.md +17 -16
  3. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/pyproject.toml +1 -1
  4. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/setup.py +1 -1
  5. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/__init__.py +1 -1
  6. jarvis_ai_assistant-0.1.43/src/jarvis/__pycache__/__init__.cpython-313.pyc +0 -0
  7. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/__pycache__/agent.cpython-313.pyc +0 -0
  8. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/__pycache__/main.cpython-313.pyc +0 -0
  9. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/agent.py +2 -2
  10. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/main.py +3 -3
  11. jarvis_ai_assistant-0.1.43/src/jarvis/models/__init__.py +3 -0
  12. jarvis_ai_assistant-0.1.43/src/jarvis/models/__pycache__/__init__.cpython-313.pyc +0 -0
  13. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/models/__pycache__/ai8.cpython-313.pyc +0 -0
  14. jarvis_ai_assistant-0.1.43/src/jarvis/models/__pycache__/base.cpython-313.pyc +0 -0
  15. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/models/__pycache__/kimi.cpython-313.pyc +0 -0
  16. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/models/__pycache__/openai.cpython-313.pyc +0 -0
  17. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/models/__pycache__/oyi.cpython-313.pyc +0 -0
  18. jarvis_ai_assistant-0.1.43/src/jarvis/models/__pycache__/registry.cpython-313.pyc +0 -0
  19. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/models/ai8.py +11 -7
  20. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/models/base.py +5 -2
  21. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/models/kimi.py +22 -18
  22. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/models/openai.py +7 -3
  23. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/models/oyi.py +11 -7
  24. jarvis_ai_assistant-0.1.43/src/jarvis/models/registry.py +203 -0
  25. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/__pycache__/generator.cpython-313.pyc +0 -0
  26. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/__pycache__/registry.cpython-313.pyc +0 -0
  27. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/generator.py +7 -2
  28. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/registry.py +1 -1
  29. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43/src/jarvis_ai_assistant.egg-info}/PKG-INFO +18 -17
  30. jarvis_ai_assistant-0.1.41/src/jarvis/__pycache__/__init__.cpython-313.pyc +0 -0
  31. jarvis_ai_assistant-0.1.41/src/jarvis/models/__init__.py +0 -3
  32. jarvis_ai_assistant-0.1.41/src/jarvis/models/__pycache__/__init__.cpython-313.pyc +0 -0
  33. jarvis_ai_assistant-0.1.41/src/jarvis/models/__pycache__/base.cpython-313.pyc +0 -0
  34. jarvis_ai_assistant-0.1.41/src/jarvis/models/__pycache__/registry.cpython-313.pyc +0 -0
  35. jarvis_ai_assistant-0.1.41/src/jarvis/models/registry.py +0 -199
  36. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/LICENSE +0 -0
  37. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/MANIFEST.in +0 -0
  38. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/setup.cfg +0 -0
  39. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/__pycache__/models.cpython-313.pyc +0 -0
  40. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/__pycache__/tools.cpython-313.pyc +0 -0
  41. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/__pycache__/utils.cpython-313.pyc +0 -0
  42. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/__pycache__/zte_llm.cpython-313.pyc +0 -0
  43. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/__init__.py +0 -0
  44. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/__pycache__/__init__.cpython-313.pyc +0 -0
  45. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/__pycache__/base.cpython-313.pyc +0 -0
  46. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/__pycache__/bing_search.cpython-313.pyc +0 -0
  47. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/__pycache__/calculator.cpython-313.pyc +0 -0
  48. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/__pycache__/calculator_tool.cpython-313.pyc +0 -0
  49. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/__pycache__/file_ops.cpython-313.pyc +0 -0
  50. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/__pycache__/methodology.cpython-313.pyc +0 -0
  51. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/__pycache__/python_script.cpython-313.pyc +0 -0
  52. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/__pycache__/rag.cpython-313.pyc +0 -0
  53. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/__pycache__/search.cpython-313.pyc +0 -0
  54. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/__pycache__/shell.cpython-313.pyc +0 -0
  55. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/__pycache__/sub_agent.cpython-313.pyc +0 -0
  56. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/__pycache__/user_confirmation.cpython-313.pyc +0 -0
  57. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/__pycache__/user_input.cpython-313.pyc +0 -0
  58. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/__pycache__/user_interaction.cpython-313.pyc +0 -0
  59. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/__pycache__/webpage.cpython-313.pyc +0 -0
  60. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/base.py +0 -0
  61. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/file_ops.py +0 -0
  62. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/methodology.py +0 -0
  63. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/shell.py +0 -0
  64. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/tools/sub_agent.py +0 -0
  65. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis/utils.py +0 -0
  66. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis_ai_assistant.egg-info/SOURCES.txt +0 -0
  67. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis_ai_assistant.egg-info/dependency_links.txt +0 -0
  68. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis_ai_assistant.egg-info/entry_points.txt +0 -0
  69. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/src/jarvis_ai_assistant.egg-info/requires.txt +0 -0
  70. {jarvis_ai_assistant-0.1.41 → jarvis_ai_assistant-0.1.43}/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.41
3
+ Version: 0.1.43
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
@@ -134,8 +134,8 @@ jarvis
134
134
 
135
135
  ### With Specific Model
136
136
  ```bash
137
- jarvis -m kimi # Use Kimi model
138
- jarvis -m openai # Use OpenAI model
137
+ jarvis -p kimi # Use Kimi platform
138
+ jarvis -p openai # Use OpenAI platform
139
139
  ```
140
140
 
141
141
  ### Process Files
@@ -154,10 +154,11 @@ jarvis --keep-history # Don't delete chat session after completion
154
154
 
155
155
  | Tool | Description |
156
156
  |------|-------------|
157
- | shell | Execute shell commands |
158
- | file | File operations (read/write/append) |
159
- | git | Git operations |
160
- | methodology | Manage problem-solving methodologies |
157
+ | execute_shell | Execute system commands and capture output |
158
+ | file_operation | File operations (read/write/append/delete) |
159
+ | generate_tool | AI-powered tool generation and integration |
160
+ | methodology | Experience accumulation and methodology management |
161
+ | create_sub_agent | Create specialized sub-agents for specific tasks |
161
162
 
162
163
  ### Tool Locations
163
164
  - Built-in tools: `src/jarvis/tools/`
@@ -166,21 +167,21 @@ jarvis --keep-history # Don't delete chat session after completion
166
167
  ### Key Features
167
168
 
168
169
  #### 1. Self-Extending Capabilities
169
- - AI-powered tool generation
170
- - Automatic integration of new tools
171
- - Dynamic capability expansion
170
+ - Tool generation through natural language description
171
+ - Automatic code generation and integration
172
+ - Dynamic capability expansion through sub-agents
172
173
 
173
174
  #### 2. Methodology Learning
174
- - Automatic extraction of problem-solving patterns
175
- - Continuous methodology refinement
176
- - Experience-based improvement
175
+ - Automatic experience accumulation from interactions
176
+ - Pattern recognition and methodology extraction
177
+ - Continuous refinement through usage
177
178
 
178
179
  #### 3. Adaptive Problem Solving
179
- - Context-aware tool selection
180
- - Dynamic strategy adjustment
181
- - Learning from execution results
180
+ - Context-aware sub-agent creation
181
+ - Dynamic tool composition
182
+ - Learning from execution feedback
182
183
 
183
- ## �� Extending Jarvis
184
+ ## 🎯 Extending Jarvis
184
185
 
185
186
  ### Adding New Tools
186
187
 
@@ -80,8 +80,8 @@ jarvis
80
80
 
81
81
  ### With Specific Model
82
82
  ```bash
83
- jarvis -m kimi # Use Kimi model
84
- jarvis -m openai # Use OpenAI model
83
+ jarvis -p kimi # Use Kimi platform
84
+ jarvis -p openai # Use OpenAI platform
85
85
  ```
86
86
 
87
87
  ### Process Files
@@ -100,10 +100,11 @@ jarvis --keep-history # Don't delete chat session after completion
100
100
 
101
101
  | Tool | Description |
102
102
  |------|-------------|
103
- | shell | Execute shell commands |
104
- | file | File operations (read/write/append) |
105
- | git | Git operations |
106
- | methodology | Manage problem-solving methodologies |
103
+ | execute_shell | Execute system commands and capture output |
104
+ | file_operation | File operations (read/write/append/delete) |
105
+ | generate_tool | AI-powered tool generation and integration |
106
+ | methodology | Experience accumulation and methodology management |
107
+ | create_sub_agent | Create specialized sub-agents for specific tasks |
107
108
 
108
109
  ### Tool Locations
109
110
  - Built-in tools: `src/jarvis/tools/`
@@ -112,21 +113,21 @@ jarvis --keep-history # Don't delete chat session after completion
112
113
  ### Key Features
113
114
 
114
115
  #### 1. Self-Extending Capabilities
115
- - AI-powered tool generation
116
- - Automatic integration of new tools
117
- - Dynamic capability expansion
116
+ - Tool generation through natural language description
117
+ - Automatic code generation and integration
118
+ - Dynamic capability expansion through sub-agents
118
119
 
119
120
  #### 2. Methodology Learning
120
- - Automatic extraction of problem-solving patterns
121
- - Continuous methodology refinement
122
- - Experience-based improvement
121
+ - Automatic experience accumulation from interactions
122
+ - Pattern recognition and methodology extraction
123
+ - Continuous refinement through usage
123
124
 
124
125
  #### 3. Adaptive Problem Solving
125
- - Context-aware tool selection
126
- - Dynamic strategy adjustment
127
- - Learning from execution results
126
+ - Context-aware sub-agent creation
127
+ - Dynamic tool composition
128
+ - Learning from execution feedback
128
129
 
129
- ## �� Extending Jarvis
130
+ ## 🎯 Extending Jarvis
130
131
 
131
132
  ### Adding New Tools
132
133
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "jarvis-ai-assistant"
7
- version = "0.1.41"
7
+ version = "0.1.43"
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" }]
@@ -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.41",
5
+ version="0.1.43",
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",
@@ -1,3 +1,3 @@
1
1
  """Jarvis AI Assistant"""
2
2
 
3
- __version__ = "0.1.41"
3
+ __version__ = "0.1.43"
@@ -3,7 +3,7 @@ from typing import Dict, List, Optional
3
3
 
4
4
  import yaml
5
5
 
6
- from .models.registry import ModelRegistry
6
+ from .models.registry import PlatformRegistry
7
7
  from .tools import ToolRegistry
8
8
  from .utils import PrettyOutput, OutputType, get_multiline_input, while_success
9
9
  import os
@@ -20,7 +20,7 @@ class Agent:
20
20
  name: Agent名称,默认为"Jarvis"
21
21
  is_sub_agent: 是否为子Agent,默认为False
22
22
  """
23
- self.model = ModelRegistry.get_global_model()
23
+ self.model = PlatformRegistry.get_global_platform()
24
24
  self.tool_registry = ToolRegistry.get_global_tool_registry()
25
25
  self.name = name
26
26
  self.is_sub_agent = is_sub_agent
@@ -8,7 +8,7 @@ import sys
8
8
  from pathlib import Path
9
9
  from prompt_toolkit import prompt
10
10
 
11
- from jarvis.models.registry import ModelRegistry
11
+ from jarvis.models.registry import PlatformRegistry
12
12
 
13
13
  # 添加父目录到Python路径以支持导入
14
14
  sys.path.insert(0, str(Path(__file__).parent.parent))
@@ -114,14 +114,14 @@ def main():
114
114
  PrettyOutput.print("未指定AI平台,请使用 -p 参数或者设置 JARVIS_PLATFORM 环境变量", OutputType.ERROR)
115
115
  return 1
116
116
 
117
- ModelRegistry.get_model_registry().set_global_model(platform)
117
+ PlatformRegistry.get_global_platform_registry().set_global_platform_name(platform)
118
118
 
119
119
  try:
120
120
  # 获取全局模型实例
121
121
  agent = Agent()
122
122
 
123
123
  # 欢迎信息
124
- PrettyOutput.print(f"Jarvis 已初始化 - With {platform} 平台", OutputType.SYSTEM)
124
+ PrettyOutput.print(f"Jarvis 已初始化 - With {platform} 平台,模型: {agent.model.name()}", OutputType.SYSTEM)
125
125
  if args.keep_history:
126
126
  PrettyOutput.print("已启用历史保留模式", OutputType.INFO)
127
127
 
@@ -0,0 +1,3 @@
1
+ from .base import BasePlatform
2
+
3
+ __all__ = ['BasePlatform']
@@ -1,15 +1,15 @@
1
1
  import os
2
2
  from typing import Dict, List
3
- from jarvis.models.base import BaseModel
3
+ from jarvis.models.base import BasePlatform
4
4
  from jarvis.utils import PrettyOutput, OutputType
5
5
  import requests
6
6
  import json
7
7
  import base64
8
8
 
9
- class AI8Model(BaseModel):
9
+ class AI8Model(BasePlatform):
10
10
  """AI8 model implementation"""
11
11
 
12
- model_name = "ai8"
12
+ platform_name = "ai8"
13
13
  BASE_URL = "https://ai8.rcouyi.com"
14
14
 
15
15
  def __init__(self):
@@ -62,11 +62,15 @@ class AI8Model(BaseModel):
62
62
  self.system_message = ""
63
63
  self.conversation = None
64
64
  self.files = []
65
- self.model = os.getenv("AI8_MODEL") or "deepseek-chat"
65
+ self.model_name = os.getenv("AI8_MODEL") or "deepseek-chat"
66
66
  self.token = os.getenv("AI8_API_KEY")
67
- if not all([self.model, self.token]):
67
+ if not all([self.model_name, self.token]):
68
68
  raise Exception("AI8_MODEL or AI8_API_KEY is not set")
69
- PrettyOutput.print(f"当前使用模型: {self.model}", OutputType.SYSTEM)
69
+ PrettyOutput.print(f"当前使用模型: {self.model_name}", OutputType.SYSTEM)
70
+
71
+ def set_model_name(self, model_name: str):
72
+ """设置模型名称"""
73
+ self.model_name = model_name
70
74
 
71
75
  def create_conversation(self) -> bool:
72
76
  """Create a new conversation"""
@@ -102,7 +106,7 @@ class AI8Model(BaseModel):
102
106
  # 2. 更新会话设置
103
107
  session_data = {
104
108
  **self.conversation,
105
- "model": self.model,
109
+ "model": self.model_name,
106
110
  "contextCount": 1024,
107
111
  "prompt": self.system_message,
108
112
  "plugins": ["tavily_search"],
@@ -3,14 +3,17 @@ from typing import Dict, List
3
3
  from ..utils import OutputType, PrettyOutput
4
4
 
5
5
 
6
- class BaseModel(ABC):
6
+ class BasePlatform(ABC):
7
7
  """大语言模型基类"""
8
8
 
9
9
  def __init__(self):
10
10
  """初始化模型"""
11
11
  pass
12
+
13
+ def set_model_name(self, model_name: str):
14
+ """设置模型名称"""
15
+ raise NotImplementedError("set_model_name is not implemented")
12
16
 
13
-
14
17
  @abstractmethod
15
18
  def chat(self, message: str) -> str:
16
19
  """执行对话"""
@@ -4,14 +4,14 @@ import json
4
4
  import os
5
5
  import mimetypes
6
6
  import time
7
- from jarvis.models.base import BaseModel
7
+ from jarvis.models.base import BasePlatform
8
8
  from jarvis.utils import PrettyOutput, OutputType
9
9
  from jarvis.utils import while_success
10
10
 
11
- class KimiModel(BaseModel):
11
+ class KimiModel(BasePlatform):
12
12
  """Kimi模型实现"""
13
13
 
14
- model_name = "kimi"
14
+ platform_name = "kimi"
15
15
 
16
16
  def __init__(self):
17
17
  """
@@ -19,21 +19,21 @@ class KimiModel(BaseModel):
19
19
  """
20
20
  self.api_key = os.getenv("KIMI_API_KEY")
21
21
  if not self.api_key:
22
- PrettyOutput.info("\n需要设置 KIMI_API_KEY 才能使用 Jarvis。请按以下步骤操作:")
23
- PrettyOutput.info("\n1. 获取 Kimi API Key:")
24
- PrettyOutput.info(" • 访问 Kimi AI 平台: https://kimi.moonshot.cn")
25
- PrettyOutput.info(" • 登录您的账号")
26
- PrettyOutput.info(" • 打开浏览器开发者工具 (F12 或右键 -> 检查)")
27
- PrettyOutput.info(" • 切换到 Network 标签页")
28
- PrettyOutput.info(" • 发送任意消息")
29
- PrettyOutput.info(" • 在请求中找到 Authorization 头部")
30
- PrettyOutput.info(" • 复制 token 值(去掉 'Bearer ' 前缀)")
31
- PrettyOutput.info("\n2. 设置环境变量:")
32
- PrettyOutput.info(" 方法 1: 创建或编辑 ~/.jarvis_env 文件:")
33
- PrettyOutput.info(" echo 'KIMI_API_KEY=your_key_here' > ~/.jarvis_env")
34
- PrettyOutput.info("\n 方法 2: 直接设置环境变量:")
35
- PrettyOutput.info(" export KIMI_API_KEY=your_key_here")
36
- PrettyOutput.info("\n设置完成后重新运行 Jarvis。")
22
+ PrettyOutput.print("\n需要设置 KIMI_API_KEY 才能使用 Jarvis。请按以下步骤操作:", OutputType.INFO)
23
+ PrettyOutput.print("\n1. 获取 Kimi API Key:", OutputType.INFO)
24
+ PrettyOutput.print(" • 访问 Kimi AI 平台: https://kimi.moonshot.cn", OutputType.INFO)
25
+ PrettyOutput.print(" • 登录您的账号", OutputType.INFO)
26
+ PrettyOutput.print(" • 打开浏览器开发者工具 (F12 或右键 -> 检查)", OutputType.INFO)
27
+ PrettyOutput.print(" • 切换到 Network 标签页", OutputType.INFO)
28
+ PrettyOutput.print(" • 发送任意消息", OutputType.INFO)
29
+ PrettyOutput.print(" • 在请求中找到 Authorization 头部", OutputType.INFO)
30
+ PrettyOutput.print(" • 复制 token 值(去掉 'Bearer ' 前缀)", OutputType.INFO)
31
+ PrettyOutput.print("\n2. 设置环境变量:", OutputType.INFO)
32
+ PrettyOutput.print(" 方法 1: 创建或编辑 ~/.jarvis_env 文件:", OutputType.INFO)
33
+ PrettyOutput.print(" echo 'KIMI_API_KEY=your_key_here' > ~/.jarvis_env", OutputType.INFO)
34
+ PrettyOutput.print("\n 方法 2: 直接设置环境变量:", OutputType.INFO)
35
+ PrettyOutput.print(" export KIMI_API_KEY=your_key_here", OutputType.INFO)
36
+ PrettyOutput.print("\n设置完成后重新运行 Jarvis。", OutputType.INFO)
37
37
  raise Exception("KIMI_API_KEY is not set")
38
38
  self.auth_header = f"Bearer {self.api_key}"
39
39
  self.chat_id = ""
@@ -45,6 +45,10 @@ class KimiModel(BaseModel):
45
45
  """设置系统消息"""
46
46
  self.system_message = message
47
47
 
48
+ def set_model_name(self, model_name: str):
49
+ """设置模型名称"""
50
+ pass
51
+
48
52
  def _create_chat(self) -> bool:
49
53
  """创建新的对话会话"""
50
54
  url = "https://kimi.moonshot.cn/api/chat"
@@ -1,13 +1,13 @@
1
1
  from typing import Dict, List
2
2
  import os
3
3
  from openai import OpenAI
4
- from jarvis.models.base import BaseModel
4
+ from jarvis.models.base import BasePlatform
5
5
  from jarvis.utils import PrettyOutput, OutputType
6
6
 
7
- class OpenAIModel(BaseModel):
7
+ class OpenAIModel(BasePlatform):
8
8
  """DeepSeek模型实现"""
9
9
 
10
- model_name = "openai"
10
+ platform_name = "openai"
11
11
 
12
12
  def __init__(self):
13
13
  """
@@ -41,6 +41,10 @@ class OpenAIModel(BaseModel):
41
41
  self.messages: List[Dict[str, str]] = []
42
42
  self.system_message = ""
43
43
 
44
+ def set_model_name(self, model_name: str):
45
+ """设置模型名称"""
46
+ self.model_name = model_name
47
+
44
48
  def set_system_message(self, message: str):
45
49
  """设置系统消息"""
46
50
  self.system_message = message
@@ -1,15 +1,15 @@
1
1
  import mimetypes
2
2
  import os
3
3
  from typing import Dict, List
4
- from jarvis.models.base import BaseModel
4
+ from jarvis.models.base import BasePlatform
5
5
  from jarvis.utils import PrettyOutput, OutputType
6
6
  import requests
7
7
  import json
8
8
 
9
- class OyiModel(BaseModel):
9
+ class OyiModel(BasePlatform):
10
10
  """Oyi model implementation"""
11
11
 
12
- model_name = "oyi"
12
+ platform_name = "oyi"
13
13
  BASE_URL = "https://api-10086.rcouyi.com"
14
14
 
15
15
  def __init__(self):
@@ -47,11 +47,15 @@ class OyiModel(BaseModel):
47
47
  self.conversation = None
48
48
  self.upload_files = []
49
49
  self.first_chat = True
50
- self.model = os.getenv("OYI_MODEL") or "deepseek-chat"
50
+ self.model_name = os.getenv("OYI_MODEL") or "deepseek-chat"
51
51
  self.token = os.getenv("OYI_API_KEY")
52
- if not all([self.model, self.token]):
52
+ if not all([self.model_name, self.token]):
53
53
  raise Exception("OYI_MODEL or OYI_API_KEY is not set")
54
- PrettyOutput.print(f"当前使用模型: {self.model}", OutputType.SYSTEM)
54
+ PrettyOutput.print(f"当前使用模型: {self.model_name}", OutputType.SYSTEM)
55
+
56
+ def set_model_name(self, model_name: str):
57
+ """设置模型名称"""
58
+ self.model_name = model_name
55
59
 
56
60
 
57
61
  def create_conversation(self) -> bool:
@@ -71,7 +75,7 @@ class OyiModel(BaseModel):
71
75
  "isLock": False,
72
76
  "systemMessage": "",
73
77
  "params": json.dumps({
74
- "model": "gpt-4o-mini",
78
+ "model": self.model_name,
75
79
  "is_webSearch": True,
76
80
  "message": [],
77
81
  "systemMessage": None,
@@ -0,0 +1,203 @@
1
+ import importlib
2
+ import inspect
3
+ import os
4
+ import sys
5
+ from typing import Dict, Type, Optional, List
6
+ from .base import BasePlatform
7
+ from ..utils import PrettyOutput, OutputType
8
+
9
+ REQUIRED_METHODS = [
10
+ ('chat', ['message']), # 方法名和参数列表
11
+ ('name', []),
12
+ ('delete_chat', []),
13
+ ('reset', []),
14
+ ('set_system_message', ['message'])
15
+ ]
16
+
17
+ class PlatformRegistry:
18
+ """平台注册器"""
19
+
20
+ global_platform_name = "kimi"
21
+ global_platform_registry = None
22
+
23
+ @staticmethod
24
+ def get_platform_dir() -> str:
25
+ user_platform_dir = os.path.expanduser("~/.jarvis_models")
26
+ if not os.path.exists(user_platform_dir):
27
+ try:
28
+ os.makedirs(user_platform_dir)
29
+ # 创建 __init__.py 使其成为 Python 包
30
+ with open(os.path.join(user_platform_dir, "__init__.py"), "w") as f:
31
+ pass
32
+ PrettyOutput.print(f"已创建平台目录: {user_platform_dir}", OutputType.INFO)
33
+ except Exception as e:
34
+ PrettyOutput.print(f"创建平台目录失败: {str(e)}", OutputType.ERROR)
35
+ return ""
36
+ return user_platform_dir
37
+
38
+ @staticmethod
39
+ def check_platform_implementation(platform_class: Type[BasePlatform]) -> bool:
40
+ """检查平台类是否实现了所有必要的方法
41
+
42
+ Args:
43
+ platform_class: 要检查的平台类
44
+
45
+ Returns:
46
+ bool: 是否实现了所有必要的方法
47
+ """
48
+ missing_methods = []
49
+
50
+ for method_name, params in REQUIRED_METHODS:
51
+ if not hasattr(platform_class, method_name):
52
+ missing_methods.append(method_name)
53
+ continue
54
+
55
+ method = getattr(platform_class, method_name)
56
+ if not callable(method):
57
+ missing_methods.append(method_name)
58
+ continue
59
+
60
+ # 检查方法参数
61
+ import inspect
62
+ sig = inspect.signature(method)
63
+ method_params = [p for p in sig.parameters if p != 'self']
64
+ if len(method_params) != len(params):
65
+ missing_methods.append(f"{method_name}(参数不匹配)")
66
+
67
+ if missing_methods:
68
+ PrettyOutput.print(
69
+ f"平台 {platform_class.__name__} 缺少必要的方法: {', '.join(missing_methods)}",
70
+ OutputType.ERROR
71
+ )
72
+ return False
73
+
74
+ return True
75
+
76
+ @staticmethod
77
+ def load_platform_from_dir(directory: str) -> Dict[str, Type[BasePlatform]]:
78
+ """从指定目录加载平台
79
+
80
+ Args:
81
+ directory: 平台目录路径
82
+
83
+ Returns:
84
+ Dict[str, Type[BaseModel]]: 平台名称到平台类的映射
85
+ """
86
+ platforms = {}
87
+
88
+ # 确保目录存在
89
+ if not os.path.exists(directory):
90
+ PrettyOutput.print(f"平台目录不存在: {directory}", OutputType.ERROR)
91
+ return platforms
92
+
93
+ # 获取目录的包名
94
+ package_name = None
95
+ if directory == os.path.dirname(__file__):
96
+ package_name = "jarvis.models"
97
+
98
+ # 添加目录到Python路径
99
+ if directory not in sys.path:
100
+ sys.path.append(directory)
101
+
102
+ # 遍历目录下的所有.py文件
103
+ for filename in os.listdir(directory):
104
+ if filename.endswith('.py') and not filename.startswith('__'):
105
+ module_name = filename[:-3] # 移除.py后缀
106
+ try:
107
+ # 导入模块
108
+ if package_name:
109
+ module = importlib.import_module(f"{package_name}.{module_name}")
110
+ else:
111
+ module = importlib.import_module(module_name)
112
+
113
+ # 遍历模块中的所有类
114
+ for name, obj in inspect.getmembers(module):
115
+ # 检查是否是BaseModel的子类,但不是BaseModel本身
116
+ if (inspect.isclass(obj) and
117
+ issubclass(obj, BasePlatform) and
118
+ obj != BasePlatform and
119
+ hasattr(obj, 'platform_name')):
120
+ # 检查平台实现
121
+ if not PlatformRegistry.check_platform_implementation(obj):
122
+ continue
123
+ platforms[obj.platform_name] = obj
124
+ PrettyOutput.print(f"从 {directory} 加载平台: {obj.platform_name}", OutputType.INFO)
125
+ break
126
+ except Exception as e:
127
+ PrettyOutput.print(f"加载平台 {module_name} 失败: {str(e)}", OutputType.ERROR)
128
+
129
+ return platforms
130
+
131
+
132
+ @staticmethod
133
+ def get_global_platform_registry():
134
+ """获取全局平台注册器"""
135
+ if PlatformRegistry.global_platform_registry is None:
136
+ PlatformRegistry.global_platform_registry = PlatformRegistry()
137
+
138
+ # 从用户平台目录加载额外平台
139
+ platform_dir = PlatformRegistry.get_platform_dir()
140
+ if platform_dir and os.path.exists(platform_dir):
141
+ for platform_name, platform_class in PlatformRegistry.load_platform_from_dir(platform_dir).items():
142
+ PlatformRegistry.global_platform_registry.register_platform(platform_name, platform_class)
143
+ platform_dir = os.path.dirname(__file__)
144
+ if platform_dir and os.path.exists(platform_dir):
145
+ for platform_name, platform_class in PlatformRegistry.load_platform_from_dir(platform_dir).items():
146
+ PlatformRegistry.global_platform_registry.register_platform(platform_name, platform_class)
147
+ return PlatformRegistry.global_platform_registry
148
+
149
+ def __init__(self):
150
+ """初始化平台注册器
151
+ """
152
+ self.platforms: Dict[str, Type[BasePlatform]] = {}
153
+
154
+ @staticmethod
155
+ def get_global_platform() -> BasePlatform:
156
+ """获取全局平台实例"""
157
+ platform = PlatformRegistry.get_global_platform_registry().create_platform(PlatformRegistry.global_platform_name)
158
+ if not platform:
159
+ raise Exception(f"Failed to create platform: {PlatformRegistry.global_platform_name}")
160
+ return platform
161
+
162
+ def register_platform(self, name: str, platform_class: Type[BasePlatform]):
163
+ """注册平台类
164
+
165
+ Args:
166
+ name: 平台名称
167
+ model_class: 平台类
168
+ """
169
+ self.platforms[name] = platform_class
170
+ PrettyOutput.print(f"已注册平台: {name}", OutputType.INFO)
171
+
172
+ def create_platform(self, name: str) -> Optional[BasePlatform]:
173
+ """创建平台实例
174
+
175
+ Args:
176
+ name: 平台名称
177
+
178
+ Returns:
179
+ BaseModel: 平台实例
180
+ """
181
+ if name not in self.platforms:
182
+ PrettyOutput.print(f"未找到平台: {name}", OutputType.ERROR)
183
+ return None
184
+
185
+ try:
186
+ platform = self.platforms[name]()
187
+ PrettyOutput.print(f"已创建平台实例: {name}", OutputType.INFO)
188
+ return platform
189
+ except Exception as e:
190
+ PrettyOutput.print(f"创建平台失败: {str(e)}", OutputType.ERROR)
191
+ return None
192
+
193
+ def get_available_platforms(self) -> List[str]:
194
+ """获取可用平台列表"""
195
+ return list(self.platforms.keys())
196
+
197
+ def set_global_platform_name(self, platform_name: str):
198
+ """设置全局平台"""
199
+ PlatformRegistry.global_platform_name = platform_name
200
+
201
+ def get_global_platform_name(self) -> str:
202
+ """获取全局平台名称"""
203
+ return PlatformRegistry.global_platform_name
@@ -1,6 +1,7 @@
1
+ import os
1
2
  from typing import Dict, Any
2
3
  from pathlib import Path
3
- from jarvis.models.registry import ModelRegistry
4
+ from jarvis.models.registry import PlatformRegistry
4
5
  from jarvis.tools.registry import ToolRegistry
5
6
  from jarvis.utils import OutputType, PrettyOutput
6
7
 
@@ -41,7 +42,11 @@ class ToolGeneratorTool:
41
42
 
42
43
  def _generate_tool_code(self, tool_name: str, class_name: str, description: str, parameters: Dict) -> str:
43
44
  """使用大模型生成工具代码"""
44
- model = ModelRegistry.get_global_model()
45
+ platform_name = os.getenv("JARVIS_CODEGEN_PLATFORM") or PlatformRegistry.get_global_platform_name()
46
+ model = PlatformRegistry.create_platform(platform_name)
47
+ model_name = os.getenv("JARVIS_CODEGEN_MODEL")
48
+ if model_name:
49
+ model.set_model_name(model_name)
45
50
 
46
51
  prompt = f"""请生成一个Python工具类的代码,要求如下,除了代码,不要输出任何内容:
47
52
 
@@ -5,7 +5,7 @@ from pathlib import Path
5
5
  import sys
6
6
  from typing import Any, Callable, Dict, List, Optional
7
7
 
8
- from jarvis.models.registry import ModelRegistry
8
+ from jarvis.models.registry import PlatformRegistry
9
9
  from jarvis.tools.base import Tool
10
10
  from jarvis.utils import OutputType, PrettyOutput
11
11
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: jarvis-ai-assistant
3
- Version: 0.1.41
3
+ Version: 0.1.43
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
@@ -134,8 +134,8 @@ jarvis
134
134
 
135
135
  ### With Specific Model
136
136
  ```bash
137
- jarvis -m kimi # Use Kimi model
138
- jarvis -m openai # Use OpenAI model
137
+ jarvis -p kimi # Use Kimi platform
138
+ jarvis -p openai # Use OpenAI platform
139
139
  ```
140
140
 
141
141
  ### Process Files
@@ -154,10 +154,11 @@ jarvis --keep-history # Don't delete chat session after completion
154
154
 
155
155
  | Tool | Description |
156
156
  |------|-------------|
157
- | shell | Execute shell commands |
158
- | file | File operations (read/write/append) |
159
- | git | Git operations |
160
- | methodology | Manage problem-solving methodologies |
157
+ | execute_shell | Execute system commands and capture output |
158
+ | file_operation | File operations (read/write/append/delete) |
159
+ | generate_tool | AI-powered tool generation and integration |
160
+ | methodology | Experience accumulation and methodology management |
161
+ | create_sub_agent | Create specialized sub-agents for specific tasks |
161
162
 
162
163
  ### Tool Locations
163
164
  - Built-in tools: `src/jarvis/tools/`
@@ -166,21 +167,21 @@ jarvis --keep-history # Don't delete chat session after completion
166
167
  ### Key Features
167
168
 
168
169
  #### 1. Self-Extending Capabilities
169
- - AI-powered tool generation
170
- - Automatic integration of new tools
171
- - Dynamic capability expansion
170
+ - Tool generation through natural language description
171
+ - Automatic code generation and integration
172
+ - Dynamic capability expansion through sub-agents
172
173
 
173
174
  #### 2. Methodology Learning
174
- - Automatic extraction of problem-solving patterns
175
- - Continuous methodology refinement
176
- - Experience-based improvement
175
+ - Automatic experience accumulation from interactions
176
+ - Pattern recognition and methodology extraction
177
+ - Continuous refinement through usage
177
178
 
178
179
  #### 3. Adaptive Problem Solving
179
- - Context-aware tool selection
180
- - Dynamic strategy adjustment
181
- - Learning from execution results
180
+ - Context-aware sub-agent creation
181
+ - Dynamic tool composition
182
+ - Learning from execution feedback
182
183
 
183
- ## �� Extending Jarvis
184
+ ## 🎯 Extending Jarvis
184
185
 
185
186
  ### Adding New Tools
186
187
 
@@ -1,3 +0,0 @@
1
- from .base import BaseModel
2
-
3
- __all__ = ['BaseModel']
@@ -1,199 +0,0 @@
1
- import importlib
2
- import inspect
3
- import os
4
- import sys
5
- from typing import Dict, Type, Optional, List
6
- from .base import BaseModel
7
- from ..utils import PrettyOutput, OutputType
8
-
9
- REQUIRED_METHODS = [
10
- ('chat', ['message']), # 方法名和参数列表
11
- ('name', []),
12
- ('delete_chat', []),
13
- ('reset', []),
14
- ('set_system_message', ['message'])
15
- ]
16
-
17
- class ModelRegistry:
18
- """模型注册器"""
19
-
20
- global_model_name = "kimi"
21
- global_model_registry = None
22
-
23
- @staticmethod
24
- def get_models_dir() -> str:
25
- user_models_dir = os.path.expanduser("~/.jarvis_models")
26
- if not os.path.exists(user_models_dir):
27
- try:
28
- os.makedirs(user_models_dir)
29
- # 创建 __init__.py 使其成为 Python 包
30
- with open(os.path.join(user_models_dir, "__init__.py"), "w") as f:
31
- pass
32
- PrettyOutput.print(f"已创建模型目录: {user_models_dir}", OutputType.INFO)
33
- except Exception as e:
34
- PrettyOutput.print(f"创建模型目录失败: {str(e)}", OutputType.ERROR)
35
- return ""
36
- return user_models_dir
37
-
38
- @staticmethod
39
- def check_model_implementation(model_class: Type[BaseModel]) -> bool:
40
- """检查模型类是否实现了所有必要的方法
41
-
42
- Args:
43
- model_class: 要检查的模型类
44
-
45
- Returns:
46
- bool: 是否实现了所有必要的方法
47
- """
48
- missing_methods = []
49
-
50
- for method_name, params in REQUIRED_METHODS:
51
- if not hasattr(model_class, method_name):
52
- missing_methods.append(method_name)
53
- continue
54
-
55
- method = getattr(model_class, method_name)
56
- if not callable(method):
57
- missing_methods.append(method_name)
58
- continue
59
-
60
- # 检查方法参数
61
- import inspect
62
- sig = inspect.signature(method)
63
- method_params = [p for p in sig.parameters if p != 'self']
64
- if len(method_params) != len(params):
65
- missing_methods.append(f"{method_name}(参数不匹配)")
66
-
67
- if missing_methods:
68
- PrettyOutput.print(
69
- f"模型 {model_class.__name__} 缺少必要的方法: {', '.join(missing_methods)}",
70
- OutputType.ERROR
71
- )
72
- return False
73
-
74
- return True
75
-
76
- @staticmethod
77
- def load_models_from_dir(directory: str) -> Dict[str, Type[BaseModel]]:
78
- """从指定目录加载模型
79
-
80
- Args:
81
- directory: 模型目录路径
82
-
83
- Returns:
84
- Dict[str, Type[BaseModel]]: 模型名称到模型类的映射
85
- """
86
- models = {}
87
-
88
- # 确保目录存在
89
- if not os.path.exists(directory):
90
- PrettyOutput.print(f"模型目录不存在: {directory}", OutputType.ERROR)
91
- return models
92
-
93
- # 获取目录的包名
94
- package_name = None
95
- if directory == os.path.dirname(__file__):
96
- package_name = "jarvis.models"
97
-
98
- # 添加目录到Python路径
99
- if directory not in sys.path:
100
- sys.path.append(directory)
101
-
102
- # 遍历目录下的所有.py文件
103
- for filename in os.listdir(directory):
104
- if filename.endswith('.py') and not filename.startswith('__'):
105
- module_name = filename[:-3] # 移除.py后缀
106
- try:
107
- # 导入模块
108
- if package_name:
109
- module = importlib.import_module(f"{package_name}.{module_name}")
110
- else:
111
- module = importlib.import_module(module_name)
112
-
113
- # 遍历模块中的所有类
114
- for name, obj in inspect.getmembers(module):
115
- # 检查是否是BaseModel的子类,但不是BaseModel本身
116
- if (inspect.isclass(obj) and
117
- issubclass(obj, BaseModel) and
118
- obj != BaseModel and
119
- hasattr(obj, 'model_name')):
120
- # 检查模型实现
121
- if not ModelRegistry.check_model_implementation(obj):
122
- continue
123
- models[obj.model_name] = obj
124
- PrettyOutput.print(f"从 {directory} 加载模型: {obj.model_name}", OutputType.INFO)
125
- break
126
- except Exception as e:
127
- PrettyOutput.print(f"加载模型 {module_name} 失败: {str(e)}", OutputType.ERROR)
128
-
129
- return models
130
-
131
-
132
- @staticmethod
133
- def get_model_registry():
134
- """获取全局模型注册器"""
135
- if ModelRegistry.global_model_registry is None:
136
- ModelRegistry.global_model_registry = ModelRegistry()
137
-
138
- # 从用户模型目录加载额外模型
139
- models_dir = ModelRegistry.get_models_dir()
140
- if models_dir and os.path.exists(models_dir):
141
- for model_name, model_class in ModelRegistry.load_models_from_dir(models_dir).items():
142
- ModelRegistry.global_model_registry.register_model(model_name, model_class)
143
- models_dir = os.path.dirname(__file__)
144
- if models_dir and os.path.exists(models_dir):
145
- for model_name, model_class in ModelRegistry.load_models_from_dir(models_dir).items():
146
- ModelRegistry.global_model_registry.register_model(model_name, model_class)
147
- return ModelRegistry.global_model_registry
148
-
149
- def __init__(self):
150
- """初始化模型注册器
151
- """
152
- self.models: Dict[str, Type[BaseModel]] = {}
153
-
154
- @staticmethod
155
- def get_global_model() -> BaseModel:
156
- """获取全局模型实例"""
157
- model = ModelRegistry.get_model_registry().create_model(ModelRegistry.global_model_name)
158
- if not model:
159
- raise Exception(f"Failed to create model: {ModelRegistry.global_model_name}")
160
- return model
161
-
162
- def register_model(self, name: str, model_class: Type[BaseModel]):
163
- """注册模型类
164
-
165
- Args:
166
- name: 模型名称
167
- model_class: 模型类
168
- """
169
- self.models[name] = model_class
170
- PrettyOutput.print(f"已注册模型: {name}", OutputType.INFO)
171
-
172
- def create_model(self, name: str) -> Optional[BaseModel]:
173
- """创建模型实例
174
-
175
- Args:
176
- name: 模型名称
177
-
178
- Returns:
179
- BaseModel: 模型实例
180
- """
181
- if name not in self.models:
182
- PrettyOutput.print(f"未找到模型: {name}", OutputType.ERROR)
183
- return None
184
-
185
- try:
186
- model = self.models[name]()
187
- PrettyOutput.print(f"已创建模型实例: {name}", OutputType.INFO)
188
- return model
189
- except Exception as e:
190
- PrettyOutput.print(f"创建模型失败: {str(e)}", OutputType.ERROR)
191
- return None
192
-
193
- def get_available_models(self) -> List[str]:
194
- """获取可用模型列表"""
195
- return list(self.models.keys())
196
-
197
- def set_global_model(self, model_name: str):
198
- """设置全局模型"""
199
- ModelRegistry.global_model_name = model_name