Add customizable system prompt

This commit is contained in:
mudler
2024-04-10 20:35:04 +02:00
parent 0dda705017
commit 230d012915
4 changed files with 26 additions and 0 deletions

View File

@@ -207,6 +207,16 @@ func (a *Agent) consumeJob(job *Job, role string) {
})
}
if a.options.systemPrompt != "" {
if !Messages(a.currentConversation).Exist(a.options.systemPrompt) {
a.currentConversation = append([]openai.ChatCompletionMessage{
{
Role: "system",
Content: a.options.systemPrompt,
}}, a.currentConversation...)
}
}
// RAG
if memory {
// Walk conversation from bottom to top, and find the first message of the user

View File

@@ -30,6 +30,8 @@ type options struct {
kbResults int
ragdb RAGDB
systemPrompt string
// callbacks
reasoningCallback func(ActionCurrentState) bool
resultCallback func(ActionState)
@@ -110,6 +112,13 @@ func WithRAGDB(db RAGDB) Option {
}
}
func WithSystemPrompt(prompt string) Option {
return func(o *options) error {
o.systemPrompt = prompt
return nil
}
}
func WithLLMAPIURL(url string) Option {
return func(o *options) error {
o.LLMAPI.APIURL = url