# generated by datamodel-codegen:
#   filename:  .openapi.json
#   timestamp: 2025-08-29T04:49:38+00:00

from __future__ import annotations
from typing import Annotated, Any, Dict, List, Optional, Union
from pydantic import AwareDatetime, BaseModel, ConfigDict, Field, RootModel


class TraceAndSpanId(RootModel[List]):
    root: Annotated[List, Field(max_length=2, min_length=2)]


class EvalResultsFetch(BaseModel):
    experiment_run_id: Annotated[str, Field(title="Experiment Run Id")]
    project_name: Annotated[str, Field(title="Project Name")]


class DatasetFetch(BaseModel):
    dataset_alias: Annotated[str, Field(title="Dataset Alias")]
    project_name: Annotated[str, Field(title="Project Name")]


class TraceSave(BaseModel):
    project_name: Annotated[str, Field(title="Project Name")]
    trace_id: Annotated[str, Field(title="Trace Id")]
    name: Annotated[str, Field(title="Name")]
    created_at: Annotated[str, Field(title="Created At")]
    duration: Annotated[float, Field(title="Duration")]
    offline_mode: Annotated[Optional[bool], Field(title="Offline Mode")] = False
    has_notification: Annotated[Optional[bool], Field(title="Has Notification")] = False
    customer_id: Annotated[Optional[str], Field(title="Customer Id")] = None
    tags: Annotated[Optional[List[str]], Field(title="Tags")] = None
    metadata: Annotated[Optional[Dict[str, Any]], Field(title="Metadata")] = None
    update_id: Annotated[Optional[int], Field(title="Update Id")] = 1


class TraceFetch(BaseModel):
    trace_id: Annotated[str, Field(title="Trace Id")]


class TraceAddToDataset(BaseModel):
    trace_id: Annotated[str, Field(title="Trace Id")]
    trace_span_id: Annotated[str, Field(title="Trace Span Id")]
    dataset_alias: Annotated[str, Field(title="Dataset Alias")]
    project_name: Annotated[str, Field(title="Project Name")]


class EvaluationRunsBatchRequest(BaseModel):
    organization_id: Annotated[str, Field(title="Organization Id")]
    evaluation_entries: Annotated[
        List[Dict[str, Any]], Field(title="Evaluation Entries")
    ]


class ProjectAdd(BaseModel):
    project_name: Annotated[str, Field(title="Project Name")]


class ProjectAddResponse(BaseModel):
    project_id: Annotated[str, Field(title="Project Id")]


class ProjectDeleteFromJudgevalResponse(BaseModel):
    project_name: Annotated[str, Field(title="Project Name")]


class ProjectDeleteResponse(BaseModel):
    message: Annotated[str, Field(title="Message")]


class ScorerExistsRequest(BaseModel):
    name: Annotated[str, Field(title="Name")]


class ScorerExistsResponse(BaseModel):
    exists: Annotated[bool, Field(title="Exists")]


class SavePromptScorerRequest(BaseModel):
    name: Annotated[str, Field(title="Name")]
    prompt: Annotated[str, Field(title="Prompt")]
    threshold: Annotated[float, Field(title="Threshold")]
    options: Annotated[Optional[Dict[str, float]], Field(title="Options")] = None
    is_trace: Annotated[Optional[bool], Field(title="Is Trace")] = False


class SavePromptScorerResponse(BaseModel):
    message: Annotated[str, Field(title="Message")]
    name: Annotated[str, Field(title="Name")]


class FetchPromptScorerRequest(BaseModel):
    name: Annotated[str, Field(title="Name")]


class CustomScorerUploadPayload(BaseModel):
    scorer_name: Annotated[str, Field(title="Scorer Name")]
    scorer_code: Annotated[str, Field(title="Scorer Code")]
    requirements_text: Annotated[str, Field(title="Requirements Text")]


class CustomScorerTemplateResponse(BaseModel):
    scorer_name: Annotated[str, Field(title="Scorer Name")]
    status: Annotated[str, Field(title="Status")]
    message: Annotated[str, Field(title="Message")]


class ResolveProjectNameRequest(BaseModel):
    project_name: Annotated[str, Field(title="Project Name")]


class ResolveProjectNameResponse(BaseModel):
    project_id: Annotated[str, Field(title="Project Id")]


class TraceIdRequest(BaseModel):
    trace_id: Annotated[str, Field(title="Trace Id")]


class SpanScoreRequest(BaseModel):
    span_id: Annotated[str, Field(title="Span Id")]
    trace_id: Annotated[str, Field(title="Trace Id")]


