Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AIClient ¶
type AIClient interface {
GenerateResponse(ctx context.Context, prompt, userMessage string) (*BotLLMResponse, error)
}
AIClient interface for AI operations.
type Bot ¶
type Bot interface {
HandleMessage(ctx context.Context, userID int64, username, firstName, lastName, message string) ([]pkg.OutputMessage, error)
HandleCommand(userID int64, username, firstName, lastName, message string) ([]pkg.OutputMessage, error)
GetName() string
}
Bot represents a telegram bot interface.
type BotConfig ¶
type BotConfig struct {
Name string `json:"name" yaml:"name"`
NameEnv string `json:"name_env" yaml:"name_env"`
Token string `json:"token" yaml:"token"`
TokenEnv string `json:"token_env" yaml:"token_env"`
PromptFiles map[string][]string `json:"prompt_files" yaml:"prompt_files"` // For every stage each character may have different prompts
Description string `json:"description" yaml:"description"`
CommandHandlers map[string]func(chatID int64, sender MessageSender) error
StateHandlers map[string]StateTransition `json:"state_handlers" yaml:"state_handlers"`
TransitionHandlers map[string]func(chatID int64, sender MessageSender) error
}
BotConfig represents the configuration for a single bot.
func (*BotConfig) AddCommandHandler ¶
func (s *BotConfig) AddCommandHandler(key string, value func(chatID int64, sender MessageSender) error)
func (*BotConfig) AddStateHandler ¶
func (s *BotConfig) AddStateHandler(key string, value StateTransition)
func (*BotConfig) AddTransitionHandler ¶
func (s *BotConfig) AddTransitionHandler(key string, value func(chatID int64, sender MessageSender) error)
type BotLLMResponse ¶
type BotLLMResponse struct {
Answer string `json:"answer"`
Goals []string `json:"goals"`
Command string `json:"command,omitempty"`
Reasoning string `json:"reasoning,omitempty"`
}
BotLLMResponse represents the response structure expected from the LLM by the bot.
type BotManager ¶
type Config ¶
type Config struct {
LLMAPIKey string
GenerationConfig GenerationConfig `json:"generation_config" yaml:"generation_config"`
Bots map[string]*BotConfig `json:"bots" yaml:"bots"`
LogLevel string
}
Config represents the overall application configuration.
func LoadConfig ¶
LoadConfig loads the configuration from environment variables.
func LoadFromYAML ¶
LoadFromYAML loads the configuration from a YAML file.
type GameEngine ¶
type GameEngine struct {
// contains filtered or unexported fields
}
GameEngine represents the main quest service that orchestrates bots and telegram managers.
func NewGameEngine ¶
func NewGameEngine( botManager BotManager, tgManager MessengerManager, logger *slog.Logger, ) (*GameEngine, error)
NewGameEngine creates a new GameEngine instance with the provided logger and configuration.
func (*GameEngine) Run ¶
func (s *GameEngine) Run(ctx context.Context) error
Run starts the service, including the bot manager and telegram manager. If consoleMode is true, it also starts a console input loop.
func (*GameEngine) RunConsoleLoop ¶
func (s *GameEngine) RunConsoleLoop(ctx context.Context)
RunConsoleLoop starts an interactive console loop for testing bots. This method blocks the calling goroutine until the user enters 'exit' or until the context is cancelled.
type GenerationConfig ¶
type GenerationConfig struct {
ModelName string `json:"model_name" yaml:"model_name"`
Temperature float32 `json:"temperature" yaml:"temperature"`
MaxOutputTokens int32 `json:"max_output_tokens" yaml:"max_output_tokens"`
}
GenerationConfig represents the configuration for the GenerationConfig AI client.
type GenerationOptions ¶
type MessageSender ¶
type MessageSender interface {
SendMessage(chatID int64, text string) error
SendPhoto(chatID int64, photoPath string) error
}
MessageSender is an interface for sending messages and photos.
type MessengerManager ¶
type OptionFunc ¶
type OptionFunc func(*GenerationOptions)
func WithMaxOutputTokens ¶
func WithMaxOutputTokens(maxOutputTokens int32) OptionFunc
func WithModelName ¶
func WithModelName(modelName string) OptionFunc
func WithTemperature ¶
func WithTemperature(temperature float32) OptionFunc
type StateTransition ¶
type StateTransition struct {
TargetState string `json:"target_state" yaml:"target_state"`
Goals []string `json:"goals" yaml:"goals"`
}
StateTransition represents a transition to a target state when goals are reached.