Implement logging strategy (#444)

* Logging strategy and convert all prints() to logging invocations
This commit is contained in:
cybermaggedon 2025-07-30 23:18:38 +01:00 committed by GitHub
parent 3e0651222b
commit dd70aade11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
117 changed files with 1216 additions and 667 deletions

View file

@ -3,6 +3,10 @@ import ibis
import json
from jsonschema import validate
import re
import logging
# Module logger
logger = logging.getLogger(__name__)
class PromptConfiguration:
def __init__(self, system_template, global_terms={}, prompts={}):
@ -101,7 +105,7 @@ class PromptManager:
async def invoke(self, id, input, llm):
print("Invoke...", flush=True)
logger.debug("Invoking prompt template...")
terms = self.terms | self.prompts[id].terms | input
@ -123,13 +127,13 @@ class PromptManager:
try:
obj = self.parse_json(resp)
except:
print("Parse fail:", resp, flush=True)
logger.error(f"JSON parse failed: {resp}")
raise RuntimeError("JSON parse fail")
if self.prompts[id].schema:
try:
validate(instance=obj, schema=self.prompts[id].schema)
print("Validated", flush=True)
logger.debug("Schema validation successful")
except Exception as e:
raise RuntimeError(f"Schema validation fail: {e}")