-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
72 lines (62 loc) · 1.64 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import pyperclip as clip
import time
import wmi
import json2dict as j2d
import google.generativeai as genai
path = None
module = None
# Search Function to search answers with questions
def search(question):
global module
print("Searching")
for i in module:
if i == question:
return module[i]
# Define WMI Batter Class
def battery():
c = wmi.WMI()
battery_info = c.Win32_Battery()[0]
return battery_info
def json():
while True:
event = battery()
# Battery Discharging State
if event.BatteryStatus == 1:
question = str(clip.paste())
ans = str(search(question))
clip.copy(ans)
print("Done")
time.sleep(5)
continue
def gemini(key):
genai.configure(api_key=key)
model = genai.GenerativeModel('gemini-1.5-pro')
chat = model.start_chat(history=[])
while True:
event = battery()
# Battery Discharging State
if event.BatteryStatus == 1:
question = str(clip.paste())
response = chat.send_message(question)
clip.copy(str(response.text))
time.sleep(5)
continue
# Main function
def main():
global path, module
print("""Choose modes:
1. JSON
2. GEMINI""")
mode = int(input("Enter mode: "))
if mode == 1:
path = str(input("Enter Module to be used : "))
module = j2d.load_json(path)
json()
elif mode == 2:
api_key = str(input("Enter API Key: "))
gemini(api_key)
else:
print("Invalid Mode")
# Main
if __name__ == "__main__":
main()