added post guards to deck.llm

This commit is contained in:
Luxferre
2025-12-27 12:02:03 +02:00
parent 8d8796b01d
commit c15e8004ce
+3 -3
View File
@@ -86,7 +86,7 @@ class LLMChat:
self.messages = [{"role": "system", "content": self.config.get('system_prompt', '')}]
return (True, "Context cleared")
def guarded_post(url, headers={}, payload={}):
def guarded_post(self, url, headers={}, payload={}):
"""
Performs a POST request trying to bypass possible 429 errors with heuristics.
"""
@@ -106,7 +106,7 @@ class LLMChat:
except:
pass
time.sleep(sleeptime)
return guarded_post(url, headers, payload)
return self.guarded_post(url, headers, payload)
else:
data = response.json()
response.close()
@@ -131,7 +131,7 @@ class LLMChat:
url = f"{self.provider.get('base_url').rstrip('/')}/chat/completions"
try:
response = guarded_post(url, self.headers, payload)
response = self.guarded_post(url, self.headers, payload)
data = response.json()
response.close() # Important for CircuitPython memory
bot_content = data['choices'][0]['message']['content']