class BaseScorer(BaseModel):
    score_type: Annotated[str, Field(title="Score Type")]
    threshold: Annotated[Optional[float], Field(title="Threshold")] = 0.5
    name: Annotated[Optional[str], Field(title="Name")] = None
    class_name: Annotated[Optional[str], Field(title="Class Name")] = None
    score: Annotated[Optional[float], Field(title="Score")] = None
    score_breakdown: Annotated[
        Optional[Dict[str, Any]], Field(title="Score Breakdown")
    ] = None
    reason: Annotated[Optional[str], Field(title="Reason")] = ""
    using_native_model: Annotated[Optional[bool], Field(title="Using Native Model")] = (
        None
    )
    success: Annotated[Optional[bool], Field(title="Success")] = None
    model: Annotated[Optional[str], Field(title="Model")] = None
    model_client: Annotated[Any, Field(title="Model Client")] = None
    strict_mode: Annotated[Optional[bool], Field(title="Strict Mode")] = False
    error: Annotated[Optional[str], Field(title="Error")] = None
    additional_metadata: Annotated[
        Optional[Dict[str, Any]], Field(title="Additional Metadata")
    ] = None
    user: Annotated[Optional[str], Field(title="User")] = None
    server_hosted: Annotated[Optional[bool], Field(title="Server Hosted")] = False


class ScorerConfig(BaseModel):
    score_type: Annotated[str, Field(title="Score Type")]
    name: Annotated[Optional[str], Field(title="Name")] = None
    threshold: Annotated[Optional[float], Field(title="Threshold")] = 0.5
    strict_mode: Annotated[Optional[bool], Field(title="Strict Mode")] = False
    required_params: Annotated[Optional[List[str]], Field(title="Required Params")] = []
    kwargs: Annotated[Optional[Dict[str, Any]], Field(title="Kwargs")] = None


class Example(BaseModel):
    model_config = ConfigDict(
        extra="allow",
    )
    example_id: Annotated[str, Field(title="Example Id")]
    created_at: Annotated[str, Field(title="Created At")]
    name: Annotated[Optional[str], Field(title="Name")] = None


class ValidationError(BaseModel):
    loc: Annotated[List[Union[str, int]], Field(title="Location")]
    msg: Annotated[str, Field(title="Message")]
    type: Annotated[str, Field(title="Error Type")]


class SpanBatchItem(BaseModel):
    span_id: Annotated[str, Field(title="Span Id")]
    trace_id: Annotated[str, Field(title="Trace Id")]
    function: Annotated[str, Field(title="Function")]
    created_at: Annotated[Any, Field(title="Created At")] = None
    parent_span_id: Annotated[Optional[str], Field(title="Parent Span Id")] = None
    span_type: Annotated[Optional[str], Field(title="Span Type")] = "span"
    inputs: Annotated[Optional[Dict[str, Any]], Field(title="Inputs")] = None
    output: Annotated[Any, Field(title="Output")] = None
    error: Annotated[Optional[Dict[str, Any]], Field(title="Error")] = None
    usage: Annotated[Optional[Dict[str, Any]], Field(title="Usage")] = None
    duration: Annotated[Optional[float], Field(title="Duration")] = None
    expected_tools: Annotated[
        Optional[List[Dict[str, Any]]], Field(title="Expected Tools")
    ] = None
    additional_metadata: Annotated[
        Optional[Dict[str, Any]], Field(title="Additional Metadata")
    ] = None
    has_evaluation: Annotated[Optional[bool], Field(title="Has Evaluation")] = False
    agent_name: Annotated[Optional[str], Field(title="Agent Name")] = None
    class_name: Annotated[Optional[str], Field(title="Class Name")] = None
    state_before: Annotated[Optional[Dict[str, Any]], Field(title="State Before")] = (
        None
    )
    state_after: Annotated[Optional[Dict[str, Any]], Field(title="State After")] = None
    span_state: Annotated[str, Field(title="Span State")]
    update_id: Annotated[Optional[int], Field(title="Update Id")] = 1
    queued_at: Annotated[float, Field(title="Queued At")]


class PromptScorer(BaseModel):
    name: Annotated[str, Field(title="Name")]
    prompt: Annotated[str, Field(title="Prompt")]
    threshold: Annotated[float, Field(title="Threshold")]
    options: Annotated[Optional[Dict[str, float]], Field(title="Options")] = None
    created_at: Annotated[Optional[AwareDatetime], Field(title="Created At")] = None
    updated_at: Annotated[Optional[AwareDatetime], Field(title="Updated At")] = None
    is_trace: Annotated[Optional[bool], Field(title="Is Trace")] = False


