PikoAi 0.1.1__py3-none-any.whl → 0.1.3__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.
@@ -5,19 +5,19 @@ import os
5
5
  import sys
6
6
  import time
7
7
  sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../')))
8
- from Src.Utils.ter_interface import TerminalInterface
9
- from Src.Utils.executor_utils import parse_tool_call, parse_code, parse_shell_command
10
- from Src.Agents.Executor.prompts import get_system_prompt, get_task_prompt # Import prompts
8
+ from Utils.ter_interface import TerminalInterface
9
+ from Utils.executor_utils import parse_tool_call, parse_code, parse_shell_command
10
+ from Agents.Executor.prompts import get_system_prompt, get_task_prompt # Import prompts
11
11
 
12
12
  from typing import Optional
13
13
  from mistralai.models.sdkerror import SDKError # This might be an issue if LiteLLM doesn't use SDKError
14
14
  # LiteLLM maps exceptions to OpenAI exceptions.
15
15
  # We'll keep it for now and see if errors arise during testing.
16
- from Src.Env import python_executor
17
- from Src.Env.shell import ShellExecutor # Import ShellExecutor
18
- from Src.llm_interface.llm import LiteLLMInterface # Import LiteLLMInterface
16
+ from Env import python_executor
17
+ from Env.shell import ShellExecutor # Import ShellExecutor
18
+ from llm_interface.llm import LiteLLMInterface # Import LiteLLMInterface
19
19
 
20
- from Src.Tools import tool_manager
20
+ from Tools import tool_manager
21
21
 
22
22
  class RateLimiter:
23
23
  def __init__(self, wait_time: float = 5.0, max_retries: int = 3):
OpenCopilot.py CHANGED
@@ -10,7 +10,7 @@ from prompt_toolkit.formatted_text import FormattedText
10
10
  # Add the parent directory to the path to enable imports
11
11
  sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../')))
12
12
 
13
- from Src.Agents.Executor.executor import executor
13
+ from Agents.Executor.executor import executor
14
14
 
15
15
  # sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../')))
16
16
 
Tools/tool_dir.json ADDED
@@ -0,0 +1,74 @@
1
+ [
2
+ {
3
+ "name":"web_loader",
4
+ "summary":"Scrappes the web page and returns it",
5
+ "arguments":{
6
+ "url":"url of the website/webpage to be scrapped"
7
+ }
8
+
9
+ },
10
+ {"name":"web_search",
11
+ "summary":"It does a google search and returns the results. Important for up to date links",
12
+ "arguments":{
13
+ "query":"query that needs to be searched"
14
+ }
15
+ },
16
+ {
17
+ "name": "file_reader",
18
+ "summary": "Reads the content of a specified file and returns it.",
19
+ "arguments": {
20
+ "file_path": "path to the file to read"
21
+ }
22
+ },
23
+ {
24
+ "name": "file_maker",
25
+ "summary": "Creates an empty file at the specified path",
26
+ "arguments": {
27
+ "file_path": "path for the new file"
28
+ }
29
+ },
30
+ {
31
+ "name": "file_writer",
32
+ "summary": "Writes or appends content to a specified file",
33
+ "arguments": {
34
+ "file_path": "path to the file",
35
+ "content": "content to write",
36
+ "append": "boolean, set to true to append (optional, defaults to false)"
37
+ }
38
+ },
39
+ {
40
+ "name": "directory_maker",
41
+ "summary": "Creates a directory at the specified path",
42
+ "arguments": {
43
+ "dir_path": "path for the new directory"
44
+ }
45
+ },
46
+ {
47
+ "name": "get_os_details",
48
+ "summary": "Gets operating system details including system, release, version, machine, and processor information",
49
+ "arguments": {}
50
+ },
51
+ {
52
+ "name": "get_datetime",
53
+ "summary": "Gets current date, time, and timezone information",
54
+ "arguments": {}
55
+ },
56
+ {
57
+ "name": "get_memory_usage",
58
+ "summary": "Gets memory usage details including total, available, used memory and usage percentage",
59
+ "arguments": {}
60
+ },
61
+ {
62
+ "name": "get_cpu_info",
63
+ "summary": "Gets CPU information including core count, frequency, and usage percentage",
64
+ "arguments": {}
65
+ },
66
+ {
67
+ "name": "get_user_input",
68
+ "summary": "Prompts the user for input and returns their response",
69
+ "arguments": {
70
+ "prompt": "The message to display to the user",
71
+ "input_type": "Type of input to validate (text, number, boolean, optional, defaults to text)"
72
+ }
73
+ }
74
+ ]
Tools/tool_manager.py CHANGED
@@ -1,11 +1,12 @@
1
1
  import sys
2
2
  import os
3
+ import json
3
4
  sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../')))
