Update generation configuration
(
self,
image_timeout: Optional[int] = None,
video_timeout: Optional[int] = None,
max_retries: Optional[int] = None,
)
| 1425 | return None |
| 1426 | |
| 1427 | async def update_generation_config( |
| 1428 | self, |
| 1429 | image_timeout: Optional[int] = None, |
| 1430 | video_timeout: Optional[int] = None, |
| 1431 | max_retries: Optional[int] = None, |
| 1432 | ): |
| 1433 | """Update generation configuration""" |
| 1434 | async with self._connect(write=True) as db: |
| 1435 | db.row_factory = aiosqlite.Row |
| 1436 | cursor = await db.execute("SELECT * FROM generation_config WHERE id = 1") |
| 1437 | row = await cursor.fetchone() |
| 1438 | current = dict(row) if row else {} |
| 1439 | |
| 1440 | normalized_image_timeout = ( |
| 1441 | image_timeout |
| 1442 | if image_timeout is not None |
| 1443 | else current.get("image_timeout", 300) |
| 1444 | ) |
| 1445 | normalized_video_timeout = ( |
| 1446 | video_timeout |
| 1447 | if video_timeout is not None |
| 1448 | else current.get("video_timeout", 1500) |
| 1449 | ) |
| 1450 | try: |
| 1451 | normalized_max_retries = ( |
| 1452 | max(1, int(max_retries)) |
| 1453 | if max_retries is not None |
| 1454 | else max(1, int(current.get("max_retries", 3))) |
| 1455 | ) |
| 1456 | except Exception: |
| 1457 | normalized_max_retries = 3 |
| 1458 | |
| 1459 | if row: |
| 1460 | await db.execute(""" |
| 1461 | UPDATE generation_config |
| 1462 | SET image_timeout = ?, video_timeout = ?, max_retries = ?, updated_at = CURRENT_TIMESTAMP |
| 1463 | WHERE id = 1 |
| 1464 | """, (normalized_image_timeout, normalized_video_timeout, normalized_max_retries)) |
| 1465 | else: |
| 1466 | await db.execute(""" |
| 1467 | INSERT INTO generation_config (id, image_timeout, video_timeout, max_retries) |
| 1468 | VALUES (1, ?, ?, ?) |
| 1469 | """, (normalized_image_timeout, normalized_video_timeout, normalized_max_retries)) |
| 1470 | await db.commit() |
| 1471 | |
| 1472 | async def get_call_logic_config(self) -> CallLogicConfig: |
| 1473 | """Get token call logic configuration.""" |