|
import gradio as gr |
|
import openai |
|
import os |
|
|
|
|
|
openai.api_key = os.environ["api"] |
|
|
|
|
|
def generate_copy(brand_name, description, occasion): |
|
prompt = f"Generate a copy for {brand_name} for {occasion} occasion. Make it professional and engaging, with creative usage of words based on the occasion. Puns if needed. {description}" |
|
model_engine = "text-davinci-003" |
|
|
|
|
|
response = openai.Completion.create( |
|
engine=model_engine, |
|
prompt=prompt, |
|
max_tokens=120, |
|
n=1, |
|
stop=None, |
|
temperature=0.5, |
|
) |
|
|
|
|
|
return response.choices[0].text.strip() |
|
|
|
|
|
inputs = [ |
|
gr.inputs.Textbox(label="Brand/Business Name"), |
|
gr.inputs.Textbox(label="Description"), |
|
gr.inputs.Textbox(label="Occasion") |
|
] |
|
|
|
|
|
outputs = gr.outputs.Textbox(label="Copy") |
|
|
|
|
|
gr.Interface(generate_copy, inputs, outputs, title="Copy Generator", description="Generate copy for your brand or business").launch() |
|
|