4
- from Src.Tools.web_loader import load_data
5
- from Src.Tools.web_search import web_search
6
- from Src.Tools.file_task import file_reader, file_maker, file_writer, directory_maker
7
- from Src.Tools.system_details import get_os_details, get_datetime, get_memory_usage, get_cpu_info
8
- from Src.Tools.userinp import get_user_input
5
+ from Tools.web_loader import load_data
6
+ from Tools.web_search import web_search
7
+ from Tools.file_task import file_reader, file_maker, file_writer, directory_maker
8
+ from Tools.system_details import get_os_details, get_datetime, get_memory_usage, get_cpu_info
9
+ from Tools.userinp import get_user_input
9
10
 
10
11
  #need to transform it into map of dictionary
11
12
  #name : [function : xyz,description : blah bah]
Utils/__init__.py ADDED
@@ -0,0 +1 @@
1
+ # Utils package
@@ -0,0 +1,33 @@
1
+ import json
2
+ from typing import Optional
3
+
4
+ def parse_tool_call(response: str) -> Optional[dict]:
5
+ """
6
+ Parses a tool call from the response.
7
+ """
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()
10
+ try:
11
+ tool_call = json.loads(tool_call_str)
12
+ return tool_call
13
+ except json.JSONDecodeError:
14
+ return None
15
+ return None
16
+
17
+ def parse_code(response: str) -> Optional[str]:
18
+ """
19
+ Parses code from the response.
20
+ """
21
+ if "<<CODE>>" in response and "<<CODE>>" in response: # There was a typo in the original file, it checked for <<CODE>> twice
22
+ code = response.split("<<CODE>>")[1].split("<<CODE>>")[0].strip()
23
+ return code
24
+ return None
25
+
26
+ def parse_shell_command(response: str) -> Optional[str]:
27
+ """
28
+ Parses a shell command from the response.
29
+ """
30
+ if "<<SHELL_COMMAND>>" in response and "<<END_SHELL_COMMAND>>" in response:
31
+ shell_command = response.split("<<SHELL_COMMAND>>")[1].split("<<END_SHELL_COMMAND>>")[0].strip()
32
+ return shell_command
33
+ return None
Utils/ter_interface.py ADDED
@@ -0,0 +1,152 @@
1
+ #used for terminal logging with panels, colours etc for different types of messages
2
+
3
+ from rich.console import Console
4
+ from rich.panel import Panel
5
+ from rich.text import Text
6
+ from rich.markdown import Markdown
7
+ from rich.syntax import Syntax
8
+
9
+ import json
10
+
11
+ class TerminalInterface:
12
+ def __init__(self):
13
+ self.console = Console()
14
+ # Markdown streaming attributes
15
+ self.buffer = ""
16
+ self.inside_code_block = False
17
+ self.code_lang = ""
18
+ self.code_buffer = ""
19
+ self.inside_tool_call = False
20
+ self.tool_call_buffer = ""
21
+ # Shell command tracking attributes
22
+ self.inside_shell_command = False
23
+ self.shell_command_buffer = ""
24
+
25
+ def tool_output_log(self, message: str, tool_name: str = "Tool"):
26
+ """
27
+ Print a tool output message in a formatted panel.
28
+
29
+ Args:
30
+ message (str): The message to display
31
+ tool_name (str): Name of the tool generating the output
32
+ """
33
+ # Convert message to string if it's not already
34
+ if isinstance(message, dict):
35
+ message = json.dumps(message, indent=2)
36
+ elif not isinstance(message, str):
37
+ message = str(message)
38
+
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
+ # )
45
+ panel = Panel(
46
+ Text(message, style="blue"),
47
+ title=f"[bold green]{tool_name} Output[/bold green]",
48
+ border_style="green"
49
+ )
50
+ self.console.print(panel)
51
+
52
+ def process_markdown_chunk(self, chunk):
53
+ """
54
+ Process a chunk of markdown text, handling code blocks, shell commands, tool calls, and regular markdown.
55
+ Args:
56
+ chunk (str): A piece of markdown text to process
57
+ """
58
+ # Initialize tracking attributes if they don't exist yet
59
+
60
+
61
+ self.buffer += chunk
62
+ while "\n" in self.buffer:
63
+ line, self.buffer = self.buffer.split("\n", 1)
64
+ line_stripped = line.strip()
65
+
66
+ # Handle code blocks
67
+ if line_stripped.startswith("<<CODE>>"):
68
+ if self.inside_code_block:
69
+ # Closing code block
70
+ self.console.print(Syntax(self.code_buffer, "python", theme="bw", line_numbers=False))
71
+ self.inside_code_block = False
72
+ self.code_buffer = ""
73
+ else:
74
+ # Opening code block
75
+ self.inside_code_block = True
76
+ self.code_lang = line_stripped[8:].strip() or "python" # default lang
77
+
78
+ # Handle shell command blocks
79
+ elif line_stripped.startswith("<<SHELL_COMMAND>>"):
80
+ self.inside_shell_command = True
81
+ self.shell_command_buffer = ""
82
+ # Print a styled header for shell commands
83
+ self.console.print("[bold yellow]Shell Command:[/bold yellow]")
84
+
85
+ elif line_stripped.startswith("<<END_SHELL_COMMAND>>"):
86
+ if self.inside_shell_command:
87
+ # Closing shell command block
88
+ self.console.print(Syntax(self.shell_command_buffer.strip(), "bash", theme="monokai", line_numbers=False))
89
+ self.inside_shell_command = False
90
+ self.shell_command_buffer = ""
91
+
92
+ # Handle tool call opening delimiter - be more flexible with whitespace
93
+ elif "<<TOOL_CALL>>" in line_stripped:
94
+ self.inside_tool_call = True
95
+ self.tool_call_buffer = ""
96
+ # Print a styled header for tool calls
97
+ self.console.print("[bold cyan]Tool Call:[/bold cyan]")
98
+
99
+ # Handle tool call closing delimiter - be more flexible with whitespace
100
+ elif "<<END_TOOL_CALL>>" in line_stripped:
101
+ self.console.print(Syntax('{"status": "end_tool_call"}', "json", theme="monokai", line_numbers=False))
102
+ self.console.print("[bold cyan]--------------------------------[/bold cyan]")
103
+ self.inside_tool_call = False
104
+ self.tool_call_buffer = ""
105
+
106
+ # Handle content inside code blocks
107
+ elif self.inside_code_block:
108
+ self.code_buffer += line + "\n"
109
+
110
+ # Handle content inside shell command blocks
111
+ elif self.inside_shell_command:
112
+ self.shell_command_buffer += line + "\n"
113
+
114
+ # Handle content inside tool calls
115
+ elif self.inside_tool_call:
116
+ self.tool_call_buffer += line + "\n"
117
+ # Print the line with styling as it comes in
118
+
119
+
120
+ # Regular markdown content
121
+ else:
122
+ self.console.print(Markdown(line))
123
+
124
+ def flush_markdown(self):
125
+ """
126
+ Flush any remaining markdown content in the buffer.
127
+ """
128
+ if self.inside_code_block:
129
+ self.console.print(Syntax(self.code_buffer, "python", theme="bw", line_numbers=False))
130
+ self.inside_code_block = False
131
+ elif self.inside_shell_command:
132
+ self.console.print(Syntax(self.shell_command_buffer.strip(), "bash", theme="monokai", line_numbers=False))
133
+
134
+ self.inside_shell_command = False
135
+ elif hasattr(self, 'inside_tool_call') and self.inside_tool_call:
136
+ # Handle case where tool call is not properly terminated
137
+ self.console.print(Syntax(self.tool_call_buffer.strip(), "json", theme="monokai", line_numbers=False))
138
+ self.console.print("[bold cyan]End Tool Call (forced)[/bold cyan]")
139
+ self.inside_tool_call = False
140
+ elif self.buffer:
141
+ if "TASK_DONE" in self.buffer:
142
+ self.console.print("━" * 80) # Print a solid line
143
+ else:
144
+ self.console.print(Markdown(self.buffer))
145
+
146
+ self.buffer = ""
147
+ self.code_buffer = ""
148
+ self.shell_command_buffer = ""
149
+ if hasattr(self, 'tool_call_buffer'):
150
+ self.tool_call_buffer = ""
151
+
152
+
llm_interface/llm.py CHANGED
@@ -10,7 +10,7 @@ import litellm # Added import for litellm
10
10
 
