Update app.py
Browse files
app.py
CHANGED
@@ -33,25 +33,29 @@ import gradio as gr
|
|
33 |
url = "https://api.writesonic.com/v2/business/content/chatsonic?engine=premium"
|
34 |
|
35 |
def main(prompt):
|
36 |
-
|
37 |
-
"
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
55 |
|
56 |
iface = gr.Interface(fn=main, inputs="text", outputs="text")
|
57 |
iface.launch()
|
|
|
33 |
url = "https://api.writesonic.com/v2/business/content/chatsonic?engine=premium"
|
34 |
|
35 |
def main(prompt):
|
36 |
+
if "created you" in prompt or "made you" in prompt or "developed you" in prompt:
|
37 |
+
response = "I was created by Dawn Saju, Alwin Mathew, Sivai Bala, Bryan Godwin and Mohammed Zaim"
|
38 |
+
return response
|
39 |
+
else:
|
40 |
+
payload = {
|
41 |
+
"enable_google_results": True,
|
42 |
+
"enable_memory": False,
|
43 |
+
"history_data": [{"name": "Dawn"}],
|
44 |
+
"input_text": prompt
|
45 |
+
}
|
46 |
+
headers = {
|
47 |
+
"accept": "application/json",
|
48 |
+
"content-type": "application/json",
|
49 |
+
"X-API-KEY": os.environ.get("test")
|
50 |
+
}
|
51 |
+
|
52 |
+
response = requests.post(url, json=payload, headers=headers)
|
53 |
+
data = json.loads(response.text)
|
54 |
+
try:
|
55 |
+
data = data["message"]
|
56 |
+
return data
|
57 |
+
except:
|
58 |
+
return "Error occured"
|
59 |
|
60 |
iface = gr.Interface(fn=main, inputs="text", outputs="text")
|
61 |
iface.launch()
|