mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-11 05:45:01 +00:00
Retry session and tenant (#4822)
This commit is contained in:
parent
49e4aaf673
commit
d1b6839d97
@ -8,6 +8,7 @@ from typing import Any, Dict, List, Optional
|
|||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
from tenacity import retry, stop_after_attempt, wait_fixed
|
||||||
|
|
||||||
from langchain.callbacks.tracers.base import BaseTracer
|
from langchain.callbacks.tracers.base import BaseTracer
|
||||||
from langchain.callbacks.tracers.schemas import (
|
from langchain.callbacks.tracers.schemas import (
|
||||||
@ -33,6 +34,7 @@ def get_endpoint() -> str:
|
|||||||
return os.getenv("LANGCHAIN_ENDPOINT", "http://localhost:8000")
|
return os.getenv("LANGCHAIN_ENDPOINT", "http://localhost:8000")
|
||||||
|
|
||||||
|
|
||||||
|
@retry(stop=stop_after_attempt(3), wait=wait_fixed(0.5))
|
||||||
def _get_tenant_id(
|
def _get_tenant_id(
|
||||||
tenant_id: Optional[str], endpoint: Optional[str], headers: Optional[dict]
|
tenant_id: Optional[str], endpoint: Optional[str], headers: Optional[dict]
|
||||||
) -> str:
|
) -> str:
|
||||||
@ -106,6 +108,7 @@ class LangChainTracer(BaseTracer):
|
|||||||
self.tenant_id = tenant_id
|
self.tenant_id = tenant_id
|
||||||
return tenant_id
|
return tenant_id
|
||||||
|
|
||||||
|
@retry(stop=stop_after_attempt(3), wait=wait_fixed(0.5))
|
||||||
def ensure_session(self) -> TracerSession:
|
def ensure_session(self) -> TracerSession:
|
||||||
"""Upsert a session."""
|
"""Upsert a session."""
|
||||||
if self.session is not None:
|
if self.session is not None:
|
||||||
|
Loading…
Reference in New Issue
Block a user