PikoAi 0.1.23__py3-none-any.whl → 0.1.25__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.
@@ -4,6 +4,8 @@
4
4
  import os
5
5
  import sys
6
6
  import time
7
+ import logging
8
+ import json
7
9
  sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../')))
8
10
  from Utils.ter_interface import TerminalInterface
9
11
  from Utils.executor_utils import parse_tool_call
@@ -30,11 +32,28 @@ class executor:
30
32
  self.user_prompt = user_prompt
31
33
  self.max_iter = max_iter
32
34
  self.rate_limiter = RateLimiter(wait_time=3.0, max_retries=3)
35
+
36
+ # Load environment configuration
37
+ self.environment = self.load_environment_config()
38
+
39
+ # Setup logging if in development environment
40
+ if self.environment == "development":
41
+ self.setup_logging()
42
+
33
43
  self.executor_prompt_init() # Update system_prompt
34
44
  # self.python_executor = python_executor.PythonExecutor() # Initialize PythonExecutor
35
45
  # self.shell_executor = ShellExecutor() # Initialize ShellExecutor
36
46
  self.message = [
37
47
  {"role": "system", "content": self.system_prompt},
48
+ {"role":"user","content":"Hi"},
49
+ {"role":"assistant","content":"""```json
50
+ {
51
+ "tool_name": "get_user_input",
52
+ "input": {
53
+ "query": "Hi,im your terminal assistant. How can I help you?"
54
+ }
55
+ }
56
+ ```"""},
38
57
  {"role": "user", "content": self.user_prompt}
39
58
  ]
40
59
  self.terminal = TerminalInterface()
@@ -74,6 +93,10 @@ class executor:
74
93
 
75
94
  response = self.llm.chat(self.message) # LiteLLMInterface.chat() returns the full response string
76
95
 
96
+ # Log response in development environment
97
+ if self.environment == "development":
98
+ self.logger.info(f"LLM Response: {response}")
99
+
77
100
  # Streaming is handled within LiteLLMInterface.chat()
78
101
  # and TerminalInterface.process_markdown_chunk()
79
102
  if response.strip():
@@ -144,6 +167,48 @@ class executor:
144
167
  # result = exec_env.execute(code)
145
168
  # return result
146
169
 
170
+ def load_environment_config(self):
171
+ """Load environment configuration from config.json"""
172
+ try:
173
+ config_path = os.path.join(os.path.dirname(__file__), '../../../config.json')
174
+ with open(config_path, "r") as config_file:
175
+ config = json.load(config_file)
176
+ return config.get("environment", "production")
177
+ except Exception as e:
178
+
179
+ return "production"
180
+
181
+ def setup_logging(self):
182
+ """Setup logging for development environment"""
183
+ try:
184
+ # Create logs directory if it doesn't exist
185
+ logs_dir = os.path.join(os.path.dirname(__file__), '../../../logs')
186
+ os.makedirs(logs_dir, exist_ok=True)
187
+
188
+ # Create a specific logger for executor responses
189
+ self.logger = logging.getLogger('executor_responses')
190
+ self.logger.setLevel(logging.INFO)
191
+
192
+ # Prevent propagation to parent loggers (this stops console output)
193
+ self.logger.propagate = False
194
+
195
+ # Remove any existing handlers to avoid duplicates
196
+ for handler in self.logger.handlers[:]:
197
+ self.logger.removeHandler(handler)
198
+
199
+ # Add file handler only (no console output)
200
+ log_file = os.path.join(logs_dir, 'executor_responses.log')
201
+ file_handler = logging.FileHandler(log_file)
202
+ file_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
203
+ self.logger.addHandler(file_handler)
204
+
205
+ # Suppress LiteLLM's verbose logging
206
+ logging.getLogger('litellm').setLevel(logging.WARNING)
207
+
208
+ self.logger.info("Development logging enabled for executor responses")
209
+ except Exception as e:
210
+ print(f"Warning: Could not setup logging: {e}")
211
+
147
212
  if __name__ == "__main__":
148
213
  # e1 = executor("") # Commenting out example usage for now as it might need adjustment
149
214
  # user_prompt = input("Please enter your prompt: ")
