Skip to content

Commit

Permalink
feat: Added wifi turn on, off and connect tools
Browse files Browse the repository at this point in the history
  • Loading branch information
onuratakan committed Jul 29, 2024
1 parent 080e826 commit 9f2a48f
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 14 deletions.
62 changes: 60 additions & 2 deletions gpt_computer_assistant/standard_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
import re
from urllib.parse import urljoin
import datetime
import traceback

from .tooler import tool
from .top_bar_wrapper import wrapper
try:
from .tooler import tool
from .top_bar_wrapper import wrapper
except:
from tooler import tool
from top_bar_wrapper import wrapper

_standard_tools_ = {}

Expand Down Expand Up @@ -211,8 +216,61 @@ def get_current_time() -> str:



@register_tool
@wrapper
def turn_off_wifi() -> bool:
"""
Turn off the wifi.
"""
try:
from pywifi import ControlPeripheral
wifi = ControlPeripheral()
wifi.disable()
return True
except:

return False

@register_tool
@wrapper
def turn_on_wifi() -> bool:
"""
Turn on the wifi.
"""
try:
from pywifi import ControlPeripheral
wifi = ControlPeripheral()
wifi.enable()
return True
except:

return False


@register_tool
@wrapper
def connect_wifi(ssid: str, password: str) -> bool:
"""
Connect to the wifi with the given ssid and password.
"""
try:
from pywifi import ControlConnection

# Arguments passed during object instantiation
controller = ControlConnection(wifi_ssid=ssid, wifi_password=password)
controller.wifi_connector()
return True
except:
return False



def get_standard_tools():
print("Tool len", len(_standard_tools_))
last_list = [_standard_tools_[each] for each in _standard_tools_]
return last_list



if __name__ == "__main__":
print(turn_on_wifi())
23 changes: 13 additions & 10 deletions gpt_computer_assistant/top_bar_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ def wrapper(func):
"""A decorator that logs the start and end of the function call."""
@functools.wraps(func)
def wrapped_func(*args, **kwargs):
from .gpt_computer_assistant import the_main_window
try:
from .gpt_computer_assistant import the_main_window

print("GOOGLE-searching")
function_name = "Tool: " + func.__name__
the_main_window.active_border_animation(function_name)
time.sleep(2)
result = func(*args, **kwargs)
the_main_window.deactive_border_animation(function_name)
time.sleep(1)
print("GOOGLE SEARCHİNG COMPLEATES")
print("GOOGLE-searching")
function_name = "Tool: " + func.__name__
the_main_window.active_border_animation(function_name)
time.sleep(2)
result = func(*args, **kwargs)
the_main_window.deactive_border_animation(function_name)
time.sleep(1)
print("GOOGLE SEARCHİNG COMPLEATES")

return result
return result
except:
return func(*args, **kwargs)
return wrapped_func
3 changes: 2 additions & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ google==3.0.0
duckduckgo-search==5.3.0
beautifulsoup4==4.12.3

pytesseract==0.3.10
pytesseract==0.3.10
pywifi-controls==0.7
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -591,4 +591,6 @@ google==3.0.0
duckduckgo-search==5.3.0
beautifulsoup4==4.12.3

pytesseract==0.3.10
pytesseract==0.3.10

pywifi-controls==0.7

0 comments on commit 9f2a48f

Please sign in to comment.