PikoAi 0.1.0__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.
- Agents/Executor/__init__.py +0 -0
- Agents/Executor/executor.py +242 -0
- Agents/Executor/prompts.py +99 -0
- Agents/__init__.py +0 -0
- Env/__init__.py +5 -0
- Env/base_env.py +44 -0
- Env/base_executor.py +24 -0
- Env/env.py +5 -0
- Env/js_executor.py +63 -0
- Env/python_executor.py +96 -0
- Env/shell.py +55 -0
- Tools/__init__.py +0 -0
- Tools/file_task.py +240 -0
- Tools/system_details.py +76 -0
- Tools/tool_manager.py +51 -0
- Tools/userinp.py +34 -0
- Tools/web_loader.py +173 -0
- Tools/web_search.py +30 -0
- llm_interface/__init__.py +0 -0
- llm_interface/llm.py +148 -0
- pikoai-0.1.0.dist-info/METADATA +101 -0
- pikoai-0.1.0.dist-info/RECORD +26 -0
- pikoai-0.1.0.dist-info/WHEEL +5 -0
- pikoai-0.1.0.dist-info/entry_points.txt +2 -0
- pikoai-0.1.0.dist-info/licenses/LICENSE +21 -0
- pikoai-0.1.0.dist-info/top_level.txt +4 -0
llm_interface/llm.py
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
#simple interface for now. will integrate will other models to make orchestration simpler.For
|
2
|
+
# faster tasks you can do with lighter models
|
3
|
+
from dotenv import load_dotenv
|
4
|
+
import os
|
5
|
+
# from groq import Groq # Commented out
|
6
|
+
# from openai import OpenAI # Commented out
|
7
|
+
import sys
|
8
|
+
import json
|
9
|
+
import litellm # Added import for litellm
|
10
|
+
|
11
|
+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../')))
|
12
|
+
|
13
|
+
from Src.Utils.ter_interface import TerminalInterface
|
14
|
+
|
15
|
+
|
16
|
+
# Load environment variables from .env file
|
17
|
+
load_dotenv()
|
18
|
+
|
19
|
+
# Accessing an environment variable
|
20
|
+
|
21
|
+
# from mistralai import Mistral # Commented out
|
22
|
+
|
23
|
+
# def get_model_name(): # Commented out as logic moved to LiteLLMInterface.load_config()
|
24
|
+
# config_path = os.path.join(os.path.dirname(__file__), '../../config.json')
|
25
|
+
# with open(config_path, "r") as config_file:
|
26
|
+
# config = json.load(config_file)
|
27
|
+
# return config.get("model_name", "mistral-large-latest")
|
28
|
+
|
29
|
+
class LiteLLMInterface:
|
30
|
+
def __init__(self):
|
31
|
+
self.terminal = TerminalInterface()
|
32
|
+
self.model_name = self.load_config()
|
33
|
+
|
34
|
+
def load_config(self):
|
35
|
+
config_path = os.path.join(os.path.dirname(__file__), '../../config.json')
|
36
|
+
try:
|
37
|
+
with open(config_path, "r") as config_file:
|
38
|
+
config = json.load(config_file)
|
39
|
+
return config.get("model_name", "gpt-3.5-turbo") # Default to gpt-3.5-turbo
|
40
|
+
except FileNotFoundError:
|
41
|
+
print(f"Warning: Config file not found at {config_path}. Defaulting model to gpt-3.5-turbo.")
|
42
|
+
return "gpt-3.5-turbo"
|
43
|
+
except json.JSONDecodeError:
|
44
|
+
print(f"Warning: Error decoding JSON from {config_path}. Defaulting model to gpt-3.5-turbo.")
|
45
|
+
return "gpt-3.5-turbo"
|
46
|
+
|
47
|
+
def chat(self, messages):
|
48
|
+
response_content = ""
|
49
|
+
try:
|
50
|
+
stream_response = litellm.completion(
|
51
|
+
model=self.model_name,
|
52
|
+
messages=messages,
|
53
|
+
stream=True,
|
54
|
+
)
|
55
|
+
|
56
|
+
for chunk in stream_response:
|
57
|
+
content = chunk.choices[0].delta.content
|
58
|
+
if content:
|
59
|
+
self.terminal.process_markdown_chunk(content)
|
60
|
+
response_content += content
|
61
|
+
|
62
|
+
self.terminal.flush_markdown()
|
63
|
+
return response_content
|
64
|
+
except Exception as e:
|
65
|
+
# litellm maps exceptions to OpenAI exceptions.
|
66
|
+
# The executor should catch these and handle them.
|
67
|
+
print(f"An error occurred during the API call: {e}")
|
68
|
+
self.terminal.flush_markdown() # Ensure terminal is flushed even on error
|
69
|
+
raise # Re-raise the exception to be caught by the executor
|
70
|
+
|
71
|
+
|
72
|
+
# class MistralModel:
|
73
|
+
# def __init__(self):
|
74
|
+
# api_key = os.environ.get('MISTRAL_API_KEY')
|
75
|
+
# self.client = Mistral(api_key=api_key)
|
76
|
+
# self.terminal = TerminalInterface()
|
77
|
+
# self.model_name = get_model_name()
|
78
|
+
|
79
|
+
# def chat(self, messages):
|
80
|
+
|
81
|
+
# response = ""
|
82
|
+
# stream_response = self.client.chat.stream(
|
83
|
+
# model=self.model_name,
|
84
|
+
# messages=messages,
|
85
|
+
# temperature=0.2,
|
86
|
+
# )
|
87
|
+
|
88
|
+
# for chunk in stream_response:
|
89
|
+
# content = chunk.data.choices[0].delta.content
|
90
|
+
# if content:
|
91
|
+
# self.terminal.process_markdown_chunk(content)
|
92
|
+
# response += content
|
93
|
+
|
94
|
+
# self.terminal.flush_markdown()
|
95
|
+
# return response
|
96
|
+
|
97
|
+
|
98
|
+
# class Groqinference:
|
99
|
+
# def __init__(self):
|
100
|
+
# api_key = os.environ.get('GROQ_API_KEY')
|
101
|
+
# self.client = Groq(
|
102
|
+
# api_key=api_key,
|
103
|
+
# )
|
104
|
+
# self.model_name = get_model_name()
|
105
|
+
|
106
|
+
# def chat(self, messages):
|
107
|
+
# chat_completion = self.client.chat.completions.create(
|
108
|
+
# messages=messages,
|
109
|
+
# model=self.model_name,
|
110
|
+
# )
|
111
|
+
# return chat_completion
|
112
|
+
|
113
|
+
# class OpenAi:
|
114
|
+
# def __init__(self):
|
115
|
+
# api_key = os.environ.get('OPENAI_API_KEY')
|
116
|
+
# self.client = OpenAI(api_key=api_key)
|
117
|
+
# self.terminal = TerminalInterface()
|
118
|
+
# self.model_name = get_model_name()
|
119
|
+
|
120
|
+
# def chat(self, messages):
|
121
|
+
# response = ""
|
122
|
+
# stream = self.client.chat.completions.create(
|
123
|
+
# model=self.model_name,
|
124
|
+
# messages=messages,
|
125
|
+
# stream=True
|
126
|
+
# )
|
127
|
+
|
128
|
+
# for chunk in stream:
|
129
|
+
# content = chunk.choices[0].delta.content
|
130
|
+
# if content is not None:
|
131
|
+
# self.terminal.process_markdown_chunk(content)
|
132
|
+
# response += content
|
133
|
+
|
134
|
+
# self.terminal.flush_markdown()
|
135
|
+
# return response
|
136
|
+
|
137
|
+
# for groq
|
138
|
+
# print(chat_completion.choices[0].message.content)
|
139
|
+
|
140
|
+
# # Iterate over the stream and store chunks
|
141
|
+
# for chunk in stream_response:
|
142
|
+
# content = chunk.data.choices[0].delta.content
|
143
|
+
# print(content, end="") # Print in real-time
|
144
|
+
# full_response += content # Append to the full response
|
145
|
+
|
146
|
+
# # Now `full_response` contains the complete response
|
147
|
+
# # Perform operations on the complete response
|
148
|
+
# print("\n\nFull response captured:")
|
@@ -0,0 +1,101 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: PikoAi
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: An AI-powered task automation tool
|
5
|
+
Home-page: https://github.com/nihaaaar22/OS-Assistant
|
6
|
+
Author: Nihar S
|
7
|
+
Author-email: nihar.sr22@gmail.com
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
10
|
+
Classifier: Operating System :: OS Independent
|
11
|
+
Requires-Python: >=3.8
|
12
|
+
Description-Content-Type: text/markdown
|
13
|
+
License-File: LICENSE
|
14
|
+
Requires-Dist: python-dotenv>=1.0.1
|
15
|
+
Requires-Dist: openai>=1.58.1
|
16
|
+
Requires-Dist: groq>=0.22.0
|
17
|
+
Requires-Dist: requests>=2.32.3
|
18
|
+
Requires-Dist: pdfplumber>=0.11.4
|
19
|
+
Requires-Dist: beautifulsoup4>=4.13.4
|
20
|
+
Requires-Dist: duckduckgo_search>=7.4.2
|
21
|
+
Requires-Dist: rich>=13.9.4
|
22
|
+
Requires-Dist: mistralai>=1.2.5
|
23
|
+
Requires-Dist: click>=8.1.8
|
24
|
+
Requires-Dist: httpx>=0.28.1
|
25
|
+
Requires-Dist: psutil>=5.9.8
|
26
|
+
Requires-Dist: inquirer>=3.1.3
|
27
|
+
Requires-Dist: litellm
|
28
|
+
Requires-Dist: PyPDF2
|
29
|
+
Requires-Dist: python-docx
|
30
|
+
Dynamic: author
|
31
|
+
Dynamic: author-email
|
32
|
+
Dynamic: classifier
|
33
|
+
Dynamic: description
|
34
|
+
Dynamic: description-content-type
|
35
|
+
Dynamic: home-page
|
36
|
+
Dynamic: license-file
|
37
|
+
Dynamic: requires-dist
|
38
|
+
Dynamic: requires-python
|
39
|
+
Dynamic: summary
|
40
|
+
|
41
|
+
<p align="center">
|
42
|
+
<img src="https://www.python.org/static/community_logos/python-logo-master-v3-TM.png" alt="Python 3.8+" width="200"/>
|
43
|
+
</p>
|
44
|
+
|
45
|
+
# TaskAutomator
|
46
|
+
|
47
|
+
**Empower your terminal with AI!**
|
48
|
+
|
49
|
+
Just type `ocp` and open a chat with your companion, your copilot. It will search the internet for you, scrape information from sites, help you with projects, do research, and much more. Your system just became a lot more capable. You now have a companion.
|
50
|
+
|
51
|
+
---
|
52
|
+
|
53
|
+
## 🚀 Core Features
|
54
|
+
|
55
|
+
- **LLM-Powered Task Automation:** Utilizes LLMs to understand prompts and orchestrate task execution.
|
56
|
+
- **Multi-Provider Support:** Seamlessly switch between LLM providers like Mistral, Groq, and OpenAI.
|
57
|
+
- **Extensible Tool System:** Equip agents with custom tools to interact with various environments and APIs.
|
58
|
+
- **Flexible Execution Modes:**
|
59
|
+
- **Conversational Mode:** Engage in an interactive dialogue to accomplish tasks.
|
60
|
+
- **One-Shot Task Execution:** Directly execute specific tasks with a single command.
|
61
|
+
- **User-Friendly CLI:** A command-line interface to manage configurations, tools, and task execution.
|
62
|
+
|
63
|
+
---
|
64
|
+
|
65
|
+
## 🛠️ Getting Started
|
66
|
+
|
67
|
+
### **Prerequisites**
|
68
|
+
- 
|
69
|
+
|
70
|
+
### **Installation**
|
71
|
+
Install using pip:
|
72
|
+
|
73
|
+
```bash
|
74
|
+
pip install ocp
|
75
|
+
```
|
76
|
+
|
77
|
+
---
|
78
|
+
|
79
|
+
## ⚡ One-Shot Task Execution
|
80
|
+
|
81
|
+
```bash
|
82
|
+
ocp --task "Your task description here"
|
83
|
+
```
|
84
|
+
|
85
|
+
You can set the maximum number of iterations for a task:
|
86
|
+
|
87
|
+
```bash
|
88
|
+
ocp --task "Your task description here" --max-iter 5
|
89
|
+
```
|
90
|
+
|
91
|
+
---
|
92
|
+
|
93
|
+
## 🤝 Contributing
|
94
|
+
|
95
|
+
We welcome contributions! Please feel free to fork the repository, make your changes, and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.
|
96
|
+
|
97
|
+
---
|
98
|
+
|
99
|
+
## 📄 License
|
100
|
+
|
101
|
+
This project is licensed under the terms of the LICENSE file
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
Agents/Executor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
Agents/Executor/executor.py,sha256=OpaZCTVl9o0WcOM50Y4W-4RR6XClwlY1OTUwwhZxsh8,12516
|
4
|
+
Agents/Executor/prompts.py,sha256=wLS3lPAYWjeKF02LzJ8vP5bZ2VQrMJUd4A7rBfl6qSQ,3846
|
5
|
+
Env/__init__.py,sha256=KLe7UcNV5L395SxhMwbYGyu7KPrSNaoV_9QJo3mLop0,196
|
6
|
+
Env/base_env.py,sha256=ORM6U5qwj7cTuSHFtSmCSsE0cl6pZ28D97CEyyFnucI,1323
|
7
|
+
Env/base_executor.py,sha256=awTwJ44CKWV4JO2KUHfHDX0p1Ujw55hlaL5oNYTEW9M,893
|
8
|
+
Env/env.py,sha256=I3lOoyBJR5QNq3tWk_HVH6ncRx1vnilRYmj7b7h4jic,114
|
9
|
+
Env/js_executor.py,sha256=tEAg5ho8Pa8LzxUbS1Idau8XuJWZZqPiNlvFPDwGkgc,2690
|
10
|
+
Env/python_executor.py,sha256=KiQxyxLgdEph1iRBLteqYy6KJGE8ag_jxiYJ_-BEEB4,3221
|
11
|
+
Env/shell.py,sha256=gr6czmeuSWtB3xSA9TZN7wnK2BENOuA9zjNttwbxztU,1877
|
12
|
+
Tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
|
+
Tools/file_task.py,sha256=VUhWq_G-SWvGahQo8PG7TOpElHUW3BGLUabrTdJS89o,12151
|
14
|
+
Tools/system_details.py,sha256=7-mTm3CG4NoatHcvcosalEgEcpWlNsCsZ7kuS3y_EmY,2262
|
15
|
+
Tools/tool_manager.py,sha256=ulrFDICPfjDJc7BPTUGdEmJX9Umo0Jnsmz2T05z_a2o,1744
|
16
|
+
Tools/userinp.py,sha256=vUhEj3y1W1_ZFHqo2xQwvqDyeOg3VsisSKTI0EurUH8,1205
|
17
|
+
Tools/web_loader.py,sha256=PyZk2g7WngZT0tCLs9Danx20dYspnaZwy4rlVE9Sx_4,5054
|
18
|
+
Tools/web_search.py,sha256=4EGq1VZqfDgG-_yXTd4_Ha1iEUcR-szdlgRV7oFPru4,1259
|
19
|
+
llm_interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
20
|
+
llm_interface/llm.py,sha256=4ny7punKBXfXfBuYrGpdp7DW2jbhHHksrPkydHSqnxU,5189
|
21
|
+
pikoai-0.1.0.dist-info/licenses/LICENSE,sha256=cELUVOboOAderKFp8bdtcM5VyJi61YH1oDbRhOuoQZw,1067
|
22
|
+
pikoai-0.1.0.dist-info/METADATA,sha256=68B0uut29umBRzeRX7RWE8wqnWVBNPpNDCcHGeCDcMs,2961
|
23
|
+
pikoai-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
24
|
+
pikoai-0.1.0.dist-info/entry_points.txt,sha256=QVeDO6N3nO3UScMb2ksusQWPgcVn86vXosgL-8gu6fo,33
|
25
|
+
pikoai-0.1.0.dist-info/top_level.txt,sha256=BdpmoBrO5mzJyrLfIpeh-gw0SFY9k8V8f2jsnzGsg9c,31
|
26
|
+
pikoai-0.1.0.dist-info/RECORD,,
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 nihaaaar22
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|