Spaces:
Sleeping
Sleeping
Abhishek
commited on
Commit
•
06f9e8d
1
Parent(s):
8add1cc
Upload Product Name Generator.py
Browse files- Product Name Generator.py +31 -0
Product Name Generator.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import gradio
|
3 |
+
import pyperclip
|
4 |
+
|
5 |
+
openai.api_key = "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"
|
6 |
+
|
7 |
+
def generate_product_name(prompt):
|
8 |
+
model_engine = "text-davinci-003"
|
9 |
+
prompt = (f"{prompt} \n\n Generated product names: \n\n")
|
10 |
+
|
11 |
+
completions = openai.Completion.create(
|
12 |
+
engine=model_engine,
|
13 |
+
prompt=prompt,
|
14 |
+
max_tokens=1024,
|
15 |
+
n=1,
|
16 |
+
stop=None,
|
17 |
+
temperature=0.5,
|
18 |
+
)
|
19 |
+
|
20 |
+
|
21 |
+
message = completions.choices[0].text.strip()
|
22 |
+
return message
|
23 |
+
|
24 |
+
iface = gradio.Interface(
|
25 |
+
fn=generate_product_name,
|
26 |
+
inputs="text",
|
27 |
+
outputs="text",
|
28 |
+
title="Product Name Generator",
|
29 |
+
flagging=False
|
30 |
+
)
|
31 |
+
iface.launch()
|