jarvis-ai-assistant 0.1.96__py3-none-any.whl → 0.1.98__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 (41) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/agent.py +138 -144
  3. jarvis/jarvis_codebase/main.py +87 -54
  4. jarvis/jarvis_coder/git_utils.py +22 -25
  5. jarvis/jarvis_coder/main.py +166 -171
  6. jarvis/jarvis_coder/patch_handler.py +153 -453
  7. jarvis/jarvis_coder/plan_generator.py +76 -48
  8. jarvis/jarvis_platform/main.py +39 -39
  9. jarvis/jarvis_rag/main.py +182 -182
  10. jarvis/jarvis_smart_shell/main.py +34 -34
  11. jarvis/main.py +24 -24
  12. jarvis/models/ai8.py +22 -22
  13. jarvis/models/base.py +17 -13
  14. jarvis/models/kimi.py +31 -31
  15. jarvis/models/ollama.py +28 -28
  16. jarvis/models/openai.py +22 -24
  17. jarvis/models/oyi.py +25 -25
  18. jarvis/models/registry.py +33 -34
  19. jarvis/tools/ask_user.py +5 -5
  20. jarvis/tools/base.py +2 -2
  21. jarvis/tools/chdir.py +9 -9
  22. jarvis/tools/codebase_qa.py +4 -4
  23. jarvis/tools/coder.py +4 -4
  24. jarvis/tools/file_ops.py +1 -1
  25. jarvis/tools/generator.py +23 -23
  26. jarvis/tools/methodology.py +4 -4
  27. jarvis/tools/rag.py +4 -4
  28. jarvis/tools/registry.py +38 -38
  29. jarvis/tools/search.py +42 -42
  30. jarvis/tools/shell.py +13 -13
  31. jarvis/tools/sub_agent.py +16 -16
  32. jarvis/tools/thinker.py +41 -41
  33. jarvis/tools/webpage.py +17 -17
  34. jarvis/utils.py +59 -60
  35. {jarvis_ai_assistant-0.1.96.dist-info → jarvis_ai_assistant-0.1.98.dist-info}/METADATA +1 -1
  36. jarvis_ai_assistant-0.1.98.dist-info/RECORD +47 -0
  37. jarvis_ai_assistant-0.1.96.dist-info/RECORD +0 -47
  38. {jarvis_ai_assistant-0.1.96.dist-info → jarvis_ai_assistant-0.1.98.dist-info}/LICENSE +0 -0
  39. {jarvis_ai_assistant-0.1.96.dist-info → jarvis_ai_assistant-0.1.98.dist-info}/WHEEL +0 -0
  40. {jarvis_ai_assistant-0.1.96.dist-info → jarvis_ai_assistant-0.1.98.dist-info}/entry_points.txt +0 -0
  41. {jarvis_ai_assistant-0.1.96.dist-info → jarvis_ai_assistant-0.1.98.dist-info}/top_level.txt +0 -0
jarvis/tools/search.py CHANGED
@@ -58,26 +58,26 @@ def bing_search(query):
58
58
  return summaries
59
59
 
60
60
  except Exception as error:
61
- PrettyOutput.print(f"搜索出错: {str(error)}", OutputType.ERROR)
61
+ PrettyOutput.print(f"Search error: {str(error)}", OutputType.ERROR)
62
62
  return None
63
63
 
64
64
  class SearchTool:
65
65
  name = "search"
66
- description = "使用Bing搜索引擎搜索信息,并根据问题提取关键信息"
66
+ description = "Use Bing search engine to search for information, and extract key information based on the question"
67
67
  parameters = {
68
68
  "type": "object",
69
69
  "properties": {
70
70
  "query": {
71
71
  "type": "string",
72
- "description": "搜索关键词"
72
+ "description": "Search keywords"
73
73
  },
74
74
  "question": {
75
75
  "type": "string",
76
- "description": "需要回答的具体问题,用于从搜索结果中提取相关信息"
76
+ "description": "Specific question to answer, used to extract relevant information from search results"
77
77
  },
78
78
  "max_results": {
79
79
  "type": "integer",
80
- "description": "最大搜索结果数量",
80
+ "description": "Maximum number of search results",
81
81
  "default": 3
82
82
  }
83
83
  },
@@ -85,12 +85,12 @@ class SearchTool:
85
85
  }
