File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 44from fastapi import Depends
55from langchain_mcp_adapters .tools import load_mcp_tools
66from langchain_openai import ChatOpenAI
7+ from langfuse .callback import CallbackHandler
78from sqlalchemy .ext .asyncio import AsyncEngine , create_async_engine
89
910from api .core .agent .persistence import checkpointer_context
@@ -47,3 +48,17 @@ async def setup_graph() -> AsyncGenerator[Resource]:
4748 tools = tools ,
4849 session = session ,
4950 )
51+
52+
53+ def get_langfuse_handler () -> CallbackHandler :
54+
55+ return CallbackHandler (
56+ public_key = settings .langfuse_public_key ,
57+ secret_key = settings .langfuse_secret_key ,
58+ host = settings .langfuse_host ,
59+ session_id = settings .environment ,
60+ environment = settings .environment ,
61+ )
62+
63+
64+ LangfuseHandlerDep = Annotated [CallbackHandler , Depends (get_langfuse_handler )]
You can’t perform that action at this time.
0 commit comments