api

package
v1.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package api provides Forge-style HTTP handlers for the Sentinel evaluation engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API wires all Forge-style HTTP handlers together for the Sentinel system.

func New

func New(eng *engine.Engine, router forge.Router) *API

New creates an API from a Sentinel Engine.

func (*API) Handler

func (a *API) Handler() http.Handler

Handler returns the fully assembled http.Handler with all routes.

func (*API) RegisterRoutes

func (a *API) RegisterRoutes(router forge.Router)

RegisterRoutes registers all Sentinel API routes into the given Forge router.

type CompareModelsRequest

type CompareModelsRequest struct {
	SuiteID string   `path:"suiteId" description:"Suite ID"`
	Models  []string `json:"models" description:"Model names to compare" required:"true"`
	Scorers []string `json:"scorers,omitempty" description:"Scorer names to use"`
	Tags    []string `json:"tags,omitempty" description:"Tags for the run"`
}

CompareModelsRequest is the request body for comparing models.

type CreateCaseRequest

type CreateCaseRequest struct {
	Name         string                `json:"name" description:"Case name" required:"true"`
	Input        string                `json:"input" description:"Case input" required:"true"`
	Expected     string                `json:"expected,omitempty" description:"Expected output"`
	ScenarioType string                `json:"scenario_type,omitempty" description:"Scenario type"`
	Scorers      []ScorerConfigRequest `json:"scorers,omitempty" description:"Scorer configurations"`
	Tags         []string              `json:"tags,omitempty" description:"Tags"`
	Context      map[string]any        `json:"context,omitempty" description:"Case context"`
	Metadata     map[string]any        `json:"metadata,omitempty" description:"Case metadata"`
}

CreateCaseRequest is the request body for creating a test case.

type CreateCasesRequest

type CreateCasesRequest struct {
	SuiteID string              `path:"suiteId" description:"Suite ID"`
	Cases   []CreateCaseRequest `json:"cases" description:"Cases to create" required:"true"`
}

CreateCasesRequest holds a batch of cases to create.

type CreatePromptVersionRequest

type CreatePromptVersionRequest struct {
	SuiteID      string `path:"suiteId" description:"Suite ID"`
	SystemPrompt string `json:"system_prompt" description:"The system prompt" required:"true"`
	Label        string `json:"label,omitempty" description:"Human-readable label"`
}

CreatePromptVersionRequest is the request body for creating a prompt version.

type CreateSuiteRequest

type CreateSuiteRequest struct {
	Name         string         `json:"name" description:"Suite name" required:"true"`
	Description  string         `json:"description,omitempty" description:"Suite description"`
	SystemPrompt string         `json:"system_prompt,omitempty" description:"System prompt for evaluation"`
	Model        string         `json:"model,omitempty" description:"LLM model name"`
	Temperature  float64        `json:"temperature,omitempty" description:"LLM temperature"`
	PersonaRef   string         `json:"persona_ref,omitempty" description:"Persona reference for persona-aware eval"`
	Metadata     map[string]any `json:"metadata,omitempty" description:"Suite metadata"`
}

CreateSuiteRequest is the request body for creating a suite.

type DeleteCaseRequest

type DeleteCaseRequest struct {
	CaseID string `path:"caseId" description:"Case ID"`
}

DeleteCaseRequest binds the path for DELETE /cases/:caseId.

type DeleteSuiteRequest

type DeleteSuiteRequest struct {
	SuiteID string `path:"suiteId" description:"Suite ID"`
}

DeleteSuiteRequest binds the path for DELETE /suites/:suiteId.

type ExportReportRequest

type ExportReportRequest struct {
	RunID  string `path:"runId" description:"Run ID"`
	Format string `json:"format,omitempty" description:"Report format: terminal, json, html, ci"`
}

ExportReportRequest is the request body for exporting a report.

type GenerateAttacksRequest

type GenerateAttacksRequest struct {
	SuiteID     string   `path:"suiteId" description:"Suite ID"`
	AttackTypes []string `json:"attack_types,omitempty" description:"Attack types to generate"`
	Count       int      `json:"count,omitempty" description:"Number of attacks per type"`
}

GenerateAttacksRequest is the request body for generating red team attacks.

type GenerateScenariosRequest

type GenerateScenariosRequest struct {
	SuiteID    string `path:"suiteId" description:"Suite ID"`
	Type       string `json:"type" description:"Scenario type to generate" required:"true"`
	Count      int    `json:"count,omitempty" description:"Number of scenarios"`
	Difficulty string `json:"difficulty,omitempty" description:"Difficulty level"`
}

GenerateScenariosRequest is the request body for generating test scenarios.

type GetBaselineRequest

type GetBaselineRequest struct {
	BaselineID string `path:"baselineId" description:"Baseline ID"`
}

GetBaselineRequest binds the path for GET /baselines/:baselineId.

type GetCaseRequest

type GetCaseRequest struct {
	CaseID string `path:"caseId" description:"Case ID"`
}

GetCaseRequest binds the path for GET /cases/:caseId.

type GetReportRequest

type GetReportRequest struct {
	RunID string `path:"runId" description:"Run ID"`
}

GetReportRequest binds the path for GET /runs/:runId/report.

type GetRunRequest

