PikoAi 0.1.2__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.
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
+ ]
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
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PikoAi
3
- Version: 0.1.2
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
@@ -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_dir.json,sha256=1zF0Z8ATZn5GT5lGq0cGRlBQoh0F655RP_htkZwnJHI,2302
17
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
26
  llm_interface/llm.py,sha256=tI_KDOW14QLWowA7bB3GPe2qjlk0sjS5fBavs9XD1fo,5185
23
- pikoai-0.1.2.dist-info/licenses/LICENSE,sha256=cELUVOboOAderKFp8bdtcM5VyJi61YH1oDbRhOuoQZw,1067
24
- pikoai-0.1.2.dist-info/METADATA,sha256=8m0dTg6SbBwPFM-cOtlKgQ4uRm_8-zqRYqk55kYESFk,2961
25
- pikoai-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
- pikoai-0.1.2.dist-info/entry_points.txt,sha256=QVeDO6N3nO3UScMb2ksusQWPgcVn86vXosgL-8gu6fo,33
27
- pikoai-0.1.2.dist-info/top_level.txt,sha256=_xQTtTA77f_GF7zdtD6C3gMyPP8GqRZvuhOSTVvSePU,47
28
- pikoai-0.1.2.dist-info/RECORD,,
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