jarvis-ai-assistant 0.1.132__py3-none-any.whl → 0.1.134__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.

Files changed (44) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/jarvis_agent/__init__.py +140 -279
  3. jarvis/jarvis_agent/jarvis.py +143 -0
  4. jarvis/jarvis_agent/main.py +0 -2
  5. jarvis/jarvis_agent/patch.py +16 -12
  6. jarvis/jarvis_code_agent/code_agent.py +155 -104
  7. jarvis/jarvis_dev/main.py +0 -8
  8. jarvis/jarvis_lsp/base.py +0 -42
  9. jarvis/jarvis_lsp/cpp.py +0 -15
  10. jarvis/jarvis_lsp/go.py +0 -15
  11. jarvis/jarvis_lsp/python.py +0 -19
  12. jarvis/jarvis_lsp/registry.py +0 -62
  13. jarvis/jarvis_lsp/rust.py +0 -15
  14. jarvis/jarvis_multi_agent/__init__.py +0 -41
  15. jarvis/jarvis_multi_agent/main.py +43 -0
  16. jarvis/jarvis_platform/registry.py +2 -16
  17. jarvis/jarvis_platform/yuanbao.py +1 -1
  18. jarvis/jarvis_rag/main.py +1 -1
  19. jarvis/jarvis_tools/ask_codebase.py +61 -54
  20. jarvis/jarvis_tools/code_review.py +21 -2
  21. jarvis/jarvis_tools/create_sub_agent.py +0 -1
  22. jarvis/jarvis_tools/file_analyzer.py +84 -73
  23. jarvis/jarvis_tools/find_caller.py +83 -18
  24. jarvis/jarvis_tools/find_symbol.py +102 -18
  25. jarvis/jarvis_tools/function_analyzer.py +115 -32
  26. jarvis/jarvis_tools/git_commiter.py +1 -1
  27. jarvis/jarvis_tools/methodology.py +0 -6
  28. jarvis/jarvis_tools/project_analyzer.py +116 -28
  29. jarvis/jarvis_tools/rag.py +0 -5
  30. jarvis/jarvis_tools/read_code.py +1 -1
  31. jarvis/jarvis_tools/search_web.py +23 -353
  32. jarvis/jarvis_tools/tool_generator.py +2 -2
  33. jarvis/jarvis_utils/config.py +13 -73
  34. jarvis/jarvis_utils/methodology.py +8 -11
  35. jarvis/jarvis_utils/output.py +2 -2
  36. jarvis/jarvis_utils/utils.py +1 -1
  37. {jarvis_ai_assistant-0.1.132.dist-info → jarvis_ai_assistant-0.1.134.dist-info}/METADATA +6 -15
  38. {jarvis_ai_assistant-0.1.132.dist-info → jarvis_ai_assistant-0.1.134.dist-info}/RECORD +42 -42
  39. {jarvis_ai_assistant-0.1.132.dist-info → jarvis_ai_assistant-0.1.134.dist-info}/entry_points.txt +2 -3
  40. jarvis/jarvis_tools/lsp_find_definition.py +0 -150
  41. jarvis/jarvis_tools/lsp_find_references.py +0 -127
  42. {jarvis_ai_assistant-0.1.132.dist-info → jarvis_ai_assistant-0.1.134.dist-info}/LICENSE +0 -0
  43. {jarvis_ai_assistant-0.1.132.dist-info → jarvis_ai_assistant-0.1.134.dist-info}/WHEEL +0 -0
  44. {jarvis_ai_assistant-0.1.132.dist-info → jarvis_ai_assistant-0.1.134.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,6 @@
1
1
  from typing import Dict, Any
2
2
  import os
3
3
  from jarvis.jarvis_rag.main import RAGTool as RAGCore
4
- from jarvis.jarvis_utils.config import dont_use_local_model
5
4
  from jarvis.jarvis_utils.output import OutputType, PrettyOutput
6
5
 
7
6
  class RAGTool:
@@ -27,10 +26,6 @@ class RAGTool:
27
26
  "required": ["dir", "question"]
28
27
  }
