jarvis-ai-assistant 0.1.57__py3-none-any.whl → 0.1.59__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 +98 -50
- jarvis/jarvis_coder/main.py +417 -243
- jarvis/models/ai8.py +9 -10
- jarvis/models/base.py +5 -0
- jarvis/models/kimi.py +18 -8
- jarvis/models/openai.py +9 -4
- jarvis/models/oyi.py +7 -1
- jarvis/models/registry.py +3 -3
- jarvis/tools/coder.py +66 -0
- jarvis/tools/search.py +33 -1
- {jarvis_ai_assistant-0.1.57.dist-info → jarvis_ai_assistant-0.1.59.dist-info}/METADATA +56 -36
- jarvis_ai_assistant-0.1.59.dist-info/RECORD +29 -0
- jarvis/tools/bing_search.py +0 -38
- jarvis_ai_assistant-0.1.57.dist-info/RECORD +0 -29
- {jarvis_ai_assistant-0.1.57.dist-info → jarvis_ai_assistant-0.1.59.dist-info}/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.57.dist-info → jarvis_ai_assistant-0.1.59.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.57.dist-info → jarvis_ai_assistant-0.1.59.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.57.dist-info → jarvis_ai_assistant-0.1.59.dist-info}/top_level.txt +0 -0
jarvis/models/ai8.py
CHANGED
|
@@ -14,6 +14,7 @@ class AI8Model(BasePlatform):
|
|
|
14
14
|
|
|
15
15
|
def __init__(self):
|
|
16
16
|
"""Initialize model"""
|
|
17
|
+
super().__init__()
|
|
17
18
|
self.system_message = ""
|
|
18
19
|
self.conversation = None
|
|
19
20
|
self.files = []
|
|
@@ -156,15 +157,11 @@ class AI8Model(BasePlatform):
|
|
|
156
157
|
self.system_message = message
|
|
157
158
|
|
|
158
159
|
def chat(self, message: str) -> str:
|
|
159
|
-
"""
|
|
160
|
-
|
|
161
|
-
Args:
|
|
162
|
-
message: User input message
|
|
163
|
-
|
|
164
|
-
Returns:
|
|
165
|
-
str: Model response
|
|
166
|
-
"""
|
|
160
|
+
"""执行对话"""
|
|
167
161
|
try:
|
|
162
|
+
if not self.suppress_output:
|
|
163
|
+
PrettyOutput.print("发送请求...", OutputType.PROGRESS)
|
|
164
|
+
|
|
168
165
|
# 确保有会话ID
|
|
169
166
|
if not self.conversation:
|
|
170
167
|
if not self.create_conversation():
|
|
@@ -219,12 +216,14 @@ class AI8Model(BasePlatform):
|
|
|
219
216
|
chunk = data.get('data', '')
|
|
220
217
|
if chunk:
|
|
221
218
|
full_response += chunk
|
|
222
|
-
|
|
219
|
+
if not self.suppress_output:
|
|
220
|
+
PrettyOutput.print_stream(chunk)
|
|
223
221
|
|
|
224
222
|
except json.JSONDecodeError:
|
|
225
223
|
continue
|
|
226
224
|
|
|
227
|
-
|
|
225
|
+
if not self.suppress_output:
|
|
226
|
+
PrettyOutput.print_stream_end()
|
|
228
227
|
|
|
229
228
|
return full_response
|
|
230
229
|
|
jarvis/models/base.py
CHANGED
|
@@ -7,6 +7,7 @@ class BasePlatform(ABC):
|
|
|
7
7
|
|
|
8
8
|
def __init__(self):
|
|
9
9
|
"""初始化模型"""
|
|
10
|
+
self.suppress_output = False # 添加输出控制标志
|
|
10
11
|
pass
|
|
11
12
|
|
|
12
13
|
def set_model_name(self, model_name: str):
|
|
@@ -39,3 +40,7 @@ class BasePlatform(ABC):
|
|
|
39
40
|
def set_system_message(self, message: str):
|
|
40
41
|
"""设置系统消息"""
|
|
41
42
|
raise NotImplementedError("set_system_message is not implemented")
|
|
43
|
+
|
|
44
|
+
def set_suppress_output(self, suppress: bool):
|
|
45
|
+
"""设置是否屏蔽输出"""
|
|
46
|
+
self.suppress_output = suppress
|
jarvis/models/kimi.py
CHANGED
|
@@ -17,6 +17,7 @@ class KimiModel(BasePlatform):
|
|
|
17
17
|
"""
|
|
18
18
|
初始化Kimi模型
|
|
19
19
|
"""
|
|
20
|
+
super().__init__()
|
|
20
21
|
self.api_key = os.getenv("KIMI_API_KEY")
|
|
21
22
|
if not self.api_key:
|
|
22
23
|
PrettyOutput.print("\n需要设置 KIMI_API_KEY 才能使用 Jarvis。请按以下步骤操作:", OutputType.INFO)
|
|
@@ -217,7 +218,8 @@ class KimiModel(BasePlatform):
|
|
|
217
218
|
def chat(self, message: str) -> str:
|
|
218
219
|
"""发送消息并获取响应"""
|
|
219
220
|
if not self.chat_id:
|
|
220
|
-
|
|
221
|
+
if not self.suppress_output:
|
|
222
|
+
PrettyOutput.print("创建新的对话会话...", OutputType.PROGRESS)
|
|
221
223
|
if not self._create_chat():
|
|
222
224
|
raise Exception("Failed to create chat session")
|
|
223
225
|
|
|
@@ -228,13 +230,15 @@ class KimiModel(BasePlatform):
|
|
|
228
230
|
refs_file = []
|
|
229
231
|
if self.first_chat:
|
|
230
232
|
if self.uploaded_files:
|
|
231
|
-
|
|
233
|
+
if not self.suppress_output:
|
|
234
|
+
PrettyOutput.print(f"首次对话,引用 {len(self.uploaded_files)} 个文件...", OutputType.PROGRESS)
|
|
232
235
|
refs = [f["id"] for f in self.uploaded_files]
|
|
233
236
|
refs_file = self.uploaded_files
|
|
234
237
|
message = self.system_message + "\n" + message
|
|
235
238
|
self.first_chat = False
|
|
236
239
|
|
|
237
|
-
|
|
240
|
+
if not self.suppress_output:
|
|
241
|
+
PrettyOutput.print("发送请求...", OutputType.PROGRESS)
|
|
238
242
|
payload = {
|
|
239
243
|
"messages": [{"role": "user", "content": message}],
|
|
240
244
|
"use_search": True,
|
|
@@ -259,7 +263,9 @@ class KimiModel(BasePlatform):
|
|
|
259
263
|
search_results = []
|
|
260
264
|
ref_sources = []
|
|
261
265
|
|
|
262
|
-
|
|
266
|
+
if not self.suppress_output:
|
|
267
|
+
PrettyOutput.print("接收响应...", OutputType.PROGRESS)
|
|
268
|
+
|
|
263
269
|
for line in response.iter_lines():
|
|
264
270
|
if not line:
|
|
265
271
|
continue
|
|
@@ -276,7 +282,8 @@ class KimiModel(BasePlatform):
|
|
|
276
282
|
# 处理补全文本
|
|
277
283
|
text = data.get("text", "")
|
|
278
284
|
if text:
|
|
279
|
-
|
|
285
|
+
if not self.suppress_output:
|
|
286
|
+
PrettyOutput.print_stream(text)
|
|
280
287
|
full_response += text
|
|
281
288
|
|
|
282
289
|
elif event == "search_plus":
|
|
@@ -311,11 +318,12 @@ class KimiModel(BasePlatform):
|
|
|
311
318
|
except json.JSONDecodeError:
|
|
312
319
|
continue
|
|
313
320
|
|
|
314
|
-
|
|
321
|
+
if not self.suppress_output:
|
|
322
|
+
PrettyOutput.print_stream_end()
|
|
315
323
|
|
|
316
324
|
|
|
317
325
|
# 显示搜索结果摘要
|
|
318
|
-
if search_results:
|
|
326
|
+
if search_results and not self.suppress_output:
|
|
319
327
|
PrettyOutput.print("\n搜索结果:", OutputType.PROGRESS)
|
|
320
328
|
for result in search_results:
|
|
321
329
|
PrettyOutput.print(f"- {result['title']}", OutputType.PROGRESS)
|
|
@@ -328,7 +336,7 @@ class KimiModel(BasePlatform):
|
|
|
328
336
|
PrettyOutput.print("", OutputType.PROGRESS)
|
|
329
337
|
|
|
330
338
|
# 显示引用来源
|
|
331
|
-
if ref_sources:
|
|
339
|
+
if ref_sources and not self.suppress_output:
|
|
332
340
|
PrettyOutput.print("\n引用来源:", OutputType.PROGRESS)
|
|
333
341
|
for source in ref_sources:
|
|
334
342
|
PrettyOutput.print(f"- [{source['ref_id']}] {source['title']} ({source['source']})", OutputType.PROGRESS)
|
|
@@ -352,6 +360,8 @@ class KimiModel(BasePlatform):
|
|
|
352
360
|
PrettyOutput.print(f" 原文: {text}", OutputType.PROGRESS)
|
|
353
361
|
|
|
354
362
|
PrettyOutput.print("", OutputType.PROGRESS)
|
|
363
|
+
|
|
364
|
+
PrettyOutput.print(full_response, OutputType.RESULT)
|
|
355
365
|
|
|
356
366
|
return full_response
|
|
357
367
|
|
jarvis/models/openai.py
CHANGED
|
@@ -13,6 +13,7 @@ class OpenAIModel(BasePlatform):
|
|
|
13
13
|
"""
|
|
14
14
|
初始化DeepSeek模型
|
|
15
15
|
"""
|
|
16
|
+
super().__init__()
|
|
16
17
|
self.api_key = os.getenv("OPENAI_API_KEY")
|
|
17
18
|
if not self.api_key:
|
|
18
19
|
PrettyOutput.print("\n需要设置以下环境变量才能使用 OpenAI 模型:", OutputType.INFO)
|
|
@@ -54,7 +55,8 @@ class OpenAIModel(BasePlatform):
|
|
|
54
55
|
def chat(self, message: str) -> str:
|
|
55
56
|
"""执行对话"""
|
|
56
57
|
try:
|
|
57
|
-
|
|
58
|
+
if not self.suppress_output:
|
|
59
|
+
PrettyOutput.print("发送请求...", OutputType.PROGRESS)
|
|
58
60
|
|
|
59
61
|
# 添加用户消息到历史记录
|
|
60
62
|
self.messages.append({"role": "user", "content": message})
|
|
@@ -65,16 +67,19 @@ class OpenAIModel(BasePlatform):
|
|
|
65
67
|
stream=True
|
|
66
68
|
)
|
|
67
69
|
|
|
68
|
-
|
|
70
|
+
if not self.suppress_output:
|
|
71
|
+
PrettyOutput.print("接收响应...", OutputType.PROGRESS)
|
|
69
72
|
full_response = ""
|
|
70
73
|
|
|
71
74
|
for chunk in response:
|
|
72
75
|
if chunk.choices[0].delta.content:
|
|
73
76
|
text = chunk.choices[0].delta.content
|
|
74
|
-
|
|
77
|
+
if not self.suppress_output:
|
|
78
|
+
PrettyOutput.print_stream(text)
|
|
75
79
|
full_response += text
|
|
76
80
|
|
|
77
|
-
|
|
81
|
+
if not self.suppress_output:
|
|
82
|
+
PrettyOutput.print_stream_end()
|
|
78
83
|
|
|
79
84
|
# 添加助手回复到历史记录
|
|
80
85
|
self.messages.append({"role": "assistant", "content": full_response})
|
jarvis/models/oyi.py
CHANGED
|
@@ -14,6 +14,7 @@ class OyiModel(BasePlatform):
|
|
|
14
14
|
|
|
15
15
|
def __init__(self):
|
|
16
16
|
"""Initialize model"""
|
|
17
|
+
super().__init__()
|
|
17
18
|
PrettyOutput.section("支持的模型", OutputType.SUCCESS)
|
|
18
19
|
|
|
19
20
|
# 获取可用模型列表
|
|
@@ -114,6 +115,9 @@ class OyiModel(BasePlatform):
|
|
|
114
115
|
str: Model response
|
|
115
116
|
"""
|
|
116
117
|
try:
|
|
118
|
+
if not self.suppress_output:
|
|
119
|
+
PrettyOutput.print("发送请求...", OutputType.PROGRESS)
|
|
120
|
+
|
|
117
121
|
# 确保有会话ID
|
|
118
122
|
if not self.conversation:
|
|
119
123
|
if not self.create_conversation():
|
|
@@ -182,7 +186,9 @@ class OyiModel(BasePlatform):
|
|
|
182
186
|
)
|
|
183
187
|
|
|
184
188
|
if response.status_code == 200:
|
|
185
|
-
|
|
189
|
+
if not self.suppress_output:
|
|
190
|
+
PrettyOutput.print("接收响应...", OutputType.PROGRESS)
|
|
191
|
+
PrettyOutput.print(response.text, OutputType.SYSTEM)
|
|
186
192
|
self.messages.append({"role": "assistant", "content": response.text})
|
|
187
193
|
return response.text
|
|
188
194
|
else:
|
jarvis/models/registry.py
CHANGED
|
@@ -81,7 +81,7 @@ class PlatformRegistry:
|
|
|
81
81
|
directory: 平台目录路径
|
|
82
82
|
|
|
83
83
|
Returns:
|
|
84
|
-
Dict[str, Type[
|
|
84
|
+
Dict[str, Type[BasePlatform]]: 平台名称到平台类的映射
|
|
85
85
|
"""
|
|
86
86
|
platforms = {}
|
|
87
87
|
|
|
@@ -112,7 +112,7 @@ class PlatformRegistry:
|
|
|
112
112
|
|
|
113
113
|
# 遍历模块中的所有类
|
|
114
114
|
for name, obj in inspect.getmembers(module):
|
|
115
|
-
# 检查是否是
|
|
115
|
+
# 检查是否是BasePlatform的子类,但不是BasePlatform本身
|
|
116
116
|
if (inspect.isclass(obj) and
|
|
117
117
|
issubclass(obj, BasePlatform) and
|
|
118
118
|
obj != BasePlatform and
|
|
@@ -176,7 +176,7 @@ class PlatformRegistry:
|
|
|
176
176
|
name: 平台名称
|
|
177
177
|
|
|
178
178
|
Returns:
|
|
179
|
-
|
|
179
|
+
BasePlatform: 平台实例
|
|
180
180
|
"""
|
|
181
181
|
if name not in self.platforms:
|
|
182
182
|
PrettyOutput.print(f"未找到平台: {name}", OutputType.ERROR)
|
jarvis/tools/coder.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from typing import Dict, Any, Optional
|
|
3
|
+
from jarvis.jarvis_coder.main import JarvisCoder
|
|
4
|
+
from jarvis.utils import PrettyOutput, OutputType
|
|
5
|
+
|
|
6
|
+
class CoderTool:
|
|
7
|
+
"""代码修改工具"""
|
|
8
|
+
|
|
9
|
+
name = "coder"
|
|
10
|
+
description = "用于自动修改和生成代码的工具"
|
|
11
|
+
parameters = {
|
|
12
|
+
"feature": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "要实现的功能描述",
|
|
15
|
+
"required": True
|
|
16
|
+
},
|
|
17
|
+
"dir": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "项目根目录",
|
|
20
|
+
"required": False
|
|
21
|
+
},
|
|
22
|
+
"language": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "编程语言",
|
|
25
|
+
"required": False
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _init_coder(self, dir: Optional[str] = None, language: Optional[str] = "python") -> None:
|
|
31
|
+
"""初始化JarvisCoder实例"""
|
|
32
|
+
if not self._coder:
|
|
33
|
+
import os
|
|
34
|
+
work_dir = dir or os.getcwd()
|
|
35
|
+
self._coder = JarvisCoder(work_dir, language)
|
|
36
|
+
|
|
37
|
+
def execute(self, **kwargs) -> Dict[str, Any]:
|
|
38
|
+
"""执行代码修改
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
feature: 要实现的功能描述
|
|
42
|
+
dir: 可选,项目根目录
|
|
43
|
+
language: 可选,编程语言
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
Dict[str, Any]: 执行结果
|
|
47
|
+
"""
|
|
48
|
+
feature = kwargs.get("feature")
|
|
49
|
+
dir = kwargs.get("dir")
|
|
50
|
+
language = kwargs.get("language", "python")
|
|
51
|
+
|
|
52
|
+
try:
|
|
53
|
+
self.current_dir = os.getcwd()
|
|
54
|
+
self._init_coder(dir, language)
|
|
55
|
+
result = self._coder.execute(feature)
|
|
56
|
+
return result
|
|
57
|
+
except Exception as e:
|
|
58
|
+
PrettyOutput.print(f"代码修改失败: {str(e)}", OutputType.ERROR)
|
|
59
|
+
return {
|
|
60
|
+
"success": False,
|
|
61
|
+
"stdout": "",
|
|
62
|
+
"stderr": f"执行失败: {str(e)}",
|
|
63
|
+
"error": e
|
|
64
|
+
}
|
|
65
|
+
finally:
|
|
66
|
+
os.chdir(self.current_dir)
|
jarvis/tools/search.py
CHANGED
|
@@ -2,7 +2,39 @@ from typing import Dict, Any, List
|
|
|
2
2
|
from jarvis.models.registry import PlatformRegistry
|
|
3
3
|
from jarvis.utils import PrettyOutput, OutputType
|
|
4
4
|
from jarvis.tools.webpage import WebpageTool
|
|
5
|
-
from
|
|
5
|
+
from playwright.sync_api import sync_playwright
|
|
6
|
+
from urllib.parse import quote
|
|
7
|
+
|
|
8
|
+
def bing_search(query):
|
|
9
|
+
try:
|
|
10
|
+
with sync_playwright() as p:
|
|
11
|
+
browser = p.chromium.launch()
|
|
12
|
+
page = browser.new_page()
|
|
13
|
+
page.goto(
|
|
14
|
+
f"https://www.bing.com/search?form=QBRE&q={quote(query)}&cc=US"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
page.wait_for_selector("#b_results", timeout=10000)
|
|
18
|
+
|
|
19
|
+
summaries = page.evaluate("""() => {
|
|
20
|
+
const liElements = Array.from(
|
|
21
|
+
document.querySelectorAll("#b_results > .b_algo")
|
|
22
|
+
);
|
|
23
|
+
return liElements.map((li) => {
|
|
24
|
+
const abstractElement = li.querySelector(".b_caption > p");
|
|
25
|
+
const linkElement = li.querySelector("a");
|
|
26
|
+
const href = linkElement.getAttribute("href");
|
|
27
|
+
const title = linkElement.textContent;
|
|
28
|
+
const abstract = abstractElement ? abstractElement.textContent : "";
|
|
29
|
+
return { href, title, abstract };
|
|
30
|
+
});
|
|
31
|
+
}""")
|
|
32
|
+
|
|
33
|
+
browser.close()
|
|
34
|
+
print(summaries)
|
|
35
|
+
return summaries
|
|
36
|
+
except Exception as error:
|
|
37
|
+
print("An error occurred:", error)
|
|
6
38
|
|
|
7
39
|
class SearchTool:
|
|
8
40
|
name = "search"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: jarvis-ai-assistant
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.59
|
|
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
|
|
@@ -66,6 +66,8 @@ Dynamic: requires-python
|
|
|
66
66
|
|
|
67
67
|
*Your intelligent assistant for development and system interaction*
|
|
68
68
|
|
|
69
|
+
English | [简体中文](README_zh.md)
|
|
70
|
+
|
|
69
71
|
[Features](#features) •
|
|
70
72
|
[Usage](#usage) •
|
|
71
73
|
[Configuration](#configuration) •
|
|
@@ -112,19 +114,23 @@ pip install jarvis-ai-assistant
|
|
|
112
114
|
|
|
113
115
|
## 🔧 Configuration
|
|
114
116
|
|
|
115
|
-
|
|
117
|
+
Jarvis supports configuration through environment variables that can be set in the `~/.jarvis_env` file:
|
|
116
118
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
| Environment Variable | Description | Default Value | Required |
|
|
120
|
+
|---------|------|--------|------|
|
|
121
|
+
| JARVIS_PLATFORM | AI platform to use, supports kimi/openai/ai8 etc | kimi | Yes |
|
|
122
|
+
| JARVIS_MODEL | Model name to use | - | No |
|
|
123
|
+
| JARVIS_CODEGEN_PLATFORM | AI platform for code generation | Same as JARVIS_PLATFORM | No |
|
|
124
|
+
| JARVIS_CODEGEN_MODEL | Model name for code generation | Same as JARVIS_MODEL | No |
|
|
125
|
+
| OPENAI_API_KEY | API key for OpenAI platform | - | Required for OpenAI |
|
|
126
|
+
| OPENAI_API_BASE | Base URL for OpenAI API | https://api.deepseek.com | No |
|
|
127
|
+
| OPENAI_MODEL_NAME | Model name for OpenAI | deepseek-chat | No |
|
|
128
|
+
| AI8_API_KEY | API key for AI8 platform | - | Required for AI8 |
|
|
129
|
+
| AI8_MODEL | Model name for AI8 platform | deepseek-chat | No |
|
|
130
|
+
| KIMI_API_KEY | API key for Kimi platform | - | Required for Kimi |
|
|
131
|
+
| OYI_API_KEY | API key for OYI platform | - | Required for OYI |
|
|
132
|
+
| OYI_MODEL | Model name for OYI platform | deepseek-chat | No |
|
|
121
133
|
|
|
122
|
-
### For OpenAI:
|
|
123
|
-
```bash
|
|
124
|
-
OPENAI_API_KEY=your_api_key_here
|
|
125
|
-
OPENAI_API_BASE=your_api_base # Optional, defaults to https://api.deepseek.com
|
|
126
|
-
OPENAI_MODEL_NAME=your_model_name # Optional, defaults to deepseek-chat
|
|
127
|
-
```
|
|
128
134
|
|
|
129
135
|
## 🎯 Usage
|
|
130
136
|
|
|
@@ -241,55 +247,57 @@ Create a new Python file in `~/.jarvis_models/`:
|
|
|
241
247
|
|
|
242
248
|
```python
|
|
243
249
|
from typing import Dict, List
|
|
244
|
-
from jarvis.models.base import
|
|
250
|
+
from jarvis.models.base import BasePlatform
|
|
245
251
|
from jarvis.utils import PrettyOutput, OutputType
|
|
246
252
|
|
|
247
|
-
class
|
|
253
|
+
class CustomPlatform(BasePlatform):
|
|
248
254
|
"""Custom model implementation"""
|
|
249
255
|
|
|
250
|
-
|
|
256
|
+
platform_name = "custom" # Platform identifier
|
|
251
257
|
|
|
252
258
|
def __init__(self):
|
|
253
259
|
"""Initialize model"""
|
|
254
|
-
#
|
|
260
|
+
# add initialization code
|
|
261
|
+
super().__init__()
|
|
255
262
|
self.messages = []
|
|
256
263
|
self.system_message = ""
|
|
257
|
-
|
|
258
|
-
def
|
|
259
|
-
"""Set
|
|
260
|
-
self.
|
|
261
|
-
|
|
264
|
+
|
|
265
|
+
def set_model_name(self, model_name: str):
|
|
266
|
+
"""Set model name"""
|
|
267
|
+
self.model_name = model_name
|
|
268
|
+
|
|
262
269
|
def chat(self, message: str) -> str:
|
|
263
|
-
"""
|
|
270
|
+
"""Chat with model
|
|
264
271
|
|
|
265
272
|
Args:
|
|
266
|
-
message:
|
|
273
|
+
message: user input message
|
|
267
274
|
|
|
268
275
|
Returns:
|
|
269
|
-
str:
|
|
276
|
+
str: model response
|
|
270
277
|
"""
|
|
271
278
|
try:
|
|
272
|
-
#
|
|
273
|
-
PrettyOutput.print("
|
|
279
|
+
# implement chat logic
|
|
280
|
+
PrettyOutput.print("Sending request...", OutputType.PROGRESS)
|
|
274
281
|
|
|
275
|
-
#
|
|
282
|
+
# add message to history
|
|
276
283
|
self.messages.append({"role": "user", "content": message})
|
|
277
284
|
|
|
278
|
-
#
|
|
279
|
-
response = "
|
|
285
|
+
# get response from model
|
|
286
|
+
response = "model response"
|
|
280
287
|
|
|
281
|
-
#
|
|
288
|
+
# add response to history
|
|
282
289
|
self.messages.append({"role": "assistant", "content": response})
|
|
283
290
|
|
|
284
291
|
return response
|
|
285
292
|
|
|
286
293
|
except Exception as e:
|
|
287
|
-
PrettyOutput.print(f"
|
|
294
|
+
PrettyOutput.print(f"Chat failed: {str(e)}", OutputType.ERROR)
|
|
288
295
|
raise Exception(f"Chat failed: {str(e)}")
|
|
289
|
-
|
|
290
|
-
def
|
|
291
|
-
"""
|
|
292
|
-
|
|
296
|
+
|
|
297
|
+
def upload_files(self, file_list: List[str]) -> List[Dict]:
|
|
298
|
+
"""Upload files"""
|
|
299
|
+
# implement file upload logic
|
|
300
|
+
return []
|
|
293
301
|
|
|
294
302
|
def reset(self):
|
|
295
303
|
"""Reset model state"""
|
|
@@ -297,10 +305,22 @@ class CustomModel(BaseModel):
|
|
|
297
305
|
if self.system_message:
|
|
298
306
|
self.messages.append({"role": "system", "content": self.system_message})
|
|
299
307
|
|
|
308
|
+
def name(self) -> str:
|
|
309
|
+
"""Return model name"""
|
|
310
|
+
return self.model_name
|
|
311
|
+
|
|
300
312
|
def delete_chat(self) -> bool:
|
|
301
313
|
"""Delete current chat session"""
|
|
302
314
|
self.reset()
|
|
303
|
-
return True
|
|
315
|
+
return True
|
|
316
|
+
|
|
317
|
+
def set_system_message(self, message: str):
|
|
318
|
+
"""Set system message"""
|
|
319
|
+
self.system_message = message
|
|
320
|
+
|
|
321
|
+
def set_suppress_output(self, suppress: bool):
|
|
322
|
+
"""Set whether to suppress output"""
|
|
323
|
+
self.suppress_output = suppress
|
|
304
324
|
```
|
|
305
325
|
|
|
306
326
|
### Development Guidelines
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
jarvis/__init__.py,sha256=b8yvcF8JU8Ok7r75ZnTd8pf8eQvluvd5CjMfxkewBAc,50
|
|
2
|
+
jarvis/agent.py,sha256=vSba-jPjCCxYqI2uje6OZK_m-VwmNTOnJSheZy1C5PA,13914
|
|
3
|
+
jarvis/main.py,sha256=gXXtnrkkvGwEswJL6qiYjVrg3bpzye-GJeAe0Nf2B9o,6509
|
|
4
|
+
jarvis/utils.py,sha256=JlkuC9RtspXH2VWDmj9nR0vnb8ie1gIsKc4vC7WRco8,7321
|
|
5
|
+
jarvis/jarvis_coder/main.py,sha256=TosDDiaYSjDpzKPNKcygxZ3XXWbcnvBmIIMn3UMBc60,35102
|
|
6
|
+
jarvis/models/__init__.py,sha256=mrOt67nselz_H1gX9wdAO4y2DY5WPXzABqJbr5Des8k,63
|
|
7
|
+
jarvis/models/ai8.py,sha256=aSiUazBrj4Fsit3tQX7jj8nM8MDBhHFnFrbQC6CvcGw,12745
|
|
8
|
+
jarvis/models/base.py,sha256=ShV1H8Unee4RMaiFO4idROQA0Hc6wu4dyeRPX5fcszk,1433
|
|
9
|
+
jarvis/models/kimi.py,sha256=1iTB0Z_WOmCML3Ufsge6jmeKOYvccr7I5lS3JUXymU4,17611
|
|
10
|
+
jarvis/models/openai.py,sha256=FcZVcCK41jP4SB_q4kZ6bga2tYbL-s6zjpS4KU30-tw,4477
|
|
11
|
+
jarvis/models/oyi.py,sha256=vVs1ru5K8WpofjwoYTxUQVvXL4Yc7ZH6nZhKYpEZcdk,15288
|
|
12
|
+
jarvis/models/registry.py,sha256=G4Woj4-GnLiKEPAZObyJN47mOQ2r0bo4xmaQdWZwHrs,7963
|
|
13
|
+
jarvis/tools/__init__.py,sha256=Kj1bKj34lwRDKMKHLOrLyQElf2lHbqA2tDgP359eaDo,71
|
|
14
|
+
jarvis/tools/base.py,sha256=EGRGbdfbLXDLwtyoWdvp9rlxNX7bzc20t0Vc2VkwIEY,652
|
|
15
|
+
jarvis/tools/coder.py,sha256=FBAk9A8P6WCVpexcTLYw-bqH3z6CkYa9c1EWooLzv5s,1992
|
|
16
|
+
jarvis/tools/file_ops.py,sha256=h8g0eT9UvlJf4kt0DLXvdSsjcPj7x19lxWdDApeDfpg,3842
|
|
17
|
+
jarvis/tools/generator.py,sha256=vVP3eN5cCDpRXf_fn0skETkPXAW1XZFWx9pt2_ahK48,5999
|
|
18
|
+
jarvis/tools/methodology.py,sha256=G3cOaHTMujGZBhDLhQEqyCV2NISizO3MXRuho1KfI6Y,5223
|
|
19
|
+
jarvis/tools/registry.py,sha256=mlOAmUq3yzRz-7yvwrrCwbe5Lmw8eh1v8-_Fa5sezwI,7209
|
|
20
|
+
jarvis/tools/search.py,sha256=1EqOVvLhg2Csh-i03-XeCrusbyfmH69FZ8khwZt8Tow,6131
|
|
21
|
+
jarvis/tools/shell.py,sha256=UPKshPyOaUwTngresUw-ot1jHjQIb4wCY5nkJqa38lU,2520
|
|
22
|
+
jarvis/tools/sub_agent.py,sha256=rEtAmSVY2ZjFOZEKr5m5wpACOQIiM9Zr_3dT92FhXYU,2621
|
|
23
|
+
jarvis/tools/webpage.py,sha256=d3w3Jcjcu1ESciezTkz3n3Zf-rp_l91PrVoDEZnckOo,2391
|
|
24
|
+
jarvis_ai_assistant-0.1.59.dist-info/LICENSE,sha256=AGgVgQmTqFvaztRtCAXsAMryUymB18gZif7_l2e1XOg,1063
|
|
25
|
+
jarvis_ai_assistant-0.1.59.dist-info/METADATA,sha256=--vje3-tzKtlivC7SlLfAPjA9MqIhkEcbFoKYXz7WFU,11213
|
|
26
|
+
jarvis_ai_assistant-0.1.59.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
27
|
+
jarvis_ai_assistant-0.1.59.dist-info/entry_points.txt,sha256=ieRI4ilnGNx1R6LlzT2P510mJ27lhLesVZToezDjSd8,89
|
|
28
|
+
jarvis_ai_assistant-0.1.59.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
|
|
29
|
+
jarvis_ai_assistant-0.1.59.dist-info/RECORD,,
|
jarvis/tools/bing_search.py
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
from playwright.sync_api import sync_playwright
|
|
2
|
-
from urllib.parse import quote
|
|
3
|
-
|
|
4
|
-
def bing_search(query):
|
|
5
|
-
try:
|
|
6
|
-
with sync_playwright() as p:
|
|
7
|
-
browser = p.chromium.launch()
|
|
8
|
-
page = browser.new_page()
|
|
9
|
-
page.goto(
|
|
10
|
-
f"https://www.bing.com/search?form=QBRE&q={quote(query)}&cc=US"
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
page.wait_for_selector("#b_results", timeout=10000)
|
|
14
|
-
|
|
15
|
-
summaries = page.evaluate("""() => {
|
|
16
|
-
const liElements = Array.from(
|
|
17
|
-
document.querySelectorAll("#b_results > .b_algo")
|
|
18
|
-
);
|
|
19
|
-
return liElements.map((li) => {
|
|
20
|
-
const abstractElement = li.querySelector(".b_caption > p");
|
|
21
|
-
const linkElement = li.querySelector("a");
|
|
22
|
-
const href = linkElement.getAttribute("href");
|
|
23
|
-
const title = linkElement.textContent;
|
|
24
|
-
const abstract = abstractElement ? abstractElement.textContent : "";
|
|
25
|
-
return { href, title, abstract };
|
|
26
|
-
});
|
|
27
|
-
}""")
|
|
28
|
-
|
|
29
|
-
browser.close()
|
|
30
|
-
print(summaries)
|
|
31
|
-
return summaries
|
|
32
|
-
except Exception as error:
|
|
33
|
-
print("An error occurred:", error)
|
|
34
|
-
|
|
35
|
-
if __name__ == "__main__":
|
|
36
|
-
# results = bing_search("北京到西雅图的距离")
|
|
37
|
-
results = bing_search("北京到西雅图的距离")
|
|
38
|
-
print(results)
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
jarvis/__init__.py,sha256=-q4D2JY6Ni6dPq7tp7WXJYH_SHjtIVacs3XNObG5bSY,50
|
|
2
|
-
jarvis/agent.py,sha256=s8VebNef8BbKM6D9IDWWN-XenEXEL9KoYnDLGKyZY58,12347
|
|
3
|
-
jarvis/main.py,sha256=gXXtnrkkvGwEswJL6qiYjVrg3bpzye-GJeAe0Nf2B9o,6509
|
|
4
|
-
jarvis/utils.py,sha256=JlkuC9RtspXH2VWDmj9nR0vnb8ie1gIsKc4vC7WRco8,7321
|
|
5
|
-
jarvis/jarvis_coder/main.py,sha256=eKo7ipNb3eSRuUMwMZclTozz6LUtU95t2B-w_LGkexs,30155
|
|
6
|
-
jarvis/models/__init__.py,sha256=mrOt67nselz_H1gX9wdAO4y2DY5WPXzABqJbr5Des8k,63
|
|
7
|
-
jarvis/models/ai8.py,sha256=6Nu4AJ_YtzVcVJirOrzbRI1WF0WpGBzWuDvu_C5oP0s,12624
|
|
8
|
-
jarvis/models/base.py,sha256=eeNJJbv9ikPVTtV_E7mgW8LZzVgjQ-OzxlHF6slYrHw,1237
|
|
9
|
-
jarvis/models/kimi.py,sha256=N0bPQ1ugx0RwjR96jLchmOPvCmws-fXyA0mnOAdo2k4,17161
|
|
10
|
-
jarvis/models/openai.py,sha256=yJ8e4js365uh-pdka-q8tD6iUoSdP-n4kdxUfaHIQ28,4262
|
|
11
|
-
jarvis/models/oyi.py,sha256=VwPW4UawGrMrDOCIbSs9ieNlE6N0pBtgiroyg9JCJ48,15004
|
|
12
|
-
jarvis/models/registry.py,sha256=iVBjN9ImEvGHcz8WR-z8pPMJQZI907o_nccVOFANhak,7951
|
|
13
|
-
jarvis/tools/__init__.py,sha256=Kj1bKj34lwRDKMKHLOrLyQElf2lHbqA2tDgP359eaDo,71
|
|
14
|
-
jarvis/tools/base.py,sha256=EGRGbdfbLXDLwtyoWdvp9rlxNX7bzc20t0Vc2VkwIEY,652
|
|
15
|
-
jarvis/tools/bing_search.py,sha256=SvYeXM83eP9qREDcWguh0_r0m0npbcwXIyzEwwfreKU,1444
|
|
16
|
-
jarvis/tools/file_ops.py,sha256=h8g0eT9UvlJf4kt0DLXvdSsjcPj7x19lxWdDApeDfpg,3842
|
|
17
|
-
jarvis/tools/generator.py,sha256=vVP3eN5cCDpRXf_fn0skETkPXAW1XZFWx9pt2_ahK48,5999
|
|
18
|
-
jarvis/tools/methodology.py,sha256=G3cOaHTMujGZBhDLhQEqyCV2NISizO3MXRuho1KfI6Y,5223
|
|
19
|
-
jarvis/tools/registry.py,sha256=mlOAmUq3yzRz-7yvwrrCwbe5Lmw8eh1v8-_Fa5sezwI,7209
|
|
20
|
-
jarvis/tools/search.py,sha256=o7EJqEtKKDqlENkXhxDuDA73djzeEH9j4BB0n61egso,4899
|
|
21
|
-
jarvis/tools/shell.py,sha256=UPKshPyOaUwTngresUw-ot1jHjQIb4wCY5nkJqa38lU,2520
|
|
22
|
-
jarvis/tools/sub_agent.py,sha256=rEtAmSVY2ZjFOZEKr5m5wpACOQIiM9Zr_3dT92FhXYU,2621
|
|
23
|
-
jarvis/tools/webpage.py,sha256=d3w3Jcjcu1ESciezTkz3n3Zf-rp_l91PrVoDEZnckOo,2391
|
|
24
|
-
jarvis_ai_assistant-0.1.57.dist-info/LICENSE,sha256=AGgVgQmTqFvaztRtCAXsAMryUymB18gZif7_l2e1XOg,1063
|
|
25
|
-
jarvis_ai_assistant-0.1.57.dist-info/METADATA,sha256=fL_tBGFyE-SBJaY2E2iSpl_LA_nldw2SHtZh054y6Xg,10049
|
|
26
|
-
jarvis_ai_assistant-0.1.57.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
27
|
-
jarvis_ai_assistant-0.1.57.dist-info/entry_points.txt,sha256=ieRI4ilnGNx1R6LlzT2P510mJ27lhLesVZToezDjSd8,89
|
|
28
|
-
jarvis_ai_assistant-0.1.57.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
|
|
29
|
-
jarvis_ai_assistant-0.1.57.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{jarvis_ai_assistant-0.1.57.dist-info → jarvis_ai_assistant-0.1.59.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|