Documentation
¶
Index ¶
- Constants
- Variables
- type BotChatCompletionMessage
- type BotConfig
- type BotEvent
- type BotEventPair
- type BotEventType
- type BotInterface
- type BotLocationConfig
- type BotMemoryResponse
- type BotNetworkSnapshot
- type BotService
- type BotServiceOpts
- type BotSession
- type BotTask
- func (t *BotTask) Cancel(ctx context.Context, reason types.TaskCancellationReason) error
- func (t *BotTask) Execute(ctx context.Context, options ...interface{}) error
- func (t *BotTask) HeartBeat(ctx context.Context) (bool, error)
- func (t *BotTask) Message() *types.TaskMessage
- func (t *BotTask) Metadata() types.TaskMetadata
- func (t *BotTask) Retry(ctx context.Context) error
- type BotTransitionConfig
- type BotTransitionResponse
- type BotUserResponse
- type Marker
- type MarkerField
- type MetadataKey
- type PetriBotService
- func (s *PetriBotService) PopBotTask(ctx context.Context, in *pb.PopBotTaskRequest) (*pb.PopBotTaskResponse, error)
- func (s *PetriBotService) PushBotEvent(ctx context.Context, in *pb.PushBotEventRequest) (*pb.PushBotEventResponse, error)
- func (s *PetriBotService) PushBotEventBlocking(ctx context.Context, in *pb.PushBotEventBlockingRequest) (*pb.PushBotEventBlockingResponse, error)
- func (s *PetriBotService) PushBotMarkers(ctx context.Context, in *pb.PushBotMarkersRequest) (*pb.PushBotMarkersResponse, error)
Constants ¶
View Source
const PromptTypeMemory = "memory_message"
View Source
const PromptTypeTransition = "transition_message"
View Source
const PromptTypeUser = "user_message"
Variables ¶
View Source
var ErrBotSessionNotFound = fmt.Errorf("bot session not found")
View Source
var Keys = &keys{}
Functions ¶
This section is empty.
Types ¶
type BotChatCompletionMessage ¶
type BotChatCompletionMessage struct {
Role string `json:"role" redis:"role"`
Content string `json:"content" redis:"content"`
// This property isn't in the official documentation, but it's in
// the documentation for the official library for python:
// - https://github.com/openai/openai-python/blob/main/chatml.md
// - https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb
Name string `json:"name,omitempty" redis:"name,omitempty"`
}
type BotConfig ¶
type BotConfig struct {
Model string `json:"model" redis:"model"`
Locations map[string]BotLocationConfig `json:"locations" redis:"locations"`
Transitions map[string]BotTransitionConfig `json:"transitions" redis:"transitions"`
ApiKey string `json:"api_key" redis:"api_key"`
Authorized bool `json:"authorized" redis:"authorized"`
WelcomeMessage string `json:"welcome_message" redis:"welcome_message"`
}
BotConfig holds the overall config for the bot
func (*BotConfig) FormatLocations ¶
func (*BotConfig) FormatTransitions ¶
type BotEvent ¶
type BotEvent struct {
Type BotEventType `json:"type" redis:"type"`
Value string `json:"value" redis:"value"`
Metadata map[string]string `json:"metadata" redis:"metadata"`
PairId string `json:"pair_id" redis:"pair_id"`
}
type BotEventPair ¶
type BotEventType ¶
type BotEventType string
const ( BotEventTypeError BotEventType = "error" BotEventTypeAgentMessage BotEventType = "agent_message" BotEventTypeUserMessage BotEventType = "user_message" BotEventTypeTransitionMessage BotEventType = "transition_message" BotEventTypeMemoryMessage BotEventType = "memory_message" BotEventTypeMemoryUpdated BotEventType = "memory_updated" BotEventTypeSessionCreated BotEventType = "session_created" BotEventTypeTransitionFired BotEventType = "transition_fired" BotEventTypeTransitionFailed BotEventType = "transition_failed" BotEventTypeTransitionStarted BotEventType = "transition_started" BotEventTypeTransitionCompleted BotEventType = "transition_completed" BotEventTypeNetworkState BotEventType = "network_state" BotEventTypeConfirmTransition BotEventType = "confirm_transition" BotEventTypeAcceptTransition BotEventType = "accept_transition" BotEventTypeRejectTransition BotEventType = "reject_transition" BotEventTypeInputFileRequest BotEventType = "input_file_request" BotEventTypeInputFileResponse BotEventType = "input_file_response" BotEventTypeOutputFile BotEventType = "output_file" BotEventTypeConfirmRequest BotEventType = "confirm_request" BotEventTypeConfirmResponse BotEventType = "confirm_response" )
type BotInterface ¶
type BotInterface struct {
// contains filtered or unexported fields
}
func NewBotInterface ¶
func NewBotInterface(opts botInterfaceOpts) (*BotInterface, error)
func (*BotInterface) SendPrompt ¶
func (bi *BotInterface) SendPrompt(sessionId, messageType string, request *BotEvent) error
type BotLocationConfig ¶
type BotLocationConfig struct {
Name string `json:"name" redis:"name"`
Marker map[string]string `json:"marker" redis:"marker"`
Expose bool `json:"expose" redis:"expose"`
}
BotLocationConfig holds the config for a location in the bot network
func (*BotLocationConfig) FormatLocation ¶
func (l *BotLocationConfig) FormatLocation() string
type BotMemoryResponse ¶
type BotMemoryResponse struct {
Msg string `json:"msg" redis:"msg"`
}
type BotNetworkSnapshot ¶
type BotService ¶
type BotService interface {
pb.BotServiceServer
PushBotEvent(ctx context.Context, in *pb.PushBotEventRequest) (*pb.PushBotEventResponse, error)
PushBotEventBlocking(ctx context.Context, in *pb.PushBotEventBlockingRequest) (*pb.PushBotEventBlockingResponse, error)
PopBotTask(ctx context.Context, in *pb.PopBotTaskRequest) (*pb.PopBotTaskResponse, error)
PushBotMarkers(ctx context.Context, in *pb.PushBotMarkersRequest) (*pb.PushBotMarkersResponse, error)
}
func NewPetriBotService ¶
func NewPetriBotService(ctx context.Context, opts BotServiceOpts) (BotService, error)
type BotServiceOpts ¶
type BotServiceOpts struct {
Config types.AppConfig
RedisClient *common.RedisClient
BackendRepo repository.BackendRepository
WorkspaceRepo repository.WorkspaceRepository
TaskRepo repository.TaskRepository
ContainerRepo repository.ContainerRepository
Scheduler *scheduler.Scheduler
RouteGroup *echo.Group
Tailscale *network.Tailscale
TaskDispatcher *task.Dispatcher
EventRepo repository.EventRepository
}
type BotSession ¶
type BotSession struct {
Id string `json:"id" redis:"id"`
Messages []BotChatCompletionMessage `json:"messages" redis:"messages"`
CreatedAt int64 `json:"created_at" redis:"created_at"`
EventHistory []*BotEvent `json:"event_history" redis:"event_history"`
}
func (*BotSession) GetMessagesInOpenAIFormat ¶
func (s *BotSession) GetMessagesInOpenAIFormat() []openai.ChatCompletionMessage
type BotTask ¶
type BotTask struct {
// contains filtered or unexported fields
}
func (*BotTask) Message ¶
func (t *BotTask) Message() *types.TaskMessage
func (*BotTask) Metadata ¶
func (t *BotTask) Metadata() types.TaskMetadata
type BotTransitionConfig ¶
type BotTransitionConfig struct {
Cpu int64 `json:"cpu" redis:"cpu"`
Gpu types.GpuType `json:"gpu" redis:"gpu"`
Memory int64 `json:"memory" redis:"memory"`
PythonVersion string `json:"python_version" redis:"python_version"`
ImageId string `json:"image_id" redis:"image_id"`
Timeout int `json:"timeout" redis:"timeout"`
KeepWarm int `json:"keep_warm" redis:"keep_warm"`
MaxPending int `json:"max_pending" redis:"max_pending"`
Volumes []string `json:"volumes" redis:"volumes"`
Secrets []string `json:"secrets" redis:"secrets"`
Handler string `json:"handler" redis:"handler"`
OnStart string `json:"on_start" redis:"on_start"`
CallbackUrl string `json:"callback_url" redis:"callback_url"`
TaskPolicy string `json:"task_policy" redis:"task_policy"`
Name string `json:"name" redis:"name"`
Inputs map[string]int `json:"inputs" redis:"inputs"`
Outputs []string `json:"outputs" redis:"outputs"`
Description string `json:"description" redis:"description"`
Expose bool `json:"expose" redis:"expose"`
Confirm bool `json:"confirm" redis:"confirm"`
}
BotTransitionConfig holds the config for a transition
func (*BotTransitionConfig) FormatTransition ¶
func (t *BotTransitionConfig) FormatTransition() string
type BotTransitionResponse ¶
type BotTransitionResponse struct {
Msg string `json:"msg" redis:"msg"`
}
type BotUserResponse ¶
type Marker ¶
type Marker struct {
LocationName string `json:"location_name" mapstructure:"location_name"`
Fields []MarkerField `json:"marker_data" mapstructure:"marker_data"`
SourceTaskId string `json:"source_task_id" mapstructure:"source_task_id"`
}
type MarkerField ¶
type MetadataKey ¶
type MetadataKey string
const ( MetadataRequestId MetadataKey = "request_id" MetadataSessionId MetadataKey = "session_id" MetadataTransitionName MetadataKey = "transition_name" MetadataTaskId MetadataKey = "task_id" MetadataErrorMsg MetadataKey = "error_msg" )
type PetriBotService ¶
type PetriBotService struct {
pb.UnimplementedBotServiceServer
// contains filtered or unexported fields
}
func (*PetriBotService) PopBotTask ¶
func (s *PetriBotService) PopBotTask(ctx context.Context, in *pb.PopBotTaskRequest) (*pb.PopBotTaskResponse, error)
func (*PetriBotService) PushBotEvent ¶
func (s *PetriBotService) PushBotEvent(ctx context.Context, in *pb.PushBotEventRequest) (*pb.PushBotEventResponse, error)
func (*PetriBotService) PushBotEventBlocking ¶
func (s *PetriBotService) PushBotEventBlocking(ctx context.Context, in *pb.PushBotEventBlockingRequest) (*pb.PushBotEventBlockingResponse, error)
func (*PetriBotService) PushBotMarkers ¶
func (s *PetriBotService) PushBotMarkers(ctx context.Context, in *pb.PushBotMarkersRequest) (*pb.PushBotMarkersResponse, error)
Click to show internal directories.
Click to hide internal directories.