functions

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package functions provides operations for managing Braintrust functions (prompts, tools, scorers).

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 provides methods for interacting with functions.

func New

func New(client *https.Client) *API

New creates a new functions API client.

func (*API) Create

func (a *API) Create(ctx context.Context, params CreateParams) (*Function, error)

Create creates a new function.

func (*API) Delete

func (a *API) Delete(ctx context.Context, functionID string) error

Delete deletes a function by ID.

func (*API) Invoke

func (a *API) Invoke(ctx context.Context, functionID string, input any) (any, error)

Invoke calls a function with the given input and returns the output.

func (*API) Query

func (a *API) Query(ctx context.Context, params QueryParams) ([]Function, error)

Query searches for functions matching the given options. Returns a list of functions that match the criteria.

type CreateParams

type CreateParams struct {
	ProjectID    string         `json:"project_id"`
	Name         string         `json:"name"`
	Slug         string         `json:"slug"`
	FunctionType string         `json:"function_type,omitempty"`
	FunctionData map[string]any `json:"function_data"`
	PromptData   map[string]any `json:"prompt_data,omitempty"`
	Description  string         `json:"description,omitempty"`
}

CreateParams represents the request payload for creating a function.

type Function

type Function struct {
	ID           string `json:"id"`
	ProjectID    string `json:"project_id"`
	Name         string `json:"name"`
	Slug         string `json:"slug"`
	FunctionType string `json:"function_type"`
	Description  string `json:"description,omitempty"`
}

Function represents a Braintrust function (prompt, tool, or scorer).

type InvokeParams

type InvokeParams struct {
	Input any `json:"input"`
}

InvokeParams represents the request payload for invoking a function.

type QueryParams

type QueryParams struct {
	// Project identity (either/or)
	ProjectName string // Filter by project name
	ProjectID   string // Filter by specific project ID

	// Function identity (either/or)
	Slug         string // Filter by function slug
	FunctionName string // Filter by function name

	// Query modifiers
	Version     string // Specific function version
	Environment string // Environment to load (dev/staging/production)
	Limit       int    // Max results (default: no limit)
}

QueryParams contains options for querying functions.

type QueryResponse

type QueryResponse struct {
	Objects []Function `json:"objects"`
}

QueryResponse represents the response from querying functions.

Jump to

Keyboard shortcuts

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