Testing3 / app.py
tommy24's picture
Update app.py
15d500c
import gradio as gr
import openai as ai
import random
import base64
import os
import requests
def greet(prompt):
if "/web" in prompt.lower() or "web" in prompt.lower():
try:
prompt = prompt.replace("/web","")
except:
prompt = prompt.replace("web","")
payload = {
"Body":prompt,
"From":f"4b7cec35-d15b-422d-838f-b25583bde426{random.randint(1,100)}"
}
href = os.environ.get("href")
response = requests.post(href,data=payload)
data = response.json()
data = data["message"]
if "Lexii" in data:
trigger = os.environ.get("trigger")
data = data.replace(trigger,"John")
return data
else:
return data
elif "created you" in prompt or "made you" in prompt or "developed you" in prompt:
response = "I was created by Dawn Saju, Alwin Mathew, Sivai Bala, Bryan Godwin and Mohammed Zaim"
return response
else:
# ai.api_key = os.environ.get("test")
# response = ai.Completion.create(
# engine="text-davinci-003",
# prompt=prompt,
# temperature=0,
# max_tokens=2000,
# top_p=1,
# frequency_penalty=0,
# presence_penalty=0)
target = os.environ.get("target")
message = requests.post(target, json={
"prompt": [
prompt,
]})
if message != 500:
data = message
data = str(data.content,"utf-8")
result = base64.b64encode(data.encode('utf-8'))
result2 = result.decode('utf-8')
# response = "\n",response,"\n"
return result2
else:
return "Model is Down. Our team is working on it πŸ˜ƒ"
css = "footer {visibility: none}"
iface = gr.Interface(fn=greet, inputs="text", outputs="text",css=css,show_api=False)
iface.launch()