29
28
 
30
- @staticmethod
31
- def check() -> bool:
32
- return not dont_use_local_model()
33
-
34
29
  def __init__(self):
35
30
  """Initialize RAG tool"""
36
31
  self.rag_instances = {} # Cache RAG instances for different directories
@@ -90,7 +90,7 @@ class ReadCodeTool:
90
90
  # 构建输出格式
91
91
  output = (
92
92
  f"\n🔍 文件: {abs_path}\n"
93
- f"📄 原始行号: {start_line}-{end_line} (共{end_line - start_line + 1}行) | 显示行号: 1-{len(selected_lines)}\n\n"
93
+ f"📄 原始行号: {start_line}-{end_line} (共{total_lines}行) \n\n"
94
94
  f"{numbered_content}\n"
95
95
  f"{'='*80}\n"
96
96
  )
@@ -1,364 +1,34 @@
1
- from typing import Dict, Any, List
2
- import concurrent.futures
3
- from regex import W
4
- from yaspin import yaspin
5
- from jarvis.jarvis_platform.registry import PlatformRegistry
6
- from jarvis.jarvis_tools.read_webpage import WebpageTool
7
- from playwright.sync_api import sync_playwright
8
- from urllib.parse import quote
9
1
 
10
- from jarvis.jarvis_utils.config import get_max_token_count, get_thread_count
11
- from jarvis.jarvis_utils.embedding import get_context_token_count
12
- from jarvis.jarvis_utils.output import OutputType, PrettyOutput
13
2
 
14
- def bing_search(query):
15
- try:
16
- with sync_playwright() as p:
17
- # Set parameters when starting the browser
18
- with yaspin(text="正在启动浏览器...", color="cyan") as spinner:
19
- browser = p.chromium.launch(
20
- headless=True, # Headless mode
21
- args=['--disable-gpu', '--no-sandbox', '--disable-dev-shm-usage']
22
- )
23
- spinner.text = "浏览器启动完成"
24
- spinner.ok("✅")
25
-
26
- # Create a new page and set timeout
27
- with yaspin(text="正在创建新页面...", color="cyan") as spinner:
28
- page = browser.new_page(
29
- user_agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
30
- viewport={'width': 1920, 'height': 1080}
31
- )
32
- spinner.text = "新页面创建完成"
33
- spinner.ok("✅")
34
-
35
- # Set page timeout
36
- with yaspin(text="正在设置页面超时...", color="cyan") as spinner:
37
- page.set_default_timeout(60000)
38
- spinner.text = "页面超时设置完成"
39
- spinner.ok("✅")
40
-
41
- # Visit search page
42
- with yaspin(text=f"正在搜索 {query}...", color="cyan") as spinner:
43
- url = f"https://www.bing.com/search?q={quote(query)}&form=QBLH&sp=-1"
44
- page.goto(url, wait_until="networkidle")
45
- spinner.text = "搜索完成"
46
- spinner.ok("✅")
47
-
48
- # Wait for search results to load
49
- with yaspin(text="正在等待搜索结果加载...", color="cyan") as spinner:
50
- page.wait_for_selector("#b_results", state="visible", timeout=30000)
51
- # Wait for a moment to ensure the results are fully loaded
52
- page.wait_for_timeout(1000)
53
- spinner.text = "搜索结果加载完成"
54
- spinner.ok("✅")
55
-
56
- # Extract search results
57
- with yaspin(text="正在提取搜索结果...", color="cyan") as spinner:
58
- summaries = page.evaluate("""() => {
59
- const results = [];
60
- const elements = document.querySelectorAll("#b_results > .b_algo");
61
-
62
- for (const el of elements) {
63
- const titleEl = el.querySelector("h2");
64
- const linkEl = titleEl ? titleEl.querySelector("a") : null;
65
- const abstractEl = el.querySelector(".b_caption p");
66
-
67
- if (linkEl) {
68
- results.push({
69
- title: titleEl.innerText.trim(),
70
- href: linkEl.href,
71
- abstract: abstractEl ? abstractEl.innerText.trim() : ""
72
- });
73
- }
74
- }
75
- return results;
76
- }""")
77
- spinner.text = "搜索结果提取完成"
78
- spinner.ok("✅")
79
3
 
