feat(AI): add done channel for faster response
This commit is contained in:
parent
5e65a2ce32
commit
39868f4f07
3 changed files with 11 additions and 3 deletions
|
|
@ -134,7 +134,10 @@ func assistantStreamedResponse(request openai.ChatRequest, cb assistantStreamedR
|
|||
if minWaitSatisfied {
|
||||
break Drain
|
||||
}
|
||||
<-minWait
|
||||
select {
|
||||
case <-minWait:
|
||||
case <-resp.Done:
|
||||
}
|
||||
minWaitSatisfied = true
|
||||
}
|
||||
}
|
||||
|
|
@ -155,7 +158,7 @@ func assistantStreamedResponse(request openai.ChatRequest, cb assistantStreamedR
|
|||
minWaitDurSecs := lo.Min([]int{nUpdates, 4}) + nErrs*3
|
||||
minWait = time.After(time.Duration(minWaitDurSecs) * time.Second)
|
||||
|
||||
// send the partial message
|
||||
// Send the partial message
|
||||
respText := respBuilder.String() + assistantWritingSign
|
||||
if err := cb(respText, false); err != nil {
|
||||
logger.Warnw("failed to send partial update", "error", err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue