加些log
This commit is contained in:
parent
3a5af241e7
commit
b5ca131619
@ -24,7 +24,7 @@ func (task *Task) chatWithStream(msg string, withThink bool) error {
|
|||||||
option := llms.WithStreamingFunc(func(ctx context.Context, chunk []byte) error {
|
option := llms.WithStreamingFunc(func(ctx context.Context, chunk []byte) error {
|
||||||
select {
|
select {
|
||||||
case <-task.ctx.Done():
|
case <-task.ctx.Done():
|
||||||
return nil
|
return errors.New("task cancelled")
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,11 +46,14 @@ func (task *Task) chatWithStream(msg string, withThink bool) error {
|
|||||||
buf.Write(chunk)
|
buf.Write(chunk)
|
||||||
// 避免client网络太慢
|
// 避免client网络太慢
|
||||||
if len(ch) == 0 {
|
if len(ch) == 0 {
|
||||||
task.client.WriteJson(&message.ResponseExecSuccess{
|
err := task.client.WriteJson(&message.ResponseExecSuccess{
|
||||||
RequestId : task.request_id,
|
RequestId : task.request_id,
|
||||||
Msg : buf.String(),
|
Msg : buf.String(),
|
||||||
Stream_SeqId : &seqId,
|
Stream_SeqId : &seqId,
|
||||||
}, true)
|
}, true)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
buf.Reset()
|
buf.Reset()
|
||||||
seqId++
|
seqId++
|
||||||
}
|
}
|
||||||
@ -62,13 +65,12 @@ func (task *Task) chatWithStream(msg string, withThink bool) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
task.client.WriteJson(&message.ResponseExecSuccess{
|
return task.client.WriteJson(&message.ResponseExecSuccess{
|
||||||
RequestId : task.request_id,
|
RequestId : task.request_id,
|
||||||
Msg : buf.String(),
|
Msg : buf.String(),
|
||||||
Stream_SeqId : &seqId,
|
Stream_SeqId : &seqId,
|
||||||
Stream_Finish: true,
|
Stream_Finish: true,
|
||||||
}, true)
|
}, true)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (task *Task) chat(msg string, stream bool) error {
|
func (task *Task) chat(msg string, stream bool) error {
|
||||||
|
@ -37,11 +37,10 @@ func (task *Task) docstring() error {
|
|||||||
|
|
||||||
// TODO extract doc part
|
// TODO extract doc part
|
||||||
|
|
||||||
task.client.WriteJson(&message.ResponseExecSuccess{
|
return task.client.WriteJson(&message.ResponseExecSuccess{
|
||||||
RequestId: task.request_id,
|
RequestId: task.request_id,
|
||||||
Msg : answer,
|
Msg : answer,
|
||||||
}, false)
|
}, false)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (task *Task) fix() error {
|
func (task *Task) fix() error {
|
||||||
|
@ -3,6 +3,7 @@ package workflow
|
|||||||
import (
|
import (
|
||||||
"agent/src/common"
|
"agent/src/common"
|
||||||
"agent/src/llm"
|
"agent/src/llm"
|
||||||
|
"agent/src/utils/log"
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
@ -81,6 +82,7 @@ func (t *TaskPool) loop() {
|
|||||||
case <-tick.C:
|
case <-tick.C:
|
||||||
// 清除pending太久的task
|
// 清除pending太久的task
|
||||||
t.queue.RemoveTimeout(PendingTimeOut)
|
t.queue.RemoveTimeout(PendingTimeOut)
|
||||||
|
log.Info("[TaskPool] stat", "queueLen", t.queue.Len())
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user