Vorxart commited on
Commit
b00b29e
·
verified ·
1 Parent(s): 79277f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -7
app.py CHANGED
@@ -9,13 +9,15 @@ import os
9
  # Set up page configuration
10
  st.set_page_config(page_title="ProductProse - AI Product Description Generator", layout="wide")
11
 
12
- # Initialize session state to track API responses and query count
13
  if 'generated_description' not in st.session_state:
14
  st.session_state.generated_description = None
15
  if 'translated_description' not in st.session_state:
16
  st.session_state.translated_description = None
17
  if 'customized_description' not in st.session_state:
18
  st.session_state.customized_description = None
 
 
19
 
20
  # Sidebar for product data input
21
  st.sidebar.title("Product Data Input")
@@ -25,7 +27,7 @@ benefits = st.sidebar.text_area("Product Benefits", "Benefit 1, Benefit 2, Benef
25
  specifications = st.sidebar.text_area("Product Specifications", "Specification 1, Specification 2, Specification 3")
26
 
27
  # Select target language for translation
28
- target_language = st.sidebar.selectbox("Target Language for Translation", ["French", "Spanish", "German", "Chinese", "Japanese"])
29
 
30
  # Main app title and description
31
  st.title("ProductProse - AI Product Description Generator")
@@ -43,7 +45,13 @@ if api_key and project_id:
43
  client = APIClient(credentials)
44
  client.set.default_project(project_id)
45
 
46
- # Generate Product Description
 
 
 
 
 
 
47
  st.header("Step 1: Generate Product Description")
48
  if st.button("Generate Description"):
49
  if product_name and features and benefits and specifications:
@@ -74,7 +82,7 @@ if api_key and project_id:
74
  else:
75
  st.warning("Please fill in all the product data fields before generating a description.")
76
 
77
- # Translate Product Description
78
  st.header("Step 2: Translate Product Description")
79
  if st.session_state.generated_description:
80
  if st.button("Translate Description"):
@@ -105,15 +113,15 @@ if api_key and project_id:
105
  st.subheader(f"Translated Product Description ({target_language})")
106
  st.write(st.session_state.translated_description)
107
 
108
- # Customize Product Description via Chat Interface
109
  st.header("Step 3: Customize Product Description")
110
- customization_prompt = st.text_input("Customize the product description (e.g., adjust tone, add brand-specific details)")
111
 
112
  if st.session_state.generated_description and customization_prompt:
113
  if st.button("Customize Description"):
114
  try:
115
  # Customize the description using Granite-13B-Chat
116
- prompt = f"Customize the following product description based on the user's request:\n{st.session_state.generated_description}\nCustomization Request: {customization_prompt}\nGenerate only the final customized product description."
117
  model = ModelInference(model_id=ModelTypes.GRANITE_13B_CHAT_V2, params={
118
  GenParams.DECODING_METHOD: DecodingMethods.GREEDY,
119
  GenParams.MIN_NEW_TOKENS: 50,
@@ -134,5 +142,15 @@ if api_key and project_id:
134
  st.subheader("Customized Product Description")
135
  st.write(st.session_state.customized_description)
136
 
 
 
 
 
 
 
 
 
 
 
137
  else:
138
  st.error("IBM WatsonX API credentials are not set. Please check your environment variables.")
 
9
  # Set up page configuration
10
  st.set_page_config(page_title="ProductProse - AI Product Description Generator", layout="wide")
11
 
12
+ # Initialize session state to track API responses and user feedback
13
  if 'generated_description' not in st.session_state:
14
  st.session_state.generated_description = None
15
  if 'translated_description' not in st.session_state:
16
  st.session_state.translated_description = None
17
  if 'customized_description' not in st.session_state:
18
  st.session_state.customized_description = None
19
+ if 'feedback' not in st.session_state:
20
+ st.session_state.feedback = None
21
 
22
  # Sidebar for product data input
23
  st.sidebar.title("Product Data Input")
 
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", ["Arabic", "Chinese", "French", "German", "Japanese", "Portugese", "Russian", "Spanish", "Urdu"])
31
 
32
  # Main app title and description
33
  st.title("ProductProse - AI Product Description Generator")
 
45
  client = APIClient(credentials)
46
  client.set.default_project(project_id)
47
 
48
+ # Tone Selection for Description Customization
49
+ tone = st.sidebar.selectbox("Select Tone for Description", ["Formal", "Casual", "Professional", "Playful"])
50
+
51
+ # Keyword Input for SEO Optimization
52
+ seo_keywords = st.sidebar.text_area("SEO Keywords (comma-separated)", "smart home, intelligent, automation")
53
+
54
+ # Step 1: Generate Product Description
55
  st.header("Step 1: Generate Product Description")
56
  if st.button("Generate Description"):
57
  if product_name and features and benefits and specifications:
 
82
  else:
83
  st.warning("Please fill in all the product data fields before generating a description.")
84
 
85
+ # Step 2: Translate Product Description
86
  st.header("Step 2: Translate Product Description")
87
  if st.session_state.generated_description:
88
  if st.button("Translate Description"):
 
113
  st.subheader(f"Translated Product Description ({target_language})")
114
  st.write(st.session_state.translated_description)
115
 
116
+ # Step 3: Customize Product Description via Chat Interface
117
  st.header("Step 3: Customize Product Description")
118
+ customization_prompt = st.text_input(f"Customize the product description with a {tone} tone and the following SEO keywords: {seo_keywords}")
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 {tone} tone, using the following SEO keywords: {seo_keywords}.\nProduct Description:\n{st.session_state.generated_description}\nCustomization Request: {customization_prompt}\nGenerate only the final customized product description."
125
  model = ModelInference(model_id=ModelTypes.GRANITE_13B_CHAT_V2, params={
126
  GenParams.DECODING_METHOD: DecodingMethods.GREEDY,
127
  GenParams.MIN_NEW_TOKENS: 50,
 
142
  st.subheader("Customized Product Description")
143
  st.write(st.session_state.customized_description)
144
 
145
+ # Step 4: Feedback and Quality Scoring
146
+ st.header("Step 4: Provide Feedback")
147
+ feedback = st.slider("Rate the quality of the generated product description (1 = Poor, 5 = Excellent)", 1, 5, 3)
148
+ feedback_comments = st.text_area("Additional Comments")
149
+
150
+ if st.button("Submit Feedback"):
151
+ st.session_state.feedback = {"rating": feedback, "comments": feedback_comments}
152
+ st.success("Thank you for your feedback!")
153
+ st.write(st.session_state.feedback)
154
+
155
  else:
156
  st.error("IBM WatsonX API credentials are not set. Please check your environment variables.")