asteroid

package module
v0.0.0-...-ae74f89 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package asteroid provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.4.1 DO NOT EDIT.

Index

Constants

View Source
const MAX_SUPERVISORS_PER_CLIENT = 8

Variables

This section is empty.

Functions

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.

func Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, m ServeMux) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, m ServeMux, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options StdHTTPServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

func InitAPI

func InitAPI(store Store)

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

Types

type AsteroidChat

type AsteroidChat struct {
	RequestData  string `json:"request_data"`
	ResponseData string `json:"response_data"`
}

AsteroidChat The raw b64 encoded JSON of the request and response data sent/received from the LLM.

type AsteroidChoice

type AsteroidChoice struct {
	AsteroidId   string                     `json:"asteroid_id"`
	FinishReason AsteroidChoiceFinishReason `json:"finish_reason"`
	Index        int                        `json:"index"`
	Message      AsteroidMessage            `json:"message"`
}

AsteroidChoice defines model for AsteroidChoice.

type AsteroidChoiceFinishReason

type AsteroidChoiceFinishReason string

AsteroidChoiceFinishReason defines model for AsteroidChoice.FinishReason.

const (
	ContentFilter AsteroidChoiceFinishReason = "content_filter"
	FunctionCall  AsteroidChoiceFinishReason = "function_call"
	Length        AsteroidChoiceFinishReason = "length"
	LessThannil   AsteroidChoiceFinishReason = "<nil>"
	Stop          AsteroidChoiceFinishReason = "stop"
	ToolCalls     AsteroidChoiceFinishReason = "tool_calls"
)

Defines values for AsteroidChoiceFinishReason.

type AsteroidConverter

type AsteroidConverter interface {
	ToAsteroidMessages(requestData, responseData []byte) ([]AsteroidMessage, error)
	ToAsteroidChoices(responseData []byte) ([]AsteroidChoice, error)
	ValidateB64EncodedRequest(encodedData string) ([]byte, error)
	ValidateB64EncodedResponse(encodedData string) ([]byte, error)
}

type AsteroidMessage

type AsteroidMessage struct {
	Content   string     `json:"content"`
	CreatedAt *time.Time `json:"created_at,omitempty"`

	// Data The raw b64 encoded JSON of the message objects in its original form
	Data      *string             `json:"data,omitempty"`
	Id        *openapi_types.UUID `json:"id,omitempty"`
	Role      AsteroidMessageRole `json:"role"`
	ToolCalls *[]AsteroidToolCall `json:"tool_calls,omitempty"`
	Type      *MessageType        `json:"type,omitempty"`
}

AsteroidMessage defines model for AsteroidMessage.

type AsteroidMessageRole

type AsteroidMessageRole string

AsteroidMessageRole defines model for AsteroidMessage.Role.

const (
	AsteroidMessageRoleAssistant AsteroidMessageRole = "assistant"
	AsteroidMessageRoleAsteroid  AsteroidMessageRole = "asteroid"
	AsteroidMessageRoleFunction  AsteroidMessageRole = "function"
	AsteroidMessageRoleSystem    AsteroidMessageRole = "system"
	AsteroidMessageRoleTool      AsteroidMessageRole = "tool"
	AsteroidMessageRoleUser      AsteroidMessageRole = "user"
)

Defines values for AsteroidMessageRole.

type AsteroidToolCall

type AsteroidToolCall struct {
	// Arguments Arguments in JSON format
	Arguments *string            `json:"arguments,omitempty"`
	CallId    *string            `json:"call_id,omitempty"`
	CreatedAt *time.Time         `json:"created_at,omitempty"`
	Id        openapi_types.UUID `json:"id"`
	Name      *string            `json:"name,omitempty"`
	ToolId    openapi_types.UUID `json:"tool_id"`
}

AsteroidToolCall defines model for AsteroidToolCall.

type ChainExecution

type ChainExecution struct {
	ChainId    openapi_types.UUID `json:"chain_id"`
	CreatedAt  time.Time          `json:"created_at"`
	Id         openapi_types.UUID `json:"id"`
	ToolcallId openapi_types.UUID `json:"toolcall_id"`
}

ChainExecution defines model for ChainExecution.

type ChainExecutionState

type ChainExecutionState struct {
	Chain               SupervisorChain           `json:"chain"`
	ChainExecution      ChainExecution            `json:"chain_execution"`
	SupervisionRequests []SupervisionRequestState `json:"supervision_requests"`
}

ChainExecutionState defines model for ChainExecutionState.

type ChainRequest

type ChainRequest struct {
	// SupervisorIds Array of supervisor IDs to create chains with
	SupervisorIds *[]openapi_types.UUID `json:"supervisor_ids,omitempty"`
}

ChainRequest defines model for ChainRequest.

type ChatIds

type ChatIds struct {
	ChatId    openapi_types.UUID `json:"chat_id"`
	ChoiceIds []ChoiceIds        `json:"choice_ids"`
}

ChatIds defines model for ChatIds.

type ChatStore

type ChatStore interface {
	CreateChatRequest(
		ctx context.Context,
		runId uuid.UUID,
		request []byte,
		response []byte,
		choices []AsteroidChoice,
		format string,
		requestMessages []AsteroidMessage,
	) (*uuid.UUID, error)
	// GetMessagesForRun(ctx context.Context, runId uuid.UUID, includeInvalidated bool) ([]AsteroidMessage, error)
	GetChat(ctx context.Context, runId uuid.UUID, index int) ([]byte, []byte, error)
	GetMessage(ctx context.Context, id uuid.UUID) (*AsteroidMessage, error)
	UpdateMessage(ctx context.Context, id uuid.UUID, message AsteroidMessage) error
	GetRunChatCount(ctx context.Context, runId uuid.UUID) (int, error)
}