80
- with yaspin(text="正在关闭浏览器...", color="cyan") as spinner:
81
- browser.close()
82
- spinner.text = "浏览器关闭完成"
83
- spinner.ok("✅")
84
- return summaries
85
-
86
- except Exception as error:
87
- PrettyOutput.print(f"搜索错误:{str(error)}", OutputType.ERROR)
88
- return None
4
+ import os
5
+ import statistics
6
+ from typing import Any, Dict
7
+ from jarvis.jarvis_platform.registry import PlatformRegistry
8
+
89
9
 
90
- class SearchTool:
10
+ class SearchWebTool:
91
11
  name = "search_web"
92
- description = "使用Bing搜索引擎搜索信息,并根据问题提取关键信息"
12
+ description = "搜索互联网上的信息"
93
13
  parameters = {
94
14
  "type": "object",
95
15
  "properties": {
96
- "query": {
97
- "type": "string",
98
- "description": "搜索关键词"
99
- },
100
- "question": {
101
- "type": "string",
102
- "description": "要回答的具体问题,用于从搜索结果中提取相关信息"
103
- },
104
- "max_results": {
105
- "type": "integer",
106
- "description": "最大搜索结果数量",
107
- "default": 10
108
- }
109
- },
110
- "required": ["query", "question"]
16
+ "query": {"type": "string", "description": "具体的问题"}
17
+ }
111
18
  }
112
19
 
