removed unnecessary files

This commit is contained in:
2024-08-18 14:27:20 -05:00
parent 3acad2f861
commit a8bda7622e
6 changed files with 2 additions and 296 deletions
-31
View File
@@ -1,31 +0,0 @@
# tools/camera_tool.py
from .base_tool import BaseTool
import picamera
import time
import base64
from io import BytesIO
class CameraTool(BaseTool):
def get_functions(self):
return [{
"name": "take_picture",
"description": "Take a picture using the Raspberry Pi camera",
"parameters": {
"type": "object",
"properties": {},
"required": []
}
}]
def execute(self, function_name, **kwargs):
if function_name == "take_picture":
with picamera.PiCamera() as camera:
camera.resolution = (1024, 768)
camera.start_preview()
# Camera warm-up time
time.sleep(2)
image_stream = BytesIO()
camera.capture(image_stream, 'jpeg')
image_stream.seek(0)
image_base64 = base64.b64encode(image_stream.getvalue()).decode('utf-8')
return f"data:image/jpeg;base64,{image_base64}"
-79
View File
@@ -1,79 +0,0 @@
import os
import openai
import json
from tools.base_tool import BaseTool
class PersonaTool(BaseTool):
def __init__(self):
super().__init__()
self.api_key = os.environ.get("OPENAI_API_KEY")
GPT_4O = "gpt-4o"
GPT_4O_MINI = "gpt-4o-mini"
def generate_response(self, persona_description: str, query: str) -> str:
"""
Makes a call to the OpenAI API using the persona as a system prompt.
Parameters:
persona_description (str): Description of the persona.
query (str): Query to be processed.
Returns:
str: The response generated by the OpenAI API.
"""
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": persona_description},
{"role": "user", "content": query}
]
)
return response.choices[0].message['content']
def get_functions(self):
return json.dumps({
"functions": [
{
"name": "generate_response",
"description": "Generates a response based on a persona description and a user query.",
"parameters": {
"type": "object",
"properties": {
"persona_description": {
"type": "string",
"description": "Description of the persona."
},
"query": {
"type": "string",
"description": "User's query to be processed."
}
},
"required": ["persona_description", "query"]
}
}
]
})
def execute(self, function_name, **kwargs):
if function_name == "generate_response":
return self.generate_response(kwargs.get("persona_description"), kwargs.get("query"))
else:
raise ValueError(f"Function {function_name} not found")
def get_chat_response(client, messages, model):
model_max_tokens = {
GPT_4O: 4096,
GPT_4O_MINI: 16384
}
response = client.chat.completions.create(
model=model,
messages=messages,
function_call="none",
max_tokens=model_max_tokens[model]
)
return response
-49
View File
@@ -1,49 +0,0 @@
# tools/telegram_keyboard_tool.py
from .base_tool import BaseTool
class TelegramKeyboardTool(BaseTool):
def get_functions(self):
return [
{
"name": "create_keyboard",
"description": "Create a Telegram keyboard layout.",
"parameters": {
"type": "object",
"properties": {
"buttons": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "string",
"description": "Text on the button."
},
"description": "A row of buttons."
},
"description": "List of rows of buttons."
}
},
"required": ["buttons"]
}
}
]
def execute(self, function_name, **kwargs):
if function_name == "create_keyboard":
return self._create_keyboard(kwargs.get("buttons"))
else:
return f"Unknown function: {function_name}"
def _create_keyboard(self, buttons):
if not isinstance(buttons, list):
return "Invalid input: 'buttons' must be a list of lists."
keyboard = {
"keyboard": buttons,
"resize_keyboard": True,
"one_time_keyboard": True
}
return keyboard