type ChoiceIds

type ChoiceIds struct {
	ChoiceId    string        `json:"choice_id"`
	MessageId   string        `json:"message_id"`
	ToolCallIds []ToolCallIds `json:"tool_call_ids"`
}

ChoiceIds defines model for ChoiceIds.

type Client

type Client struct {
	Hub  *Hub
	Conn *websocket.Conn
	Send chan SupervisionRequest
}

Client represents a single WebSocket connection

func (*Client) ReadPump

func (c *Client) ReadPump()

ReadPump handles the reading of messages from the client and handles the processing of responses

func (*Client) WritePump

func (c *Client) WritePump()

WritePump handles the sending of reviews to the client

type CreateNewChatJSONRequestBody

type CreateNewChatJSONRequestBody = AsteroidChat

CreateNewChatJSONRequestBody defines body for CreateNewChat for application/json ContentType.

type CreateProjectJSONBody

type CreateProjectJSONBody struct {
	Name          string   `json:"name"`
	RunResultTags []string `json:"run_result_tags"`
}

CreateProjectJSONBody defines parameters for CreateProject.

type CreateProjectJSONRequestBody

type CreateProjectJSONRequestBody CreateProjectJSONBody

CreateProjectJSONRequestBody defines body for CreateProject for application/json ContentType.

type CreateRunToolJSONBody

type CreateRunToolJSONBody struct {
	Attributes        map[string]interface{} `json:"attributes"`
	Code              string                 `json:"code"`
	Description       string                 `json:"description"`
	IgnoredAttributes *[]string              `json:"ignored_attributes,omitempty"`
	Name              string                 `json:"name"`
}

CreateRunToolJSONBody defines parameters for CreateRunTool.

type CreateRunToolJSONRequestBody

type CreateRunToolJSONRequestBody CreateRunToolJSONBody

CreateRunToolJSONRequestBody defines body for CreateRunTool for application/json ContentType.

type CreateSupervisionRequestJSONRequestBody

type CreateSupervisionRequestJSONRequestBody = SupervisionRequest

CreateSupervisionRequestJSONRequestBody defines body for CreateSupervisionRequest for application/json ContentType.

type CreateSupervisionResultJSONRequestBody

type CreateSupervisionResultJSONRequestBody = SupervisionResult

CreateSupervisionResultJSONRequestBody defines body for CreateSupervisionResult for application/json ContentType.

type CreateSupervisorJSONRequestBody

type CreateSupervisorJSONRequestBody = Supervisor

CreateSupervisorJSONRequestBody defines body for CreateSupervisor for application/json ContentType.

type CreateTaskJSONBody

type CreateTaskJSONBody struct {
	Description *string `json:"description,omitempty"`
	Name        string  `json:"name"`
}

CreateTaskJSONBody defines parameters for CreateTask.

type CreateTaskJSONRequestBody

type CreateTaskJSONRequestBody CreateTaskJSONBody

CreateTaskJSONRequestBody defines body for CreateTask for application/json ContentType.

type CreateToolSupervisorChainsJSONBody

type CreateToolSupervisorChainsJSONBody = []ChainRequest

CreateToolSupervisorChainsJSONBody defines parameters for CreateToolSupervisorChains.

type CreateToolSupervisorChainsJSONRequestBody

type CreateToolSupervisorChainsJSONRequestBody = CreateToolSupervisorChainsJSONBody

CreateToolSupervisorChainsJSONRequestBody defines body for CreateToolSupervisorChains for application/json ContentType.

type Decision

type Decision string

Decision defines model for Decision.

const (
	Approve   Decision = "approve"
	Escalate  Decision = "escalate"
	Modify    Decision = "modify"
	Reject    Decision = "reject"
	Terminate Decision = "terminate"
)

Defines values for Decision.

type ErrorResponse

type ErrorResponse struct {
	Details *string `json:"details,omitempty"`
	Error   string  `json:"error"`
}

ErrorResponse defines model for ErrorResponse.

type Hub

type Hub struct {
	// Clients is a map of clients to their connection status
	Clients      map[*Client]bool
	ClientsMutex sync.RWMutex
	// ReviewChan is a channel that receives new reviews, then assigns them to a connected client
	ReviewChan chan SupervisionRequest
	// Register and Unregister are used when a new client connects and disconnects
	Register   chan *Client
	Unregister chan *Client
	// AssignedReviews is a map of clients to the reviews they are currently processing
	AssignedReviews      map[*Client]map[string]bool
	AssignedReviewsMutex sync.RWMutex

	// CompletedReviewCount is used to count the number of reviews that have been completed
	CompletedReviewCount int
	Store                Store
}

Hub maintains active connections and broadcasts messages

func NewHub

func NewHub(store Store, humanReviewChan chan SupervisionRequest) *Hub

func (*Hub) Run

func (h *Hub) Run()

Run starts the hub and handles client connections/disconnections and supervisor assignments

type HubStats

type HubStats struct {
	AssignedReviews       map[string]int `json:"assigned_reviews"`
	AssignedReviewsCount  int            `json:"assigned_reviews_count"`
	BusyClients           int            `json:"busy_clients"`
	CompletedReviewsCount int            `json:"completed_reviews_count"`
	ConnectedClients      int            `json:"connected_clients"`
	FreeClients           int            `json:"free_clients"`
	PendingReviewsCount   int            `json:"pending_reviews_count"`
	ReviewDistribution    map[string]int `json:"review_distribution"`
}

