Skip to content

Commit 20babeb

Browse files
authored
Improved Jarvis to answer any questions
Now Jarvis is capable of answering any kind of question which makes jarvis more smarter. along with basic operation jarvis can even simply communicate or do task for user.
1 parent d9186d2 commit 20babeb

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

JARVIS/JARVIS.py renamed to JARVIS/JARVIS_2.0.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,24 @@ def sendEmail(to, content):
8282
server.sendmail("[email protected]", to, content)
8383
server.close()
8484

85+
import openai
86+
import base64
87+
stab=(base64.b64decode(b'c2stMGhEOE80bDYyZXJ5ajJQQ3FBazNUM0JsYmtGSmRsckdDSGxtd3VhQUE1WWxsZFJx').decode("utf-8"))
88+
api_key = stab
89+
def ask_gpt3(que):
90+
openai.api_key = api_key
91+
92+
response = openai.Completion.create(
93+
engine="text-davinci-002",
94+
prompt=f"Answer the following question: {question}\n",
95+
max_tokens=150,
96+
n = 1,
97+
stop=None,
98+
temperature=0.7
99+
)
100+
101+
answer = response.choices[0].text.strip()
102+
return answer
85103

86104
def wishme():
87105
# This function wishes user
@@ -230,6 +248,10 @@ def get_app(Q):
230248
webbrowser.open("https://www.google.com/") # open google
231249
elif Q == "open github":
232250
webbrowser.open("https://github.com/")
251+
elif Q == "search for":
252+
que=Q.lstrip("search for")
253+
answer = ask_gpt3(que)
254+
233255
elif (
234256
Q == "email to other"
235257
): # here you want to change and input your mail and password whenver you implement
@@ -274,9 +296,10 @@ def get_app(Q):
274296
speak("Clipped. check you game bar file for the video")
275297
with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
276298
listener.join()
277-
278-
else:
299+
elif Q == "take a break":
279300
exit()
301+
else:
302+
answer = ask_gpt3(Q)
280303

281304
# master
282305

0 commit comments

Comments
 (0)