File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed
plot_agent/langgraph_plot_agent Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 2121logger = logging .getLogger (__name__ )
2222# Set logging level to DEBUG for more detailed logs
2323logging .basicConfig (level = logging .DEBUG , format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' )
24-
24+ from langfuse . callback import CallbackHandler
2525from dotenv import load_dotenv
2626
2727load_dotenv ('.env' )
2828
29+ langfuse_handler = CallbackHandler ()
30+
2931# Create plots directory if it doesn't exist
3032PLOTS_DIR = os .path .join (os .path .dirname (os .path .abspath (__file__ )), "plots" )
3133os .makedirs (PLOTS_DIR , exist_ok = True )
@@ -165,7 +167,7 @@ async def process_query(job_id: str, query: str):
165167
166168 try :
167169 # Invoke the agent to get final output
168- final_result = agent .invoke ({"messages" : messages })
170+ final_result = agent .invoke ({"messages" : messages }, config = { "callbacks" : [ langfuse_handler ]} )
169171
170172 logger .debug (f"Agent invocation complete. Processing final result messages..." )
171173
Original file line number Diff line number Diff line change @@ -19,3 +19,4 @@ typing-extensions
1919traceloop-sdk
2020fastapi
2121langchain_community
22+ langfuse
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ anyio==4.9.0
1818 # via
1919 # anthropic
2020 # httpx
21+ # langfuse
2122 # openai
2223 # starlette
2324attrs == 25.3.0
@@ -26,7 +27,9 @@ attrs==25.3.0
2627 # jsonschema
2728 # referencing
2829backoff == 2.2.1
29- # via posthog
30+ # via
31+ # langfuse
32+ # posthog
3033blinker == 1.9.0
3134 # via streamlit
3235cachetools == 5.5.2
@@ -100,6 +103,7 @@ httpcore==1.0.9
100103httpx == 0.28.1
101104 # via
102105 # anthropic
106+ # langfuse
103107 # langgraph-sdk
104108 # langsmith
105109 # openai
@@ -111,6 +115,7 @@ idna==3.10
111115 # via
112116 # anyio
113117 # httpx
118+ # langfuse
114119 # requests
115120 # yarl
116121importlib-metadata == 8.6.1
@@ -156,6 +161,8 @@ langchain-openai==0.3.16
156161 # via -r requirements.in
157162langchain-text-splitters == 0.3.8
158163 # via langchain
164+ langfuse == 2.60.4
165+ # via -r requirements.in
159166langgraph == 0.4.3
160167 # via -r requirements.in
161168langgraph-checkpoint == 2.0.25
@@ -439,6 +446,7 @@ packaging==24.2
439446 # altair
440447 # huggingface-hub
441448 # langchain-core
449+ # langfuse
442450 # langsmith
443451 # marshmallow
444452 # matplotlib
@@ -475,6 +483,7 @@ pydantic==2.11.4
475483 # fastapi
476484 # langchain
477485 # langchain-core
486+ # langfuse
478487 # langgraph
479488 # langsmith
480489 # openai
@@ -521,6 +530,7 @@ requests==2.32.3
521530 # huggingface-hub
522531 # langchain
523532 # langchain-community
533+ # langfuse
524534 # langsmith
525535 # opentelemetry-exporter-otlp-proto-http
526536 # posthog
@@ -611,6 +621,7 @@ uvicorn==0.34.2
611621wrapt == 1.17.2
612622 # via
613623 # deprecated
624+ # langfuse
614625 # opentelemetry-instrumentation
615626 # opentelemetry-instrumentation-sqlalchemy
616627 # opentelemetry-instrumentation-threading
You can’t perform that action at this time.
0 commit comments