Documentation ¶
Index ¶
- Constants
- func ConvertMessagesToOpenAIMessages(messages []*Message) ([]openai.ChatCompletionMessage, error)
- func RunIntoWriter(ctx context2.Context, c GeppettoRunnable, manager *Manager, w io.Writer) error
- func RunToString(ctx context2.Context, c GeppettoRunnable, manager *Manager) (string, error)
- type GeppettoRunnable
- type Manager
- func (c *Manager) AddMessages(messages ...*Message)
- func (c *Manager) GetMessages() []*Message
- func (c *Manager) GetMessagesWithSystemPrompt() []*Message
- func (c *Manager) GetSinglePrompt() string
- func (c *Manager) GetSystemPrompt() string
- func (c *Manager) PrependMessages(messages ...*Message)
- func (c *Manager) SaveToFile(s string) error
- func (c *Manager) SetMessages(messages []*Message)
- func (c *Manager) SetSystemPrompt(systemPrompt string)
- type ManagerOption
- type Message
Constants ¶
const RoleAssistant = "assistant"
const RoleSystem = "system"
const RoleTool = "tool"
const RoleUser = "user"
Variables ¶
This section is empty.
Functions ¶
func RunIntoWriter ¶ added in v0.2.24
func RunToString ¶ added in v0.2.24
Types ¶
type GeppettoRunnable ¶ added in v0.2.24
type Manager ¶
func CreateManager ¶ added in v0.2.24
func CreateManager( systemPrompt string, prompt string, messages []*Message, params interface{}, options ...ManagerOption, ) (*Manager, error)
CreateManager creates a new Context Manager. It is used by the code generator to initialize a conversation by passing a custom glazed struct for params.
The systemPrompt and prompt templates are rendered using the params. Messages are also rendered using the params before being added to the manager.
ManagerOptions can be passed to further customize the manager on creation.
func NewManager ¶
func NewManager(options ...ManagerOption) *Manager
func RunToContextManager ¶ added in v0.2.24
func (*Manager) AddMessages ¶
func (*Manager) GetMessages ¶
func (*Manager) GetMessagesWithSystemPrompt ¶
GetMessagesWithSystemPrompt returns all messages with the system prompt prepended
func (*Manager) GetSinglePrompt ¶
GetSinglePrompt is a helper to use the context manager with a completion api. It just concatenates all the messages together with a prompt in front (if there are more than one message).
func (*Manager) GetSystemPrompt ¶
func (*Manager) PrependMessages ¶ added in v0.2.24
func (*Manager) SaveToFile ¶ added in v0.2.24
func (*Manager) SetMessages ¶
func (*Manager) SetSystemPrompt ¶
type ManagerOption ¶
type ManagerOption func(*Manager)
func WithAddMessages ¶ added in v0.2.24
func WithAddMessages(messages ...*Message) ManagerOption
func WithMessages ¶
func WithMessages(messages []*Message) ManagerOption
func WithSystemPrompt ¶
func WithSystemPrompt(systemPrompt string) ManagerOption
type Message ¶
type Message struct { Text string `json:"text" yaml:"text"` Time time.Time `json:"time" yaml:"time"` Role string `json:"role" yaml:"role"` // additional metadata for the message Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty"` }
func LoadFromFile ¶
LoadFromFile loads messages from a json file or yaml file