File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 1414import tiktoken
1515from botocore .config import Config
1616from fastapi import HTTPException
17+ from langfuse import Langfuse
1718from langfuse .decorators import langfuse_context , observe
1819from starlette .concurrency import run_in_threadpool
1920
5455
5556logger = logging .getLogger (__name__ )
5657
58+ # Explicitly initialize Langfuse client for @observe decorator
59+ # This ensures the consumer and auth check happen at module load time
60+ try :
61+ _langfuse = Langfuse (
62+ debug = DEBUG
63+ )
64+ if DEBUG :
65+ logger .info ("Langfuse client initialized successfully" )
66+ except Exception as e :
67+ logger .warning (f"Failed to initialize Langfuse client: { e } " )
68+ _langfuse = None
69+
5770config = Config (
5871 connect_timeout = 60 , # Connection timeout: 60 seconds
5972 read_timeout = 900 , # Read timeout: 15 minutes (suitable for long streaming responses)
You can’t perform that action at this time.
0 commit comments