Spaces:
Runtime error
Runtime error
slogan genius
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import gradio as gr
|
3 |
+
import os
|
4 |
+
|
5 |
+
api_key = osgetenv ("OPENAI_API_KEY")
|
6 |
+
client = OpenAI (api_key=api_key)
|
7 |
+
|
8 |
+
messages = [
|
9 |
+
{"role": "system", "content": "You are a helpful and kind AI named Henri, present yourself with your name at the start of your first reply, you are specialized in creating catchy slogan for companies and ask two or three questions after the first query to create the best and tailored slogan for the client, do not answer questions unrelated to slogans."},
|
10 |
+
]
|
11 |
+
|
12 |
+
def chatbot(input):
|
13 |
+
if input:
|
14 |
+
messages.append({"role": "user", "content": input})
|
15 |
+
chat = openai.ChatCompletion.create(
|
16 |
+
model="gpt-3.5-turbo", messages=messages
|
17 |
+
)
|
18 |
+
reply = chat.choices[0].message.content
|
19 |
+
messages.append({"role": "assistant", "content": reply})
|
20 |
+
return reply
|
21 |
+
|
22 |
+
inputs = gr.Textbox(lines=7, label="Chat with Henri")
|
23 |
+
outputs = gr.Textbox(label="Reply")
|
24 |
+
|
25 |
+
gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="Henri: The Slogan Genius",
|
26 |
+
description="Ask for the Perfect Slogan!",
|
27 |
+
theme="soft").launch(share=True)
|