This commit is contained in:
zyp
2026-11-02 09:28:08 +08:00
parent e343640105
commit 53ba04606b
56 changed files with 49973 additions and 2 deletions
+3 -2
View File
@@ -27,8 +27,9 @@ class DirectLLMAdapter(AIAdapter):
provider_name = AIProviderName.DIRECT_LLM
def __init__(self, settings: Settings):
def __init__(self, settings: Settings, *, timeout_seconds: float = 60):
self.settings = settings
self.timeout_seconds = timeout_seconds
def ask(self, prompt: str, context: dict[str, Any] | None = None) -> dict[str, Any]:
if not self.settings.direct_llm_api_key:
@@ -46,7 +47,7 @@ class DirectLLMAdapter(AIAdapter):
AIHttpPayloadKey.MODEL: self.settings.direct_llm_model,
AIHttpPayloadKey.MESSAGES: _chat_messages(prompt, context),
}
with httpx.Client(timeout=60, trust_env=False) as client:
with httpx.Client(timeout=self.timeout_seconds, trust_env=False) as client:
response = client.post(url, json=payload, headers=headers)
if response.status_code >= status.HTTP_400_BAD_REQUEST:
raise HTTPException(