Spaces:
Running
Running
Update main.py
Browse files
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 |
-
|
| 601 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|