@@ -160,4 +225,4 @@ if __name__ == "__main__":
160
225
  # e1.message.append({"role": "user", "content": user_prompt})
161
226
  # # e1.message.append({"role":"user","content":e1.system_prompt})
162
227
  # e1.run()
163
- pass # Placeholder if main execution is commented out
228
+ pass
@@ -23,22 +23,22 @@ Your primary objective is to accomplish the user's goal by performing step-by-st
23
23
 
24
24
  You must break down the user's goal into smaller steps and perform one action at a time. After each action, carefully evaluate the output to determine the next step.
25
25
 
26
- ### Action Guidelines:
27
- - **Tool Call**: Use when a specific tool can help with the current step. Format:
28
-
29
- <<TOOL_CALL>>
26
+ ## Action Guidelines:
27
+ - **Tool Call**: Use when a specific tool can help with the current step. Format your tool calls as a JSON object within a markdown code block starting with ```json.
28
+ like this :
29
+ ```json
30
30
  {{
31
31
  "tool_name": "name_of_tool",
32
32
  "input": {{
33
- "key": "value" //Replace 'key' with the actual parameter name for the tool
33
+ "key": "value" // Replace 'key' with the actual parameter name for the tool
34
34
  }}
35
35
  }}
36
- <<END_TOOL_CALL>>
37
-
38
- - **Direct Response**: Provide a direct answer if the task doesn't require tool calling
36
+ ```
37
+ Ensure your entire response for a tool call is *only* this markdown code block if a tool call is being made.
38
+ - **Direct Response**: Provide a direct answer if the task doesn't require tool calling. If providing a direct response, do not use the markdown JSON code block.
39
39
 
40
40
 
41
- These are the things that you learned from the mistakes you made earlier :
41
+ These are the points that you learned from the mistakes you made earlier :
42
42
  - When given a data file and asked to understand data/do data analysis/ data visualisation or similar stuff
43
43
  do not use file reader and read the whole data. Only use python code to do the analysis
44
44
  - This is a standard Python environment, not a python notebook or a repl. previous execution
@@ -56,7 +56,18 @@ These are the things that you learned from the mistakes you made earlier :
56
56
  - Continue performing actions until the user's goal is fully achieved. Only then, include 'TASK_DONE' in your response.
57
57
  - Do not end the task immediately after a tool call without evaluating its output.
58
58
  - The best way to give output is to save it open the file using shell commands.
59
- - The tool call in json format should be done between the delimiters <<TOOL_CALL>> and <<END_TOOL_CALL>>.
59
+ - The tool call in json format must be done between the delimiters <<TOOL_CALL>> and <<END_TOOL_CALL>>. This is non-negotiable.
60
+
61
+ for e.g. User: what is the latest news on Ai.
62
+ your response should be :
60
63
 
64
+ ```json
65
+ {{
66
+ "tool_name": "web_search",
67
+ "input": {{
68
+ "query": "latest news"
69
+ }}
70
+ }}
71
+ ```
61
72
 
62
73
  """
Env/__init__.py CHANGED
@@ -1,5 +1 @@
1
- from .base_executor import BaseExecutor
2
- from .python_executor import PythonExecutor
3
- from .js_executor import JavaScriptExecutor
4
1
 
5
- __all__ = ["BaseExecutor", "PythonExecutor", "JavaScriptExecutor"]
Env/python_executor.py CHANGED
@@ -1,20 +1,3 @@
1
- # from .base_executor import BaseExecutor
2
-
3
- # class PythonExecutor():
4
- # def execute(self, code: str) -> str:
5
- # """Executes Python code and returns the result or an error message."""
6
-
7
- # # if not self.validate_code(code):
8
- # # return "Code validation failed: Unsafe code detected."
9
-
10
- # local_vars = {}
11
- # try:
12
- # exec(code, {}, local_vars) # Execute code in an isolated environment
13
- # return local_vars.get("output", "Code executed successfully.")
14
- # except Exception as e:
15
- # # return self.handle_error(e)
16
- # print("error in running python code", e)
17
-
18
1
  import subprocess
19
2
  import tempfile
20
3
  import os
OpenCopilot.py CHANGED
@@ -257,7 +257,11 @@ Examples:
257
257
  print("\nGoodbye!")
258
258
  except Exception as e:
259
259
  print_formatted_text(FormattedText([
260
- ('class:error', f"Failed to start OpenCopilot: {e}")
260
+ ('class:error', f"Failed to start OpenCopilot: {e.__class__.__name__}: {e}")
261
+ ]))
262
+ import traceback
263
+ print_formatted_text(FormattedText([
264
+ ('class:error', f"Error occurred at: {traceback.format_exc()}")
261
265
  ]))
262
266
 
263
267
  def run_task(self, user_prompt, max_iter=10):
Tools/tool_manager.py CHANGED
@@ -9,10 +9,12 @@ from Tools.system_details import get_os_details, get_datetime, get_memory_usage,
9
9
  from Tools.userinp import get_user_input
10
10
  from Env.python_executor import PythonExecutor
11
11
  from Env.shell import ShellExecutor
12
+ from Utils.ter_interface import TerminalInterface
12
13
 
13
14
  #need to transform it into map of dictionary
14
15
  #name : [function : xyz,description : blah bah]
15
16
 
17
+ terminal = TerminalInterface()
16
18
 
17
19
 
18
20
 
@@ -20,9 +22,9 @@ def execute_python_code_tool(code: str) -> str:
20
22
  """
21
23
  Prompts for confirmation, then executes the given Python code and returns a formatted result string.
22
24
  """
23
- user_confirmation = input(f"Do you want to execute this Python code snippet?\n```python\n{code}\n```\n(y/n): ")
25
+ terminal.code_log(code)
26
+ user_confirmation = input(f"Do you want to execute this Python code snippet?\n(y/n): ")
24
27
  if user_confirmation.lower() != 'y':
25
- print("Python code execution skipped by the user.")
26
28
  return "User chose not to execute the Python code."
27
29
  executor = PythonExecutor()
28
30
  result = executor.execute(code)
@@ -48,9 +50,9 @@ def execute_shell_command_tool(command: str) -> str:
48
50
  """
49
51
  Prompts for confirmation, then executes the given shell command and returns a formatted result string.
50
52
  """
51
- user_confirmation = input(f"Do you want to execute the shell command: '{command}'? (y/n): ")
53
+ terminal.code_log(command)
54
+ user_confirmation = input(f"Do you want to execute the shell command? (y/n): ")
52
55
  if user_confirmation.lower() != 'y':
53
- print("Shell command execution skipped by the user.")
54
56
  return "User chose not to execute the shell command."
55
57
  executor = ShellExecutor()
56
58
  result = executor.execute(command)
@@ -73,11 +75,13 @@ def call_tool(tool_name, tool_input):
73
75
  tool_name (str): Name of the tool to call
74
76
  tool_input (dict): Input parameters for the tool
75
77
  """
78
+
76
79
  if tool_name in tools_function_map:
77
80
  # Pass the tool_input dictionary as kwargs to the tool function
78
81
  return tools_function_map[tool_name](**tool_input)
79
- else:
80
- return f"This tool is invalid. Please check the tools available in the tool directory"
82
+ else: raise ValueError(f"This tool is invalid. Please check the tools available in the tool directory")
83
+
84
+
81
85
 
82
86
  tools_function_map = {
83
87
  "web_loader": load_data,
Tools/web_loader.py CHANGED
@@ -125,7 +125,7 @@ def load_data(**kwargs):
125
125
  }
126
126
  content = ""
127
127
  try:
128
- response = session.get(url, headers=headers, timeout=30)
128
+ response = session.get(url, headers=headers, timeout=3)
129
129
  response.raise_for_status()
130
130
  data = response.content
131
131
  # Check content type
@@ -138,6 +138,12 @@ def load_data(**kwargs):
138
138
  # Extract text from each page and combine it
139
139
  content = "\n".join([page.extract_text() for page in pdf.pages if page.extract_text()])
140
140
 
141
+ except requests.exceptions.Timeout:
142
+ logging.error(f"Timeout error loading data from {url}: The webpage didn't load in time")
143
+ content = f"Error: The webpage at {url} didn't load in time. Please try again later or check other urls for the task. use web_search tool to find other urls."
144
+ except requests.exceptions.RequestException as e:
145
+ logging.error(f"Request error loading data from {url}: {e}")
146
+ content = f"Error: Failed to load webpage at {url}. {str(e)}"
141
147
  except Exception as e:
142
148
  logging.error(f"Error loading data from {url}: {e}")
143
149
  content = ""
Utils/executor_utils.py CHANGED
@@ -1,15 +1,32 @@
1
1
  import json
2
2
  from typing import Optional
3
3
 
4
+ import re
5
+
4
6
  def parse_tool_call(response: str) -> Optional[dict]:
5
7
  """
6
- Parses a tool call from the response.
8
+ Parses a tool call from the response, expecting it in a markdown JSON code block.
9
+ Example:
10
+ ```json
11
+ {
12
+ "tool_name": "tool_name",
13
+ "input": {"arg": "value"}
14
+ }
15
+ ```
7
16
  """
8
- if "<<TOOL_CALL>>" in response and "<<END_TOOL_CALL>>" in response:
9
- tool_call_str = response.split("<<TOOL_CALL>>")[1].split("<<END_TOOL_CALL>>")[0].strip()
17
+ # Regex to find ```json ... ``` blocks
18
+ # It captures the content within the fences.
19
+ # re.DOTALL allows '.' to match newlines, which is crucial for multi-line JSON.
20
+ match = re.search(r"```json\s*([\s\S]+?)\s*```", response, re.DOTALL)
21
+
22
+ if match:
23
+ json_str = match.group(1).strip()
10
24
  try:
11
- tool_call = json.loads(tool_call_str)
12
- return tool_call
25
+ tool_call = json.loads(json_str)
26
+ # Basic validation for the expected structure
27
+ if isinstance(tool_call, dict) and "tool_name" in tool_call and "input" in tool_call:
28
+ return tool_call
13
29
  except json.JSONDecodeError:
30
+ # Invalid JSON within the markdown block
14
31
  return None
15
32
  return None
Utils/ter_interface.py CHANGED
@@ -5,6 +5,8 @@ from rich.panel import Panel
5
5
  from rich.text import Text
6
6
  from rich.markdown import Markdown
7
7
  from rich.syntax import Syntax
8
+ from yaspin import yaspin
9
+ import time
8
10
 
9
11
  import json
10
12
 
@@ -36,12 +38,7 @@ class TerminalInterface:
36
38
  elif not isinstance(message, str):
37
39
  message = str(message)
38
40
 
39
- # Original code:
40
- # panel = Panel(
41
- # Text(message, style="orange"),
42
- # title=f"[bold green]{tool_name} Output[/bold green]",
43
- # border_style="green"
44
- # )
41
+
45
42
  panel = Panel(
46
43
  Text(message, style="blue"),
47
44
  title=f"[bold green]{tool_name} Output[/bold green]",
@@ -49,6 +46,17 @@ class TerminalInterface:
49
46
  )
50
47
  self.console.print(panel)
51
48
 
49
+ def code_log(self, code: str):
50
+ """
51
+ Print a code snippet in a formatted panel.
52
+ """
53
+ panel = Panel(
54
+ Syntax(code, "python", theme="monokai", line_numbers=True),
55
+ title=f"[bold green]Code Snippet[/bold green]",
56
+ border_style="green"
57
+ )
58
+ self.console.print(panel)
59
+
52
60
  def process_markdown_chunk(self, chunk):
53
61
  """
54
62
  Process a chunk of markdown text, handling tool calls and regular markdown.
@@ -61,15 +69,19 @@ class TerminalInterface:
61
69
  line_stripped = line.strip()
62
70
 
63
71
  # Handle tool call opening delimiter - be more flexible with whitespace
64
- if "<<TOOL_CALL>>" in line_stripped:
72
+ if "```json" in line_stripped:
65
73
  self.inside_tool_call = True
