cortex 0.2.... i think?
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# reasoning.py
|
||||
import os
|
||||
import json
|
||||
import logging
|
||||
from llm.llm_router import call_llm
|
||||
|
||||
|
||||
@@ -9,6 +10,34 @@ from llm.llm_router import call_llm
|
||||
# ============================================================
|
||||
CORTEX_LLM = os.getenv("CORTEX_LLM", "PRIMARY").upper()
|
||||
GLOBAL_TEMP = float(os.getenv("LLM_TEMPERATURE", "0.7"))
|
||||
VERBOSE_DEBUG = os.getenv("VERBOSE_DEBUG", "false").lower() == "true"
|
||||
|
||||
# Logger
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if VERBOSE_DEBUG:
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
# Console handler
|
||||
console_handler = logging.StreamHandler()
|
||||
console_handler.setFormatter(logging.Formatter(
|
||||
'%(asctime)s [REASONING] %(levelname)s: %(message)s',
|
||||
datefmt='%H:%M:%S'
|
||||
))
|
||||
logger.addHandler(console_handler)
|
||||
|
||||
# File handler
|
||||
try:
|
||||
os.makedirs('/app/logs', exist_ok=True)
|
||||
file_handler = logging.FileHandler('/app/logs/cortex_verbose_debug.log', mode='a')
|
||||
file_handler.setFormatter(logging.Formatter(
|
||||
'%(asctime)s [REASONING] %(levelname)s: %(message)s',
|
||||
datefmt='%Y-%m-%d %H:%M:%S'
|
||||
))
|
||||
logger.addHandler(file_handler)
|
||||
logger.debug("VERBOSE_DEBUG mode enabled for reasoning.py - logging to file")
|
||||
except Exception as e:
|
||||
logger.debug(f"VERBOSE_DEBUG mode enabled for reasoning.py - file logging failed: {e}")
|
||||
|
||||
|
||||
async def reason_check(
|
||||
@@ -147,10 +176,26 @@ async def reason_check(
|
||||
# --------------------------------------------------------
|
||||
# Call the LLM using the module-specific backend
|
||||
# --------------------------------------------------------
|
||||
if VERBOSE_DEBUG:
|
||||
logger.debug(f"\n{'='*80}")
|
||||
logger.debug("[REASONING] Full prompt being sent to LLM:")
|
||||
logger.debug(f"{'='*80}")
|
||||
logger.debug(prompt)
|
||||
logger.debug(f"{'='*80}")
|
||||
logger.debug(f"Backend: {CORTEX_LLM}, Temperature: {GLOBAL_TEMP}")
|
||||
logger.debug(f"{'='*80}\n")
|
||||
|
||||
draft = await call_llm(
|
||||
prompt,
|
||||
backend=CORTEX_LLM,
|
||||
temperature=GLOBAL_TEMP,
|
||||
)
|
||||
|
||||
if VERBOSE_DEBUG:
|
||||
logger.debug(f"\n{'='*80}")
|
||||
logger.debug("[REASONING] LLM Response received:")
|
||||
logger.debug(f"{'='*80}")
|
||||
logger.debug(draft)
|
||||
logger.debug(f"{'='*80}\n")
|
||||
|
||||
return draft
|
||||
|
||||
Reference in New Issue
Block a user