Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ benefits = st.sidebar.text_area("Product Benefits", "Benefit 1, Benefit 2, Benef
|
|
27 |
specifications = st.sidebar.text_area("Product Specifications", "Specification 1, Specification 2, Specification 3")
|
28 |
|
29 |
# Select target language for translation
|
30 |
-
target_language = st.sidebar.selectbox("Target Language for Translation", ["
|
31 |
|
32 |
# Main app title and description
|
33 |
st.title("ProductProse - AI Product Description Generator")
|
@@ -46,10 +46,12 @@ if api_key and project_id:
|
|
46 |
client.set.default_project(project_id)
|
47 |
|
48 |
# Tone Selection for Description Customization
|
49 |
-
|
|
|
50 |
|
51 |
# Keyword Input for SEO Optimization
|
52 |
-
|
|
|
53 |
|
54 |
# Step 1: Generate Product Description
|
55 |
st.header("Step 1: Generate Product Description")
|
@@ -75,6 +77,7 @@ if api_key and project_id:
|
|
75 |
with st.spinner("Generating product description..."):
|
76 |
description_response = model.generate_text(prompt=prompt)
|
77 |
st.session_state.generated_description = description_response
|
|
|
78 |
st.success("Product description generated!")
|
79 |
st.write(description_response)
|
80 |
except Exception as e:
|
@@ -115,13 +118,13 @@ if api_key and project_id:
|
|
115 |
|
116 |
# Step 3: Customize Product Description via Chat Interface
|
117 |
st.header("Step 3: Customize Product Description")
|
118 |
-
customization_prompt = st.text_input(
|
119 |
|
120 |
if st.session_state.generated_description and customization_prompt:
|
121 |
if st.button("Customize Description"):
|
122 |
try:
|
123 |
# Customize the description using Granite-13B-Chat
|
124 |
-
prompt = f"Customize the following product description with a {
|
125 |
model = ModelInference(model_id=ModelTypes.GRANITE_13B_CHAT_V2, params={
|
126 |
GenParams.DECODING_METHOD: DecodingMethods.GREEDY,
|
127 |
GenParams.MIN_NEW_TOKENS: 50,
|
|
|
27 |
specifications = st.sidebar.text_area("Product Specifications", "Specification 1, Specification 2, Specification 3")
|
28 |
|
29 |
# Select target language for translation
|
30 |
+
target_language = st.sidebar.selectbox("Target Language for Translation", ["French", "Spanish", "German", "Chinese", "Japanese"])
|
31 |
|
32 |
# Main app title and description
|
33 |
st.title("ProductProse - AI Product Description Generator")
|
|
|
46 |
client.set.default_project(project_id)
|
47 |
|
48 |
# Tone Selection for Description Customization
|
49 |
+
tone_example = st.sidebar.selectbox("Select Example Tone (Feel free to modify)", ["Formal", "Casual", "Professional", "Playful"])
|
50 |
+
st.sidebar.markdown("_Example: You can choose a tone that best fits your brand's style._")
|
51 |
|
52 |
# Keyword Input for SEO Optimization
|
53 |
+
seo_keywords_example = st.sidebar.text_area("SEO Keywords (comma-separated, e.g., 'smart home, automation')", "smart home, intelligent, automation")
|
54 |
+
st.sidebar.markdown("_Example: Add keywords to optimize for search engines._")
|
55 |
|
56 |
# Step 1: Generate Product Description
|
57 |
st.header("Step 1: Generate Product Description")
|
|
|
77 |
with st.spinner("Generating product description..."):
|
78 |
description_response = model.generate_text(prompt=prompt)
|
79 |
st.session_state.generated_description = description_response
|
80 |
+
st.session_state.translated_description = None # Clear previous translations
|
81 |
st.success("Product description generated!")
|
82 |
st.write(description_response)
|
83 |
except Exception as e:
|
|
|
118 |
|
119 |
# Step 3: Customize Product Description via Chat Interface
|
120 |
st.header("Step 3: Customize Product Description")
|
121 |
+
customization_prompt = st.text_input("Customize the product description (Feel free to modify the example tone and SEO keywords)")
|
122 |
|
123 |
if st.session_state.generated_description and customization_prompt:
|
124 |
if st.button("Customize Description"):
|
125 |
try:
|
126 |
# Customize the description using Granite-13B-Chat
|
127 |
+
prompt = f"Customize the following product description with a {tone_example} tone, using the following SEO keywords: {seo_keywords_example}.\nProduct Description:\n{st.session_state.generated_description}\nCustomization Request: {customization_prompt}\nGenerate only the final customized product description."
|
128 |
model = ModelInference(model_id=ModelTypes.GRANITE_13B_CHAT_V2, params={
|
129 |
GenParams.DECODING_METHOD: DecodingMethods.GREEDY,
|
130 |
GenParams.MIN_NEW_TOKENS: 50,
|