Update app.py
Browse files
app.py
CHANGED
|
@@ -1,81 +1,8 @@
|
|
| 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 |
def get_input(var1):
|
|
@@ -103,48 +30,8 @@ def main(user):
|
|
| 103 |
# if chatbot_commands(PROMPT):
|
| 104 |
# continue
|
| 105 |
response = chatbot.ask(PROMPT)
|
| 106 |
-
response =
|
| 107 |
return response
|
| 108 |
|
| 109 |
iface = gr.Interface(fn=main, inputs="text", outputs="text")
|
| 110 |
-
iface.launch()
|
| 111 |
-
|
| 112 |
-
# import requests
|
| 113 |
-
# import json
|
| 114 |
-
# import os
|
| 115 |
-
# import gradio as gr
|
| 116 |
-
|
| 117 |
-
# url = "https://api.writesonic.com/v2/business/content/chatsonic?engine=premium"
|
| 118 |
-
|
| 119 |
-
# def main(prompt):
|
| 120 |
-
# if "created you" in prompt or "made you" in prompt or "developed you" in prompt:
|
| 121 |
-
# response = "I was created by Dawn Saju, Alwin Mathew, Sivai Bala, Bryan Godwin and Mohammed Zaim"
|
| 122 |
-
# return response
|
| 123 |
-
# else:
|
| 124 |
-
# payload = {
|
| 125 |
-
# "enable_google_results": True,
|
| 126 |
-
# "enable_memory": False,
|
| 127 |
-
# "history_data": [{"name": "Dawn"}],
|
| 128 |
-
# "input_text": prompt
|
| 129 |
-
# }
|
| 130 |
-
# headers = {
|
| 131 |
-
# "accept": "application/json",
|
| 132 |
-
# "content-type": "application/json",
|
| 133 |
-
# "X-API-KEY": os.environ.get("test")
|
| 134 |
-
# }
|
| 135 |
-
|
| 136 |
-
# try:
|
| 137 |
-
# response = requests.post(url, json=payload, headers=headers)
|
| 138 |
-
# data = json.loads(response.text)
|
| 139 |
-
# try:
|
| 140 |
-
# data = data["message"]
|
| 141 |
-
# if "ChatSonic" in data:
|
| 142 |
-
# data = data.replace("ChatSonic","John")
|
| 143 |
-
# return data
|
| 144 |
-
# except Exception as e:
|
| 145 |
-
# return "Error occured!"
|
| 146 |
-
# except Exception as e:
|
| 147 |
-
# return e.message
|
| 148 |
-
|
| 149 |
-
# iface = gr.Interface(fn=main, inputs="text", outputs="text")
|
| 150 |
-
# iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
+
import gradio as gr
|
| 3 |
+
os.environ.get("var2")
|
| 4 |
|
| 5 |
def main(user):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
chatbot = Chatbot(api_key=os.environ.get("test2"))
|
| 7 |
# Start chat
|
| 8 |
def get_input(var1):
|
|
|
|
| 30 |
# if chatbot_commands(PROMPT):
|
| 31 |
# continue
|
| 32 |
response = chatbot.ask(PROMPT)
|
| 33 |
+
response = response["choices"][0]["text"]
|
| 34 |
return response
|
| 35 |
|
| 36 |
iface = gr.Interface(fn=main, inputs="text", outputs="text")
|
| 37 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|