abhishekt commited on
Commit
84e09dd
·
1 Parent(s): a0cb624
Files changed (1) hide show
  1. app.py +37 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import openai
3
+ import os
4
+
5
+ # Set up OpenAI API credentials
6
+ openai.api_key = os.environ["api"]
7
+
8
+ # Define function to generate copy
9
+ def generate_copy(brand_name, description, occasion):
10
+ prompt = f"Generate a copy for {brand_name} for {occasion} occasion. {description}"
11
+ model_engine = "text-davinci-002" # Use the most advanced and expensive GPT-3 model
12
+
13
+ # Call OpenAI's GPT-3 model to generate the copy
14
+ response = openai.Completion.create(
15
+ engine=model_engine,
16
+ prompt=prompt,
17
+ max_tokens=1024,
18
+ n=1,
19
+ stop=None,
20
+ temperature=0.5,
21
+ )
22
+
23
+ # Extract and return the generated copy from the response
24
+ return response.choices[0].text.strip()
25
+
26
+ # Define inputs using Gradio library
27
+ inputs = [
28
+ gr.inputs.Textbox(label="Brand/Business Name"),
29
+ gr.inputs.Textbox(label="Description"),
30
+ gr.inputs.Dropdown(label="Occasion", choices=["Anniversary", "Birthday", "Holiday", "Other"])
31
+ ]
32
+
33
+ # Define outputs using Gradio library
34
+ outputs = gr.outputs.Textbox(label="Copy")
35
+
36
+ # Define Gradio interface
37
+ gr.Interface(generate_copy, inputs, outputs, title="Copy Generator", description="Generate copy for your brand or business").launch()