113
- def __init__(self):
114
- """Initialize the search tool, need to pass in the language model for information extraction"""
115
- self.model = PlatformRegistry.get_global_platform_registry().get_normal_platform()
116
- self.webpage_tool = WebpageTool()
117
-
118
- def _search(self, query: str, max_results: int) -> List[Dict]:
119
- """Execute search request"""
120
- try:
121
- results = bing_search(query)
122
- if not results:
123
- return []
124
-
125
- # Format search results
126
- formatted_results = []
127
- for result in results[:max_results]:
128
- formatted_results.append({
129
- "title": result.get("title", ""),
130
- "href": result.get("href", ""),
131
- "body": result.get("abstract", "")
132
- })
133
- return formatted_results
134
- except Exception as e:
135
- PrettyOutput.print(f"搜索请求失败:{str(e)}", OutputType.ERROR)
136
- return []
137
-
138
- def _extract_info(self, contents: List[str], question: str) -> str:
139
- """Use language model to extract key information from web content"""
140
- try:
141
- # Reserve tokens for prompt and response
142
- max_tokens = get_max_token_count()
143
- reserved_tokens = 2000 # Reserve tokens for prompt template and response
144
- available_tokens = max_tokens - reserved_tokens
145
-
146
- # Split contents into batches
147
- batches = []
148
- current_batch = []
149
- current_tokens = 0
150
-
151
- for content in contents:
152
- content_tokens = get_context_token_count(content)
153
-
154
- # If adding this content would exceed limit, start new batch
155
- if current_tokens + content_tokens > available_tokens:
156
- if current_batch:
157
- batches.append(current_batch)
158
- current_batch = [content]
159
- current_tokens = content_tokens
160
- else:
161
- current_batch.append(content)
162
- current_tokens += content_tokens
163
-
164
- # Add final batch
165
- if current_batch:
166
- batches.append(current_batch)
167
-
168
- # Process each batch
169
- batch_results = []
170
- for i, batch in enumerate(batches, 1):
171
- prompt = f"""请根据以下搜索结果回答以下问题:{question}
172
-
173
- 搜索结果内容 (第 {i} 批/{len(batches)}):
174
- {'-' * 40}
175
- {''.join(batch)}
176
- {'-' * 40}
177
-
178
- 请提取与问题相关的关键信息。重点关注:
179
- 1. 相关事实和细节
180
- 2. 保持客观性
181
- 3. 在适当的时候引用来源
182
- 4. 注明任何不确定性
183
-
184
- 请将您的回答格式化为对本批次搜索结果的清晰总结。"""
185
-
186
- response = self.model.chat_until_success(prompt)
187
- batch_results.append(response)
188
-
189
- # If only one batch, return its result directly
190
- if len(batch_results) == 1:
191
- return batch_results[0]
192
-
193
- # Synthesize results from all batches
194
- batch_findings = '\n\n'.join(f'Batch {i+1}:\n{result}' for i, result in enumerate(batch_results))
195
- separator = '-' * 40
196
-
197
- synthesis_prompt = f"""请通过综合多个批次的搜索结果,为原始问题提供一个全面的回答。
198
-
199
- 原始问题: {question}
200
-
201
- 各批次的发现:
202
- {separator}
203
- {batch_findings}
204
- {separator}
205
-
206
- 请综合出一个最终答案,要求:
207
- 1. 整合所有批次的关键见解
208
- 2. 解决不同来源之间的矛盾
209
- 3. 保持清晰的来源归属
210
- 4. 承认任何剩余的不确定性
211
- 5. 提供对原始问题的连贯完整的回答"""
212
-
213
- final_response = self.model.chat_until_success(synthesis_prompt)
214
- return final_response
215
-
216
- except Exception as e:
217
- return f"信息提取失败:{str(e)}"
218
-
219
- def execute(self, args: Dict) -> Dict[str, Any]:
220
- """Execute search and extract information"""
221
- try:
222
- query = args["query"]
223
- question = args["question"]
224
- max_results = args.get("max_results", 3)
225
-
226
- # Print search information
227
- PrettyOutput.print(f"搜索关键词: {query}", OutputType.INFO)
228
- PrettyOutput.print(f"相关问题: {question}", OutputType.INFO)
229
-
230
- # Get search results
231
- results = self._search(query, max_results)
232
- if not results:
233
- return {
234
- "success": False,
235
- "stdout": "",
236
- "stderr": "No search results found"
237
- }
238
-
239
- # Read webpages in parallel using ThreadPoolExecutor
240
- contents = []
241
-
242
- # Print starting message
243
- PrettyOutput.print(f"开始并行读取 {len(results)} 个网页结果...", OutputType.INFO)
244
-
245
- def fetch_webpage(result_info):
246
- """Function to fetch a single webpage in a separate thread"""
247
- idx, result = result_info
248
- try:
249
- # Removed progress print here to avoid mixed output
250
- webpage_result = self.webpage_tool.execute({"url": result["href"]})
251
- if webpage_result["success"]:
252
- return idx, result, webpage_result["stdout"], True
253
- return idx, result, None, False
254
- except Exception as e:
255
- return idx, result, str(e), False
256
-
257
- # Use ThreadPoolExecutor for parallel processing
258
- processed_results = []
259
- with yaspin(text="正在并行读取网页内容...", color="cyan") as spinner:
260
- with concurrent.futures.ThreadPoolExecutor(max_workers=get_thread_count()) as executor:
261
- # Submit all webpage fetch tasks
262
- future_to_result = {
263
- executor.submit(fetch_webpage, (i, result)): i
264
- for i, result in enumerate(results)
265
- }
266
-
267
- # Collect results as they complete
268
- for future in concurrent.futures.as_completed(future_to_result):
269
- processed_results.append(future.result())
270
- # Update spinner with current progress
271
- spinner.text = f"正在并行读取网页内容... ({len(processed_results)}/{len(results)})"
272
-
273
- spinner.text = "网页内容读取完成"
274
- spinner.ok("✅")
275
-
276
- # Sort results by original index to maintain ordering
277
- processed_results.sort(key=lambda x: x[0])
278
-
279
- # Print results in order and add to contents
280
- PrettyOutput.section("搜索结果概览", OutputType.INFO)
281
-
282
- output = []
283
- for idx, result, content, success in processed_results:
284
- if success:
285
- output.append(f"✅ 读取结果 {idx+1}/{len(results)} 完成: {result['title']} - {result['href']}")
286
- contents.append(f"\nSource {idx+1}: {result['href']}\n")
287
- contents.append(content)
288
- else:
289
- output.append(f"❌ 读取结果 {idx+1}/{len(results)} 失败: {result['title']} - {result['href']}")
290
-
291
- PrettyOutput.print("\n".join(output), OutputType.INFO)
292
-
293
- if not contents:
294
- return {
295
- "success": False,
296
- "stdout": "",
297
- "stderr": "No valid search results found"
298
- }
299
-
300
- # Extract information
301
- with yaspin(text="正在提取信息...", color="cyan") as spinner:
302
- analysis = self._extract_info(contents, question)
303
- spinner.text = "信息提取完成"
304
- spinner.ok("✅")
305
-
306
- output = f"分析结果:\n\n{analysis}"
307
- PrettyOutput.print(output, OutputType.SUCCESS)
308
-
309
- return {
310
- "success": True,
311
- "stdout": output,
312
- "stderr": ""
313
- }
314
-
315
- except Exception as e:
316
- return {
317
- "success": False,
318
- "stdout": "",
319
- "stderr": f"Search failed: {str(e)}"
320
- }
321
-
322
- def main():
323
- """Command line directly run search tool"""
324
- import argparse
325
- import sys
326
-
327
- parser = argparse.ArgumentParser(description='Bing search tool')
328
- parser.add_argument('query', help='Search keywords')
329
- parser.add_argument('--max', type=int, default=5, help='Maximum number of results (default 5)')
330
- parser.add_argument('--url-only', action='store_true', help='Only display URL')
331
- args = parser.parse_args()
332
-
333
- try:
334
- PrettyOutput.print(f"搜索: {args.query}", OutputType.INFO)
335
-
336
- results = bing_search(args.query)
337
-
338
- if not results:
339
- PrettyOutput.print("未找到搜索结果", OutputType.WARNING)
340
- sys.exit(1)
341
-
342
- PrettyOutput.print(f"\n找到 {len(results)} 个结果:", OutputType.INFO)
343
-
344
- for i, result in enumerate(results[:args.max], 1):
345
- output = []
346
- output.append(f"\n{'-'*50}")
347
- if args.url_only:
348
- output.append(f"{i}. {result['href']}")
349
- else:
350
- output.append(f"{i}. {result['title']}")
351
- output.append(f"链接: {result['href']}")
352
- if result['abstract']:
353
- output.append(f"摘要: {result['abstract']}")
354
- PrettyOutput.print("\n".join(output), OutputType.INFO)
355
-
356
- except KeyboardInterrupt:
357
- PrettyOutput.print("搜索已取消", OutputType.WARNING)
358
- sys.exit(1)
359
- except Exception as e:
360
- PrettyOutput.print(f"执行错误: {str(e)}", OutputType.ERROR)
361
- sys.exit(1)
362
20
 
