mirror of
https://github.com/AstrBotDevs/AstrBot.git
synced 2026-12-01 03:18:51 +08:00
* feat(provider): add OpenAI Decisions API decision provider Add an independent `openai_decision` provider backed by POST /v1/decisions. It reuses DecisionService (ask/choose/yes_no) and never joins the main agent flow. - Map boolean/choice/score questions to predicate/choice/score with generated names; match answers by name, keep full distributions, confidence, fractional scores and the score legend. - Send string state as text and dict/list-of-dict state as input_json; reject state and questions the API cannot express before sending. - Treat refusals and contract violations as DecisionError; reuse the existing timeout, concurrency and retry conventions. - Add the "OpenAI Decisions" config template, manager lazy import, single-string key validation, WebUI support and i18n hints. - Document configuration and supported inputs; System One is unchanged. * fix: clarify OpenAI Decisions model hint * fix(provider): harden OpenAI decision request handling * fix(provider): validate decision score consistency * fix(provider): validate decision question input types * fix(provider): support list state in OpenAI Decisions --------- Co-authored-by: Soulter <905617992@qq.com>
33 lines
889 B
Python
33 lines
889 B
Python
import logging
|
|
|
|
import httpx
|
|
import pytest
|
|
|
|
import astrbot.core.provider.sources.request_retry as request_retry
|
|
from astrbot.core.provider.sources.request_retry import retry_provider_request
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_retry_provider_request_uses_configured_max_retries(monkeypatch, caplog):
|
|
caplog.set_level(logging.WARNING, logger="astrbot")
|
|
monkeypatch.setattr(request_retry, "REQUEST_RETRY_WAIT_MIN_S", 0)
|
|
monkeypatch.setattr(request_retry, "REQUEST_RETRY_WAIT_MAX_S", 0)
|
|
|
|
calls = 0
|
|
|
|
async def request():
|
|
nonlocal calls
|
|
calls += 1
|
|
raise httpx.ConnectError("temporary connection failure")
|
|
|
|
with pytest.raises(httpx.ConnectError):
|
|
await retry_provider_request(
|
|
"Test",
|
|
request,
|
|
max_attempts=2,
|
|
)
|
|
|
|
assert calls == 2
|
|
|
|
assert "temporary connection failure" in caplog.text
|