HubStats defines model for HubStats.

type InvalidParamFormatError

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap

func (e *InvalidParamFormatError) Unwrap() error

type MessageRole

type MessageRole string

MessageRole defines model for MessageRole.

const (
	MessageRoleAssistant MessageRole = "assistant"
	MessageRoleSystem    MessageRole = "system"
	MessageRoleUser      MessageRole = "user"
)

Defines values for MessageRole.

type MessageType

type MessageType string

MessageType defines model for MessageType.

const (
	Audio    MessageType = "audio"
	Image    MessageType = "image"
	ImageUrl MessageType = "image_url"
	Text     MessageType = "text"
)

Defines values for MessageType.

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type OpenAIConverter

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

func (*OpenAIConverter) ConvertChoices

func (c *OpenAIConverter) ConvertChoices(
	ctx context.Context,
	choices []openai.ChatCompletionChoice,
	runId uuid.UUID,
) ([]AsteroidChoice, error)

func (*OpenAIConverter) ConvertMessage

func (c *OpenAIConverter) ConvertMessage(
	ctx context.Context,
	message openai.ChatCompletionMessage,
	runId uuid.UUID,
) (AsteroidMessage, error)

func (*OpenAIConverter) ConvertToolCall

func (c *OpenAIConverter) ConvertToolCall(
	ctx context.Context,
	toolCall openai.ToolCall,
	runId uuid.UUID,
) (*AsteroidToolCall, error)

func (*OpenAIConverter) ConvertToolCalls

func (c *OpenAIConverter) ConvertToolCalls(
	ctx context.Context,
	toolCalls []openai.ToolCall,
	runId uuid.UUID,
) ([]AsteroidToolCall, error)

func (*OpenAIConverter) ToAsteroidChoices

func (c *OpenAIConverter) ToAsteroidChoices(
	ctx context.Context,
	responseData []byte,
	runId uuid.UUID,
) ([]AsteroidChoice, error)

func (*OpenAIConverter) ToAsteroidMessages

func (c *OpenAIConverter) ToAsteroidMessages(
	ctx context.Context,
	requestData, responseData []byte,
	runId uuid.UUID,
) ([]AsteroidMessage, error)

func (*OpenAIConverter) ValidateB64EncodedRequest

func (c *OpenAIConverter) ValidateB64EncodedRequest(encodedData string) ([]byte, error)

func (*OpenAIConverter) ValidateB64EncodedResponse

func (c *OpenAIConverter) ValidateB64EncodedResponse(encodedData string) ([]byte, error)

type Processor

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

func NewProcessor

func NewProcessor(store Store, humanReviewChan chan SupervisionRequest) *Processor

func (*Processor) Start

func (p *Processor) Start(ctx context.Context)

type Project

type Project struct {
	CreatedAt     time.Time          `json:"created_at"`
	Id            openapi_types.UUID `json:"id"`
	Name          string             `json:"name"`
	RunResultTags []string           `json:"run_result_tags"`
}

Project defines model for Project.

type ProjectStore

type ProjectStore interface {
	CreateProject(ctx context.Context, project Project) error
	GetProject(ctx context.Context, id uuid.UUID) (*Project, error)
	GetProjectFromName(ctx context.Context, name string) (*Project, error)
	GetProjects(ctx context.Context) ([]Project, error)
}

type RequiredHeaderError

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error

func (e *RequiredParamError) Error() string

type ReviewPayload

type ReviewPayload struct {
	ChainState ChainExecutionState `json:"chain_state"`

	// Messages The messages in the run
	Messages []AsteroidMessage `json:"messages"`

	// RunId The ID of the run this review is for
	RunId              openapi_types.UUID `json:"run_id"`
	SupervisionRequest SupervisionRequest `json:"supervision_request"`
	Toolcall           AsteroidToolCall   `json:"toolcall"`
}

ReviewPayload Contains all the information needed for a human reviewer to make a supervision decision

type Run

type Run struct {
	CreatedAt time.Time          `json:"created_at"`
	Id        openapi_types.UUID `json:"id"`
	Result    *string            `json:"result,omitempty"`
	Status    *Status            `json:"status,omitempty"`
	TaskId    openapi_types.UUID `json:"task_id"`
}

Run defines model for Run.

type RunExecution

type RunExecution struct {
	Chains   []ChainExecutionState `json:"chains"`
	Status   Status                `json:"status"`
	Toolcall AsteroidToolCall      `json:"toolcall"`
}

RunExecution defines model for RunExecution.

type RunState

type RunState = []RunExecution

RunState defines model for RunState.

type RunStore

type RunStore interface {
	CreateRun(ctx context.Context, run Run) (uuid.UUID, error)
	GetRun(ctx context.Context, id uuid.UUID) (*Run, error)
	GetRuns(ctx context.Context, taskId uuid.UUID) ([]Run, error)
	GetTaskRuns(ctx context.Context, taskId uuid.UUID) ([]Run, error)
	UpdateRunStatus(ctx context.Context, runId uuid.UUID, status Status) error
	UpdateRunResult(ctx context.Context, runId uuid.UUID, result string) error
}

type ServeMux

type ServeMux interface {
	HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
	ServeHTTP(w http.ResponseWriter, r *http.Request)
}

ServeMux is an abstraction of http.ServeMux.

type Server

type Server struct {
	Hub   *Hub
	Store Store
}

func (Server) CreateNewChat

func (s Server) CreateNewChat(w http.ResponseWriter, r *http.Request, runId uuid.UUID)

func (Server) CreateProject

func (s Server) CreateProject(w http.ResponseWriter, r *http.Request)

