Add conversation history for jobs
This commit is contained in:
@@ -167,6 +167,9 @@ func (a *Agent) consumeJob(job *Job, role string) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
a.actionContext = action.NewContext(ctx, cancel)
|
||||
a.selfEvaluationInProgress = selfEvaluation
|
||||
if len(job.conversationHistory) != 0 {
|
||||
a.currentConversation = job.conversationHistory
|
||||
}
|
||||
a.Unlock()
|
||||
|
||||
if selfEvaluation {
|
||||
|
||||
@@ -2,6 +2,8 @@ package agent
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/sashabaranov/go-openai"
|
||||
)
|
||||
|
||||
// Job is a request to the agent to do something
|
||||
@@ -9,11 +11,12 @@ type Job struct {
|
||||
// The job is a request to the agent to do something
|
||||
// It can be a question, a command, or a request to do something
|
||||
// The agent will try to do it, and return a response
|
||||
Text string
|
||||
Image string // base64 encoded image
|
||||
Result *JobResult
|
||||
reasoningCallback func(ActionCurrentState) bool
|
||||
resultCallback func(ActionState)
|
||||
Text string
|
||||
Image string // base64 encoded image
|
||||
Result *JobResult
|
||||
reasoningCallback func(ActionCurrentState) bool
|
||||
resultCallback func(ActionState)
|
||||
conversationHistory []openai.ChatCompletionMessage
|
||||
}
|
||||
|
||||
// JobResult is the result of a job
|
||||
@@ -28,6 +31,12 @@ type JobResult struct {
|
||||
|
||||
type JobOption func(*Job)
|
||||
|
||||
func WithConversationHistory(history []openai.ChatCompletionMessage) JobOption {
|
||||
return func(j *Job) {
|
||||
j.conversationHistory = history
|
||||
}
|
||||
}
|
||||
|
||||
func WithReasoningCallback(f func(ActionCurrentState) bool) JobOption {
|
||||
return func(r *Job) {
|
||||
r.reasoningCallback = f
|
||||
|
||||
Reference in New Issue
Block a user