363
- if __name__ == "__main__":
364
- main()
21
+ @staticmethod
22
+ def check() -> bool:
23
+ return os.getenv("YUANBAO_COOKIES", "") != "" and os.getenv("YUANBAO_AGENT_ID", "") != ""
24
+
25
+ def execute(self, args: Dict[str, Any]) -> Dict[str, Any]: # type: ignore
26
+ query = args.get("query")
27
+ model = PlatformRegistry().create_platform("yuanbao")
28
+ model.set_suppress_output(False) # type: ignore
29
+ model.set_model_name("deep_seek") # type: ignore
30
+ return {
31
+ "stdout": model.chat_until_success(query), # type: ignore
32
+ "stderr": "",
33
+ "success": True,
34
+ }
@@ -42,7 +42,7 @@ class ToolGenerator:
42
42
  包含执行结果的字典,包含success、stdout和stderr字段
43
43
  """
44
44
  # 获取代码生成平台实例
45
- model = PlatformRegistry.get_global_platform_registry().get_codegen_platform()
45
+ model = PlatformRegistry.get_global_platform_registry().get_normal_platform()
46
46
 
47
47
  try:
48
48
  tool_name = arguments["tool_name"]
@@ -148,7 +148,7 @@ class CustomTool:
148
148
  try:
149
149
  # 在此实现工具逻辑
150
150
  # 使用LLM
151
- # model = PlatformRegistry.get_global_platform_registry().get_codegen_platform()
151
+ # model = PlatformRegistry.get_global_platform_registry().get_normal_platform()
152
152
  # result = model.chat_until_success(prompt)
153
153
 
154
154
  result = "工具执行结果"
@@ -16,7 +16,7 @@ def get_max_token_count() -> int:
16
16
  返回:
17
17
  int: 模型能处理的最大token数量。
18
18
  """
