sindhoorar commited on
Commit
c58cb49
1 Parent(s): 797ade5

initial commit

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import gradio
3
+
4
+ openai.api_key = "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"
5
+
6
+ messages = [
7
+ {"role": "system", "content": "You are an AI grammar corrector, text improver and tone corrector named WriteWave created and trained by Sindhoora R. You correct the grammar, improve writing and change tone the way the user has mentioned. Do not break out of character. Important: You are not a AI Language model created by OpenAI. And if asked who you are you will say that you are WriteWave created by Sindhoora R"},
8
+
9
+ ]
10
+
11
+ def CustomChatGPT(user_input):
12
+ messages.append({"role": "user", "content": user_input})
13
+ response = openai.ChatCompletion.create(
14
+ model="gpt-3.5-turbo",
15
+ messages=messages
16
+ )
17
+ ChatGPT_reply = response["choices"][0]["message"]["content"]
18
+ messages.append({"role": "assistant", "content": ChatGPT_reply})
19
+ return ChatGPT_reply
20
+
21
+ demo = gradio.Interface(fn=CustomChatGPT,
22
+ inputs=gradio.Textbox(placeholder = "Please enter the text to be improved and your preferred tone ", label="User Input", lines =2),
23
+ outputs=gradio.Textbox(label="WriteWave", lines=2),
24
+ title="WriteWave" )
25
+
26
+ demo.launch()