Spaces:
Sleeping
Sleeping
File size: 874 Bytes
06f9e8d 5a780b3 06f9e8d 5a780b3 06f9e8d 5a780b3 06f9e8d 5a780b3 06f9e8d |
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 |
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()
|