ag1 / app.py
Abhishek
Update app.py
5a780b3
raw
history blame
874 Bytes
import openai
import gradio
openai.api_key = "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"
def generate_product_name(prompt, num_names=5):
model_engine = "text-davinci-003"
prompt = (f"{prompt} \n\n Generated product names: \n\n")
product_names = []
for _ in range(num_names):
completions = openai.Completion.create(
engine=model_engine,
prompt=prompt,
max_tokens=1024,
n=1,
stop=None,
temperature=0.5,
)
message = completions.choices[0].text.strip()
product_names.append(message)
return product_names
iface = gradio.Interface(
fn=generate_product_name,
inputs=["text", gradio.inputs.Number(default=5, label="Number of product names")],
outputs="text",
title="Product Name Generator",
flagging=False
)
iface.launch()