86
86
 
87
87
  def __init__(self):
88
- """初始化搜索工具,需要传入语言模型用于信息提取"""
88
+ """Initialize the search tool, need to pass in the language model for information extraction"""
89
89
  self.model = PlatformRegistry.get_global_platform_registry().get_normal_platform()
90
90
  self.webpage_tool = WebpageTool()
91
91
 
92
92
  def _search(self, query: str, max_results: int) -> List[Dict]:
93
- """执行搜索请求"""
93
+ """Execute search request"""
94
94
  try:
95
95
  results = bing_search(query)
96
96
  if not results:
@@ -106,76 +106,76 @@ class SearchTool:
106
106
  })
107
107
  return formatted_results
108
108
  except Exception as e:
109
- PrettyOutput.print(f"搜索请求失败: {str(e)}", OutputType.ERROR)
109
+ PrettyOutput.print(f"Search request failed: {str(e)}", OutputType.ERROR)
110
110
  return []
111
111
 
112
112
  def _extract_info(self, contents: List[str], question: str) -> str:
113
- """使用语言模型从网页内容中提取关键信息"""
114
- prompt = f"""请根据以下搜索结果内容,回答问题:{question}
113
+ """Use language model to extract key information from web content"""
114
+ prompt = f"""Please answer the question based on the following search results: {question}
115
115
 
116
- 搜索结果内容:
116
+ Search results content:
117
117
  {'-' * 40}
118
118
  {''.join(contents)}
119
119
  {'-' * 40}
120
120
 
121
- 请提供一个简洁、准确的答案,重点关注与问题直接相关的信息。如果搜索结果中没有相关信息,请明确说明。
122
- 回答时注意:
123
- 1. 保持客观性,只基于搜索结果提供信息
124
- 2. 如果不同来源有冲突,请指出差异
125
- 3. 适当引用信息来源
126
- 4. 如果信息不完整或不确定,请说明"""
121
+ Please provide a concise and accurate answer, focusing on information directly related to the question. If there is no relevant information in the search results, please clearly state that.
122
+ When answering, pay attention to:
123
+ 1. Maintain objectivity, providing information based solely on search results
124
+ 2. If there are conflicts between different sources, point out the differences
125
+ 3. Appropriately cite information sources
126
+ 4. If the information is incomplete or uncertain, please explain"""
127
127
 
128
128
  try:
129
- response = self.model.chat(prompt)
129
+ response = self.model.chat_until_success(prompt)
130
130
  return response
131
131
  except Exception as e:
132
- return f"信息提取失败: {str(e)}"
132
+ return f"Information extraction failed: {str(e)}"
133
133
 
134
134
  def execute(self, args: Dict) -> Dict[str, Any]:
135
- """执行搜索并提取信息"""
135
+ """Execute search and extract information"""
136
136
  try:
137
137
  query = args["query"]
138
138
  question = args["question"]
139
139
  max_results = args.get("max_results", 3)
140
140
 
141
- # 打印搜索信息
142
- PrettyOutput.print(f"搜索查询: {query}", OutputType.INFO)
143
- PrettyOutput.print(f"相关问题: {question}", OutputType.INFO)
141
+ # Print search information
142
+ PrettyOutput.print(f"Search query: {query}", OutputType.INFO)
143
+ PrettyOutput.print(f"Related question: {question}", OutputType.INFO)
144
144
 
145
145
  # 获取搜索结果
146
146
  results = self._search(query, max_results)
147
147
  if not results:
148
148
  return {
149
149
  "success": False,
150
- "error": "未能获取任何搜索结果"
150
+ "error": "No search results found"
151
151
  }
152
152
 
153
153
  # 收集网页内容
154
154
  contents = []
155
155
  for i, result in enumerate(results, 1):
156
156
  try:
157
- PrettyOutput.print(f"正在读取第 {i}/{len(results)} 个结果... {result['title']} - {result['href']}", OutputType.PROGRESS)
157
+ PrettyOutput.print(f"Reading result {i}/{len(results)}... {result['title']} - {result['href']}", OutputType.PROGRESS)
158
158
  webpage_result = self.webpage_tool.execute({"url": result["href"]})
159
159
  if webpage_result["success"]:
