AIbrahim / scripts /verify_langfuse.py
Ibrahim Kabore
v2.0: Gradio 5 migration, knowledge base consolidation, intelligence upgrades
dea2eaa
Raw
History Blame Contribute Delete
1.65 kB
import sys
import os
import logging
# Configure logging to stdout
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
handlers=[logging.StreamHandler(sys.stdout)]
)
# Add project root to path
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from aibrahim.config import CONFIG
from aibrahim.infra.tracing import TRACER
logger = logging.getLogger("verify_langfuse")
def verify():
logger.info("Starting Langfuse verification...")
# 1. Check Config
logger.info(f"Adding Langfuse public key to config: {CONFIG.langfuse_public_key[:10]}...")
logger.info(f"Tracing enabled in config: {CONFIG.enable_tracing}")
if not CONFIG.enable_tracing:
logger.error("Tracing is NOT enabled in config! Check your .env file keys.")
return
# 2. Check Tracer Initialization
callbacks = TRACER.get_callbacks(["verification-test"])
if callbacks:
logger.info(f"Tracer returned callbacks: {len(callbacks)}")
logger.info("SUCCESS: Langfuse tracer is initialized and ready.")
# Simulate a small LangChain interaction if needed, but the init check is the most important part regarding keys.
# We can also check environment variables were set by the TRACER init
logger.info(f"Env LANGFUSE_PUBLIC_KEY: {os.environ.get('LANGFUSE_PUBLIC_KEY')}")
logger.info(f"Env LANGFUSE_HOST: {os.environ.get('LANGFUSE_HOST')}")
else:
logger.error("FAILURE: Tracer returned no callbacks. Check logs for initialization errors.")
if __name__ == "__main__":
verify()