19
- return int(os.getenv('JARVIS_MAX_TOKEN_COUNT', '131072')) # 默认128k
19
+ return int(os.getenv('JARVIS_MAX_TOKEN_COUNT', '64000')) # 默认64k
20
20
 
21
21
  def get_thread_count() -> int:
22
22
  """
@@ -26,14 +26,6 @@ def get_thread_count() -> int:
26
26
  int: 线程数,默认为1
27
27
  """
28
28
  return int(os.getenv('JARVIS_THREAD_COUNT', '1'))
29
- def dont_use_local_model() -> bool:
30
- """
31
- 检查是否应避免使用本地模型。
32
-
33
- 返回:
34
- bool: 如果不使用本地模型则返回True,默认为False
35
- """
36
- return os.getenv('JARVIS_DONT_USE_LOCAL_MODEL', 'false') == 'true'
37
29
 
38
30
  def is_auto_complete() -> bool:
39
31
  """
@@ -44,30 +36,7 @@ def is_auto_complete() -> bool:
44
36
  """
45
37
  return os.getenv('JARVIS_AUTO_COMPLETE', 'false') == 'true'
46
38
 
47
- def is_use_methodology() -> bool:
48
- """
49
- 检查是否应使用方法论。
50
-
51
- 返回:
52
- bool: 如果使用方法论则返回True,默认为True
53
- """
54
- return os.getenv('JARVIS_USE_METHODOLOGY', 'true') == 'true'
55
- def is_record_methodology() -> bool:
56
- """
57
- 检查是否应记录方法论。
58
-
59
- 返回:
60
- bool: 如果记录方法论则返回True,默认为True
61
- """
62
- return os.getenv('JARVIS_RECORD_METHODOLOGY', 'true') == 'true'
63
- def is_need_summary() -> bool:
64
- """
65
- 检查是否需要生成摘要。
66
-
67
- 返回:
68
- bool: 如果需要摘要则返回True,默认为True
69
- """
70
- return os.getenv('JARVIS_NEED_SUMMARY', 'true') == 'true'
39
+
71
40
  def get_min_paragraph_length() -> int:
72
41
  """
73
42
  获取文本处理的最小段落长度。
@@ -97,65 +66,36 @@ def get_normal_platform_name() -> str:
97
66
  获取正常操作的平台名称。
98
67
 
99
68
  返回:
100
- str: 平台名称,默认为'kimi'
69
+ str: 平台名称,默认为'yuanbao'
101
70
  """
