From 90fd130e31e9ef9caebb545599d85e3b2d77616c Mon Sep 17 00:00:00 2001 From: mudler Date: Sat, 6 Apr 2024 15:20:45 +0200 Subject: [PATCH] comments --- agent/agent.go | 2 ++ example/webui/main.go | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index e6f896c..3aa3aa6 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -226,6 +226,8 @@ func (a *Agent) consumeJob(job *Job, role string) { } if chosenAction == nil { + // If no action was picked up, the reasoning is the message returned by the assistant + // so we can consume it as if it was a reply. //job.Result.SetResult(ActionState{ActionCurrentState{nil, nil, "No action to do, just reply"}, ""}) //job.Result.Finish(fmt.Errorf("no action to do"))\ a.currentConversation = append(a.currentConversation, openai.ChatCompletionMessage{ diff --git a/example/webui/main.go b/example/webui/main.go index f8d905f..fa601b1 100644 --- a/example/webui/main.go +++ b/example/webui/main.go @@ -69,7 +69,12 @@ func main() { WithAgentResultCallback(func(state ActionState) { text := fmt.Sprintf(`Reasoning: %s Action taken: %+v - Result: %s`, state.Reasoning, state.ActionCurrentState.Action.Definition().Name, state.Result) + Parameters: %+v + Result: %s`, + state.Reasoning, + state.ActionCurrentState.Action.Definition().Name, + state.ActionCurrentState.Params, + state.Result) sseManager.Send( sse.NewMessage( htmlIfy( @@ -183,14 +188,16 @@ func (a *App) Chat(m sse.Manager) func(w http.ResponseWriter, r *http.Request) { res := agentInstance.Ask( WithText(query), ) + fmt.Println("response is", res.Response) m.Send( sse.NewMessage( chatDiv(res.Response, "red"), ).WithEvent("messages")) - + result := `done` + _, _ = w.Write([]byte(result)) }() - result := `message received` + result := `loading` _, _ = w.Write([]byte(result)) } }