rairo commited on
Commit
3ff9df9
·
verified ·
1 Parent(s): 5ef257e

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +13 -2
main.py CHANGED
@@ -597,8 +597,19 @@ def approve_project_plan(project_id):
597
  chat = client.chats.create(model=GENERATION_MODEL, config=types.GenerateContentConfig(response_modalities=["Text", "Image"]))
598
  full_resp = chat.send_message([detailed_prompt, pil_image])
599
 
600
- combined_text = "".join(part.text + "\n" for part in full_resp.parts if hasattr(part, 'text') and part.text)
601
- inline_images = [Image.open(BytesIO(part.inline_data.data)) for part in full_resp.parts if hasattr(part, 'inline_data')]
 
 
 
 
 
 
 
 
 
 
 
602
 
603
  tools_section = re.search(r"TOOLS AND MATERIALS:\s*(.*?)\s*STEPS:", combined_text, re.DOTALL).group(1).strip()
604
  steps_section = re.search(r"STEPS:\s*(.*)", combined_text, re.DOTALL).group(1).strip()
 
597
  chat = client.chats.create(model=GENERATION_MODEL, config=types.GenerateContentConfig(response_modalities=["Text", "Image"]))
598
  full_resp = chat.send_message([detailed_prompt, pil_image])
599
 
600
+ # Fix: Access the parts through the correct structure
601
+ gen_parts = full_resp.candidates[0].content.parts
602
+
603
+ combined_text = ""
604
+ inline_images = []
605
+ for part in gen_parts:
606
+ if part.text is not None:
607
+ combined_text += part.text + "\n"
608
+ if part.inline_data is not None:
609
+ img = Image.open(BytesIO(part.inline_data.data))
610
+ inline_images.append(img)
611
+
612
+ combined_text = combined_text.strip()
613
 
614
  tools_section = re.search(r"TOOLS AND MATERIALS:\s*(.*?)\s*STEPS:", combined_text, re.DOTALL).group(1).strip()
615
  steps_section = re.search(r"STEPS:\s*(.*)", combined_text, re.DOTALL).group(1).strip()