config_entity.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. project_key: str
  18. host: str = 'https://api.langfuse.com'
  19. @field_validator("host")
  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. def set_value(cls, v, info: ValidationInfo):
  35. if v is None or v == "":
  36. v = 'https://api.smith.langchain.com'
  37. if not v.startswith('https://'):
  38. raise ValueError('endpoint must start with https://')
  39. return v