Add validation and proper default for Opik URL

Also add better documentation link for Opik configuration in the UI
This commit is contained in:
Boris Feld 2024-12-12 15:30:50 +01:00
parent e87865be80
commit a16be9ccb2
2 changed files with 14 additions and 2 deletions

View File

@ -69,12 +69,24 @@ class OpikConfig(BaseTracingConfig):
@field_validator("project")
@classmethod
def set_value(cls, v, info: ValidationInfo):
def project_validator(cls, v, info: ValidationInfo):
if v is None or v == "":
v = "Default Project"
return v
@field_validator("url")
@classmethod
def url_validator(cls, v, info: ValidationInfo):
if v is None or v == "":
v = "https://www.comet.com/opik/api/"
if not v.startswith(("https://", "http://")):
raise ValueError("url must start with https:// or http://")
if not v.endswith("/api/"):
raise ValueError("url should ends with /api/")
return v
OPS_FILE_PATH = "ops_trace/"
OPS_TRACE_FAILED_KEY = "FAILED_OPS_TRACE"

View File

@ -3,5 +3,5 @@ import { TracingProvider } from './type'
export const docURL = {
[TracingProvider.langSmith]: 'https://docs.smith.langchain.com/',
[TracingProvider.langfuse]: 'https://docs.langfuse.com',
[TracingProvider.opik]: 'https://www.comet.com/docs/opik/',
[TracingProvider.opik]: 'https://www.comet.com/docs/opik/tracing/integrations/dify#setup-instructions',
}