Update app.py
Browse files
app.py
CHANGED
|
@@ -1,28 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import openai as ai
|
| 3 |
import os
|
| 4 |
-
import requests
|
| 5 |
|
| 6 |
-
def
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
iface = gr.Interface(fn=
|
| 26 |
iface.launch()
|
| 27 |
|
| 28 |
# import requests
|
|
|
|
| 1 |
+
# import gradio as gr
|
| 2 |
+
# import openai as ai
|
| 3 |
+
# import os
|
| 4 |
+
# import requests
|
| 5 |
+
|
| 6 |
+
# def greet(prompt):
|
| 7 |
+
# if "created you" in prompt or "made you" in prompt or "developed you" in prompt:
|
| 8 |
+
# response = "I was created by Dawn Saju, Alwin Mathew, Sivai Bala, Bryan Godwin and Mohammed Zaim"
|
| 9 |
+
# return response
|
| 10 |
+
# else:
|
| 11 |
+
# ai.api_key = os.environ.get("test")
|
| 12 |
+
# response = ai.Completion.create(
|
| 13 |
+
# engine="text-davinci-003",
|
| 14 |
+
# prompt=prompt,
|
| 15 |
+
# temperature=0,
|
| 16 |
+
# max_tokens=2000,
|
| 17 |
+
# top_p=1,
|
| 18 |
+
# frequency_penalty=0,
|
| 19 |
+
# presence_penalty=0)
|
| 20 |
+
# response = response['choices'][0]['text']
|
| 21 |
+
# response = response.strip()
|
| 22 |
+
# # response = "\n",response,"\n"
|
| 23 |
+
# return response
|
| 24 |
+
|
| 25 |
+
# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 26 |
+
# iface.launch()
|
| 27 |
+
|
| 28 |
+
from revChatGPT.Official import Chatbot
|
| 29 |
import gradio as gr
|
|
|
|
| 30 |
import os
|
|
|
|
| 31 |
|
| 32 |
+
def main(user):
|
| 33 |
+
# def get_input(prompt):
|
| 34 |
+
# """
|
| 35 |
+
# Multi-line input function
|
| 36 |
+
# """
|
| 37 |
+
# # Display the prompt
|
| 38 |
+
# print(prompt, end="")
|
| 39 |
+
|
| 40 |
+
# # Initialize an empty list to store the input lines
|
| 41 |
+
# lines = []
|
| 42 |
+
|
| 43 |
+
# # Read lines of input until the user enters an empty line
|
| 44 |
+
# while True:
|
| 45 |
+
# line = input()
|
| 46 |
+
# if line == "":
|
| 47 |
+
# break
|
| 48 |
+
# lines.append(line)
|
| 49 |
+
|
| 50 |
+
# # Join the lines, separated by newlines, and store the result
|
| 51 |
+
# user_input = "\n".join(lines)
|
| 52 |
+
|
| 53 |
+
# # Return the input
|
| 54 |
+
# return user_input
|
| 55 |
+
|
| 56 |
+
# def chatbot_commands(cmd: str) -> bool:
|
| 57 |
+
# """
|
| 58 |
+
# Handle chatbot commands
|
| 59 |
+
# """
|
| 60 |
+
# if cmd == "!help":
|
| 61 |
+
# print(
|
| 62 |
+
# """
|
| 63 |
+
# !help - Display this message
|
| 64 |
+
# !rollback - Rollback chat history
|
| 65 |
+
# !reset - Reset chat history
|
| 66 |
+
# !exit - Quit chat
|
| 67 |
+
# """
|
| 68 |
+
# )
|
| 69 |
+
# elif cmd == "!exit":
|
| 70 |
+
# exit()
|
| 71 |
+
# elif cmd == "!rollback":
|
| 72 |
+
# chatbot.rollback(1)
|
| 73 |
+
# elif cmd == "!reset":
|
| 74 |
+
# chatbot.reset()
|
| 75 |
+
# else:
|
| 76 |
+
# return False
|
| 77 |
+
# return True
|
| 78 |
+
# Initialize chatbot
|
| 79 |
+
chatbot = Chatbot(api_key=os.environ.get("test2"))
|
| 80 |
+
# Start chat
|
| 81 |
+
while True:
|
| 82 |
+
PROMPT = user
|
| 83 |
+
# if PROMPT.startswith("!"):
|
| 84 |
+
# if chatbot_commands(PROMPT):
|
| 85 |
+
# continue
|
| 86 |
+
response = chatbot.ask(PROMPT)
|
| 87 |
+
print("John: " + response["choices"][0]["text"])
|
| 88 |
+
speak(response["choices"][0]["text"])
|
| 89 |
|
| 90 |
+
iface = gr.Interface(fn=main, inputs="text", outputs="text")
|
| 91 |
iface.launch()
|
| 92 |
|
| 93 |
# import requests
|