mirror of
https://github.com/NCBM/plyngent.git
synced 2026-07-23 05:55:16 +08:00
core/cli: 10 auto-retries with 5/10/15/20 then +10s waits
default_retry_delays builds (5,10,15,20,30,…80) for DEFAULT_MAX_AUTO_RETRIES=10.
This commit is contained in:
@@ -5,7 +5,14 @@ from typing import TYPE_CHECKING, Literal, overload
|
||||
import pytest
|
||||
|
||||
from plyngent.agent import ChatAgent
|
||||
from plyngent.cli.retry import retry_pending_with_retries, run_turn_with_retries, sleep_cancellable
|
||||
from plyngent.cli.retry import (
|
||||
DEFAULT_MAX_AUTO_RETRIES,
|
||||
DEFAULT_RETRY_DELAYS_SECONDS,
|
||||
default_retry_delays,
|
||||
retry_pending_with_retries,
|
||||
run_turn_with_retries,
|
||||
sleep_cancellable,
|
||||
)
|
||||
from plyngent.config.models import DatabaseConfig
|
||||
from plyngent.lmproto.openai_compatible.model import (
|
||||
AssistantChatMessage,
|
||||
@@ -23,6 +30,17 @@ if TYPE_CHECKING:
|
||||
from collections.abc import AsyncIterator
|
||||
|
||||
|
||||
def test_default_retry_delays_schedule() -> None:
|
||||
assert DEFAULT_MAX_AUTO_RETRIES == 10
|
||||
assert default_retry_delays(0) == ()
|
||||
assert default_retry_delays(4) == (5.0, 10.0, 15.0, 20.0)
|
||||
delays = default_retry_delays(10)
|
||||
assert delays[:4] == (5.0, 10.0, 15.0, 20.0)
|
||||
assert delays[4:] == (30.0, 40.0, 50.0, 60.0, 70.0, 80.0)
|
||||
assert delays == DEFAULT_RETRY_DELAYS_SECONDS
|
||||
assert len(DEFAULT_RETRY_DELAYS_SECONDS) == 10
|
||||
|
||||
|
||||
def _response(message: AssistantChatMessage) -> ChatCompletionResponse:
|
||||
return ChatCompletionResponse(
|
||||
id="1",
|
||||
|
||||
Reference in New Issue
Block a user