Spaces:
Runtime error
Runtime error
Update pages/descriptionGen.py
Browse files- pages/descriptionGen.py +11 -8
pages/descriptionGen.py
CHANGED
@@ -13,7 +13,7 @@ prompt_file = "prompt_template.txt"
|
|
13 |
|
14 |
|
15 |
class ProductDescGen(LLMChain):
|
16 |
-
"""LLM Chain specifically for generating multi
|
17 |
|
18 |
@classmethod
|
19 |
def from_llm(
|
@@ -23,7 +23,7 @@ class ProductDescGen(LLMChain):
|
|
23 |
return cls(llm=llm, prompt=prompt, **kwargs)
|
24 |
|
25 |
|
26 |
-
def product_desc_generator(product_name, keywords,
|
27 |
with open(prompt_file, "r") as file:
|
28 |
prompt_template = file.read()
|
29 |
|
@@ -34,7 +34,7 @@ def product_desc_generator(product_name, keywords, OPENAI_API):
|
|
34 |
model_name="gpt-3.5-turbo",
|
35 |
temperature=0.7,
|
36 |
# openai_api_key=OPENAI_API_KEY,
|
37 |
-
openai_api_key=
|
38 |
)
|
39 |
|
40 |
ProductDescGen_chain = ProductDescGen.from_llm(llm=llm, prompt=PROMPT)
|
@@ -49,17 +49,20 @@ def main():
|
|
49 |
"Generate multi-paragraph rich text product descriptions for your products instantly!"
|
50 |
" Provide the product name and keywords related to the product."
|
51 |
)
|
52 |
-
|
53 |
product_name = st.text_input("Product Name", "Nike Shoes")
|
54 |
-
keywords = st.text_input(
|
|
|
|
|
|
|
55 |
|
56 |
if st.button("Generate Description"):
|
57 |
-
|
58 |
-
description = product_desc_generator(product_name, keywords,
|
59 |
st.subheader("Product Description:")
|
60 |
st.text(description)
|
61 |
else:
|
62 |
st.warning("Please provide your OpenAI API Key.")
|
63 |
|
64 |
if __name__ == "__main__":
|
65 |
-
main()
|
|
|
13 |
|
14 |
|
15 |
class ProductDescGen(LLMChain):
|
16 |
+
"""LLM Chain specifically for generating multi-paragraph rich text product description using emojis."""
|
17 |
|
18 |
@classmethod
|
19 |
def from_llm(
|
|
|
23 |
return cls(llm=llm, prompt=prompt, **kwargs)
|
24 |
|
25 |
|
26 |
+
def product_desc_generator(product_name, keywords, openai_api_key):
|
27 |
with open(prompt_file, "r") as file:
|
28 |
prompt_template = file.read()
|
29 |
|
|
|
34 |
model_name="gpt-3.5-turbo",
|
35 |
temperature=0.7,
|
36 |
# openai_api_key=OPENAI_API_KEY,
|
37 |
+
openai_api_key=openai_api_key,
|
38 |
)
|
39 |
|
40 |
ProductDescGen_chain = ProductDescGen.from_llm(llm=llm, prompt=PROMPT)
|
|
|
49 |
"Generate multi-paragraph rich text product descriptions for your products instantly!"
|
50 |
" Provide the product name and keywords related to the product."
|
51 |
)
|
52 |
+
openai_api_key = st.text_input("OpenAI API Key", "your_openai_api_key_here")
|
53 |
product_name = st.text_input("Product Name", "Nike Shoes")
|
54 |
+
keywords = st.text_input(
|
55 |
+
"Keywords (separated by commas)",
|
56 |
+
"black shoes, leather shoes for men, water resistant"
|
57 |
+
)
|
58 |
|
59 |
if st.button("Generate Description"):
|
60 |
+
if openai_api_key:
|
61 |
+
description = product_desc_generator(product_name, keywords, openai_api_key)
|
62 |
st.subheader("Product Description:")
|
63 |
st.text(description)
|
64 |
else:
|
65 |
st.warning("Please provide your OpenAI API Key.")
|
66 |
|
67 |
if __name__ == "__main__":
|
68 |
+
main()
|