Spaces:
Sleeping
Sleeping
import openai | |
import gradio | |
openai.api_key = "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" | |
def generate_product_name(prompt): | |
model_engine = "text-davinci-003" | |
prompt = (f"{prompt} \n\n Generated product names: \n\n") | |
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() | |
return message.replace("\n", ", ") | |
iface = gradio.Interface( | |
fn=generate_product_name, | |
inputs="text", | |
outputs="text", | |
title="Product Name Generator", | |
flagging=False | |
) | |
iface.launch() | |