|
13 | 13 | from PIL import Image |
14 | 14 |
|
15 | 15 | from services.account_service import account_service |
| 16 | +from services.config import config |
16 | 17 | from services.proxy_service import proxy_settings |
17 | 18 | from utils.helper import build_chat_image_markdown_content, ensure_ok, new_uuid, parse_sse_lines |
18 | 19 | from utils.log import logger |
@@ -607,7 +608,7 @@ def _poll_image_results(self, conversation_id: str, timeout_secs: float = 120.0) |
607 | 608 | if file_ids: |
608 | 609 | return file_ids, sediment_ids |
609 | 610 | if sediment_ids: |
610 | | - last_sediment_ids = sediment_ids |
| 611 | + return [], sediment_ids |
611 | 612 | time.sleep(4) |
612 | 613 | return [], last_sediment_ids |
613 | 614 |
|
@@ -748,7 +749,7 @@ def _run_image_task(self, prompt: str, model: str, size: str, images: Optional[l |
748 | 749 | conversation_id = sse_result["conversation_id"] |
749 | 750 | file_ids = list(sse_result["file_ids"]) |
750 | 751 | sediment_ids = list(sse_result["sediment_ids"]) |
751 | | - if conversation_id: |
| 752 | + if conversation_id and not file_ids and not sediment_ids: |
752 | 753 | polled_file_ids, polled_sediment_ids = self._poll_image_results(conversation_id) |
753 | 754 | file_ids.extend([item for item in polled_file_ids if item not in file_ids]) |
754 | 755 | sediment_ids.extend([item for item in polled_sediment_ids if item not in sediment_ids]) |
@@ -1019,7 +1020,7 @@ def stream_image_chat_completions( |
1019 | 1020 | finally: |
1020 | 1021 | sse.close() |
1021 | 1022 |
|
1022 | | - if conversation_id: |
| 1023 | + if conversation_id and not file_ids and not sediment_ids: |
1023 | 1024 | polled_file_ids, polled_sediment_ids = self._poll_image_results(conversation_id) |
1024 | 1025 | self._append_unique(file_ids, polled_file_ids) |
1025 | 1026 | self._append_unique(sediment_ids, polled_sediment_ids) |
|
0 commit comments