Skip to content

Commit

Permalink
Fixed mandatory WithStream when stream is false
Browse files Browse the repository at this point in the history
  • Loading branch information
JexSrs committed May 22, 2024
1 parent fd87b75 commit c758651
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c758651

Please sign in to comment.