type GetRunRequest struct {
	RunID string `path:"runId" description:"Run ID"`
}

GetRunRequest binds the path for GET /runs/:runId.

type GetRunResultsRequest

type GetRunResultsRequest struct {
	RunID string `path:"runId" description:"Run ID"`
}

GetRunResultsRequest binds the path for GET /runs/:runId/results.

type GetRunStatsRequest

type GetRunStatsRequest struct {
	RunID string `path:"runId" description:"Run ID"`
}

GetRunStatsRequest binds the path for GET /runs/:runId/stats.

type GetSuiteRequest

type GetSuiteRequest struct {
	SuiteID string `path:"suiteId" description:"Suite ID"`
}

GetSuiteRequest binds the path for GET /suites/:suiteId.

type ImportCasesRequest

type ImportCasesRequest struct {
	SuiteID string `path:"suiteId" description:"Suite ID"`
	Format  string `json:"format" description:"Import format: json, csv, jsonl" required:"true"`
	Data    string `json:"data" description:"Raw data to import" required:"true"`
}

ImportCasesRequest is the request body for importing cases.

type ListBaselinesRequest

type ListBaselinesRequest struct {
	SuiteID string `path:"suiteId" description:"Suite ID"`
}

ListBaselinesRequest binds the path for GET /suites/:suiteId/baselines.

type ListCasesRequest

type ListCasesRequest struct {
	SuiteID string `path:"suiteId" description:"Suite ID"`
}

ListCasesRequest binds the path for GET /suites/:suiteId/cases.

type ListPromptVersionsRequest

type ListPromptVersionsRequest struct {
	SuiteID string `path:"suiteId" description:"Suite ID"`
}

ListPromptVersionsRequest binds the path for GET /suites/:suiteId/prompts.

type ListRunsRequest

type ListRunsRequest struct {
	SuiteID string `path:"suiteId" description:"Suite ID"`
	State   string `query:"state" description:"Filter by run state"`
	Limit   int    `query:"limit" description:"Max results to return"`
	Offset  int    `query:"offset" description:"Pagination offset"`
}

ListRunsRequest holds query params for listing runs.

type ListScenariosRequest

type ListScenariosRequest struct {
	SuiteID string `path:"suiteId" description:"Suite ID"`
}

ListScenariosRequest binds the path for GET /suites/:suiteId/scenarios.

type ListSuitesRequest

type ListSuitesRequest struct {
	Limit  int `query:"limit" description:"Max results to return"`
	Offset int `query:"offset" description:"Pagination offset"`
}

ListSuitesRequest holds query params for listing suites.

type RunEvalRequest

type RunEvalRequest struct {
	SuiteID     string   `path:"suiteId" description:"Suite ID"`
	Model       string   `json:"model,omitempty" description:"LLM model name"`
	PersonaRef  string   `json:"persona_ref,omitempty" description:"Persona reference"`
	Scorers     []string `json:"scorers,omitempty" description:"Scorer names to use"`
	Tags        []string `json:"tags,omitempty" description:"Tags for the run"`
	Concurrency int      `json:"concurrency,omitempty" description:"Max concurrent cases"`
}

RunEvalRequest is the request body for triggering an evaluation run.

type RunRedTeamRequest

type RunRedTeamRequest struct {
	SuiteID     string   `path:"suiteId" description:"Suite ID"`
	AttackTypes []string `json:"attack_types,omitempty" description:"Attack types to use"`
	Count       int      `json:"count,omitempty" description:"Number of attacks per type"`
	Scorers     []string `json:"scorers,omitempty" description:"Scorer names"`
}

RunRedTeamRequest is the request body for running a red team evaluation.

type RunWithBaselineRequest

type RunWithBaselineRequest struct {
	SuiteID   string   `path:"suiteId" description:"Suite ID"`
	Model     string   `json:"model,omitempty" description:"LLM model name"`
	Scorers   []string `json:"scorers,omitempty" description:"Scorer names"`
	Threshold float64  `json:"threshold,omitempty" description:"Regression threshold"`
}

RunWithBaselineRequest is the request body for running eval with baseline comparison.

type SaveBaselineRequest

type SaveBaselineRequest struct {
	SuiteID string `path:"suiteId" description:"Suite ID"`
	RunID   string `json:"run_id" description:"Run ID to save as baseline" required:"true"`
	Name    string `json:"name" description:"Baseline name" required:"true"`
}

SaveBaselineRequest is the request body for saving a baseline.

type ScorerConfigRequest

type ScorerConfigRequest struct {
	Name   string         `json:"name" description:"Scorer name"`
	Config map[string]any `json:"config,omitempty" description:"Scorer config"`
}

ScorerConfigRequest defines scorer configuration in API requests.

type SetCurrentPromptRequest

type SetCurrentPromptRequest struct {
	SuiteID   string `path:"suiteId" description:"Suite ID"`
	VersionID string `json:"version_id" description:"Prompt version ID to set as current" required:"true"`
}

SetCurrentPromptRequest is the request body for setting the current prompt version.

type UpdateSuiteRequest

type UpdateSuiteRequest struct {
	SuiteID string `path:"suiteId" description:"Suite ID"`
	CreateSuiteRequest
}

UpdateSuiteRequest is the request body for updating a suite.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL