config_entity.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. def set_value(cls, v, info: ValidationInfo):
  20. if v is None or v == "":
  21. v = 'https://api.langfuse.com'
  22. if not v.startswith('https://') and not v.startswith('http://'):
  23. raise ValueError('host must start with https:// or http://')
  24. return v
  25. class LangSmithConfig(BaseTracingConfig):
  26. """
  27. Model class for Langsmith tracing config.
  28. """
  29. api_key: str
  30. project: str
  31. endpoint: str = 'https://api.smith.langchain.com'
  32. @field_validator("endpoint")
  33. def set_value(cls, v, info: ValidationInfo):
  34. if v is None or v == "":
  35. v = 'https://api.smith.langchain.com'
  36. if not v.startswith('https://'):
  37. raise ValueError('endpoint must start with https://')
  38. return v