66
74
  self.tool_call_buffer = ""
67
- self.console.print("[bold cyan]Tool Call:[/bold cyan]")
75
+ # self.console.print("[bold cyan]Tool Call:[/bold cyan]")
76
+ self.spinner = yaspin(text="Tool Call...", color="yellow")
77
+ self.spinner.start()
68
78
 
69
79
  # Handle tool call closing delimiter - be more flexible with whitespace
70
- elif "<<END_TOOL_CALL>>" in line_stripped:
71
- self.console.print(self.tool_call_buffer)
72
- # self.console.print(Syntax('{"status": "end_tool_call"}', "json", theme="monokai", line_numbers=False))
80
+ elif "```" in line_stripped and self.inside_tool_call:
81
+ if hasattr(self, 'spinner'):
82
+ self.spinner.stop()
83
+ delattr(self, 'spinner')
84
+ self._display_tool_call_content()
73
85
  self.console.print("[bold cyan]--------------------------------[/bold cyan]")
74
86
  self.inside_tool_call = False
75
87
  self.tool_call_buffer = ""
@@ -82,14 +94,58 @@ class TerminalInterface:
82
94
  else:
83
95
  self.console.print(Markdown(line))
84
96
 
97
+ def _display_tool_call_content(self):
98
+ """
99
+ Parse and display tool call JSON content in a simple key-value format.
100
+ """
101
+ try:
102
+ # Try to parse the JSON content
103
+ json_content = json.loads(self.tool_call_buffer.strip())
104
+
105
+ # Check if tool_name is execute_python_code or execute_shell_command
106
+ if 'tool_name' in json_content and json_content['tool_name'] in ['execute_python_code', 'execute_shell_command']:
107
+ return
108
+
109
+ # Build content for the panel
110
+ panel_content = ""
111
+ for key, value in json_content.items():
112
+ if isinstance(value, dict):
113
+ panel_content += f"{key}:\n"
114
+ for sub_key, sub_value in value.items():
115
+ panel_content += f" {sub_key}: {sub_value}\n"
116
+ else:
117
+ panel_content += f"{key}: {value}\n"
118
+
119
+ # Create and display panel
120
+ panel = Panel(
121
+ panel_content.strip(),
122
+ title="[yellow]Tool Call[/yellow]",
123
+ border_style="blue"
124
+ )
125
+ self.console.print(panel)
126
+ except json.JSONDecodeError:
127
+ # If JSON parsing fails, display the raw content in a panel
128
+ panel = Panel(
129
+ self.tool_call_buffer.strip(),
130
+ title="[bold red]Raw Tool Call Content[/bold red]",
131
+ border_style="red"
132
+ )
133
+ self.console.print(panel)
134
+
85
135
  def flush_markdown(self):
