Update app.py
Browse files
app.py
CHANGED
|
@@ -1,31 +1,42 @@
|
|
| 1 |
-
import os
|
| 2 |
import gradio as gr
|
| 3 |
-
import
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
chatbot_module = importlib.import_module(var2)
|
| 7 |
-
Chatbot = getattr(chatbot_module, "Chatbot")
|
| 8 |
|
| 9 |
-
def
|
| 10 |
if "/web" in user:
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
return
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
iface = gr.Interface(fn=
|
| 31 |
-
iface.launch()
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import openai as ai
|
| 3 |
+
import os
|
| 4 |
+
import requests
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
def greet(prompt):
|
| 7 |
if "/web" in user:
|
| 8 |
+
payload = {
|
| 9 |
+
"Body":user,
|
| 10 |
+
"From":f"4b7cec35-d15b-422d-838f-b25583bde426{random.randint(1,100)}"
|
| 11 |
+
}
|
| 12 |
+
href = os.environ.get("href")
|
| 13 |
+
response = requests.post(href,data=payload)
|
| 14 |
+
|
| 15 |
+
data = response.json()
|
| 16 |
+
data = data["message"]
|
| 17 |
+
if "Lexii" in data:
|
| 18 |
+
trigger = os.environ.get("trigger")
|
| 19 |
+
data = data.replace(trigger,"John")
|
| 20 |
+
return data
|
| 21 |
+
else:
|
| 22 |
+
return data
|
| 23 |
+
elif "created you" in prompt or "made you" in prompt or "developed you" in prompt:
|
| 24 |
+
response = "I was created by Dawn Saju, Alwin Mathew, Sivai Bala, Bryan Godwin and Mohammed Zaim"
|
| 25 |
+
return response
|
| 26 |
+
else:
|
| 27 |
+
ai.api_key = os.environ.get("test")
|
| 28 |
+
response = ai.Completion.create(
|
| 29 |
+
engine="text-davinci-003",
|
| 30 |
+
prompt=prompt,
|
| 31 |
+
temperature=0,
|
| 32 |
+
max_tokens=2000,
|
| 33 |
+
top_p=1,
|
| 34 |
+
frequency_penalty=0,
|
| 35 |
+
presence_penalty=0)
|
| 36 |
+
response = response['choices'][0]['text']
|
| 37 |
+
response = response.strip()
|
| 38 |
+
# response = "\n",response,"\n"
|
| 39 |
+
return response
|
| 40 |
|
| 41 |
+
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 42 |
+
iface.launch()
|