neotas
commited on
Commit
•
d94573d
1
Parent(s):
6802fca
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import gradio as gr
|
3 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
4 |
+
|
5 |
+
messages = [
|
6 |
+
{"role": "system",
|
7 |
+
"content": "you name is Rebecca and you are a Pepsico call center assistant and your job is to take the order from the customer"}
|
8 |
+
]
|
9 |
+
|
10 |
+
def chatbot(input):
|
11 |
+
if input:
|
12 |
+
messages.append({"role": "user", "content": input})
|
13 |
+
chat = openai.ChatCompletion.create(
|
14 |
+
model="gpt-3.5-turbo",
|
15 |
+
messages=messages,
|
16 |
+
temperature=0.2,
|
17 |
+
max_tokens=320,
|
18 |
+
top_p=1,
|
19 |
+
frequency_penalty=0,
|
20 |
+
presence_penalty=0
|
21 |
+
)
|
22 |
+
reply = chat.choices[0].message.content
|
23 |
+
messages.append({"role": "assistant", "content": reply})
|
24 |
+
return reply
|
25 |
+
|
26 |
+
inputs = gr.inputs.Textbox(lines=7, label="Chat with PepsiCo AI assitant")
|
27 |
+
outputs = gr.outputs.Textbox(label="Reply")
|
28 |
+
|
29 |
+
gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="chatbot",
|
30 |
+
description="Ask anything you want",
|
31 |
+
theme="compact").launch(share=True)
|