加些log

This commit is contained in:
ken 2025-04-04 20:52:11 +08:00
parent 3a5af241e7
commit b5ca131619
3 changed files with 9 additions and 6 deletions

View File

@ -24,7 +24,7 @@ func (task *Task) chatWithStream(msg string, withThink bool) error {
option := llms.WithStreamingFunc(func(ctx context.Context, chunk []byte) error {
select {
case <-task.ctx.Done():
return nil
return errors.New("task cancelled")
default:
}
@ -46,11 +46,14 @@ func (task *Task) chatWithStream(msg string, withThink bool) error {
buf.Write(chunk)
// 避免client网络太慢
if len(ch) == 0 {
task.client.WriteJson(&message.ResponseExecSuccess{
err := task.client.WriteJson(&message.ResponseExecSuccess{
RequestId : task.request_id,
Msg : buf.String(),
Stream_SeqId : &seqId,
}, true)
if err != nil {
return err
}
buf.Reset()
seqId++
}
@ -62,13 +65,12 @@ func (task *Task) chatWithStream(msg string, withThink bool) error {
return err
}
task.client.WriteJson(&message.ResponseExecSuccess{
return task.client.WriteJson(&message.ResponseExecSuccess{
RequestId : task.request_id,
Msg : buf.String(),
Stream_SeqId : &seqId,
Stream_Finish: true,
}, true)
return nil
}
func (task *Task) chat(msg string, stream bool) error {

View File

@ -37,11 +37,10 @@ func (task *Task) docstring() error {
// TODO extract doc part
task.client.WriteJson(&message.ResponseExecSuccess{
return task.client.WriteJson(&message.ResponseExecSuccess{
RequestId: task.request_id,
Msg : answer,
}, false)
return nil
}
func (task *Task) fix() error {

View File

@ -3,6 +3,7 @@ package workflow
import (
"agent/src/common"
"agent/src/llm"
"agent/src/utils/log"
"context"
"errors"
"sync"
@ -81,6 +82,7 @@ func (t *TaskPool) loop() {
case <-tick.C:
// 清除pending太久的task
t.queue.RemoveTimeout(PendingTimeOut)
log.Info("[TaskPool] stat", "queueLen", t.queue.Len())
default:
}