86
136
  """
87
137
  Flush any remaining markdown content in the buffer.
88
138
  """
89
139
  if hasattr(self, 'inside_tool_call') and self.inside_tool_call:
90
140
  # Handle case where tool call is not properly terminated
91
- self.console.print(Syntax(self.tool_call_buffer.strip(), "json", theme="monokai", line_numbers=False))
92
- self.console.print("[bold cyan]End Tool Call (forced)[/bold cyan]")
141
+
142
+ if hasattr(self, 'spinner'):
143
+ self.spinner.stop()
144
+ delattr(self, 'spinner')
145
+
146
+ if self.tool_call_buffer.strip():
147
+ self._display_tool_call_content()
148
+ self.console.print("[bold cyan]--------------------------------[/bold cyan]")
93
149
  self.inside_tool_call = False
94
150
  elif self.buffer:
95
151
  if "TASK_DONE" in self.buffer:
llm_interface/llm.py CHANGED
@@ -51,6 +51,7 @@ class LiteLLMInterface:
51
51
  model=self.model_name,
52
52
  messages=messages,
53
53
  stream=True,
54
+ temperature=0.2
54
55
  )
55
56
 
56
57
  for chunk in stream_response:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PikoAi
3
- Version: 0.1.23
3
+ Version: 0.1.25
4
4
  Summary: An AI-powered task automation tool
