comments
This commit is contained in:
@@ -226,6 +226,8 @@ func (a *Agent) consumeJob(job *Job, role string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if chosenAction == nil {
|
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.SetResult(ActionState{ActionCurrentState{nil, nil, "No action to do, just reply"}, ""})
|
||||||
//job.Result.Finish(fmt.Errorf("no action to do"))\
|
//job.Result.Finish(fmt.Errorf("no action to do"))\
|
||||||
a.currentConversation = append(a.currentConversation, openai.ChatCompletionMessage{
|
a.currentConversation = append(a.currentConversation, openai.ChatCompletionMessage{
|
||||||
|
|||||||
@@ -69,7 +69,12 @@ func main() {
|
|||||||
WithAgentResultCallback(func(state ActionState) {
|
WithAgentResultCallback(func(state ActionState) {
|
||||||
text := fmt.Sprintf(`Reasoning: %s
|
text := fmt.Sprintf(`Reasoning: %s
|
||||||
Action taken: %+v
|
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(
|
sseManager.Send(
|
||||||
sse.NewMessage(
|
sse.NewMessage(
|
||||||
htmlIfy(
|
htmlIfy(
|
||||||
@@ -183,14 +188,16 @@ func (a *App) Chat(m sse.Manager) func(w http.ResponseWriter, r *http.Request) {
|
|||||||
res := agentInstance.Ask(
|
res := agentInstance.Ask(
|
||||||
WithText(query),
|
WithText(query),
|
||||||
)
|
)
|
||||||
|
fmt.Println("response is", res.Response)
|
||||||
m.Send(
|
m.Send(
|
||||||
sse.NewMessage(
|
sse.NewMessage(
|
||||||
chatDiv(res.Response, "red"),
|
chatDiv(res.Response, "red"),
|
||||||
).WithEvent("messages"))
|
).WithEvent("messages"))
|
||||||
|
result := `<i>done</i>`
|
||||||
|
_, _ = w.Write([]byte(result))
|
||||||
}()
|
}()
|
||||||
|
|
||||||
result := `<i>message received</i>`
|
result := `<i>loading</i>`
|
||||||
_, _ = w.Write([]byte(result))
|
_, _ = w.Write([]byte(result))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user