Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,54 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import openai as ai
|
3 |
-
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
import requests
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
top_p=1,
|
18 |
-
frequency_penalty=0,
|
19 |
-
presence_penalty=0)
|
20 |
-
response = response['choices'][0]['text']
|
21 |
-
response = response.strip()
|
22 |
-
# response = "\n",response,"\n"
|
23 |
-
return response
|
24 |
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# import gradio as gr
|
2 |
+
# import openai as ai
|
3 |
+
# import os
|
4 |
+
# import requests
|
5 |
+
|
6 |
+
# def greet(prompt):
|
7 |
+
# if "created you" in prompt or "made you" in prompt or "developed you" in prompt:
|
8 |
+
# response = "I was created by Dawn Saju, Alwin Mathew, Sivai Bala, Bryan Godwin and Mohammed Zaim"
|
9 |
+
# return response
|
10 |
+
# else:
|
11 |
+
# ai.api_key = os.environ.get("KEY")
|
12 |
+
# response = ai.Completion.create(
|
13 |
+
# engine="text-davinci-003",
|
14 |
+
# prompt=prompt,
|
15 |
+
# temperature=0,
|
16 |
+
# max_tokens=2000,
|
17 |
+
# top_p=1,
|
18 |
+
# frequency_penalty=0,
|
19 |
+
# presence_penalty=0)
|
20 |
+
# response = response['choices'][0]['text']
|
21 |
+
# response = response.strip()
|
22 |
+
# # response = "\n",response,"\n"
|
23 |
+
# return response
|
24 |
+
|
25 |
+
# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
26 |
+
# iface.launch()
|
27 |
+
|
28 |
import requests
|
29 |
+
import json
|
30 |
+
|
31 |
+
url = "https://api.writesonic.com/v2/business/content/chatsonic?engine=premium"
|
32 |
+
|
33 |
+
def main()
|
34 |
+
user = input("Enter the prompt: ")
|
35 |
|
36 |
+
payload = {
|
37 |
+
"enable_google_results": True,
|
38 |
+
"enable_memory": False,
|
39 |
+
"history_data": [{"name": "Dawn"}],
|
40 |
+
"input_text": user
|
41 |
+
}
|
42 |
+
headers = {
|
43 |
+
"accept": "application/json",
|
44 |
+
"content-type": "application/json",
|
45 |
+
"X-API-KEY": "96b7d0c0-3ab0-43ed-bdb1-220ba5f543d1"
|
46 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
+
response = requests.post(url, json=payload, headers=headers)
|
49 |
+
data = json.loads(response.text)
|
50 |
+
try:
|
51 |
+
data = data{"message"}
|
52 |
+
return data
|
53 |
+
except:
|
54 |
+
return "Error occured"
|