11
11
  sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../')))
12
12
 
13
- from Src.Utils.ter_interface import TerminalInterface
13
+ from Utils.ter_interface import TerminalInterface
14
14
 
15
15
 
16
16
  # Load environment variables from .env file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PikoAi
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: An AI-powered task automation tool
5
5
  Home-page: https://github.com/nihaaaar22/OS-Assistant
6
6
  Author: Nihar S
@@ -1,8 +1,8 @@
1
- OpenCopilot.py,sha256=BfAsnIRaruu6naN4OcE2vuJzpIBTQAE0H5f8UQ-v3FU,10695
1
+ OpenCopilot.py,sha256=sey9mzHUtn07aBpG8HyKjOXImoq3OAvNZo1bpXA8XEk,10691
2
2
  cli.py,sha256=o2V_DETYXEiYm6617Xg8rDcAgb0ofmojPvdlOpNHwMY,11809
3
3
  Agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  Agents/Executor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- Agents/Executor/executor.py,sha256=OpaZCTVl9o0WcOM50Y4W-4RR6XClwlY1OTUwwhZxsh8,12516
5
+ Agents/Executor/executor.py,sha256=8p226vZF8MUowWtfIuIcjL3U-2dVfJV4pfQvv47iLnQ,12488
6
6
  Agents/Executor/prompts.py,sha256=wLS3lPAYWjeKF02LzJ8vP5bZ2VQrMJUd4A7rBfl6qSQ,3846