class ScorerData(BaseModel):
    name: Annotated[str, Field(title="Name")]
    threshold: Annotated[float, Field(title="Threshold")]
    success: Annotated[bool, Field(title="Success")]
    score: Annotated[Optional[float], Field(title="Score")] = None
    reason: Annotated[Optional[str], Field(title="Reason")] = None
    strict_mode: Annotated[Optional[bool], Field(title="Strict Mode")] = None
    evaluation_model: Annotated[
        Optional[Union[List[str], str]], Field(title="Evaluation Model")
    ] = None
    error: Annotated[Optional[str], Field(title="Error")] = None
    additional_metadata: Annotated[
        Optional[Dict[str, Any]], Field(title="Additional Metadata")
    ] = None


class TraceUsage(BaseModel):
    prompt_tokens: Annotated[Optional[int], Field(title="Prompt Tokens")] = None
    completion_tokens: Annotated[Optional[int], Field(title="Completion Tokens")] = None
    cache_creation_input_tokens: Annotated[
        Optional[int], Field(title="Cache Creation Input Tokens")
    ] = None
    cache_read_input_tokens: Annotated[
        Optional[int], Field(title="Cache Read Input Tokens")
    ] = None
    total_tokens: Annotated[Optional[int], Field(title="Total Tokens")] = None
    prompt_tokens_cost_usd: Annotated[
        Optional[float], Field(title="Prompt Tokens Cost Usd")
    ] = None
    completion_tokens_cost_usd: Annotated[
        Optional[float], Field(title="Completion Tokens Cost Usd")
    ] = None
    total_cost_usd: Annotated[Optional[float], Field(title="Total Cost Usd")] = None
    model_name: Annotated[Optional[str], Field(title="Model Name")] = None


class Tool(BaseModel):
    tool_name: Annotated[str, Field(title="Tool Name")]
    parameters: Annotated[Optional[Dict[str, Any]], Field(title="Parameters")] = None
    agent_name: Annotated[Optional[str], Field(title="Agent Name")] = None
    result_dependencies: Annotated[
        Optional[List[Dict[str, Any]]], Field(title="Result Dependencies")
    ] = None
    action_dependencies: Annotated[
        Optional[List[Dict[str, Any]]], Field(title="Action Dependencies")
    ] = None
    require_all: Annotated[Optional[bool], Field(title="Require All")] = None


class ExampleEvaluationRun(BaseModel):
    id: Annotated[Optional[str], Field(title="Id")] = None
    project_name: Annotated[Optional[str], Field(title="Project Name")] = None
    eval_name: Annotated[Optional[str], Field(title="Eval Name")] = None
    custom_scorers: Annotated[
        Optional[List[BaseScorer]], Field(title="Custom Scorers")
    ] = []
    judgment_scorers: Annotated[
        Optional[List[ScorerConfig]], Field(title="Judgment Scorers")
    ] = []
    model: Annotated[str, Field(title="Model")]
    created_at: Annotated[Optional[str], Field(title="Created At")] = None
    examples: Annotated[List[Example], Field(title="Examples")]
    trace_span_id: Annotated[Optional[str], Field(title="Trace Span Id")] = None
    trace_id: Annotated[Optional[str], Field(title="Trace Id")] = None


class HTTPValidationError(BaseModel):
    detail: Annotated[Optional[List[ValidationError]], Field(title="Detail")] = None


class TraceEvaluationRun(BaseModel):
    id: Annotated[Optional[str], Field(title="Id")] = None
    project_name: Annotated[Optional[str], Field(title="Project Name")] = None
    eval_name: Annotated[Optional[str], Field(title="Eval Name")] = None
    custom_scorers: Annotated[
        Optional[List[BaseScorer]], Field(title="Custom Scorers")
    ] = []
    judgment_scorers: Annotated[
        Optional[List[ScorerConfig]], Field(title="Judgment Scorers")
    ] = []
    model: Annotated[str, Field(title="Model")]
    created_at: Annotated[Optional[str], Field(title="Created At")] = None
    trace_and_span_ids: Annotated[
        List[TraceAndSpanId], Field(title="Trace And Span Ids")
    ]
    is_offline: Annotated[Optional[bool], Field(title="Is Offline")] = False


class DatasetInsertExamples(BaseModel):
    dataset_alias: Annotated[str, Field(title="Dataset Alias")]
    examples: Annotated[List[Example], Field(title="Examples")]
    project_name: Annotated[str, Field(title="Project Name")]


class SpansBatchRequest(BaseModel):
    spans: Annotated[List[SpanBatchItem], Field(title="Spans")]
    organization_id: Annotated[str, Field(title="Organization Id")]


class FetchPromptScorerResponse(BaseModel):
    scorer: PromptScorer