func (Server) CreateRun

func (s Server) CreateRun(w http.ResponseWriter, r *http.Request, taskId uuid.UUID)

func (Server) CreateRunTool

func (s Server) CreateRunTool(w http.ResponseWriter, r *http.Request, id uuid.UUID)

func (Server) CreateSupervisionRequest

func (s Server) CreateSupervisionRequest(w http.ResponseWriter, r *http.Request, toolCallId uuid.UUID, chainId uuid.UUID, supervisorId uuid.UUID)

func (Server) CreateSupervisionResult

func (s Server) CreateSupervisionResult(w http.ResponseWriter, r *http.Request, supervisionRequestId uuid.UUID)

func (Server) CreateSupervisor

func (s Server) CreateSupervisor(w http.ResponseWriter, r *http.Request, projectId uuid.UUID)

func (Server) CreateTask

func (s Server) CreateTask(w http.ResponseWriter, r *http.Request, projectId uuid.UUID)

func (Server) CreateToolSupervisorChains

func (s Server) CreateToolSupervisorChains(w http.ResponseWriter, r *http.Request, toolId uuid.UUID)

func (Server) GetHubStats

func (s Server) GetHubStats(w http.ResponseWriter, r *http.Request)

func (Server) GetOpenAPI

func (s Server) GetOpenAPI(w http.ResponseWriter, r *http.Request)

func (Server) GetProject

func (s Server) GetProject(w http.ResponseWriter, r *http.Request, id uuid.UUID)

func (Server) GetProjectTasks

func (s Server) GetProjectTasks(w http.ResponseWriter, r *http.Request, id uuid.UUID)

func (Server) GetProjectTools

func (s Server) GetProjectTools(w http.ResponseWriter, r *http.Request, id uuid.UUID)

func (Server) GetProjects

func (s Server) GetProjects(w http.ResponseWriter, r *http.Request)

func (Server) GetRun

func (s Server) GetRun(w http.ResponseWriter, r *http.Request, id uuid.UUID)

func (Server) GetRunChatCount

func (s Server) GetRunChatCount(w http.ResponseWriter, r *http.Request, runId uuid.UUID)

func (Server) GetRunMessages

func (s Server) GetRunMessages(w http.ResponseWriter, r *http.Request, runId uuid.UUID, index int)

func (Server) GetRunStatus

func (s Server) GetRunStatus(w http.ResponseWriter, r *http.Request, runId uuid.UUID)

func (Server) GetRunTools

func (s Server) GetRunTools(w http.ResponseWriter, r *http.Request, id uuid.UUID)

func (Server) GetSupervisionRequestStatus

func (s Server) GetSupervisionRequestStatus(w http.ResponseWriter, r *http.Request, supervisionRequestId uuid.UUID)

func (Server) GetSupervisionResult

func (s Server) GetSupervisionResult(w http.ResponseWriter, r *http.Request, supervisionRequestId uuid.UUID)

func (Server) GetSupervisionReviewPayload

func (s Server) GetSupervisionReviewPayload(w http.ResponseWriter, r *http.Request, supervisionRequestId uuid.UUID)

func (Server) GetSupervisor

func (s Server) GetSupervisor(w http.ResponseWriter, r *http.Request, id uuid.UUID)

func (Server) GetSupervisors

func (s Server) GetSupervisors(w http.ResponseWriter, r *http.Request, projectId uuid.UUID)

func (Server) GetSwaggerDocs

func (s Server) GetSwaggerDocs(w http.ResponseWriter, r *http.Request)

func (Server) GetTask

func (s Server) GetTask(w http.ResponseWriter, r *http.Request, id uuid.UUID)

func (Server) GetTaskRuns

func (s Server) GetTaskRuns(w http.ResponseWriter, r *http.Request, id uuid.UUID)

func (Server) GetTool

func (s Server) GetTool(w http.ResponseWriter, r *http.Request, id uuid.UUID)

func (Server) GetToolCall

func (s Server) GetToolCall(w http.ResponseWriter, r *http.Request, id uuid.UUID)

func (Server) GetToolCallState

func (s Server) GetToolCallState(w http.ResponseWriter, r *http.Request, toolCallId string)

func (Server) GetToolCallStatus

func (s Server) GetToolCallStatus(w http.ResponseWriter, r *http.Request, toolCallId uuid.UUID)

func (Server) GetToolSupervisorChains

func (s Server) GetToolSupervisorChains(w http.ResponseWriter, r *http.Request, toolId uuid.UUID)

func (Server) UpdateRunResult

func (s Server) UpdateRunResult(w http.ResponseWriter, r *http.Request, runId uuid.UUID)

func (Server) UpdateRunStatus

func (s Server) UpdateRunStatus(w http.ResponseWriter, r *http.Request, runId uuid.UUID)

type ServerInterface

