diff --git a/functions.go b/functions.go index 64195cc..70966c5 100644 --- a/functions.go +++ b/functions.go @@ -98,6 +98,10 @@ func (o *Ollama) newChatFunc() ChatFunc { req.Stream = pointer(false) } + if req.StreamBufferSize == nil { + req.StreamBufferSize = pointer(1024) + } + // Include chat history or create a new chat if chatId != nil { chat := o.chats[*chatId] @@ -185,6 +189,10 @@ func (o *Ollama) newGenerateFunc() GenerateFunc { req.Stream = pointer(false) } + if req.StreamBufferSize == nil { + req.StreamBufferSize = pointer(1024) + } + var stream func(b []byte) if req.StreamFunc != nil { stream = func(b []byte) { @@ -263,6 +271,10 @@ func (o *Ollama) newCreateModelFunc() CreateModelFunc { f(&req) } + if req.StreamBufferSize == nil { + req.StreamBufferSize = pointer(1024) + } + var stream func(b []byte) if req.StreamFunc != nil { stream = func(b []byte) { @@ -384,6 +396,10 @@ func (o *Ollama) newPullModelFunc() PullModelFunc { f(&req) } + if req.StreamBufferSize == nil { + req.StreamBufferSize = pointer(1024) + } + var stream func(b []byte) if req.StreamFunc != nil { stream = func(b []byte) { @@ -421,6 +437,10 @@ func (o *Ollama) newPushModelFunc() PushModelFunc { f(&req) } + if req.StreamBufferSize == nil { + req.StreamBufferSize = pointer(1024) + } + var stream func(b []byte) if req.StreamFunc != nil { stream = func(b []byte) { @@ -458,6 +478,10 @@ func (o *Ollama) newGenerateEmbeddingsFunc() GenerateEmbeddingsFunc { f(&req) } + if req.StreamBufferSize == nil { + req.StreamBufferSize = pointer(1024) + } + body, err := o.Do("/api/embeddings", req, 0, nil) if err != nil { return nil, err