wip introspection
This commit is contained in:
@@ -24,6 +24,8 @@ type JobResult struct {
|
|||||||
sync.Mutex
|
sync.Mutex
|
||||||
// The result of a job
|
// The result of a job
|
||||||
Data []string
|
Data []string
|
||||||
|
reasoningCallback func(Action, action.ActionParams, string)
|
||||||
|
resultCallback func(Action, action.ActionParams, string, string)
|
||||||
ready chan bool
|
ready chan bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,6 +36,20 @@ func NewJobResult() *JobResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (j *JobResult) Callback(a Action, p action.ActionParams, s string) {
|
||||||
|
if j.reasoningCallback == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
j.reasoningCallback(a, p, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (j *JobResult) CallbackWithResult(a Action, p action.ActionParams, s, r string) {
|
||||||
|
if j.resultCallback == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
j.resultCallback(a, p, s, r)
|
||||||
|
}
|
||||||
|
|
||||||
// NewJob creates a new job
|
// NewJob creates a new job
|
||||||
// It is a request to the agent to do something
|
// It is a request to the agent to do something
|
||||||
// It has a JobResult to get the result asynchronously
|
// It has a JobResult to get the result asynchronously
|
||||||
@@ -149,6 +165,8 @@ func (a *Agent) consumeJob(job *Job) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
job.Result.Callback(chosenAction, params.actionParams, reasoning)
|
||||||
|
|
||||||
if params.actionParams == nil {
|
if params.actionParams == nil {
|
||||||
fmt.Println("no parameters")
|
fmt.Println("no parameters")
|
||||||
return
|
return
|
||||||
@@ -168,6 +186,7 @@ func (a *Agent) consumeJob(job *Job) {
|
|||||||
}
|
}
|
||||||
fmt.Printf("Action run result: %v\n", result)
|
fmt.Printf("Action run result: %v\n", result)
|
||||||
job.Result.SetResult(result)
|
job.Result.SetResult(result)
|
||||||
|
job.Result.CallbackWithResult(chosenAction, params.actionParams, reasoning, result)
|
||||||
|
|
||||||
// calling the function
|
// calling the function
|
||||||
messages = append(messages, openai.ChatCompletionMessage{
|
messages = append(messages, openai.ChatCompletionMessage{
|
||||||
|
|||||||
Reference in New Issue
Block a user