Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -145,11 +145,8 @@ def page3():
|
|
145 |
file_base64_embeds_product = [embed_base64_for_claude(location) for location in file_locations_for_product]
|
146 |
caption_list_from_claude_product = []
|
147 |
for file_embeds_base64 in file_base64_embeds_product:
|
148 |
-
caption_prompt_st = st.session_state["caption_prompt"].replace(
|
149 |
-
"{{ITEM_CATEGORY}}", st.session_state['product_description']
|
150 |
-
)
|
151 |
caption_from_claude = create_claude_image_request_for_image_captioning(
|
152 |
-
st.session_state["caption_system_prompt"],
|
153 |
caption_list_from_claude_product.append(caption_from_claude)
|
154 |
string_caption_list_product = str(caption_list_from_claude_product)
|
155 |
file_locations_for_others = []
|
@@ -166,11 +163,8 @@ def page3():
|
|
166 |
st.session_state.assistant_initialized = True
|
167 |
caption_list_from_claude = []
|
168 |
for file_embeds_base64 in file_base64_embeds:
|
169 |
-
caption_prompt_st_n = st.session_state["caption_prompt"].replace(
|
170 |
-
"{{ITEM_CATEGORY}}", st.session_state['product_description']
|
171 |
-
)
|
172 |
caption_from_claude = create_claude_image_request_for_image_captioning(
|
173 |
-
st.session_state["caption_system_prompt"],
|
174 |
caption_list_from_claude.append(caption_from_claude)
|
175 |
string_caption_list = str(caption_list_from_claude)
|
176 |
st.session_state["caption_product"] = string_caption_list_product
|
@@ -180,9 +174,11 @@ def page3():
|
|
180 |
f"{st.session_state['shoot_type']}"
|
181 |
product_info = str(string_caption_list_product) + st.session_state['product_info']
|
182 |
updated_prompt_for_claude = st.session_state["system_prompt"].replace(
|
183 |
-
"{{BRAND_DETAILS}}", st.session_state['brand_summary']).replace(
|
184 |
-
"{{PRODUCT_DETAILS}}", product_info
|
|
|
185 |
)
|
|
|
186 |
st.session_state["updated_prompt"] = updated_prompt_for_claude
|
187 |
message_schema_for_claude = [
|
188 |
{
|
@@ -202,13 +198,21 @@ def page3():
|
|
202 |
for idx, campaign in enumerate(campaigns, start=1):
|
203 |
get_model_prompt = extract_data_from_text_xml(campaign, "model_prompt")
|
204 |
get_background_prompt = extract_data_from_text_xml(campaign, "background_prompt")
|
205 |
-
|
206 |
-
|
|
|
|
|
|
|
|
|
207 |
flux_generated_theme_image = []
|
208 |
for concat_prompt in concat_prompt_list:
|
209 |
theme_image = flux_generated_image(concat_prompt)
|
210 |
flux_generated_theme_image.append(theme_image["file_name"])
|
211 |
-
|
|
|
|
|
|
|
|
|
212 |
st.session_state["descriptions"] = concat_prompt_list
|
213 |
st.session_state["claude_context"] = response_from_claude
|
214 |
st.session_state["images"] = flux_generated_theme_image
|
@@ -256,12 +260,21 @@ def page3():
|
|
256 |
for idx, campaign in enumerate(campaigns, start=1):
|
257 |
get_model_prompt = extract_data_from_text_xml(campaign, "model_prompt")
|
258 |
get_background_prompt = extract_data_from_text_xml(campaign, "background_prompt")
|
259 |
-
|
260 |
-
|
|
|
|
|
|
|
|
|
261 |
flux_generated_theme_image = []
|
262 |
for concat_prompt in concat_prompt_list:
|
263 |
theme_image = flux_generated_image(concat_prompt)
|
264 |
flux_generated_theme_image.append(theme_image["file_name"])
|
|
|
|
|
|
|
|
|
|
|
265 |
st.session_state["descriptions"] = concat_prompt_list
|
266 |
st.session_state["claude_context"] = response_from_claude
|
267 |
st.session_state["images"] = flux_generated_theme_image
|
@@ -326,9 +339,9 @@ def page4():
|
|
326 |
user_input = st.chat_input("Type your message here...")
|
327 |
if user_input:
|
328 |
st.session_state["mood_chat_messages"].append({"role": "User", "message": user_input})
|
329 |
-
updated_flux_prompt = prompts["PROMPT_TO_UPDATE_IDEA_OR_MOOD"].
|
330 |
-
|
331 |
-
|
332 |
)
|
333 |
message_schema_for_claude = [
|
334 |
{
|
|
|
145 |
file_base64_embeds_product = [embed_base64_for_claude(location) for location in file_locations_for_product]
|
146 |
caption_list_from_claude_product = []
|
147 |
for file_embeds_base64 in file_base64_embeds_product:
|
|
|
|
|
|
|
148 |
caption_from_claude = create_claude_image_request_for_image_captioning(
|
149 |
+
st.session_state["caption_system_prompt"], st.session_state["caption_prompt"], file_embeds_base64)
|
150 |
caption_list_from_claude_product.append(caption_from_claude)
|
151 |
string_caption_list_product = str(caption_list_from_claude_product)
|
152 |
file_locations_for_others = []
|
|
|
163 |
st.session_state.assistant_initialized = True
|
164 |
caption_list_from_claude = []
|
165 |
for file_embeds_base64 in file_base64_embeds:
|
|
|
|
|
|
|
166 |
caption_from_claude = create_claude_image_request_for_image_captioning(
|
167 |
+
st.session_state["caption_system_prompt"], st.session_state["caption_prompt"], file_embeds_base64)
|
168 |
caption_list_from_claude.append(caption_from_claude)
|
169 |
string_caption_list = str(caption_list_from_claude)
|
170 |
st.session_state["caption_product"] = string_caption_list_product
|
|
|
174 |
f"{st.session_state['shoot_type']}"
|
175 |
product_info = str(string_caption_list_product) + st.session_state['product_info']
|
176 |
updated_prompt_for_claude = st.session_state["system_prompt"].replace(
|
177 |
+
"{{BRAND_DETAILS}}", str(st.session_state['brand_summary'])).replace(
|
178 |
+
"{{PRODUCT_DETAILS}}", str(product_info)).replace(
|
179 |
+
"{{ADDITIONAL_INFO}}", str(additional_info_param_for_prompt)
|
180 |
)
|
181 |
+
print(f"UP PROMPT:{updated_prompt_for_claude}")
|
182 |
st.session_state["updated_prompt"] = updated_prompt_for_claude
|
183 |
message_schema_for_claude = [
|
184 |
{
|
|
|
198 |
for idx, campaign in enumerate(campaigns, start=1):
|
199 |
get_model_prompt = extract_data_from_text_xml(campaign, "model_prompt")
|
200 |
get_background_prompt = extract_data_from_text_xml(campaign, "background_prompt")
|
201 |
+
|
202 |
+
if get_model_prompt and get_background_prompt: # Ensure both prompts exist
|
203 |
+
# Clean and concatenate the prompts
|
204 |
+
concat_prompt_flux = (get_model_prompt.strip() + " " + get_background_prompt.strip()).strip()
|
205 |
+
concat_prompt_list.append(concat_prompt_flux)
|
206 |
+
|
207 |
flux_generated_theme_image = []
|
208 |
for concat_prompt in concat_prompt_list:
|
209 |
theme_image = flux_generated_image(concat_prompt)
|
210 |
flux_generated_theme_image.append(theme_image["file_name"])
|
211 |
+
|
212 |
+
# Debugging: print generated image file names
|
213 |
+
# print(flux_generated_theme_image)
|
214 |
+
|
215 |
+
# Store the session state
|
216 |
st.session_state["descriptions"] = concat_prompt_list
|
217 |
st.session_state["claude_context"] = response_from_claude
|
218 |
st.session_state["images"] = flux_generated_theme_image
|
|
|
260 |
for idx, campaign in enumerate(campaigns, start=1):
|
261 |
get_model_prompt = extract_data_from_text_xml(campaign, "model_prompt")
|
262 |
get_background_prompt = extract_data_from_text_xml(campaign, "background_prompt")
|
263 |
+
|
264 |
+
if get_model_prompt and get_background_prompt: # Ensure both prompts exist
|
265 |
+
# Clean and concatenate the prompts
|
266 |
+
concat_prompt_flux = (get_model_prompt.strip() + " " + get_background_prompt.strip()).strip()
|
267 |
+
concat_prompt_list.append(concat_prompt_flux)
|
268 |
+
|
269 |
flux_generated_theme_image = []
|
270 |
for concat_prompt in concat_prompt_list:
|
271 |
theme_image = flux_generated_image(concat_prompt)
|
272 |
flux_generated_theme_image.append(theme_image["file_name"])
|
273 |
+
|
274 |
+
# Debugging: print generated image file names
|
275 |
+
# print(flux_generated_theme_image)
|
276 |
+
|
277 |
+
# Store the session state
|
278 |
st.session_state["descriptions"] = concat_prompt_list
|
279 |
st.session_state["claude_context"] = response_from_claude
|
280 |
st.session_state["images"] = flux_generated_theme_image
|
|
|
339 |
user_input = st.chat_input("Type your message here...")
|
340 |
if user_input:
|
341 |
st.session_state["mood_chat_messages"].append({"role": "User", "message": user_input})
|
342 |
+
updated_flux_prompt = prompts["PROMPT_TO_UPDATE_IDEA_OR_MOOD"].format(
|
343 |
+
EXISTING_MODEL_BG_PROMPT=model__bg_preference,
|
344 |
+
USER_INSTRUCTIONS=user_input
|
345 |
)
|
346 |
message_schema_for_claude = [
|
347 |
{
|