type ServerInterface interface {
	// Get the OpenAPI schema
	// (GET /openapi.yaml)
	GetOpenAPI(w http.ResponseWriter, r *http.Request)
	// Get all projects
	// (GET /project)
	GetProjects(w http.ResponseWriter, r *http.Request)
	// Create a new project
	// (POST /project)
	CreateProject(w http.ResponseWriter, r *http.Request)
	// Get a project
	// (GET /project/{projectId})
	GetProject(w http.ResponseWriter, r *http.Request, projectId openapi_types.UUID)
	// Get all supervisors
	// (GET /project/{projectId}/supervisor)
	GetSupervisors(w http.ResponseWriter, r *http.Request, projectId openapi_types.UUID)
	// Create a new supervisor
	// (POST /project/{projectId}/supervisor)
	CreateSupervisor(w http.ResponseWriter, r *http.Request, projectId openapi_types.UUID)
	// Get all tasks for a project
	// (GET /project/{projectId}/tasks)
	GetProjectTasks(w http.ResponseWriter, r *http.Request, projectId openapi_types.UUID)
	// Create a new task
	// (POST /project/{projectId}/tasks)
	CreateTask(w http.ResponseWriter, r *http.Request, projectId openapi_types.UUID)
	// Get all tools for a project
	// (GET /project/{projectId}/tools)
	GetProjectTools(w http.ResponseWriter, r *http.Request, projectId openapi_types.UUID)
	// Get a run
	// (GET /run/{runId})
	GetRun(w http.ResponseWriter, r *http.Request, runId openapi_types.UUID)
	// Update a run with a result
	// (PUT /run/{runId}/result)
	UpdateRunResult(w http.ResponseWriter, r *http.Request, runId openapi_types.UUID)
	// Get the status of a run
	// (GET /run/{runId}/status)
	GetRunStatus(w http.ResponseWriter, r *http.Request, runId openapi_types.UUID)
	// Update the status of a run
	// (PUT /run/{runId}/status)
	UpdateRunStatus(w http.ResponseWriter, r *http.Request, runId openapi_types.UUID)
	// Get all tools for a run
	// (GET /run/{runId}/tool)
	GetRunTools(w http.ResponseWriter, r *http.Request, runId openapi_types.UUID)
	// Create a new tool for a run
	// (POST /run/{runId}/tool)
	CreateRunTool(w http.ResponseWriter, r *http.Request, runId openapi_types.UUID)
	// Create a new chat completion request from an existing run
	// (POST /run/{run_id}/chat)
	CreateNewChat(w http.ResponseWriter, r *http.Request, runId openapi_types.UUID)
	// Count the number of chat entries for a run
	// (GET /run/{run_id}/chat_count)
	GetRunChatCount(w http.ResponseWriter, r *http.Request, runId openapi_types.UUID)
	// Get the messages for a run
	// (GET /run/{run_id}/messages/{index})
	GetRunMessages(w http.ResponseWriter, r *http.Request, runId openapi_types.UUID, index int)
	// Get hub stats
	// (GET /stats)
	GetHubStats(w http.ResponseWriter, r *http.Request)
	// Get a supervision result
	// (GET /supervision_request/{supervisionRequestId}/result)
	GetSupervisionResult(w http.ResponseWriter, r *http.Request, supervisionRequestId openapi_types.UUID)
	// Create a supervision result for a supervision request
	// (POST /supervision_request/{supervisionRequestId}/result)
	CreateSupervisionResult(w http.ResponseWriter, r *http.Request, supervisionRequestId openapi_types.UUID)
	// Get the review payload for a supervision request
	// (GET /supervision_request/{supervisionRequestId}/review_payload)
	GetSupervisionReviewPayload(w http.ResponseWriter, r *http.Request, supervisionRequestId openapi_types.UUID)
	// Get a supervision request status
	// (GET /supervision_request/{supervisionRequestId}/status)
	GetSupervisionRequestStatus(w http.ResponseWriter, r *http.Request, supervisionRequestId openapi_types.UUID)
	// Get a supervisor
	// (GET /supervisor/{supervisorId})
	GetSupervisor(w http.ResponseWriter, r *http.Request, supervisorId openapi_types.UUID)
	// Get the Swagger UI
	// (GET /swagger-ui)
	GetSwaggerDocs(w http.ResponseWriter, r *http.Request)
	// Get a task
	// (GET /task/{taskId})
	GetTask(w http.ResponseWriter, r *http.Request, taskId openapi_types.UUID)
	// Get all runs for a task
	// (GET /task/{taskId}/run)
	GetTaskRuns(w http.ResponseWriter, r *http.Request, taskId openapi_types.UUID)
	// Create a new run for a task
	// (POST /task/{taskId}/run)
	CreateRun(w http.ResponseWriter, r *http.Request, taskId openapi_types.UUID)
	// Get a tool
	// (GET /tool/{toolId})
	GetTool(w http.ResponseWriter, r *http.Request, toolId openapi_types.UUID)
	// Get all supervisors for a tool, in chain format
	// (GET /tool/{toolId}/supervisors)
	GetToolSupervisorChains(w http.ResponseWriter, r *http.Request, toolId openapi_types.UUID)
	// Create new chains with supervisors for a tool
	// (POST /tool/{toolId}/supervisors)
	CreateToolSupervisorChains(w http.ResponseWriter, r *http.Request, toolId openapi_types.UUID)
	// Get a tool call
	// (GET /tool_call/{toolCallId})
	GetToolCall(w http.ResponseWriter, r *http.Request, toolCallId openapi_types.UUID)
	// Create a supervision request for a supervisor in a chain on a tool call
	// (POST /tool_call/{toolCallId}/chain/{chainId}/supervisor/{supervisorId}/supervision_request)
	CreateSupervisionRequest(w http.ResponseWriter, r *http.Request, toolCallId openapi_types.UUID, chainId openapi_types.UUID, supervisorId openapi_types.UUID)
	// Get the state of a tool call
	// (GET /tool_call/{toolCallId}/state)
	GetToolCallState(w http.ResponseWriter, r *http.Request, toolCallId string)
	// Get a tool call status
	// (GET /tool_call/{toolCallId}/status)
	GetToolCallStatus(w http.ResponseWriter, r *http.Request, toolCallId openapi_types.UUID)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandlerFunc   func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) CreateNewChat

