task

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const RepositoryConfigurationFileName = "repository.json"

RepositoryConfigurationFileName holds the file name for a repository configuration.

Variables

View Source
var (
	// ErrTaskUnknown indicates that a task is unknown.
	ErrTaskUnknown = errors.New("task unknown")
	// ErrTaskUnsupportedByModel indicates that the model does not support the task.
	ErrTaskUnsupportedByModel = errors.New("model does not support task")
)

Functions

This section is empty.

Types

type Context

type Context struct {
	// Language holds the language for which the task should be evaluated.
	Language language.Language
	// Repository holds the repository which should be evaluated.
	Repository Repository
	// Model holds the model which the task should be evaluated.
	Model model.Model

	// ResultPath holds the directory path where results should be written to.
	ResultPath string

	// Logger holds the logger for this tasks.
	Logger *log.Logger
}

Context holds the data need by a task to be run.

type Identifier

type Identifier string

Identifier holds the identifier of a task.

type Repository

type Repository interface {
	// Name holds the name of the repository.
	Name() (name string)
	// DataPath holds the absolute path to the repository.
	DataPath() (dataPath string)

	// Configuration returns the configuration of a repository.
	Configuration() *RepositoryConfiguration

	// Validate checks it the repository is well-formed.
	Validate(logger *log.Logger, language language.Language) (err error)

	// Reset resets the repository to its initial state.
	Reset(logger *log.Logger) (err error)
}

Repository defines a repository to be evaluated.

type RepositoryConfiguration added in v1.0.0

type RepositoryConfiguration struct {
	// Tasks holds the tasks supported by the repository.
	Tasks []Identifier `json:"tasks"`
	// IgnorePaths holds the relative paths that should be ignored when searching for cases.
	IgnorePaths []string `json:"ignore,omitempty"`

	// Prompt holds LLM prompt-related configuration.
	Prompt RepositoryConfigurationPrompt `json:"prompt,omitempty"`

	// Validation holds quality gates for evaluation.
	Validation RepositoryConfigurationValidation `json:"validation,omitempty"`

	// MaxScores holds the maximum scores per task type, case and metric for this repository.
	MaxScores map[Identifier]map[string]map[metrics.AssessmentKey]uint64 `json:"scores,omitempty"`
}

RepositoryConfiguration holds the configuration of a repository.

func LoadRepositoryConfiguration added in v1.0.0

func LoadRepositoryConfiguration(path string, defaultTasks []Identifier) (config *RepositoryConfiguration, err error)

LoadRepositoryConfiguration loads a repository configuration from the given path.

func (*RepositoryConfiguration) IsFilePathIgnored added in v1.0.0

func (rc *RepositoryConfiguration) IsFilePathIgnored(filePath string) bool

IsFilePathIgnored checks if the given relative file path is to be ignored when searching for cases.

func (*RepositoryConfiguration) Write added in v1.0.0

func (rc *RepositoryConfiguration) Write(path string) (err error)

Write stores the configuration on the given path.

type RepositoryConfigurationExecution added in v1.0.0

type RepositoryConfigurationExecution struct {
	// StdOutRE holds a regular expression that must be part of execution standard output.
	StdOutRE string `json:"stdout,omitempty"`
}

RepositoryConfigurationExecution execution-related quality gates for evaluation.

func (*RepositoryConfigurationExecution) Validate added in v1.0.0

func (e *RepositoryConfigurationExecution) Validate(stdout string) bool

Validate validates execution outcomes against the configured quality gates.

type RepositoryConfigurationPrompt added in v1.0.0

type RepositoryConfigurationPrompt struct {
	// TestFramework overwrites the language-specific test framework to use.
	TestFramework string `json:"test-framework,omitempty"`
}

RepositoryConfigurationPrompt holds LLM prompt-related configuration.

type RepositoryConfigurationValidation added in v1.0.0

type RepositoryConfigurationValidation struct {
	// Execution holds execution-related validation.
	Execution RepositoryConfigurationExecution `json:"execution,omitempty"`
}

RepositoryConfigurationValidation holds quality gates for evaluation.

type Task

type Task interface {
	// Identifier returns the task identifier.
	Identifier() (identifier Identifier)

	// Run runs a task in a given repository.
	Run(ctx Context) (assessments map[string]map[Identifier]metrics.Assessments, problems []error, err error)
}

Task defines an evaluation task.

Jump to

Keyboard shortcuts

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