Closed millfields99 closed 6 months ago
🤖
Hey @millfields99! 👋 I'm Dosu, a friendly bot here to assist you with your LangChain troubles while the human maintainers are away. I'm geared up to help you squash bugs, answer questions, and you can even consider me your personal guide to becoming a better contributor. Let's get this problem sorted together! 🤖🔍
Based on the information provided, it seems like the connection error with the LangSmith API is likely due to the LangChainTracer class in your LangChain framework. This class is designed to trace the execution of language models and send the trace data to a LangSmith API endpoint for further analysis.
Even if you are not explicitly running LangSmith or have access to it, the LangChainTracer class in your LangChain framework may still attempt to send trace data to the LangSmith API, which could result in a connection error if the API is not accessible.
To prevent these error reports from appearing, you could modify the LangChainTracer class to not use the LangSmith Client or to handle connection errors more gracefully. For example, you could modify the _persist_run_single()
and _update_run_single()
methods to catch exceptions related to the LangSmith API and log them without raising them. Here's an example of how you could modify these methods:
def _persist_run_single(self, run: Run) -> None:
"""Persist a run."""
run_dict = run.dict(exclude={"child_runs"})
run_dict["tags"] = self._get_tags(run)
extra = run_dict.get("extra", {})
extra["runtime"] = get_runtime_environment()
run_dict["extra"] = extra
try:
self.client.create_run(**run_dict, project_name=self.project_name)
except Exception as e:
# Errors are swallowed by the thread executor so we need to log them here
log_error_once("post", e)
# Don't raise the exception
# raise
def _update_run_single(self, run: Run) -> None:
"""Update a run."""
try:
run_dict = run.dict()
run_dict["tags"] = self._get_tags(run)
self.client.update_run(run.id, **run_dict)
except Exception as e:
# Errors are swallowed by the thread executor so we need to log them here
log_error_once("patch", e)
# Don't raise the exception
# raise
This way, the LangChainTracer class will still log the connection errors with the LangSmith API, but it will not raise them, which should prevent the error reports from appearing. You can find more details about this in the LangChainTracer class in the LangChain repository.
As for the LANGCHAIN_ENDPOINT
environment variable, I wasn't able to find specific information about its role within the LangChain codebase. It's possible that it's used to specify the endpoint for the LangSmith API, but without more information, it's hard to say for sure. If you have more details about how this environment variable is used in your setup, that could help clarify its role.
I hope this helps! If you have any other questions or need further clarification, please let me know.
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
Hello I encountered a similar issue, do make sure you load the env before running the langsmith client.
from dotenv import load_dotenv
from langsmith import Client
load_dotenv()
client = Client()
System Info
From pyproject.toml:
python=3.11.5 crewai = "0.1.6" langchain = '==0.0.335' openai = '==0.28.1' unstructured = '==0.10.25' pyowm = '3.3.0' tools = "^0.1.9" wikipedia = "1.4.0" yfinance = "0.2.33" sec-api = "1.0.17" tiktoken = "0.5.2" faiss-cpu = "1.7.4" python-dotenv = "1.0.0"
Who can help?
No response
Information
Related Components
Reproduction
Running any of the scripts in the crewAI (https://github.com/joaomdmoura/crewAI)
Running crewAI I get the following.
Connection error caused failure to patch http://localhost:1984/runs/7fdd9cf2-4f50-4ee1-8fef-9202b07cc756 in LangSmith API. Please confirm your LANGCHAIN_ENDPOINT. ConnectionError(MaxRetryError("HTTPConnectionPool(host='localhost', port=1984): Max retries exceeded with url: /runs/7fdd9cf2-4f50-4ee1-8fef-9202b07cc756 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x130d51e10>: Failed to establish a new connection: [Errno 61] Connection refused'))"))
Connection error caused failure to post http://localhost:1984/runs in LangSmith API. Please confirm your LANGCHAIN_ENDPOINT. ConnectionError(MaxRetryError("HTTPConnectionPool(host='localhost', port=1984): Max retries exceeded with url: /runs (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x130d6b390>: Failed to establish a new connection: [Errno 61] Connection refused'))"))
I ma not running LangSmith nor do I have any access to it. I have tried setting in my .env to no effect.
LANGCHAIN_TRACING=false LANGCHAIN_TRACING_V2=false LANGCHAIN_HANDLER=None
Expected behavior
Dont expect to see the error reports. Note that not all users are seeing this error