config_entity.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. from enum import Enum
  2. from pydantic import BaseModel, ValidationInfo, field_validator
  3. class TracingProviderEnum(Enum):
  4. LANGFUSE = "langfuse"
  5. LANGSMITH = "langsmith"
  6. class BaseTracingConfig(BaseModel):
  7. """
  8. Base model class for tracing
  9. """
  10. ...
  11. class LangfuseConfig(BaseTracingConfig):
  12. """
  13. Model class for Langfuse tracing config.
  14. """
  15. public_key: str
  16. secret_key: str
  17. host: str = "https://api.langfuse.com"
  18. @field_validator("host")
  19. @classmethod
  20. def set_value(cls, v, info: ValidationInfo):
  21. if v is None or v == "":
  22. v = "https://api.langfuse.com"
  23. if not v.startswith("https://") and not v.startswith("http://"):
  24. raise ValueError("host must start with https:// or http://")
  25. return v
  26. class LangSmithConfig(BaseTracingConfig):
  27. """
  28. Model class for Langsmith tracing config.
  29. """
  30. api_key: str
  31. project: str
  32. endpoint: str = "https://api.smith.langchain.com"
  33. @field_validator("endpoint")
  34. @classmethod
  35. def set_value(cls, v, info: ValidationInfo):
  36. if v is None or v == "":
  37. v = "https://api.smith.langchain.com"
  38. if not v.startswith("https://"):
  39. raise ValueError("endpoint must start with https://")
  40. return v