diff --git a/api/agent.py b/api/agent.py index dde8ca5..8e2e984 100644 --- a/api/agent.py +++ b/api/agent.py @@ -23,7 +23,14 @@ import logging from typing import Any, TypedDict from langgraph.graph import END, StateGraph -from openai import AzureOpenAI +# Drop-in for `openai.AzureOpenAI` - identical constructor and call signatures, +# and it records every call to Langfuse as a generation carrying the model and +# the token usage the plain client discards. That is the only thing Langfuse +# can price, so this import is what makes cost appear in the UI. Reads +# LANGFUSE_PUBLIC_KEY / LANGFUSE_SECRET_KEY / LANGFUSE_HOST from the +# environment, which the api service already has. Falls back to plain +# behaviour when they are unset - observability never breaks the answer path. +from langfuse.openai import AzureOpenAI import classifier import tools.equipment as equipment_tool