Langmsith tracing doesnt work even with good api. #26628
Replies: 1 comment
-
Hey there, @ArturasGrygelis! I'm here to help you with any bugs, questions, or contributions. Let's tackle this together! Ensure that the necessary environment variables are set correctly. You need to set Here is how you can set them: export LANGCHAIN_TRACING_V2="true"
export LANGCHAIN_API_KEY="your_api_key_here" Or, if you are using a notebook: import getpass
import os
os.environ["LANGCHAIN_TRACING_V2"] = "true"
os.environ["LANGCHAIN_API_KEY"] = getpass.getpass("Enter your API key: ") Replace Additionally, ensure that you are correctly initializing and running your agents or chains with the tracing enabled. Here are some examples: For sequential tracing: from langchain.agents import AgentType, initialize_agent, load_tools
from langchain_community.llms import OpenAI
os.environ["LANGCHAIN_TRACING"] = "true"
llm = OpenAI(temperature=0)
tools = load_tools(["llm-math", "serpapi"], llm=llm)
agent = initialize_agent(
tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True
)
agent.run("Your question here") For concurrent tracing: import asyncio
from aiohttp import ClientSession
from langchain.agents import AgentType, initialize_agent, load_tools
from langchain_community.llms import OpenAI
os.environ["LANGCHAIN_TRACING"] = "true"
aiosession = ClientSession()
llm = OpenAI(temperature=0)
async_tools = load_tools(["llm-math", "serpapi"], llm=llm, aiosession=aiosession)
agent = initialize_agent(
async_tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True
)
tasks = [agent.arun("Your question here") for _ in range(3)]
await asyncio.gather(*tasks)
await aiosession.close() For using the context manager with tracing V2: from langchain.agents import AgentType, initialize_agent, load_tools
from langchain_community.chat_models import ChatOpenAI
from langchain_core.tracers.context import tracing_v2_enabled
llm = ChatOpenAI(temperature=0)
tools = load_tools(["llm-math", "serpapi"], llm=llm)
agent = initialize_agent(
tools, llm, agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True
)
with tracing_v2_enabled():
agent.run("Your question here") # this should be traced
agent.run("Your question here") # this should not be traced Ensure that the environment variables and the tracing setup are correctly configured in your application [1][2][3]. |
Beta Was this translation helpful? Give feedback.
-
Langmsith tracing doesnt work even with good api.
My plan is premium and i tryed service and authetification api key, please help i need it to much for a debugging!
Beta Was this translation helpful? Give feedback.
All reactions