| File was renamed from aigc-director/aigc-claw/backend/tool/vlm_gpt.py |
| | |
| | | import time |
| | | import base64 |
| | | import httpx |
| | | import logging |
| | | from openai import OpenAI |
| | | from typing import Dict, List, Optional |
| | | |
| | | logger = logging.getLogger(__name__) |
| | | |
| | | |
| | | class GPTVLClient: |
| | | """ |
| | |
| | | return response.choices[0].message.content |
| | | |
| | | except Exception as e: |
| | | print(f"GPTVL 请求错误: {e}") |
| | | logger.warning("GPT VLM request failed: %s", e) |
| | | attempts += 1 |
| | | if attempts < self.max_attempts: |
| | | time.sleep(2 * attempts) # 指数退避 |
| | |
| | | else: |
| | | print(f"✗ 返回空结果 ({elapsed:.1f}s)") |
| | | except Exception as e: |
| | | print(f"✗ 失败: {e}") |
| | | print(f"✗ 失败: {e}") |