@@ -187,12 +187,12 @@ func (m *GenerativeModel) Name() string {
187
187
188
188
// GenerateContent produces a single request and response.
189
189
func (m * GenerativeModel ) GenerateContent (ctx context.Context , parts ... Part ) (* GenerateContentResponse , error ) {
190
- return m .generateContent (ctx , m .newGenerateContentRequest (newUserContent (parts )))
190
+ return m .generateContent (ctx , m .newGenerateContentRequest (NewUserContent (parts ... )))
191
191
}
192
192
193
193
// GenerateContentStream returns an iterator that enumerates responses.
194
194
func (m * GenerativeModel ) GenerateContentStream (ctx context.Context , parts ... Part ) * GenerateContentResponseIterator {
195
- streamClient , err := m .c .pc .StreamGenerateContent (ctx , m .newGenerateContentRequest (newUserContent (parts )))
195
+ streamClient , err := m .c .pc .StreamGenerateContent (ctx , m .newGenerateContentRequest (NewUserContent (parts ... )))
196
196
return & GenerateContentResponseIterator {
197
197
sc : streamClient ,
198
198
err : err ,
@@ -221,10 +221,6 @@ func (m *GenerativeModel) newGenerateContentRequest(contents ...*Content) *pb.Ge
221
221
}
222
222
}
223
223
224
- func newUserContent (parts []Part ) * Content {
225
- return & Content {Role : roleUser , Parts : parts }
226
- }
227
-
228
224
// GenerateContentResponseIterator is an iterator over GnerateContentResponse.
229
225
type GenerateContentResponseIterator struct {
230
226
sc pb.PredictionService_StreamGenerateContentClient
@@ -286,7 +282,7 @@ func protoToResponse(resp *pb.GenerateContentResponse) (*GenerateContentResponse
286
282
287
283
// CountTokens counts the number of tokens in the content.
288
284
func (m * GenerativeModel ) CountTokens (ctx context.Context , parts ... Part ) (* CountTokensResponse , error ) {
289
- req := m .newCountTokensRequest (newUserContent (parts ))
285
+ req := m .newCountTokensRequest (NewUserContent (parts ... ))
290
286
res , err := m .c .pc .CountTokens (ctx , req )
291
287
if err != nil {
292
288
return nil , err
0 commit comments