Spaces:
Runtime error
Runtime error
Commit
·
ade0b61
1
Parent(s):
0e091b6
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio
|
| 2 |
+
import openai
|
| 3 |
+
|
| 4 |
+
openai.api_key = "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"
|
| 5 |
+
|
| 6 |
+
messages = [{"role": "system", "content": "You are a Twitter Tweets experts that specializes in creating viral tweets for start up marketing and update"}]
|
| 7 |
+
|
| 8 |
+
def CustomChatGPT(user_input):
|
| 9 |
+
messages.append({"role": "user", "content": user_input})
|
| 10 |
+
response = openai.ChatCompletion.create(
|
| 11 |
+
model = "gpt-3.5-turbo",
|
| 12 |
+
messages = messages
|
| 13 |
+
)
|
| 14 |
+
ChatGPT_reply = response["choices"][0]["message"]["content"]
|
| 15 |
+
messages.append({"role": "assistant", "content": ChatGPT_reply})
|
| 16 |
+
return ChatGPT_reply
|
| 17 |
+
|
| 18 |
+
demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "Twitter Tweets Pro")
|
| 19 |
+
|
| 20 |
+
demo.launch(share=True)
|