160
- contents.append(f"\n来源 {i}{result['href']}\n")
160
+ contents.append(f"\nSource {i}: {result['href']}\n")
161
161
  contents.append(webpage_result["stdout"])
162
162
  except Exception as e:
163
- PrettyOutput.print(f"读取结果 {i} 失败: {str(e)}", OutputType.WARNING)
163
+ PrettyOutput.print(f"Failed to read result {i}: {str(e)}", OutputType.WARNING)
164
164
  continue
165
165
 
166
166
  if not contents:
167
167
  return {
168
168
  "success": False,
169
- "error": "未能获取任何有效的搜索结果"
169
+ "error": "No valid search results found"
170
170
  }
171
171
 
172
- # 提取信息
173
- PrettyOutput.print("正在分析搜索结果...", OutputType.PROGRESS)
172
+ # Extract information
173
+ PrettyOutput.print("Analyzing search results...", OutputType.PROGRESS)
174
174
  analysis = self._extract_info(contents, question)
175
175
 
176
176
  return {
177
177
  "success": True,
178
- "stdout": f"搜索分析结果:\n\n{analysis}",
178
+ "stdout": f"Search analysis results:\n\n{analysis}",
179
179
  "stderr": ""
180
180
  }
181
181
 
@@ -190,22 +190,22 @@ def main():
190
190
  import argparse
191
191
  import sys
192
192
 
193
- parser = argparse.ArgumentParser(description='Bing搜索工具')
194
- parser.add_argument('query', help='搜索关键词')
195
- parser.add_argument('--max', type=int, default=5, help='最大结果数量(默认5)')
196
- parser.add_argument('--url-only', action='store_true', help='只显示URL')
193
+ parser = argparse.ArgumentParser(description='Bing search tool')
194
+ parser.add_argument('query', help='Search keywords')
195
+ parser.add_argument('--max', type=int, default=5, help='Maximum number of results (default 5)')
196
+ parser.add_argument('--url-only', action='store_true', help='Only display URL')
197
197
  args = parser.parse_args()
198
198
 
199
199
  try:
200
- PrettyOutput.print(f"正在搜索: {args.query}", OutputType.INFO)
200
+ PrettyOutput.print(f"Searching: {args.query}", OutputType.INFO)
201
201
 
202
202
  results = bing_search(args.query)
203
203
 
204
204
  if not results:
205
- PrettyOutput.print("未找到搜索结果", OutputType.WARNING)
205
+ PrettyOutput.print("No search results found", OutputType.WARNING)
206
206
  sys.exit(1)
207
207
 
208
- PrettyOutput.print(f"\n找到 {len(results)} 条结果:", OutputType.INFO)
208
+ PrettyOutput.print(f"\nFound {len(results)} results:", OutputType.INFO)
209
209
 
210
210
  for i, result in enumerate(results[:args.max], 1):
211
211
  PrettyOutput.print(f"\n{'-'*50}", OutputType.INFO)
@@ -213,15 +213,15 @@ def main():
213
213
  PrettyOutput.print(f"{i}. {result['href']}", OutputType.INFO)
214
214
  else:
215
215
  PrettyOutput.print(f"{i}. {result['title']}", OutputType.INFO)
216
- PrettyOutput.print(f"链接: {result['href']}", OutputType.INFO)
216
+ PrettyOutput.print(f"Link: {result['href']}", OutputType.INFO)
217
217
  if result['abstract']:
218
- PrettyOutput.print(f"摘要: {result['abstract']}", OutputType.INFO)
218
+ PrettyOutput.print(f"Abstract: {result['abstract']}", OutputType.INFO)
219
219
 
220
220
  except KeyboardInterrupt:
221
- PrettyOutput.print("\n搜索已取消", OutputType.WARNING)
221
+ PrettyOutput.print("\nSearch cancelled", OutputType.WARNING)
222
222
  sys.exit(1)
223
223
  except Exception as e:
224
- PrettyOutput.print(f"执行出错: {str(e)}", OutputType.ERROR)
224
+ PrettyOutput.print(f"Execution error: {str(e)}", OutputType.ERROR)
225
225
  sys.exit(1)
226
226
 
227
227
  if __name__ == "__main__":
