Skip to content

Commit 1e20c3a

Browse files
committed
Slow down responses because it's prettier.
Send one word every 25 milliseconds (40 words per minute) Signed-off-by: Katharine Berry <[email protected]>
1 parent 592a065 commit 1e20c3a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

service/assistant/session.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,17 @@ func (ps *PromptSession) Run(ctx context.Context) {
179179
}
180180
}
181181
if strings.TrimSpace(ourContent) != "" {
182-
if err := ps.conn.Write(streamCtx, websocket.MessageText, []byte("c"+ourContent)); err != nil {
183-
streamSpan.AddField("error", err)
184-
log.Printf("write to websocket failed: %v\n", err)
185-
break
182+
words := strings.Split(ourContent, " ")
183+
for i, w := range words {
184+
if i != len(words)-1 {
185+
w += " "
186+
}
187+
if err := ps.conn.Write(streamCtx, websocket.MessageText, []byte("c"+w)); err != nil {
188+
streamSpan.AddField("error", err)
189+
log.Printf("write to websocket failed: %v\n", err)
190+
break
191+
}
192+
time.Sleep(time.Millisecond * 25)
186193
}
187194
}
188195
content += ourContent

0 commit comments

Comments
 (0)