func (siw *ServerInterfaceWrapper) CreateNewChat(w http.ResponseWriter, r *http.Request)

CreateNewChat operation middleware

func (*ServerInterfaceWrapper) CreateProject

func (siw *ServerInterfaceWrapper) CreateProject(w http.ResponseWriter, r *http.Request)

CreateProject operation middleware

func (*ServerInterfaceWrapper) CreateRun

func (siw *ServerInterfaceWrapper) CreateRun(w http.ResponseWriter, r *http.Request)

CreateRun operation middleware

func (*ServerInterfaceWrapper) CreateRunTool

func (siw *ServerInterfaceWrapper) CreateRunTool(w http.ResponseWriter, r *http.Request)

CreateRunTool operation middleware

func (*ServerInterfaceWrapper) CreateSupervisionRequest

func (siw *ServerInterfaceWrapper) CreateSupervisionRequest(w http.ResponseWriter, r *http.Request)

CreateSupervisionRequest operation middleware

func (*ServerInterfaceWrapper) CreateSupervisionResult

func (siw *ServerInterfaceWrapper) CreateSupervisionResult(w http.ResponseWriter, r *http.Request)

CreateSupervisionResult operation middleware

func (*ServerInterfaceWrapper) CreateSupervisor

func (siw *ServerInterfaceWrapper) CreateSupervisor(w http.ResponseWriter, r *http.Request)

CreateSupervisor operation middleware

func (*ServerInterfaceWrapper) CreateTask

func (siw *ServerInterfaceWrapper) CreateTask(w http.ResponseWriter, r *http.Request)

CreateTask operation middleware

func (*ServerInterfaceWrapper) CreateToolSupervisorChains

func (siw *ServerInterfaceWrapper) CreateToolSupervisorChains(w http.ResponseWriter, r *http.Request)

CreateToolSupervisorChains operation middleware

func (*ServerInterfaceWrapper) GetHubStats

func (siw *ServerInterfaceWrapper) GetHubStats(w http.ResponseWriter, r *http.Request)

GetHubStats operation middleware

func (*ServerInterfaceWrapper) GetOpenAPI

func (siw *ServerInterfaceWrapper) GetOpenAPI(w http.ResponseWriter, r *http.Request)

GetOpenAPI operation middleware

func (*ServerInterfaceWrapper) GetProject

func (siw *ServerInterfaceWrapper) GetProject(w http.ResponseWriter, r *http.Request)

GetProject operation middleware

func (*ServerInterfaceWrapper) GetProjectTasks

func (siw *ServerInterfaceWrapper) GetProjectTasks(w http.ResponseWriter, r *http.Request)

GetProjectTasks operation middleware

func (*ServerInterfaceWrapper) GetProjectTools

func (siw *ServerInterfaceWrapper) GetProjectTools(w http.ResponseWriter, r *http.Request)

GetProjectTools operation middleware

func (*ServerInterfaceWrapper) GetProjects

func (siw *ServerInterfaceWrapper) GetProjects(w http.ResponseWriter, r *http.Request)

GetProjects operation middleware

func (*ServerInterfaceWrapper) GetRun

GetRun operation middleware

func (*ServerInterfaceWrapper) GetRunChatCount

func (siw *ServerInterfaceWrapper) GetRunChatCount(w http.ResponseWriter, r *http.Request)

GetRunChatCount operation middleware

func (*ServerInterfaceWrapper) GetRunMessages

func (siw *ServerInterfaceWrapper) GetRunMessages(w http.ResponseWriter, r *http.Request)

GetRunMessages operation middleware

func (*ServerInterfaceWrapper) GetRunStatus

func (siw *ServerInterfaceWrapper) GetRunStatus(w http.ResponseWriter, r *http.Request)

GetRunStatus operation middleware

func (*ServerInterfaceWrapper) GetRunTools

func (siw *ServerInterfaceWrapper) GetRunTools(w http.ResponseWriter, r *http.Request)

GetRunTools operation middleware

func (*ServerInterfaceWrapper) GetSupervisionRequestStatus

func (siw *ServerInterfaceWrapper) GetSupervisionRequestStatus(w http.ResponseWriter, r *http.Request)

GetSupervisionRequestStatus operation middleware

func (*ServerInterfaceWrapper) GetSupervisionResult

func (siw *ServerInterfaceWrapper) GetSupervisionResult(w http.ResponseWriter, r *http.Request)

GetSupervisionResult operation middleware

func (*ServerInterfaceWrapper) GetSupervisionReviewPayload

func (siw *ServerInterfaceWrapper) GetSupervisionReviewPayload(w http.ResponseWriter, r *http.Request)

GetSupervisionReviewPayload operation middleware

func (*ServerInterfaceWrapper) GetSupervisor

func (siw *ServerInterfaceWrapper) GetSupervisor(w http.ResponseWriter, r *http.Request)

GetSupervisor operation middleware

func (*ServerInterfaceWrapper) GetSupervisors

func (siw *ServerInterfaceWrapper) GetSupervisors(w http.ResponseWriter, r *http.Request)

GetSupervisors operation middleware

func (*ServerInterfaceWrapper) GetSwaggerDocs

func (siw *ServerInterfaceWrapper) GetSwaggerDocs(w http.ResponseWriter, r *http.Request)

GetSwaggerDocs operation middleware

func (*ServerInterfaceWrapper) GetTask

GetTask operation middleware

func (*ServerInterfaceWrapper) GetTaskRuns

func (siw *ServerInterfaceWrapper) GetTaskRuns(w http.ResponseWriter, r *http.Request)

GetTaskRuns operation middleware

