Spaces:
Sleeping
Sleeping
File size: 654 Bytes
06f9e8d 95541a6 06f9e8d 95541a6 06f9e8d 44c55dc 06f9e8d 44c55dc 06f9e8d 44c55dc 332520a 06f9e8d 44c55dc 332520a 06f9e8d 332520a |
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 |
import openai
import gradio
import os
openai.api_key = os.environ["api"]
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()
|