jarvis-ai-assistant 0.1.134__py3-none-any.whl → 0.1.138__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/jarvis_agent/__init__.py +201 -79
- jarvis/jarvis_agent/builtin_input_handler.py +16 -6
- jarvis/jarvis_agent/file_input_handler.py +9 -9
- jarvis/jarvis_agent/jarvis.py +10 -10
- jarvis/jarvis_agent/main.py +12 -11
- jarvis/jarvis_agent/output_handler.py +3 -3
- jarvis/jarvis_agent/patch.py +86 -62
- jarvis/jarvis_agent/shell_input_handler.py +5 -3
- jarvis/jarvis_code_agent/code_agent.py +134 -99
- jarvis/jarvis_code_agent/file_select.py +24 -24
- jarvis/jarvis_dev/main.py +45 -51
- jarvis/jarvis_git_details/__init__.py +0 -0
- jarvis/jarvis_git_details/main.py +179 -0
- jarvis/jarvis_git_squash/main.py +7 -7
- jarvis/jarvis_lsp/base.py +11 -11
- jarvis/jarvis_lsp/cpp.py +14 -14
- jarvis/jarvis_lsp/go.py +13 -13
- jarvis/jarvis_lsp/python.py +8 -8
- jarvis/jarvis_lsp/registry.py +21 -21
- jarvis/jarvis_lsp/rust.py +15 -15
- jarvis/jarvis_methodology/main.py +101 -0
- jarvis/jarvis_multi_agent/__init__.py +11 -11
- jarvis/jarvis_multi_agent/main.py +6 -6
- jarvis/jarvis_platform/__init__.py +1 -1
- jarvis/jarvis_platform/ai8.py +67 -89
- jarvis/jarvis_platform/base.py +14 -13
- jarvis/jarvis_platform/kimi.py +25 -28
- jarvis/jarvis_platform/ollama.py +24 -26
- jarvis/jarvis_platform/openai.py +15 -19
- jarvis/jarvis_platform/oyi.py +48 -50
- jarvis/jarvis_platform/registry.py +27 -28
- jarvis/jarvis_platform/yuanbao.py +38 -42
- jarvis/jarvis_platform_manager/main.py +81 -81
- jarvis/jarvis_platform_manager/openai_test.py +21 -21
- jarvis/jarvis_rag/file_processors.py +18 -18
- jarvis/jarvis_rag/main.py +261 -277
- jarvis/jarvis_smart_shell/main.py +12 -12
- jarvis/jarvis_tools/ask_codebase.py +28 -28
- jarvis/jarvis_tools/ask_user.py +8 -8
- jarvis/jarvis_tools/base.py +4 -4
- jarvis/jarvis_tools/chdir.py +9 -9
- jarvis/jarvis_tools/code_review.py +19 -19
- jarvis/jarvis_tools/create_code_agent.py +15 -15
- jarvis/jarvis_tools/execute_python_script.py +3 -3
- jarvis/jarvis_tools/execute_shell.py +11 -11
- jarvis/jarvis_tools/execute_shell_script.py +3 -3
- jarvis/jarvis_tools/file_analyzer.py +29 -29
- jarvis/jarvis_tools/file_operation.py +22 -20
- jarvis/jarvis_tools/find_caller.py +25 -25
- jarvis/jarvis_tools/find_methodolopy.py +65 -0
- jarvis/jarvis_tools/find_symbol.py +24 -24
- jarvis/jarvis_tools/function_analyzer.py +27 -27
- jarvis/jarvis_tools/git_commiter.py +9 -9
- jarvis/jarvis_tools/lsp_get_diagnostics.py +19 -19
- jarvis/jarvis_tools/methodology.py +23 -62
- jarvis/jarvis_tools/project_analyzer.py +29 -33
- jarvis/jarvis_tools/rag.py +15 -15
- jarvis/jarvis_tools/read_code.py +24 -22
- jarvis/jarvis_tools/read_webpage.py +31 -31
- jarvis/jarvis_tools/registry.py +72 -52
- jarvis/jarvis_tools/tool_generator.py +18 -18
- jarvis/jarvis_utils/config.py +23 -23
- jarvis/jarvis_utils/embedding.py +83 -83
- jarvis/jarvis_utils/git_utils.py +20 -20
- jarvis/jarvis_utils/globals.py +18 -6
- jarvis/jarvis_utils/input.py +10 -9
- jarvis/jarvis_utils/methodology.py +140 -136
- jarvis/jarvis_utils/output.py +11 -11
- jarvis/jarvis_utils/utils.py +22 -70
- {jarvis_ai_assistant-0.1.134.dist-info → jarvis_ai_assistant-0.1.138.dist-info}/METADATA +1 -1
- jarvis_ai_assistant-0.1.138.dist-info/RECORD +85 -0
- {jarvis_ai_assistant-0.1.134.dist-info → jarvis_ai_assistant-0.1.138.dist-info}/entry_points.txt +2 -0
- jarvis/jarvis_tools/select_code_files.py +0 -62
- jarvis_ai_assistant-0.1.134.dist-info/RECORD +0 -82
- {jarvis_ai_assistant-0.1.134.dist-info → jarvis_ai_assistant-0.1.138.dist-info}/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.134.dist-info → jarvis_ai_assistant-0.1.138.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.134.dist-info → jarvis_ai_assistant-0.1.138.dist-info}/top_level.txt +0 -0
|
@@ -14,7 +14,7 @@ class YuanbaoPlatform(BasePlatform):
|
|
|
14
14
|
def get_model_list(self) -> List[Tuple[str, str]]:
|
|
15
15
|
"""获取支持的模型列表"""
|
|
16
16
|
return [("deep_seek", "DeepSeek-R1"), ("deep_seek_v3", "DeepSeek-v3"), ("hunyuan_gpt_175B_0404", "Tencent Hunyuan"), ("hunyuan_t1", "Tencent Hunyuan-T1")]
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
def __init__(self):
|
|
19
19
|
"""
|
|
20
20
|
初始化Hunyuan模型
|
|
@@ -25,13 +25,13 @@ class YuanbaoPlatform(BasePlatform):
|
|
|
25
25
|
self.cookies = os.getenv("YUANBAO_COOKIES") # 认证cookies
|
|
26
26
|
self.agent_id = os.getenv("YUANBAO_AGENT_ID") # 代理ID
|
|
27
27
|
self.web = os.getenv("YUANBAO_WEB", "false") == "true" # 是否启用网页功能
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
if not self.cookies:
|
|
30
30
|
message = (
|
|
31
31
|
"需要设置 YUANBAO_COOKIES 和 YUANBAO_AGENT_ID 才能使用 Jarvis 的元宝功能。请按照以下步骤操作:\n"
|
|
32
32
|
"1. 获取元宝 API 参数:\n"
|
|
33
33
|
" • 访问元宝平台: https://yuanbao.tencent.com\n"
|
|
34
|
-
" • 登录您的账户\n"
|
|
34
|
+
" • 登录您的账户\n"
|
|
35
35
|
" • 打开浏览器开发者工具 (F12 或右键 -> 检查)\n"
|
|
36
36
|
" • 切换到网络标签\n"
|
|
37
37
|
" • 发送任意消息\n"
|
|
@@ -47,7 +47,7 @@ class YuanbaoPlatform(BasePlatform):
|
|
|
47
47
|
)
|
|
48
48
|
PrettyOutput.print(message, OutputType.INFO)
|
|
49
49
|
PrettyOutput.print("YUANBAO_COOKIES 未设置", OutputType.WARNING)
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
self.system_message = "" # 系统消息,用于初始化对话
|
|
52
52
|
self.first_chat = True # 标识是否为第一次对话
|
|
53
53
|
self.model_name = "deep_seek_v3" # 默认模型名称,使用下划线保持一致
|
|
@@ -59,18 +59,17 @@ class YuanbaoPlatform(BasePlatform):
|
|
|
59
59
|
def set_model_name(self, model_name: str):
|
|
60
60
|
# 模型映射表,可以根据需要扩展
|
|
61
61
|
model_mapping = [m[0] for m in self.get_model_list()]
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
if model_name in model_mapping:
|
|
64
64
|
self.model_name = model_name
|
|
65
65
|
else:
|
|
66
66
|
PrettyOutput.print(f"错误:不支持的模型: {model_name}", OutputType.ERROR)
|
|
67
|
-
self.reset()
|
|
68
67
|
|
|
69
68
|
def _get_base_headers(self):
|
|
70
69
|
"""Get base headers for API requests"""
|
|
71
70
|
return {
|
|
72
71
|
'Host': 'yuanbao.tencent.com',
|
|
73
|
-
'X-Language': 'zh-CN',
|
|
72
|
+
'X-Language': 'zh-CN',
|
|
74
73
|
'X-Requested-With': 'XMLHttpRequest',
|
|
75
74
|
'chat_version': 'v1',
|
|
76
75
|
'X-Instance-ID': '5',
|
|
@@ -94,17 +93,17 @@ class YuanbaoPlatform(BasePlatform):
|
|
|
94
93
|
def _create_conversation(self) -> bool:
|
|
95
94
|
"""Create a new conversation session"""
|
|
96
95
|
url = "https://yuanbao.tencent.com/api/user/agent/conversation/create"
|
|
97
|
-
|
|
96
|
+
|
|
98
97
|
headers = self._get_base_headers()
|
|
99
|
-
|
|
98
|
+
|
|
100
99
|
payload = json.dumps({
|
|
101
100
|
"agentId": self.agent_id
|
|
102
101
|
})
|
|
103
|
-
|
|
102
|
+
|
|
104
103
|
try:
|
|
105
104
|
response = while_success(lambda: requests.post(url, headers=headers, data=payload), sleep_time=5)
|
|
106
105
|
response_json = response.json()
|
|
107
|
-
|
|
106
|
+
|
|
108
107
|
if "id" in response_json:
|
|
109
108
|
self.conversation_id = response_json["id"]
|
|
110
109
|
return True
|
|
@@ -120,11 +119,11 @@ class YuanbaoPlatform(BasePlatform):
|
|
|
120
119
|
if not self.conversation_id:
|
|
121
120
|
if not self._create_conversation():
|
|
122
121
|
raise Exception("Failed to create conversation session")
|
|
123
|
-
|
|
122
|
+
|
|
124
123
|
url = f"https://yuanbao.tencent.com/api/chat/{self.conversation_id}"
|
|
125
|
-
|
|
124
|
+
|
|
126
125
|
headers = self._get_base_headers()
|
|
127
|
-
|
|
126
|
+
|
|
128
127
|
# 准备消息内容
|
|
129
128
|
payload = {
|
|
130
129
|
"model": "gpt_175B_0404",
|
|
@@ -149,44 +148,44 @@ class YuanbaoPlatform(BasePlatform):
|
|
|
149
148
|
|
|
150
149
|
if self.web:
|
|
151
150
|
payload["supportFunctions"] = ["supportInternetSearch"]
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
|
|
152
|
+
|
|
154
153
|
# 添加系统消息(如果是第一次对话)
|
|
155
154
|
if self.first_chat and self.system_message:
|
|
156
155
|
payload["prompt"] = f"{self.system_message}\n\n{message}"
|
|
157
156
|
payload["displayPrompt"] = payload["prompt"]
|
|
158
157
|
self.first_chat = False
|
|
159
|
-
|
|
160
|
-
try:
|
|
158
|
+
|
|
159
|
+
try:
|
|
161
160
|
# 发送消息请求,获取流式响应
|
|
162
161
|
response = while_success(
|
|
163
162
|
lambda: requests.post(url, headers=headers, json=payload, stream=True),
|
|
164
163
|
sleep_time=5
|
|
165
164
|
)
|
|
166
|
-
|
|
165
|
+
|
|
167
166
|
# 检查响应状态
|
|
168
167
|
if response.status_code != 200:
|
|
169
168
|
error_msg = f"发送消息失败,状态码: {response.status_code}"
|
|
170
169
|
if hasattr(response, 'text'):
|
|
171
170
|
error_msg += f", 响应: {response.text}"
|
|
172
171
|
raise Exception(error_msg)
|
|
173
|
-
|
|
172
|
+
|
|
174
173
|
full_response = ""
|
|
175
174
|
is_text_block = False
|
|
176
|
-
|
|
175
|
+
|
|
177
176
|
# 处理SSE流响应
|
|
178
177
|
for line in response.iter_lines():
|
|
179
178
|
if not line:
|
|
180
179
|
continue
|
|
181
|
-
|
|
180
|
+
|
|
182
181
|
line_str = line.decode('utf-8')
|
|
183
|
-
|
|
182
|
+
|
|
184
183
|
# SSE格式的行通常以"data: "开头
|
|
185
184
|
if line_str.startswith("data: "):
|
|
186
185
|
try:
|
|
187
186
|
data_str = line_str[6:] # 移除"data: "前缀
|
|
188
187
|
data = json.loads(data_str)
|
|
189
|
-
|
|
188
|
+
|
|
190
189
|
# 处理文本类型的消息
|
|
191
190
|
if data.get("type") == "text":
|
|
192
191
|
is_text_block = True
|
|
@@ -195,60 +194,57 @@ class YuanbaoPlatform(BasePlatform):
|
|
|
195
194
|
if not self.suppress_output:
|
|
196
195
|
PrettyOutput.print_stream(msg)
|
|
197
196
|
full_response += msg
|
|
198
|
-
|
|
197
|
+
|
|
199
198
|
# 处理思考中的消息(可选展示)
|
|
200
199
|
elif data.get("type") == "think" and not self.suppress_output:
|
|
201
200
|
think_content = data.get("content", "")
|
|
202
201
|
# 可以选择性地显示思考过程,但不加入最终响应
|
|
203
202
|
PrettyOutput.print_stream(f"{think_content}", is_thinking=True)
|
|
204
203
|
pass
|
|
205
|
-
|
|
204
|
+
|
|
206
205
|
except json.JSONDecodeError:
|
|
207
206
|
pass
|
|
208
|
-
|
|
207
|
+
|
|
209
208
|
# 检测结束标志
|
|
210
209
|
elif line_str == "data: [DONE]":
|
|
211
210
|
break
|
|
212
|
-
|
|
211
|
+
|
|
213
212
|
if not self.suppress_output:
|
|
214
213
|
PrettyOutput.print_stream_end()
|
|
215
|
-
|
|
214
|
+
|
|
216
215
|
return full_response
|
|
217
|
-
|
|
216
|
+
|
|
218
217
|
except Exception as e:
|
|
219
218
|
raise Exception(f"对话失败: {str(e)}")
|
|
220
219
|
|
|
221
|
-
def reset(self):
|
|
222
|
-
"""Reset chat"""
|
|
223
|
-
self.conversation_id = ""
|
|
224
|
-
self.first_chat = True
|
|
225
220
|
|
|
226
221
|
def delete_chat(self) -> bool:
|
|
227
222
|
"""Delete current session"""
|
|
228
223
|
if not self.conversation_id:
|
|
229
224
|
return True # 如果没有会话ID,视为删除成功
|
|
230
|
-
|
|
225
|
+
|
|
231
226
|
# Hunyuan使用专门的clear API来清除会话
|
|
232
227
|
url = "https://yuanbao.tencent.com/api/user/agent/conversation/v1/clear"
|
|
233
|
-
|
|
228
|
+
|
|
234
229
|
# 为这个请求获取基础头部
|
|
235
230
|
headers = self._get_base_headers()
|
|
236
|
-
|
|
231
|
+
|
|
237
232
|
# 更新X-AgentID头部,需要包含会话ID
|
|
238
233
|
headers.update({
|
|
239
234
|
'X-AgentID': f"{self.agent_id}/{self.conversation_id}"
|
|
240
235
|
})
|
|
241
|
-
|
|
236
|
+
|
|
242
237
|
# 创建请求体,包含要删除的会话ID
|
|
243
238
|
payload = {
|
|
244
239
|
"conversationIds": [self.conversation_id]
|
|
245
240
|
}
|
|
246
|
-
|
|
241
|
+
|
|
247
242
|
try:
|
|
248
243
|
response = while_success(lambda: requests.post(url, headers=headers, json=payload), sleep_time=5)
|
|
249
|
-
|
|
244
|
+
|
|
250
245
|
if response.status_code == 200:
|
|
251
|
-
self.
|
|
246
|
+
self.conversation_id = ""
|
|
247
|
+
self.first_chat = True
|
|
252
248
|
return True
|
|
253
249
|
else:
|
|
254
250
|
PrettyOutput.print(f"删除会话失败: HTTP {response.status_code}", OutputType.WARNING)
|
|
@@ -261,4 +257,4 @@ class YuanbaoPlatform(BasePlatform):
|
|
|
261
257
|
|
|
262
258
|
def name(self) -> str:
|
|
263
259
|
"""Model name"""
|
|
264
|
-
return
|
|
260
|
+
return self.model_name
|