func (*ServerInterfaceWrapper) GetTool

GetTool operation middleware

func (*ServerInterfaceWrapper) GetToolCall

func (siw *ServerInterfaceWrapper) GetToolCall(w http.ResponseWriter, r *http.Request)

GetToolCall operation middleware

func (*ServerInterfaceWrapper) GetToolCallState

func (siw *ServerInterfaceWrapper) GetToolCallState(w http.ResponseWriter, r *http.Request)

GetToolCallState operation middleware

func (*ServerInterfaceWrapper) GetToolCallStatus

func (siw *ServerInterfaceWrapper) GetToolCallStatus(w http.ResponseWriter, r *http.Request)

GetToolCallStatus operation middleware

func (*ServerInterfaceWrapper) GetToolSupervisorChains

func (siw *ServerInterfaceWrapper) GetToolSupervisorChains(w http.ResponseWriter, r *http.Request)

GetToolSupervisorChains operation middleware

func (*ServerInterfaceWrapper) UpdateRunResult

func (siw *ServerInterfaceWrapper) UpdateRunResult(w http.ResponseWriter, r *http.Request)

UpdateRunResult operation middleware

func (*ServerInterfaceWrapper) UpdateRunStatus

func (siw *ServerInterfaceWrapper) UpdateRunStatus(w http.ResponseWriter, r *http.Request)

UpdateRunStatus operation middleware

type Status

type Status string

Status defines model for Status.

const (
	Assigned  Status = "assigned"
	Completed Status = "completed"
	Failed    Status = "failed"
	Pending   Status = "pending"
	Timeout   Status = "timeout"
)

Defines values for Status.

type StdHTTPServerOptions

