mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-04 15:39:33 +08:00
Image and video generation hardcode request_timeout (120 s / 60 s) with no catalog override, so slow-but-valid self-hosted backends (e.g. local unified-memory image servers) reliably fail with an opaque 'request error'. Follow the existing voice convention: a per-model 'request_timeout' field in the model catalog, resolved in provider_runtime and bounded centrally. - generation_http: resolve_generation_request_timeout() + shared defaults/bounds - provider_runtime: wire the override into imagegen/videogen resolution - openai_compat + async_task adapters: timeouts now report the limit and point at the setting instead of a generic request error - settings UI: 'Request timeout (seconds)' field for imagegen/videogen models - tests: override/default/invalid resolution + timeout message
47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
"""Resolved runtime configuration for image-generation providers.
|
|
|
|
This dataclass is the read-side adapter between the model catalog
|
|
(``services.imagegen``) and the HTTP adapter. It mirrors the shape of
|
|
:class:`TTSConfig` so a single OpenAI-compatible adapter can cover OpenAI
|
|
DALL·E / gpt-image, Volcengine Ark Seedream and compatible gateways by swapping
|
|
``base_url`` + ``api_key`` + ``model``.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
|
|
from deeptutor.services.generation_http import (
|
|
AUTH_BEARER,
|
|
DEFAULT_IMAGEGEN_REQUEST_TIMEOUT,
|
|
)
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class ImagegenConfig:
|
|
"""Resolved text-to-image configuration for one generation call."""
|
|
|
|
model: str
|
|
provider_name: str = "openai"
|
|
adapter: str = "openai_compat"
|
|
auth_style: str = AUTH_BEARER
|
|
api_key: str = ""
|
|
base_url: str = ""
|
|
api_version: str | None = None
|
|
extra_headers: dict[str, str] = field(default_factory=dict)
|
|
# Provider/model-specific generation knobs. Empty → omit from the request
|
|
# and let the provider use its default.
|
|
size: str = "" # e.g. "1024x1024"
|
|
quality: str = "" # e.g. "standard" | "hd"
|
|
style: str = "" # e.g. "natural" | "vivid"
|
|
response_format: str = "" # "" | "url" | "b64_json"
|
|
# Image generation is slow; allow generous wall-clock per request.
|
|
# Configurable per model via the catalog's ``request_timeout`` field
|
|
# (see resolve_imagegen_runtime_config); this is the unset default.
|
|
request_timeout: int = DEFAULT_IMAGEGEN_REQUEST_TIMEOUT
|
|
poll_interval: float = 2.0
|
|
poll_timeout: int = 300
|
|
|
|
|
|
__all__ = ["ImagegenConfig"]
|