|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import requests |
|
import json |
|
import os |
|
import gradio as gr |
|
|
|
url = "https://api.writesonic.com/v2/business/content/chatsonic?engine=premium" |
|
|
|
def main(prompt): |
|
if "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: |
|
payload = { |
|
"enable_google_results": True, |
|
"enable_memory": False, |
|
"history_data": [{"name": "Dawn"}], |
|
"input_text": prompt |
|
} |
|
headers = { |
|
"accept": "application/json", |
|
"content-type": "application/json", |
|
"X-API-KEY": os.environ.get("test") |
|
} |
|
|
|
try: |
|
response = requests.post(url, json=payload, headers=headers) |
|
data = json.loads(response.text) |
|
data = data["message"] |
|
if "ChatSonic" in data: |
|
data = data.replace("ChatSonic","John") |
|
return data |
|
except: |
|
return "Error occured!" |
|
|
|
iface = gr.Interface(fn=main, inputs="text", outputs="text") |
|
iface.launch() |