type StdHTTPServerOptions struct {
	BaseURL          string
	BaseRouter       ServeMux
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type Store

Store defines the interface for all storage operations

type SupervisionRequest

type SupervisionRequest struct {
	ChainexecutionId *openapi_types.UUID `json:"chainexecution_id,omitempty"`
	Id               *openapi_types.UUID `json:"id,omitempty"`
	PositionInChain  int                 `json:"position_in_chain"`
	Status           *SupervisionStatus  `json:"status,omitempty"`
	SupervisorId     openapi_types.UUID  `json:"supervisor_id"`
}

SupervisionRequest defines model for SupervisionRequest.

type SupervisionRequestState

type SupervisionRequestState struct {
	Result             *SupervisionResult `json:"result,omitempty"`
	Status             SupervisionStatus  `json:"status"`
	SupervisionRequest SupervisionRequest `json:"supervision_request"`
}

SupervisionRequestState defines model for SupervisionRequestState.

type SupervisionResult

type SupervisionResult struct {
	CreatedAt            time.Time           `json:"created_at"`
	Decision             Decision            `json:"decision"`
	Id                   *openapi_types.UUID `json:"id,omitempty"`
	Reasoning            string              `json:"reasoning"`
	SupervisionRequestId openapi_types.UUID  `json:"supervision_request_id"`
	ToolcallId           *openapi_types.UUID `json:"toolcall_id,omitempty"`
}

SupervisionResult defines model for SupervisionResult.

type SupervisionStatus

type SupervisionStatus struct {
	CreatedAt            time.Time           `json:"created_at"`
	Id                   int                 `json:"id"`
	Status               Status              `json:"status"`
	SupervisionRequestId *openapi_types.UUID `json:"supervision_request_id,omitempty"`
}

SupervisionStatus defines model for SupervisionStatus.

type SupervisionStore

type SupervisionStore interface {
	// Requests
	CreateSupervisionRequest(ctx context.Context, request SupervisionRequest, chainId uuid.UUID, toolCallId uuid.UUID) (*uuid.UUID, error)
	GetSupervisionRequest(ctx context.Context, id uuid.UUID) (*SupervisionRequest, error)
	GetSupervisionRequestsForStatus(ctx context.Context, status Status) ([]SupervisionRequest, error)

	// Results
	GetSupervisionResultFromRequestID(ctx context.Context, requestId uuid.UUID) (*SupervisionResult, error)
	CreateSupervisionResult(ctx context.Context, result SupervisionResult, requestId uuid.UUID) (*uuid.UUID, error)

	// Statuses
	CreateSupervisionStatus(ctx context.Context, requestID uuid.UUID, status SupervisionStatus) error

	// Util
	CountSupervisionRequests(ctx context.Context, status Status) (int, error)

	GetChainExecutionSupervisionRequests(ctx context.Context, chainExecutionId uuid.UUID) ([]SupervisionRequest, error)
	GetSupervisionRequestStatus(ctx context.Context, requestId uuid.UUID) (*SupervisionStatus, error)

	GetExecutionFromChainId(ctx context.Context, chainId uuid.UUID) (*uuid.UUID, error)
	GetChainExecution(ctx context.Context, executionId uuid.UUID) (*uuid.UUID, *uuid.UUID, error)
	GetChainExecutionFromChainAndToolCall(ctx context.Context, chainId uuid.UUID, toolCallId uuid.UUID) (*uuid.UUID, error)
	GetChainExecutionsFromToolCall(ctx context.Context, id uuid.UUID) ([]uuid.UUID, error)
	GetChainExecutionState(ctx context.Context, executionId uuid.UUID) (*ChainExecutionState, error)
}

type Supervisor

type Supervisor struct {
	Attributes  map[string]interface{} `json:"attributes"`
	Code        string                 `json:"code"`
	CreatedAt   time.Time              `json:"created_at"`
	Description string                 `json:"description"`
	Id          *openapi_types.UUID    `json:"id,omitempty"`
	Name        string                 `json:"name"`

	// Type The type of supervisor. ClientSupervisor means that the supervision is done client side and the server is merely informed. Other supervisor types are handled serverside, e.g. HumanSupervisor means that a human will review the request via the Asteroid UI.
	Type SupervisorType `json:"type"`
}

Supervisor defines model for Supervisor.

type SupervisorChain

type SupervisorChain struct {
	ChainId     openapi_types.UUID `json:"chain_id"`
	Supervisors []Supervisor       `json:"supervisors"`
}

SupervisorChain defines model for SupervisorChain.

type SupervisorStore

type SupervisorStore interface {
	CreateSupervisor(ctx context.Context, supervisor Supervisor) (uuid.UUID, error)
	GetSupervisor(ctx context.Context, id uuid.UUID) (*Supervisor, error)
	GetSupervisorFromValues(ctx context.Context, code string, name string, desc string, t SupervisorType, attributes map[string]interface{}) (*Supervisor, error)
	GetSupervisors(ctx context.Context, projectId uuid.UUID) ([]Supervisor, error)
	CreateSupervisorChain(ctx context.Context, toolId uuid.UUID, chain ChainRequest) (*uuid.UUID, error)
	GetSupervisorChains(ctx context.Context, toolId uuid.UUID) ([]SupervisorChain, error)
	GetSupervisorChain(ctx context.Context, id uuid.UUID) (*SupervisorChain, error)
}

type SupervisorType

type SupervisorType string

SupervisorType The type of supervisor. ClientSupervisor means that the supervision is done client side and the server is merely informed. Other supervisor types are handled serverside, e.g. HumanSupervisor means that a human will review the request via the Asteroid UI.

const (
	ClientSupervisor SupervisorType = "client_supervisor"
	HumanSupervisor  SupervisorType = "human_supervisor"
	NoSupervisor     SupervisorType = "no_supervisor"
)

Defines values for SupervisorType.

type Task

type Task struct {
	CreatedAt   time.Time          `json:"created_at"`
	Description *string            `json:"description,omitempty"`
	Id          openapi_types.UUID `json:"id"`
	Name        string             `json:"name"`
	ProjectId   openapi_types.UUID `json:"project_id"`
}

Task defines model for Task.

type TaskStore

type TaskStore interface {
	CreateTask(ctx context.Context, task Task) (*uuid.UUID, error)
	GetTask(ctx context.Context, id uuid.UUID) (*Task, error)
	GetProjectTasks(ctx context.Context, projectId uuid.UUID) ([]Task, error)
}

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error

type Tool

type Tool struct {
	Attributes        map[string]interface{} `json:"attributes"`
	Code              string                 `json:"code"`
	Description       string                 `json:"description"`
	Id                *openapi_types.UUID    `json:"id,omitempty"`
	IgnoredAttributes *[]string              `json:"ignored_attributes,omitempty"`
	Name              string                 `json:"name"`
	RunId             openapi_types.UUID     `json:"run_id"`
}

Tool defines model for Tool.

type ToolCallIds

type ToolCallIds struct {
	ToolCallId *string `json:"tool_call_id,omitempty"`
	ToolId     *string `json:"tool_id,omitempty"`
}

ToolCallIds defines model for ToolCallIds.

type ToolRequestStore

type ToolRequestStore interface {
	// CreateToolRequestGroup(ctx context.Context, toolId uuid.UUID, request ToolRequestGroup) (*ToolRequestGroup, error)
	// GetRunRequestGroups(ctx context.Context, runId uuid.UUID, includeArgs bool) ([]ToolRequestGroup, error)
	// GetRequestGroup(ctx context.Context, id uuid.UUID, includeArgs bool) (*ToolRequestGroup, error)
	// CreateToolCall(ctx context.Context, toolCallId uuid.UUID, request ToolRequest) (*uuid.UUID, error)
	GetToolCall(ctx context.Context, id uuid.UUID) (*AsteroidToolCall, error)
	GetToolCallFromCallId(ctx context.Context, id string) (*AsteroidToolCall, error)
}

type ToolStore

type ToolStore interface {
	CreateTool(ctx context.Context, runId uuid.UUID, attributes map[string]interface{}, name string, description string, ignoredAttributes []string, code string) (*Tool, error)
	GetTool(ctx context.Context, id uuid.UUID) (*Tool, error)
	// GetToolFromValues(ctx context.Context, attributes map[string]interface{}, name string, description string, ignoredAttributes []string) (*Tool, error)
	GetRunTools(ctx context.Context, id uuid.UUID) ([]Tool, error)
	GetProjectTools(ctx context.Context, id uuid.UUID) ([]Tool, error)
	GetToolFromNameAndRunId(ctx context.Context, name string, runId uuid.UUID) (*Tool, error)
}

type UnescapedCookieParamError

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap

func (e *UnescapedCookieParamError) Unwrap() error

type UnmarshalingParamError

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap

func (e *UnmarshalingParamError) Unwrap() error

type UpdateRunResultJSONBody

type UpdateRunResultJSONBody struct {
	Result *string `json:"result,omitempty"`
}

UpdateRunResultJSONBody defines parameters for UpdateRunResult.

type UpdateRunResultJSONRequestBody

type UpdateRunResultJSONRequestBody UpdateRunResultJSONBody

UpdateRunResultJSONRequestBody defines body for UpdateRunResult for application/json ContentType.

type UpdateRunStatusJSONRequestBody

type UpdateRunStatusJSONRequestBody = Status

UpdateRunStatusJSONRequestBody defines body for UpdateRunStatus for application/json ContentType.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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