class TraceSpan(BaseModel):
    span_id: Annotated[str, Field(title="Span Id")]
    trace_id: Annotated[str, Field(title="Trace Id")]
    function: Annotated[str, Field(title="Function")]
    created_at: Annotated[Any, Field(title="Created At")] = None
    parent_span_id: Annotated[Optional[str], Field(title="Parent Span Id")] = None
    span_type: Annotated[Optional[str], Field(title="Span Type")] = "span"
    inputs: Annotated[Optional[Dict[str, Any]], Field(title="Inputs")] = None
    error: Annotated[Optional[Dict[str, Any]], Field(title="Error")] = None
    output: Annotated[Any, Field(title="Output")] = None
    usage: Optional[TraceUsage] = None
    duration: Annotated[Optional[float], Field(title="Duration")] = None
    expected_tools: Annotated[Optional[List[Tool]], Field(title="Expected Tools")] = (
        None
    )
    additional_metadata: Annotated[
        Optional[Dict[str, Any]], Field(title="Additional Metadata")
    ] = None
    has_evaluation: Annotated[Optional[bool], Field(title="Has Evaluation")] = False
    agent_name: Annotated[Optional[str], Field(title="Agent Name")] = None
    class_name: Annotated[Optional[str], Field(title="Class Name")] = None
    state_before: Annotated[Optional[Dict[str, Any]], Field(title="State Before")] = (
        None
    )
    state_after: Annotated[Optional[Dict[str, Any]], Field(title="State After")] = None
    update_id: Annotated[Optional[int], Field(title="Update Id")] = 1


class Trace(BaseModel):
    trace_id: Annotated[str, Field(title="Trace Id")]
    name: Annotated[str, Field(title="Name")]
    created_at: Annotated[str, Field(title="Created At")]
    duration: Annotated[float, Field(title="Duration")]
    trace_spans: Annotated[List[TraceSpan], Field(title="Trace Spans")]
    offline_mode: Annotated[Optional[bool], Field(title="Offline Mode")] = False
    rules: Annotated[Optional[Dict[str, Any]], Field(title="Rules")] = {}
    has_notification: Annotated[Optional[bool], Field(title="Has Notification")] = False
    customer_id: Annotated[Optional[str], Field(title="Customer Id")] = None
    tags: Annotated[Optional[List[str]], Field(title="Tags")] = []
    metadata: Annotated[Optional[Dict[str, Any]], Field(title="Metadata")] = {}
    update_id: Annotated[Optional[int], Field(title="Update Id")] = 1


class ScoringResult(BaseModel):
    success: Annotated[bool, Field(title="Success")]
    scorers_data: Annotated[Optional[List[ScorerData]], Field(title="Scorers Data")] = (
        None
    )
    name: Annotated[Optional[str], Field(title="Name")] = None
    data_object: Annotated[
        Optional[Union[TraceSpan, Example]], Field(title="Data Object")
    ] = None
    trace_id: Annotated[Optional[str], Field(title="Trace Id")] = None
    run_duration: Annotated[Optional[float], Field(title="Run Duration")] = None
    evaluation_cost: Annotated[Optional[float], Field(title="Evaluation Cost")] = None


class TraceRun(BaseModel):
    project_name: Annotated[Optional[str], Field(title="Project Name")] = None
    eval_name: Annotated[Optional[str], Field(title="Eval Name")] = None
    traces: Annotated[List[Trace], Field(title="Traces")]
    scorers: Annotated[List[ScorerConfig], Field(title="Scorers")]
    model: Annotated[str, Field(title="Model")]
    trace_span_id: Annotated[Optional[str], Field(title="Trace Span Id")] = None
    tools: Annotated[Optional[List[Dict[str, Any]]], Field(title="Tools")] = None


class EvalResults(BaseModel):
    results: Annotated[List[ScoringResult], Field(title="Results")]
    run: Annotated[Union[ExampleEvaluationRun, TraceEvaluationRun], Field(title="Run")]


class DatasetPush(BaseModel):
    dataset_alias: Annotated[str, Field(title="Dataset Alias")]
    comments: Annotated[Optional[str], Field(title="Comments")] = None
    source_file: Annotated[Optional[str], Field(title="Source File")] = None
    examples: Annotated[Optional[List[Example]], Field(title="Examples")] = None
    traces: Annotated[Optional[List[Trace]], Field(title="Traces")] = None
    is_trace: Annotated[Optional[bool], Field(title="Is Trace")] = False
    project_name: Annotated[str, Field(title="Project Name")]
    overwrite: Annotated[Optional[bool], Field(title="Overwrite")] = False