7
7
  Env/__init__.py,sha256=KLe7UcNV5L395SxhMwbYGyu7KPrSNaoV_9QJo3mLop0,196
8
8
  Env/base_env.py,sha256=ORM6U5qwj7cTuSHFtSmCSsE0cl6pZ28D97CEyyFnucI,1323
@@ -14,15 +14,19 @@ Env/shell.py,sha256=gr6czmeuSWtB3xSA9TZN7wnK2BENOuA9zjNttwbxztU,1877
14
14
  Tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  Tools/file_task.py,sha256=VUhWq_G-SWvGahQo8PG7TOpElHUW3BGLUabrTdJS89o,12151
16
16
  Tools/system_details.py,sha256=7-mTm3CG4NoatHcvcosalEgEcpWlNsCsZ7kuS3y_EmY,2262
17
- Tools/tool_manager.py,sha256=ulrFDICPfjDJc7BPTUGdEmJX9Umo0Jnsmz2T05z_a2o,1744
17
+ Tools/tool_dir.json,sha256=1zF0Z8ATZn5GT5lGq0cGRlBQoh0F655RP_htkZwnJHI,2302
18
+ Tools/tool_manager.py,sha256=0i3bd_VxhbpWKLzyfSeYyv_33Z6HmvQDBUxPUxjLYlU,1736
18
19
  Tools/userinp.py,sha256=vUhEj3y1W1_ZFHqo2xQwvqDyeOg3VsisSKTI0EurUH8,1205
19
20
  Tools/web_loader.py,sha256=PyZk2g7WngZT0tCLs9Danx20dYspnaZwy4rlVE9Sx_4,5054
20
21
  Tools/web_search.py,sha256=4EGq1VZqfDgG-_yXTd4_Ha1iEUcR-szdlgRV7oFPru4,1259
22
+ Utils/__init__.py,sha256=oukU0ufroPRd8_N8d2xiFes9CTxSaw4NA6p2nS1kkSg,16
23
+ Utils/executor_utils.py,sha256=eVVxZDcAGxENRV5DhCkgh1AKiJEgfV_1q-iSQNWR5kI,1180
24
+ Utils/ter_interface.py,sha256=Zay9mwyAyKYTNQAKOWXHAa3upo9TWprSf26STiHXk0g,6255
21
25
  llm_interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- llm_interface/llm.py,sha256=4ny7punKBXfXfBuYrGpdp7DW2jbhHHksrPkydHSqnxU,5189
23
- pikoai-0.1.1.dist-info/licenses/LICENSE,sha256=cELUVOboOAderKFp8bdtcM5VyJi61YH1oDbRhOuoQZw,1067
24
- pikoai-0.1.1.dist-info/METADATA,sha256=fWSDED7hFnQxzCMdPn164Zc6amGtETQyDo9HKGLelWo,2961
25
- pikoai-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
- pikoai-0.1.1.dist-info/entry_points.txt,sha256=QVeDO6N3nO3UScMb2ksusQWPgcVn86vXosgL-8gu6fo,33
27
- pikoai-0.1.1.dist-info/top_level.txt,sha256=_xQTtTA77f_GF7zdtD6C3gMyPP8GqRZvuhOSTVvSePU,47
28
- pikoai-0.1.1.dist-info/RECORD,,
26
+ llm_interface/llm.py,sha256=tI_KDOW14QLWowA7bB3GPe2qjlk0sjS5fBavs9XD1fo,5185
27
+ pikoai-0.1.3.dist-info/licenses/LICENSE,sha256=cELUVOboOAderKFp8bdtcM5VyJi61YH1oDbRhOuoQZw,1067
28
+ pikoai-0.1.3.dist-info/METADATA,sha256=rasERryE1ZW_5pKdpqQbrgoJSNe0Z4wqtvmZMfGzgMo,2961
29
+ pikoai-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
+ pikoai-0.1.3.dist-info/entry_points.txt,sha256=QVeDO6N3nO3UScMb2ksusQWPgcVn86vXosgL-8gu6fo,33
31
+ pikoai-0.1.3.dist-info/top_level.txt,sha256=hWzBNE7UQsuNcENIOksGcJED08k3ZGRRn2X5jnStICU,53
32
+ pikoai-0.1.3.dist-info/RECORD,,
@@ -2,5 +2,6 @@ Agents
2
2
  Env
3
3
  OpenCopilot
4
4
  Tools
5
+ Utils
5
6
  cli
6
7
  llm_interface
File without changes