mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-11-06 04:42:40 +00:00
fix(monitor): read the error frequency for AI context from the real errors table columns
This commit is contained in:
@@ -24,6 +24,9 @@ class OpenAIProvider(AIProvider):
|
||||
"""
|
||||
|
||||
NAME = "openai"
|
||||
# The Monitor gives any rewrite 25 s; a local model behind an
|
||||
# OpenAI-compatible endpoint may need all of it.
|
||||
REQUEST_TIMEOUT_SECONDS = 25
|
||||
REQUIRES_API_KEY = True
|
||||
DEFAULT_API_URL = "https://api.openai.com/v1/chat/completions"
|
||||
DEFAULT_MODELS_URL = "https://api.openai.com/v1/models"
|
||||
@@ -226,7 +229,7 @@ class OpenAIProvider(AIProvider):
|
||||
}
|
||||
|
||||
api_url = self._get_api_url()
|
||||
result = self._make_request(api_url, payload, headers)
|
||||
result = self._make_request(api_url, payload, headers, timeout=self.REQUEST_TIMEOUT_SECONDS)
|
||||
|
||||
try:
|
||||
return result['choices'][0]['message']['content'].strip()
|
||||
|
||||
@@ -20,8 +20,9 @@ class CapturingOpenAIProvider(OpenAIProvider):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.captured_payload = None
|
||||
|
||||
def _make_request(self, url, payload, headers):
|
||||
def _make_request(self, url, payload, headers, timeout=15):
|
||||
self.captured_payload = payload
|
||||
self.captured_timeout = timeout
|
||||
return {"choices": [{"message": {"content": "ok"}}]}
|
||||
|
||||
|
||||
@@ -119,6 +120,14 @@ class OpenAICompatibleModelTests(unittest.TestCase):
|
||||
self.assertNotIn("reasoning_effort", provider.captured_payload)
|
||||
self.assertNotIn("max_completion_tokens", provider.captured_payload)
|
||||
|
||||
def test_a_request_waits_as_long_as_the_monitor_allows_a_rewrite(self):
|
||||
# A local model behind an OpenAI-compatible endpoint is slow; the
|
||||
# request must not give up before the Monitor's own limit.
|
||||
provider = CapturingOpenAIProvider(api_key="token", model="gemma-3-1b-it-Q4_K_M",
|
||||
base_url="http://192.0.2.22:8080/v1")
|
||||
provider.generate("system", "user", max_tokens=100)
|
||||
self.assertEqual(provider.captured_timeout, notification_manager.AI_REWRITE_TIMEOUT_SECONDS)
|
||||
|
||||
def test_official_openai_reasoning_model_still_uses_reasoning_contract(self):
|
||||
provider = CapturingOpenAIProvider(
|
||||
api_key="token",
|
||||
|
||||
Reference in New Issue
Block a user