import gradio as gr import openai import os # Set up OpenAI API credentials openai.api_key = os.environ["api"] # Define function to generate copy 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" # Use the most advanced and expensive GPT-3 model # Call OpenAI's GPT-3 model to generate the copy response = openai.Completion.create( engine=model_engine, prompt=prompt, max_tokens=120, n=1, stop=None, temperature=0.5, ) # Extract and return the generated copy from the response return response.choices[0].text.strip() # Define inputs using Gradio library inputs = [ gr.inputs.Textbox(label="Brand/Business Name"), gr.inputs.Textbox(label="Description"), gr.inputs.Textbox(label="Occasion") ] # Define outputs using Gradio library outputs = gr.outputs.Textbox(label="Copy") # Define Gradio interface gr.Interface(generate_copy, inputs, outputs, title="Copy Generator", description="Generate copy for your brand or business").launch()