|
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: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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') |
|
|
|
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() |
|
|