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

@@ -199,7 +199,19 @@ func (a *Agent) consumeJob(job *Job, role string) {
//if job.Image != "" {
// TODO: Use llava to explain the image content
//}
// Add custom prompts
for _, prompt := range a.options.prompts {
message := prompt.Render(a)
if !Messages(a.currentConversation).Exist(a.options.systemPrompt) {
a.currentConversation = append([]openai.ChatCompletionMessage{
{
Role: prompt.Role(),
Content: message,
}}, a.currentConversation...)
}
}
// TODO: move to a Promptblock?
if a.options.systemPrompt != "" {
if !Messages(a.currentConversation).Exist(a.options.systemPrompt) {
a.currentConversation = append([]openai.ChatCompletionMessage{
@@ -210,6 +222,7 @@ func (a *Agent) consumeJob(job *Job, role string) {
}
}
// TODO: move to a promptblock?
// RAG
if memory {
// Walk conversation from bottom to top, and find the first message of the user