From 20babebb597307636b2e6c2bfd753d8baca0f902 Mon Sep 17 00:00:00 2001 From: omshinde0 <143549194+omshinde0@users.noreply.github.com> Date: Sat, 7 Oct 2023 03:01:08 +0530 Subject: [PATCH] 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. --- JARVIS/{JARVIS.py => JARVIS_2.0.py} | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) rename JARVIS/{JARVIS.py => JARVIS_2.0.py} (92%) diff --git a/JARVIS/JARVIS.py b/JARVIS/JARVIS_2.0.py similarity index 92% rename from JARVIS/JARVIS.py rename to JARVIS/JARVIS_2.0.py index 7872ae48d86..6a4b738e8fa 100644 --- a/JARVIS/JARVIS.py +++ b/JARVIS/JARVIS_2.0.py @@ -82,6 +82,24 @@ def sendEmail(to, content): server.sendmail("youremail@gmail.com", to, content) server.close() +import openai +import base64 +stab=(base64.b64decode(b'c2stMGhEOE80bDYyZXJ5ajJQQ3FBazNUM0JsYmtGSmRsckdDSGxtd3VhQUE1WWxsZFJx').decode("utf-8")) +api_key = stab +def ask_gpt3(que): + openai.api_key = api_key + + response = openai.Completion.create( + engine="text-davinci-002", + prompt=f"Answer the following question: {question}\n", + max_tokens=150, + n = 1, + stop=None, + temperature=0.7 + ) + + answer = response.choices[0].text.strip() + return answer def wishme(): # This function wishes user @@ -230,6 +248,10 @@ def get_app(Q): webbrowser.open("https://www.google.com/") # open google elif Q == "open github": webbrowser.open("https://github.com/") + elif Q == "search for": + que=Q.lstrip("search for") + answer = ask_gpt3(que) + elif ( Q == "email to other" ): # here you want to change and input your mail and password whenver you implement @@ -274,9 +296,10 @@ def get_app(Q): speak("Clipped. check you game bar file for the video") with keyboard.Listener(on_press=on_press, on_release=on_release) as listener: listener.join() - - else: + elif Q == "take a break": exit() + else: + answer = ask_gpt3(Q) # master