diff --git a/vertexai/genai/client.go b/vertexai/genai/client.go index 9fb5db4ede84..cfbdef56c9f3 100644 --- a/vertexai/genai/client.go +++ b/vertexai/genai/client.go @@ -116,20 +116,12 @@ func (m *GenerativeModel) GenerateContentStream(ctx context.Context, parts ...Pa } func (m *GenerativeModel) generateContent(ctx context.Context, req *pb.GenerateContentRequest) (*GenerateContentResponse, error) { - streamClient, err := m.c.c.StreamGenerateContent(ctx, req) - iter := &GenerateContentResponseIterator{ - sc: streamClient, - err: err, - } - for { - _, err := iter.Next() - if err == iterator.Done { - return iter.merged, nil - } - if err != nil { - return nil, err - } + res, err := m.c.c.GenerateContent(ctx, req) + + if err != nil { + return nil, err } + return protoToResponse(res) } func (m *GenerativeModel) newGenerateContentRequest(contents ...*Content) *pb.GenerateContentRequest { diff --git a/vertexai/genai/client_test.go b/vertexai/genai/client_test.go index f6f5dc9ae5d5..319e92d4c989 100644 --- a/vertexai/genai/client_test.go +++ b/vertexai/genai/client_test.go @@ -259,7 +259,7 @@ func TestLive(t *testing.T) { if err != nil { t.Fatal(err) } - checkMatch(t, responseString(res), "(it's}|weather) .*cold") + checkMatch(t, responseString(res), "(it's|it is|weather) .*cold") }) }