jarvis/tools/shell.py CHANGED
@@ -8,7 +8,7 @@ from jarvis.utils import OutputType, PrettyOutput
8
8
 
9
9
  class ShellTool:
10
10
  name = "execute_shell"
11
- description = """执行shell命令并返回结果"""
11
+ description = """Execute shell command and return result"""
12
12
 
13
13
  parameters = {
14
14
  "type": "object",
@@ -23,41 +23,41 @@ class ShellTool:
23
23
 
24
24
 
25
25
  def _escape_command(self, cmd: str) -> str:
26
- """转义命令中的特殊字符"""
26
+ """Escape special characters in command"""
27
27
  return cmd.replace("'", "'\"'\"'")
28
28
 
29
29
  def execute(self, args: Dict) -> Dict[str, Any]:
30
- """执行shell命令"""
30
+ """Execute shell command"""
31
31
  try:
32
32
  command = args["command"]
33
33
 
34
- # 生成临时文件名
34
+ # Generate temporary file name
35
35
  output_file = os.path.join(tempfile.gettempdir(), f"jarvis_shell_{os.getpid()}.log")
36
36
 
37
- # 转义命令中的特殊字符
37
+ # Escape special characters in command
38
38
  escaped_command = self._escape_command(command)
39
39
 
40
- # 修改命令以使用script
40
+ # Modify command to use script
41
41
  tee_command = f"script -q -c '{escaped_command}' {output_file}"
42
42
 
43
- PrettyOutput.print(f"执行命令: {command}", OutputType.INFO)
43
+ PrettyOutput.print(f"Execute command: {command}", OutputType.INFO)
44
44
 
45
- # 执行命令
45
+ # Execute command
46
46
  return_code = os.system(tee_command)
47
47
 
48
- # 读取输出文件
48
+ # Read output file
49
49
  try:
50
50
  with open(output_file, 'r', encoding='utf-8', errors='replace') as f:
51
51
  output = f.read()
52
- # 移除script命令添加的头尾
52
+ # Remove header and footer added by script
53
53
  if output:
54
54
  lines = output.splitlines()
55
55
  if len(lines) > 2:
56
56
  output = "\n".join(lines[1:-1])
57
57
  except Exception as e:
58
- output = f"读取输出文件失败: {str(e)}"
58
+ output = f"Failed to read output file: {str(e)}"
59
59
  finally:
60
- # 清理临时文件
60
+ # Clean up temporary file
61
61
  Path(output_file).unlink(missing_ok=True)
62
62
 
63
63
  return {
@@ -68,7 +68,7 @@ class ShellTool:
68
68
  }
69
69
 
70
70
  except Exception as e:
71
- # 确保清理临时文件
71
+ # Ensure temporary file is cleaned up
72
72
  if 'output_file' in locals():
73
73
  Path(output_file).unlink(missing_ok=True)
74
74
  PrettyOutput.print(str(e), OutputType.ERROR)
jarvis/tools/sub_agent.py CHANGED
@@ -7,32 +7,32 @@ from jarvis.utils import OutputType, PrettyOutput
7
7
 
8
8
  class SubAgentTool:
9
9
  name = "create_sub_agent"
10
- description = "创建一个子代理来处理特定任务,子代理会生成任务总结报告"
10
+ description = "Create a sub-agent to handle specific tasks, the sub-agent will generate a task summary report"
11
11
  parameters = {
12
12
  "type": "object",
13
13
  "properties": {
14
14
  "agent_name": {
15
15
  "type": "string",
16
- "description": "子代理的名称"
16
+ "description": "Sub-agent name"
17
17
  },
18
18
  "task": {
19
19
  "type": "string",
20
- "description": "需要完成的具体任务"
20
+ "description": "Specific task to complete"
21
21
  },
22
22
  "context": {
23
23
  "type": "string",
24
- "description": "任务相关的上下文信息",
24
+ "description": "Context information related to the task",
25
25
  "default": ""
26
26
  },
27
27
  "goal": {
28
28
  "type": "string",
29
- "description": "任务的完成目标",
29
+ "description": "Completion goal of the task",
30
30
  "default": ""
31
31
  },
32
32
  "files": {
33
33
  "type": "array",
34
34
  "items": {"type": "string"},
35
- "description": "相关文件路径列表,用于文件问答和处理",
35
+ "description": "Related file path list, used for file question answering and processing",
36
36
  "default": []
37
37
  }
38
38
  },
@@ -41,7 +41,7 @@ class SubAgentTool:
41
41
 
42
42
 
43
43
  def execute(self, args: Dict) -> Dict[str, Any]:
44
- """创建并运行子代理"""
44
+ """Create and run sub-agent"""
45
45
  try:
46
46
  agent_name = args["agent_name"]
47
47
  task = args["task"]
@@ -49,28 +49,28 @@ class SubAgentTool:
49
49
  goal = args.get("goal", "")
50
50
  files = args.get("files", [])
51
51
 
52
- PrettyOutput.print(f"创建子代理: {agent_name}", OutputType.INFO)
52
+ PrettyOutput.print(f"Create sub-agent: {agent_name}", OutputType.INFO)
53
53
 
54
- # 构建任务描述
54
+ # Build task description
55
55
  task_description = task
56
56
  if context:
57
- task_description = f"上下文信息:\n{context}\n\n任务:\n{task}"
57
+ task_description = f"Context information:\n{context}\n\nTask:\n{task}"
58
58
  if goal:
59
- task_description += f"\n\n完成目标:\n{goal}"
59
+ task_description += f"\n\nCompletion goal:\n{goal}"
60
60
 
61
- # 创建子代理
61
+ # Create sub-agent
62
62
  sub_agent = Agent(
63
63
  name=agent_name,
64
64
  is_sub_agent=True
65
65
  )
66
66
 
67
- # 运行子代理,传入文件列表
68
- PrettyOutput.print("子代理开始执行任务...", OutputType.INFO)
67
+ # Run sub-agent, pass file list
68
+ PrettyOutput.print("Sub-agent starts executing task...", OutputType.INFO)
69
69
  result = sub_agent.run(task_description, file_list=files)
70
70
 
71
71
  return {
72
72
  "success": True,
73
- "stdout": f"子代理任务完成\n\n{result}",
73
+ "stdout": f"Sub-agent task completed\n\n{result}",
74
74
  "stderr": ""
75
75
  }
76
76
 
@@ -78,5 +78,5 @@ class SubAgentTool:
78
78
  PrettyOutput.print(str(e), OutputType.ERROR)
79
79
  return {
80
80
  "success": False,
81
- "error": f"子代理执行失败: {str(e)}"
81
+ "error": f"Sub-agent execution failed: {str(e)}"
82
82
  }
jarvis/tools/thinker.py CHANGED
@@ -4,22 +4,22 @@ from jarvis.models.registry import PlatformRegistry
4
4
 
5
5
  class ThinkerTool:
6
6
  name = "thinker"
7
- description = "使用思维链推理方式分析复杂问题,适用于需要多步推理、逻辑分析或创造性思考的场景"
7
+ description = "Use chain of thought reasoning to analyze complex problems, suitable for scenarios that require multi-step reasoning, logical analysis, or creative thinking"
8
8
  parameters = {
9
9
  "type": "object",
10
10
  "properties": {
11
11
  "question": {
12
12
  "type": "string",
13
- "description": "需要分析的问题或任务"
13
+ "description": "The problem or task to analyze"
14
14
  },
15
15
  "context": {
16
16
  "type": "string",
17
- "description": "问题相关的上下文信息或背景知识",
17
+ "description": "Context information or background knowledge related to the problem",
18
18
  "default": ""
19
19
  },
20
20
  "goal": {
21
21
  "type": "string",
22
- "description": "期望达成的具体目标或结果",
22
+ "description": "The specific goal or result to achieve",
23
23
  "default": ""
24
24
  }
25
25
  },
@@ -27,63 +27,63 @@ class ThinkerTool:
27
27
  }
28
28
 
29
29
  def __init__(self):
30
- """初始化思考工具"""
30
+ """Initialize thinker tool"""
31
31
  self.model = PlatformRegistry.get_global_platform_registry().get_thinking_platform()
32
32
 
33
33
  def _generate_prompt(self, question: str, context: str, goal: str) -> str:
34
- """生成提示词
34
+ """Generate prompt
35
35
 
36
36
  Args:
37
- question: 问题
38
- context: 上下文
39
- goal: 期望目标
37
+ question: problem
38
+ context: context
39
+ goal: goal
40
40
 
41
41
  Returns:
42
- str: 完整的提示词
42
+ str: complete prompt
43
43
  """
44
44
  # 基础提示词
45
- prompt = f"""你是一个擅长深度思考和逻辑推理的助手。请帮助分析问题并给出解决方案。
45
+ prompt = f"""You are a helpful assistant that is good at deep thinking and logical reasoning. Please help analyze the problem and provide a solution.
46
46
 
47
- 请按以下方式思考:
48
- 1. 仔细理解问题和目标
49
- 2. 进行系统性分析和推理
50
- 3. 考虑多个可能的解决方案
51
- 4. 给出最佳建议和具体行动步骤
47
+ Please think as follows:
48
+ 1. Carefully understand the problem and goal
49
+ 2. Conduct a systematic analysis and reasoning
50
+ 3. Consider multiple possible solutions
51
+ 4. Provide the best suggestions and specific action steps
52
52
 
53
- 问题:
53
+ Problem:
54
54
  {question}
55
55
  """
56
56
  # 如果有目标,添加到提示词中
57
57
  if goal:
58
58
  prompt += f"""
59
- 期望目标:
59
+ Goal:
60
60
  {goal}
61
61
  """
62
62
 
63
63
  # 如果有上下文,添加到提示词中
64
64
  if context:
65
65
  prompt += f"""
66
- 相关上下文:
66
+ Related context:
67
67
  {context}
68
68
  """
69
69
 
70
- prompt += "\n请开始分析:"
70
+ prompt += "\nPlease start analyzing:"
71
71
  return prompt
72
72
 
73
73
  def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
74
- """执行思考分析
74
+ """Execute thinking analysis
75
75
 
76
76
  Args:
77
- args: 包含参数的字典
78
- - question: 问题
79
- - context: 上下文(可选)
80
- - goal: 期望目标(可选)
77
+ args: dictionary containing parameters
78
+ - question: problem
79
+ - context: context (optional)
80
+ - goal: goal (optional)
81
81
 
82
82
  Returns:
83
- Dict[str, Any]: 执行结果
83
+ Dict[str, Any]: execution result
84
84
  """
85
85
  try:
86
- # 获取参数
86
+ # Get parameters
87
87
  question = args["question"]
88
88
  context = args.get("context", "")
89
89
  goal = args.get("goal", "")
@@ -91,20 +91,20 @@ class ThinkerTool:
91
91
  # 生成提示词
92
92
  prompt = self._generate_prompt(question, context, goal)
93
93
 
94
- # 记录开始分析
95
- PrettyOutput.print(f"开始分析问题: {question}", OutputType.INFO)
94
+ # Record start analysis
95
+ PrettyOutput.print(f"Start analyzing problem: {question}", OutputType.INFO)
96
96
  if context:
97
- PrettyOutput.print("包含上下文信息", OutputType.INFO)
97
+ PrettyOutput.print("Contains context information", OutputType.INFO)
98
98
  if goal:
99
- PrettyOutput.print(f"目标: {goal}", OutputType.INFO)
99
+ PrettyOutput.print(f"Goal: {goal}", OutputType.INFO)
100
100
 
101
101
  # 调用模型进行分析
102
- response = self.model.chat(prompt)
102
+ response = self.model.chat_until_success(prompt)
103
103
 
104
104
  if not response:
105
105
  return {
106
106
  "success": False,
107
- "error": "未能获得有效的分析结果"
107
+ "error": "Failed to obtain valid analysis results"
108
108
  }
109
109
 
110
110
  return {
@@ -114,22 +114,22 @@ class ThinkerTool:
114
114
  }
115
115
 
116
116
  except Exception as e:
117
- PrettyOutput.print(f"思考分析失败: {str(e)}", OutputType.ERROR)
117
+ PrettyOutput.print(f"Thinking analysis failed: {str(e)}", OutputType.ERROR)
118
118
  return {
119
119
  "success": False,
120
- "error": f"执行失败: {str(e)}"
120
+ "error": f"Execution failed: {str(e)}"
121
121
  }
122
122
 
123
123
  def main():
124
- """命令行直接运行工具"""
124
+ """Run tool directly from command line"""
125
125
  import argparse
126
126
 
127
127
  load_env_from_file()
128
128
 
129
- parser = argparse.ArgumentParser(description='深度思考分析工具')
130
- parser.add_argument('--question', required=True, help='需要分析的问题')
131
- parser.add_argument('--context', help='问题相关的上下文信息')
132
- parser.add_argument('--goal', help='期望达成的具体目标或结果')
129
+ parser = argparse.ArgumentParser(description='Deep thinking analysis tool')
130
+ parser.add_argument('--question', required=True, help='The problem to analyze')
131
+ parser.add_argument('--context', help='Context information related to the problem')
132
+ parser.add_argument('--goal', help='Specific goal or result to achieve')
133
133
  args = parser.parse_args()
134
134
 
135
135
  tool = ThinkerTool()
@@ -140,7 +140,7 @@ def main():
140
140
  })
141
141
 
142
142
  if result["success"]:
143
- PrettyOutput.print("\n分析结果:", OutputType.INFO)
143
+ PrettyOutput.print("\nAnalysis results:", OutputType.INFO)
144
144
  PrettyOutput.print(result["stdout"], OutputType.INFO)
145
145
  else:
146
146
  PrettyOutput.print(result["error"], OutputType.ERROR)
jarvis/tools/webpage.py CHANGED
@@ -5,56 +5,56 @@ from jarvis.utils import PrettyOutput, OutputType
5
5
 
6
6
  class WebpageTool:
7
7
  name = "read_webpage"
8
- description = "读取网页内容,提取标题和正文文本"
8
+ description = "Read webpage content, extract title and text"
9
9
  parameters = {
10
10
  "type": "object",
11
11
  "properties": {
12
12
  "url": {
13
13
  "type": "string",
14
- "description": "需要读取的网页URL"
14
+ "description": "The URL of the webpage to read"
15
15
  }
16
16
  },
17
17
  "required": ["url"]
18
18
  }
19
19
 
20
20
  def execute(self, args: Dict) -> Dict[str, Any]:
21
- """读取网页内容"""
21
+ """Read webpage content"""
22
22
  try:
23
23
  url = args["url"]
24
24
 
25
- # 设置请求头
25
+ # Set request headers
26
26
  headers = {
27
27
  'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
28
28
  }
29
29
 
30
- # 发送请求
31
- PrettyOutput.print(f"正在读取网页: {url}", OutputType.INFO)
30
+ # Send request
31
+ PrettyOutput.print(f"Reading webpage: {url}", OutputType.INFO)
32
32
  response = requests.get(url, headers=headers, timeout=10)
33
33
  response.raise_for_status()
34
34
 
35
- # 使用正确的编码
35
+ # Use correct encoding
36
36
  response.encoding = response.apparent_encoding
37
37
 
38
- # 解析HTML
38
+ # Parse HTML
39
39
  soup = BeautifulSoup(response.text, 'html.parser')
40
40
 
41
- # 移除scriptstyle标签
41
+ # Remove script and style tags
42
42
  for script in soup(["script", "style"]):
43
43
  script.decompose()
44
44
 
45
- # 提取标题
45
+ # Extract title
46
46
  title = soup.title.string if soup.title else ""
47
- title = title.strip() if title else "无标题"
47
+ title = title.strip() if title else "No title"
48
48
 
49
- # 提取正文
49
+ # Extract text
50
50
  text = soup.get_text(separator='\n', strip=True)
51
51
  lines = [line.strip() for line in text.splitlines() if line.strip()]
52
52
 
53
- # 构建输出
53
+ # Build output
54
54
  output = [
55
- f"标题: {title}",
55
+ f"Title: {title}",
56
56
  "",
57
- "正文内容:",
57
+ "Text content:",
58
58
  "\n".join(lines)
59
59
  ]
60
60
 
@@ -67,10 +67,10 @@ class WebpageTool:
67
67
  except requests.RequestException as e:
68
68
  return {
69
69
  "success": False,
70
- "error": f"网页请求失败: {str(e)}"
70
+ "error": f"Webpage request failed: {str(e)}"
71
71
  }
72
72
  except Exception as e:
73
73
  return {
74
74
  "success": False,
75
- "error": f"解析网页失败: {str(e)}"
75
+ "error": f"Failed to parse webpage: {str(e)}"
76
76
  }