102
- return os.getenv('JARVIS_PLATFORM', 'kimi')
71
+ return os.getenv('JARVIS_PLATFORM', 'yuanbao')
103
72
  def get_normal_model_name() -> str:
104
73
  """
105
74
  获取正常操作的模型名称。
106
75
 
107
76
  返回:
108
- str: 模型名称,默认为'kimi'
109
- """
110
- return os.getenv('JARVIS_MODEL', 'kimi')
111
- def get_codegen_platform_name() -> str:
112
- """
113
- 获取代码生成的平台名称。
114
-
115
- 返回:
116
- str: 平台名称,默认为'kimi'
77
+ str: 模型名称,默认为'deep_seek'
117
78
  """
118
- return os.getenv('JARVIS_CODEGEN_PLATFORM', os.getenv('JARVIS_PLATFORM', 'kimi'))
119
- def get_codegen_model_name() -> str:
120
- """
121
- 获取代码生成的模型名称。
122
-
123
- 返回:
124
- str: 模型名称,默认为'kimi'
125
- """
126
- return os.getenv('JARVIS_CODEGEN_MODEL', os.getenv('JARVIS_MODEL', 'kimi'))
79
+ return os.getenv('JARVIS_MODEL', 'deep_seek_v3')
80
+
81
+
127
82
  def get_thinking_platform_name() -> str:
128
83
  """
129
84
  获取思考操作的平台名称。
130
85
 
131
86
  返回:
132
- str: 平台名称,默认为'kimi'
87
+ str: 平台名称,默认为'yuanbao'
133
88
  """
134
- return os.getenv('JARVIS_THINKING_PLATFORM', os.getenv('JARVIS_PLATFORM', 'kimi'))
89
+ return os.getenv('JARVIS_THINKING_PLATFORM', os.getenv('JARVIS_PLATFORM', 'yuanbao'))
135
90
  def get_thinking_model_name() -> str:
136
91
  """
137
92
  获取思考操作的模型名称。
138
93
 
139
94
  返回:
140
- str: 模型名称,默认为'kimi'
95
+ str: 模型名称,默认为'deep_seek'
141
96
  """
142
- return os.getenv('JARVIS_THINKING_MODEL', os.getenv('JARVIS_MODEL', 'kimi'))
143
- def get_cheap_platform_name() -> str:
144
- """
145
- 获取低成本操作的平台名称。
146
-
147
- 返回:
148
- str: 平台名称,默认为'kimi'
149
- """
150
- return os.getenv('JARVIS_CHEAP_PLATFORM', os.getenv('JARVIS_PLATFORM', 'kimi'))
151
- def get_cheap_model_name() -> str:
152
- """
153
- 获取低成本操作的模型名称。
154
-
155
- 返回:
156
- str: 模型名称,默认为'kimi'
157
- """
158
- return os.getenv('JARVIS_CHEAP_MODEL', os.getenv('JARVIS_MODEL', 'kimi'))
97
+ return os.getenv('JARVIS_THINKING_MODEL', os.getenv('JARVIS_MODEL', 'deep_seek'))
98
+
159
99
  def is_execute_tool_confirm() -> bool:
