Add prompt blocks

This commit is contained in:
Ettore Di Giacinto
2024-04-10 23:49:13 +02:00
parent ac580b562e
commit 3b361d1a3d
3 changed files with 32 additions and 2 deletions

View File

@@ -30,6 +30,8 @@ type options struct {
kbResults int
ragdb RAGDB
prompts []PromptBlock
systemPrompt string
// callbacks
@@ -37,6 +39,11 @@ type options struct {
resultCallback func(ActionState)
}
type PromptBlock interface {
Render(a *Agent) string
Role() string
}
func defaultOptions() *options {
return &options{
periodicRuns: 15 * time.Minute,
@@ -140,6 +147,16 @@ func WithCharacterFile(path string) Option {
}
}
// WithPrompts adds additional block prompts to the agent
// to be rendered internally in the conversation
// when processing the conversation to the LLM
func WithPrompts(prompts ...PromptBlock) Option {
return func(o *options) error {
o.prompts = prompts
return nil
}
}
func WithLLMAPIKey(key string) Option {
return func(o *options) error {
o.LLMAPI.APIKey = key