File size: 1,234 Bytes
84e09dd
 
 
 
 
 
 
 
 
3752dda
7a5b93f
84e09dd
 
 
 
 
ca6b52c
84e09dd
 
 
 
 
 
 
 
 
 
 
 
3752dda
84e09dd
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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()