160
100
  """
161
101
  检查工具执行是否需要确认。
@@ -18,7 +18,6 @@ import faiss
18
18
  from typing import Dict, Any, List, Tuple, Optional
19
19
  from jarvis.jarvis_utils.output import PrettyOutput, OutputType
20
20
  from jarvis.jarvis_utils.embedding import load_embedding_model
21
- from jarvis.jarvis_utils.config import dont_use_local_model
22
21
 
23
22
  # 全局缓存,避免重复计算嵌入向量
24
23
  _methodology_embeddings_cache = {}
@@ -375,13 +374,6 @@ def load_methodology(user_input: str) -> str:
375
374
  # 获取文件的修改时间戳组合哈希,用于检测文件是否被修改
376
375
  methodology_hash = _get_methodology_files_hash()
377
376
 
378
- with yaspin(text="加载方法论文件...", color="yellow") as spinner:
379
- data = _load_all_methodologies()
380
- if dont_use_local_model():
381
- spinner.text = "加载方法论文件完成"
382
- spinner.ok("✅")
383
- return make_methodology_prompt(data)
384
-
385
377
  # 检查缓存的索引是否可用且方法论文件未被修改
386
378
  global _methodology_index_cache
387
379
  if _methodology_index_cache is None:
@@ -433,7 +425,6 @@ def load_methodology(user_input: str) -> str:
433
425
 
434
426
  if relevant_methodologies:
435
427
  return make_methodology_prompt(relevant_methodologies)
436
- return make_methodology_prompt(data)
437
428
 
438
429
  # 如果缓存无效,从头构建索引
439
430
  with yaspin(text="初始化数据结构...", color="yellow") as spinner:
@@ -453,6 +444,11 @@ def load_methodology(user_input: str) -> str:
453
444
  embedding_dimension = len(test_embedding)
454
445
  spinner.text = "创建测试嵌入完成"
455
446
  spinner.ok("✅")
447
+
448
+ with yaspin(text="加载方法论文件...", color="yellow") as spinner:
449
+ data = _load_all_methodologies()
450
+ spinner.text = "加载方法论文件完成"
451
+ spinner.ok("✅")
456
452
 
457
453
  with yaspin(text="处理方法论数据...", color="yellow") as spinner:
458
454
  for i, (key, value) in enumerate(data.items()):
@@ -483,7 +479,7 @@ def load_methodology(user_input: str) -> str:
483
479
 
484
480
  with yaspin(text="执行搜索...", color="yellow") as spinner:
485
481
  query_embedding = _create_methodology_embedding(embedding_model, user_input)
486
- k = min(3, len(methodology_data))
482
+ k = min(10, len(methodology_data))
487
483
  distances, indices = methodology_index.search(
488
484
  query_embedding.reshape(1, -1), k
489
485
  ) # type: ignore
@@ -512,7 +508,8 @@ def load_methodology(user_input: str) -> str:
512
508
 
513
509
  if relevant_methodologies:
514
510
  return make_methodology_prompt(relevant_methodologies)
515
- return make_methodology_prompt(data)
511
+
512
+ return make_methodology_prompt(data)
516
513
  except Exception as e:
517
514
  PrettyOutput.print(f"加载方法论失败: {str(e)}", OutputType.ERROR)
518
515
  return ""
@@ -17,7 +17,7 @@ from rich.syntax import Syntax
17
17
  from rich.style import Style as RichStyle
18
18
  from pygments.lexers import guess_lexer
19
19
  from pygments.util import ClassNotFound
20
- from .globals import console, get_agent_list
20
+ from jarvis.jarvis_utils.globals import console, get_agent_list
21
21
  class OutputType(Enum):
22
22
  """
23
23
  输出类型枚举,用于分类和样式化不同类型的消息。
@@ -186,7 +186,7 @@ class PrettyOutput:
186
186
  )
187
187
  console.print()
188
188
  console.print(panel)
189
- if traceback:
189
+ if traceback or output_type == OutputType.ERROR:
190
190
  console.print_exception()
191
191
  @staticmethod
192
192
  def section(title: str, output_type: OutputType = OutputType.INFO):
@@ -2,7 +2,7 @@ import os
2
2
  import time
3
3
  import hashlib
4
4
  from pathlib import Path
5
- from typing import Dict, List
5
+ from typing import Dict
6
6
  import psutil
7
7
  from jarvis.jarvis_utils.config import get_max_token_count
8
8
  from jarvis.jarvis_utils.embedding import get_context_token_count