Spaces:
Sleeping
Sleeping
StagwellMarketingCloud
commited on
Commit
•
a035bfa
1
Parent(s):
4dbcb5c
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import gradio as gr
|
3 |
+
import os
|
4 |
+
|
5 |
+
openai.api_key = os.environ['api_key']
|
6 |
+
|
7 |
+
messages = [
|
8 |
+
{"role": "system", "content": "You are an AI specialized in Marketing and PR. Do not answer anything other than marketing and pr-related queries."},
|
9 |
+
]
|
10 |
+
|
11 |
+
def chatbot(input):
|
12 |
+
if input:
|
13 |
+
messages.append({"role": "user", "content": input})
|
14 |
+
chat = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=messages )
|
15 |
+
reply = chat.choices[0].message.content
|
16 |
+
messages.append({"role": "assistant", "content": reply})
|
17 |
+
return reply
|
18 |
+
|
19 |
+
inputs = gr.inputs.Textbox(lines=15, label="Post your question below")
|
20 |
+
outputs = gr.outputs.Textbox(label="Reply")
|
21 |
+
|
22 |
+
gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="SMC AI Chatbot",
|
23 |
+
description="I am happy to assist you on anything related to Marketing and PR information",
|
24 |
+
theme="compact").launch()
|