5
5
  Home-page: https://github.com/nihaaaar22/OS-Assistant
6
6
  Author: Nihar S
@@ -0,0 +1,32 @@
1
+ OpenCopilot.py,sha256=WPorkGh0ffB4m47mXF6Tza47SVqPRCGcQCTeZQTfghY,12355
2
+ cli.py,sha256=2UvmH74pcBFFezI0WHNyWTHMYasIM5NGnrUX6wsdveM,12945
3
+ Agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ Agents/Executor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ Agents/Executor/executor.py,sha256=0mskJv5ol4yPEhQytCJX_7rHzdoJmwI6aIwrUr4blpI,9765
6
+ Agents/Executor/prompts.py,sha256=Q1b7WPdrUXYQZgj7l4M0Exz1Rr9b_SQUpRfV7uZRSkA,3447
7
+ Env/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
8
+ Env/base_env.py,sha256=K4PoWwPXn3pKeu7_-JOlUuyNbyYQ9itMhQybFOm-3K4,1563
9
+ Env/python_executor.py,sha256=g9I2A1vI7eLQJyN_ZByrRDL_yDcPoneCMMxwRXQzNOE,4018
10
+ Env/shell.py,sha256=DuttZymCUM7QNRxIOPBB81bSBcgzH-wQdUADYridRTo,7987
11
+ Env/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ Env/tests/test_python_executor.py,sha256=5kfs0cOf-RgWTOers_1wB0yvYSF-HrHPsraJ-PxgR50,3156
13
+ Env/tests/test_shell_executor.py,sha256=-RcCdSUMoRAXHISIh0IR5MCutco80fX2S3sQBcinc_Q,1034
14
+ Tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
+ Tools/file_task.py,sha256=Sqn8GWB7UHljUmUniYbkTiC_63LkVIVU4aXgudtLNTI,12566
16
+ Tools/system_details.py,sha256=RScVnhTpUOlNG0g5bGnwmtNr5nSJzOec8HJSFpbicds,2651
17
+ Tools/tool_dir.json,sha256=RTawcanxIkJaUys6Y3yftXAT5uxMH0xPZYTtD1ilJl0,3119
18
+ Tools/tool_manager.py,sha256=l_ZEFlPAfnkuz31-pH_pXclgTnxZU3NvVDUT42tHH2A,4109
19
+ Tools/userinp.py,sha256=SK69fMEdUvNQor9V3BVckeDMJcq71g6H6EHPmNfsZD4,834
20
+ Tools/web_loader.py,sha256=N2J_0kl-y-YHwqaoFr7EXppaa4AuhavsrbGvMcFFJNg,5060
21
+ Tools/web_search.py,sha256=12_VhwJGXmn3oUNhTbQ5ENFG964t9DWkfCz3UtlxrbM,2261
22
+ Utils/__init__.py,sha256=oukU0ufroPRd8_N8d2xiFes9CTxSaw4NA6p2nS1kkSg,16
23
+ Utils/executor_utils.py,sha256=ikcgkXFlqM9pr7Jaq4eZj6_5XB48EE52A3b3kMK25ss,1005
24
+ Utils/ter_interface.py,sha256=vB_Gj1vXyTI6iWqUmojb7RBaGcvMJn5hB2vvij76bBY,5852
25
+ llm_interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
+ llm_interface/llm.py,sha256=nnTfzW-wdWoRd_ZtGxCqv33qf5V2uni8nQpzXDN0A0Y,5112
27
+ pikoai-0.1.25.dist-info/licenses/LICENSE,sha256=cELUVOboOAderKFp8bdtcM5VyJi61YH1oDbRhOuoQZw,1067
28
+ pikoai-0.1.25.dist-info/METADATA,sha256=lf9M5nmsN-Qet_v7GpImFd-LWDRXSCgWN6hjaGaAptM,2962
29
+ pikoai-0.1.25.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
+ pikoai-0.1.25.dist-info/entry_points.txt,sha256=xjZnheDymNDnQ0o84R0jZKEITrhNbzQWN-AhqfA_d6s,50
31
+ pikoai-0.1.25.dist-info/top_level.txt,sha256=hWzBNE7UQsuNcENIOksGcJED08k3ZGRRn2X5jnStICU,53
32
+ pikoai-0.1.25.dist-info/RECORD,,
Env/base_executor.py DELETED
@@ -1,24 +0,0 @@
1
- # mostly won't need this. there will be only one base env
2
-
3
- from abc import ABC, abstractmethod
4
-
5
- class BaseExecutor(ABC):
6
- pass
7
- # def __init__(self):
8
- # pass
9
-
10
- # @abstractmethod
11
- # def execute(self, code: str):
12
- # """Executes the given code and returns the output or error."""
13
- # pass
14
-
15
- # def validate_code(self, code: str) -> bool:
16
- # """Basic validation to ensure code is safe to execute. Override for custom rules."""
17
- # # Implement basic checks (e.g., preventing dangerous commands)
18
- # if "import os" in code or "import sys" in code:
19
- # return False # Disallow potentially unsafe imports for security
20
- # return True
21
-
22
- # def handle_error(self, error: Exception) -> str:
23
- # """Handles errors during execution and returns a standardized error message."""
24
- # return f"Execution failed: {str(error)}"
Env/env.py DELETED
@@ -1,5 +0,0 @@
1
- #mostly won't need this. There will be only one base env
2
-
3
- # import base_env from base_env
4
-
5
- # class env(base_env):
Env/js_executor.py DELETED
@@ -1,63 +0,0 @@
1
- import subprocess
2
- import sys
3
-
4
- class JavaScriptExecutor():
5
- def __init__(self):
6
- super().__init__()
7
- self.node_installed = self.check_node_installed()
8
-
9
- def check_node_installed(self) -> bool:
10
- """Checks if Node.js is installed on the system."""
11
- try:
12
- subprocess.run(["node", "-v"], capture_output=True, check=True)
13
- return True
14
- except subprocess.CalledProcessError:
15
- return False
16
- except FileNotFoundError:
17
- return False
18
-
19
- def install_node(self) -> bool:
20
- """Attempts to install Node.js based on the operating system."""
21
- try:
22
- if sys.platform.startswith("linux"):
23
- # Try to install Node.js using apt-get (for Debian/Ubuntu-based systems)
24
- subprocess.run(["sudo", "apt-get", "update"], check=True)
25
- subprocess.run(["sudo", "apt-get", "install", "-y", "nodejs"], check=True)
26
- elif sys.platform == "darwin":
27
- # Try to install Node.js using Homebrew on macOS
28
- subprocess.run(["brew", "install", "node"], check=True)
29
- elif sys.platform == "win32":
30
- # Check if Chocolatey is installed, and install Node.js
31
- subprocess.run(["choco", "install", "nodejs", "-y"], check=True)
32
- else:
33
- return False # Unsupported OS for automatic installation
34
- return True
35
- except subprocess.CalledProcessError:
36
- return False # Installation failed
37
-
38
- def execute(self, code: str) -> str:
39
- """Executes JavaScript code using Node.js and returns the result or an error message."""
40
- # Check if Node.js is installed, attempt installation if not
41
- if not self.node_installed:
42
- if not self.install_node():
43
- return "Node.js is not installed, and automatic installation failed. Please install Node.js manually."
44
-
45
- # Recheck after attempted installation
46
- self.node_installed = self.check_node_installed()
47
- if not self.node_installed:
48
- return "Node.js is required but not installed. Please install Node.js manually."
49
-
50
- # Proceed with code execution if Node.js is available
51
- # if not self.validate_code(code):
52
- # return "Code validation failed: Unsafe code detected."
53
-
54
- try:
55
- result = subprocess.run(
56
- ["node", "-e", code],
57
- capture_output=True,
58
- text=True,
59
- check=True
60
- )
61
- return result.stdout if result.stdout else "Code executed successfully."
62
- except subprocess.CalledProcessError as e:
63
- print(e)
@@ -1,35 +0,0 @@
1
- OpenCopilot.py,sha256=kPTs0-ly84h4dM7AmBlK4uwst5Sj2AM6UAlE3okkD8U,12157
2
- cli.py,sha256=2UvmH74pcBFFezI0WHNyWTHMYasIM5NGnrUX6wsdveM,12945
3
- Agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- Agents/Executor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- Agents/Executor/executor.py,sha256=S83Rc1JVWuGvgnhV_fPMoCp8V4wwitbWy2MO_yV22X4,7212
6
- Agents/Executor/prompts.py,sha256=PNginWQYp5M4juNcmYiUOWlkIP4OU_5tguz5WK7wYQk,3000
7
- Env/__init__.py,sha256=KLe7UcNV5L395SxhMwbYGyu7KPrSNaoV_9QJo3mLop0,196
8
- Env/base_env.py,sha256=K4PoWwPXn3pKeu7_-JOlUuyNbyYQ9itMhQybFOm-3K4,1563
9
- Env/base_executor.py,sha256=awTwJ44CKWV4JO2KUHfHDX0p1Ujw55hlaL5oNYTEW9M,893
10
- Env/env.py,sha256=I3lOoyBJR5QNq3tWk_HVH6ncRx1vnilRYmj7b7h4jic,114
11
- Env/js_executor.py,sha256=tEAg5ho8Pa8LzxUbS1Idau8XuJWZZqPiNlvFPDwGkgc,2690
12
- Env/python_executor.py,sha256=siiR-BivXKlCHoL6Jyb3aSQkHdZXCFMNo3c3rspHllA,4664
13
- Env/shell.py,sha256=DuttZymCUM7QNRxIOPBB81bSBcgzH-wQdUADYridRTo,7987
14
- Env/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- Env/tests/test_python_executor.py,sha256=5kfs0cOf-RgWTOers_1wB0yvYSF-HrHPsraJ-PxgR50,3156
16
- Env/tests/test_shell_executor.py,sha256=-RcCdSUMoRAXHISIh0IR5MCutco80fX2S3sQBcinc_Q,1034
17
- Tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- Tools/file_task.py,sha256=Sqn8GWB7UHljUmUniYbkTiC_63LkVIVU4aXgudtLNTI,12566
19
- Tools/system_details.py,sha256=RScVnhTpUOlNG0g5bGnwmtNr5nSJzOec8HJSFpbicds,2651
20
- Tools/tool_dir.json,sha256=RTawcanxIkJaUys6Y3yftXAT5uxMH0xPZYTtD1ilJl0,3119
21
- Tools/tool_manager.py,sha256=xrjrGmLI1hXqCfALBRBuMFCgXwc7pb5TpKMBH_4tCzs,4106
22
- Tools/userinp.py,sha256=SK69fMEdUvNQor9V3BVckeDMJcq71g6H6EHPmNfsZD4,834
23
- Tools/web_loader.py,sha256=_oP48uwveTaCKU7G5ju2zsJGTcZd1ScXTKOvHDFtZJU,4564
24
- Tools/web_search.py,sha256=12_VhwJGXmn3oUNhTbQ5ENFG964t9DWkfCz3UtlxrbM,2261
25
- Utils/__init__.py,sha256=oukU0ufroPRd8_N8d2xiFes9CTxSaw4NA6p2nS1kkSg,16
26
- Utils/executor_utils.py,sha256=WwK3TKgw_hG_crg7ijRaqfidYnnNXYbbs37vKZRYK-0,491
27
- Utils/ter_interface.py,sha256=8Oe5818MAYC21SfUxtfnV9HQFcQ49z8Q030jjPqNP_g,3889
28
- llm_interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
- llm_interface/llm.py,sha256=Am18eyEFYlgcackuYGz8_Y0L7lQ7SSUCpNAEjcyZaAU,5080
30
- pikoai-0.1.23.dist-info/licenses/LICENSE,sha256=cELUVOboOAderKFp8bdtcM5VyJi61YH1oDbRhOuoQZw,1067
31
- pikoai-0.1.23.dist-info/METADATA,sha256=cV0qBMhVLSwLEcjlVk6Rt1GdyDa2rrOUH8QxwUEGMbM,2962
32
- pikoai-0.1.23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
- pikoai-0.1.23.dist-info/entry_points.txt,sha256=xjZnheDymNDnQ0o84R0jZKEITrhNbzQWN-AhqfA_d6s,50
34
- pikoai-0.1.23.dist-info/top_level.txt,sha256=hWzBNE7UQsuNcENIOksGcJED08k3ZGRRn2X5jnStICU,53
35
- pikoai-0.1.23.dist-info/RECORD,,