Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set old LCTracer to default to port 8000 #5381

Merged
merged 2 commits into from
May 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions langchain/callbacks/tracers/langchain_v1.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from __future__ import annotations

import logging
import os
from typing import Any, Optional, Union

import requests

from langchain.callbacks.tracers.base import BaseTracer
from langchain.callbacks.tracers.langchain import get_endpoint, get_headers
from langchain.callbacks.tracers.langchain import get_headers
from langchain.callbacks.tracers.schemas import (
ChainRun,
LLMRun,
Expand All @@ -20,14 +21,18 @@
from langchain.utils import raise_for_status_with_text


def _get_endpoint() -> str:
return os.getenv("LANGCHAIN_ENDPOINT", "http://localhost:8000")


class LangChainTracerV1(BaseTracer):
"""An implementation of the SharedTracer that POSTS to the langchain endpoint."""

def __init__(self, **kwargs: Any) -> None:
"""Initialize the LangChain tracer."""
super().__init__(**kwargs)
self.session: Optional[TracerSessionV1] = None
self._endpoint = get_endpoint()
self._endpoint = _get_endpoint()
self._headers = get_headers()

def _convert_to_v1_run(self, run: Run) -> Union[LLMRun, ChainRun, ToolRun]:
Expand Down