quotient_trace_langgraph.py
from openinference.instrumentation.langchain import LangChainInstrumentor
from quotientai import QuotientAI
quotient = QuotientAI()
quotient.tracer.init(
app_name="langgraph-weather-app",
environment="dev",
instruments=[LangChainInstrumentor()],
)
from langgraph.prebuilt import create_react_agent
def get_weather(city: str) -> str:
"""Get weather for a given city."""
return f"It's always sunny in {city}!"
@quotient.trace('langgraph-weather-agent')
def main() -> None:
agent = create_react_agent(
model="anthropic:claude-3-7-sonnet-latest",
tools=[get_weather],
prompt="You are a helpful assistant",
)
agent.invoke({"messages": [{"role": "user", "content": "what is the weather in sf"}]})
if __name__ == "__main__":
main()