1 // Copyright 2024 Google LLC. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Code generated file. DO NOT EDIT. 6 7 // Package firebaseml provides access to the Firebase ML API. 8 // 9 // For product documentation, see: https://firebase.google.com 10 // 11 // # Library status 12 // 13 // These client libraries are officially supported by Google. However, this 14 // library is considered complete and is in maintenance mode. This means 15 // that we will address critical bugs and security issues but will not add 16 // any new features. 17 // 18 // When possible, we recommend using our newer 19 // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go) 20 // that are still actively being worked and iterated on. 21 // 22 // # Creating a client 23 // 24 // Usage example: 25 // 26 // import "google.golang.org/api/firebaseml/v2beta" 27 // ... 28 // ctx := context.Background() 29 // firebasemlService, err := firebaseml.NewService(ctx) 30 // 31 // In this example, Google Application Default Credentials are used for 32 // authentication. For information on how to create and obtain Application 33 // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials. 34 // 35 // # Other authentication options 36 // 37 // To use an API key for authentication (note: some APIs do not support API 38 // keys), use [google.golang.org/api/option.WithAPIKey]: 39 // 40 // firebasemlService, err := firebaseml.NewService(ctx, option.WithAPIKey("AIza...")) 41 // 42 // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth 43 // flow, use [google.golang.org/api/option.WithTokenSource]: 44 // 45 // config := &oauth2.Config{...} 46 // // ... 47 // token, err := config.Exchange(ctx, ...) 48 // firebasemlService, err := firebaseml.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token))) 49 // 50 // See [google.golang.org/api/option.ClientOption] for details on options. 51 package firebaseml // import "google.golang.org/api/firebaseml/v2beta" 52 53 import ( 54 "bytes" 55 "context" 56 "encoding/json" 57 "errors" 58 "fmt" 59 "io" 60 "net/http" 61 "net/url" 62 "strconv" 63 "strings" 64 65 googleapi "google.golang.org/api/googleapi" 66 internal "google.golang.org/api/internal" 67 gensupport "google.golang.org/api/internal/gensupport" 68 option "google.golang.org/api/option" 69 internaloption "google.golang.org/api/option/internaloption" 70 htransport "google.golang.org/api/transport/http" 71 ) 72 73 // Always reference these packages, just in case the auto-generated code 74 // below doesn't. 75 var _ = bytes.NewBuffer 76 var _ = strconv.Itoa 77 var _ = fmt.Sprintf 78 var _ = json.NewDecoder 79 var _ = io.Copy 80 var _ = url.Parse 81 var _ = gensupport.MarshalJSON 82 var _ = googleapi.Version 83 var _ = errors.New 84 var _ = strings.Replace 85 var _ = context.Canceled 86 var _ = internaloption.WithDefaultEndpoint 87 var _ = internal.Version 88 89 const apiId = "firebaseml:v2beta" 90 const apiName = "firebaseml" 91 const apiVersion = "v2beta" 92 const basePath = "https://firebaseml.googleapis.com/" 93 const basePathTemplate = "https://firebaseml.UNIVERSE_DOMAIN/" 94 const mtlsBasePath = "https://firebaseml.mtls.googleapis.com/" 95 96 // OAuth2 scopes used by this API. 97 const ( 98 // See, edit, configure, and delete your Google Cloud data and see the email 99 // address for your Google Account. 100 CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform" 101 ) 102 103 // NewService creates a new Service. 104 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) { 105 scopesOption := internaloption.WithDefaultScopes( 106 "https://www.googleapis.com/auth/cloud-platform", 107 ) 108 // NOTE: prepend, so we don't override user-specified scopes. 109 opts = append([]option.ClientOption{scopesOption}, opts...) 110 opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) 111 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate)) 112 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) 113 opts = append(opts, internaloption.EnableNewAuthLibrary()) 114 client, endpoint, err := htransport.NewClient(ctx, opts...) 115 if err != nil { 116 return nil, err 117 } 118 s, err := New(client) 119 if err != nil { 120 return nil, err 121 } 122 if endpoint != "" { 123 s.BasePath = endpoint 124 } 125 return s, nil 126 } 127 128 // New creates a new Service. It uses the provided http.Client for requests. 129 // 130 // Deprecated: please use NewService instead. 131 // To provide a custom HTTP client, use option.WithHTTPClient. 132 // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. 133 func New(client *http.Client) (*Service, error) { 134 if client == nil { 135 return nil, errors.New("client is nil") 136 } 137 s := &Service{client: client, BasePath: basePath} 138 s.Projects = NewProjectsService(s) 139 return s, nil 140 } 141 142 type Service struct { 143 client *http.Client 144 BasePath string // API endpoint base URL 145 UserAgent string // optional additional User-Agent fragment 146 147 Projects *ProjectsService 148 } 149 150 func (s *Service) userAgent() string { 151 if s.UserAgent == "" { 152 return googleapi.UserAgent 153 } 154 return googleapi.UserAgent + " " + s.UserAgent 155 } 156 157 func NewProjectsService(s *Service) *ProjectsService { 158 rs := &ProjectsService{s: s} 159 rs.Locations = NewProjectsLocationsService(s) 160 return rs 161 } 162 163 type ProjectsService struct { 164 s *Service 165 166 Locations *ProjectsLocationsService 167 } 168 169 func NewProjectsLocationsService(s *Service) *ProjectsLocationsService { 170 rs := &ProjectsLocationsService{s: s} 171 rs.Publishers = NewProjectsLocationsPublishersService(s) 172 return rs 173 } 174 175 type ProjectsLocationsService struct { 176 s *Service 177 178 Publishers *ProjectsLocationsPublishersService 179 } 180 181 func NewProjectsLocationsPublishersService(s *Service) *ProjectsLocationsPublishersService { 182 rs := &ProjectsLocationsPublishersService{s: s} 183 rs.Models = NewProjectsLocationsPublishersModelsService(s) 184 return rs 185 } 186 187 type ProjectsLocationsPublishersService struct { 188 s *Service 189 190 Models *ProjectsLocationsPublishersModelsService 191 } 192 193 func NewProjectsLocationsPublishersModelsService(s *Service) *ProjectsLocationsPublishersModelsService { 194 rs := &ProjectsLocationsPublishersModelsService{s: s} 195 return rs 196 } 197 198 type ProjectsLocationsPublishersModelsService struct { 199 s *Service 200 } 201 202 // Blob: Content blob. It's preferred to send as text directly rather than raw 203 // bytes. 204 type Blob struct { 205 // Data: Required. Raw bytes. 206 Data string `json:"data,omitempty"` 207 // MimeType: Required. The IANA standard MIME type of the source data. 208 MimeType string `json:"mimeType,omitempty"` 209 // ForceSendFields is a list of field names (e.g. "Data") to unconditionally 210 // include in API requests. By default, fields with empty or default values are 211 // omitted from API requests. See 212 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 213 // details. 214 ForceSendFields []string `json:"-"` 215 // NullFields is a list of field names (e.g. "Data") to include in API requests 216 // with the JSON null value. By default, fields with empty values are omitted 217 // from API requests. See 218 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 219 NullFields []string `json:"-"` 220 } 221 222 func (s *Blob) MarshalJSON() ([]byte, error) { 223 type NoMethod Blob 224 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 225 } 226 227 // Candidate: A response candidate generated from the model. 228 type Candidate struct { 229 // CitationMetadata: Output only. Source attribution of the generated content. 230 CitationMetadata *CitationMetadata `json:"citationMetadata,omitempty"` 231 // Content: Output only. Content parts of the candidate. 232 Content *Content `json:"content,omitempty"` 233 // FinishMessage: Output only. Describes the reason the mode stopped generating 234 // tokens in more detail. This is only filled when `finish_reason` is set. 235 FinishMessage string `json:"finishMessage,omitempty"` 236 // FinishReason: Output only. The reason why the model stopped generating 237 // tokens. If empty, the model has not stopped generating the tokens. 238 // 239 // Possible values: 240 // "FINISH_REASON_UNSPECIFIED" - The finish reason is unspecified. 241 // "STOP" - Natural stop point of the model or provided stop sequence. 242 // "MAX_TOKENS" - The maximum number of tokens as specified in the request 243 // was reached. 244 // "SAFETY" - The token generation was stopped as the response was flagged 245 // for safety reasons. NOTE: When streaming the Candidate.content will be empty 246 // if content filters blocked the output. 247 // "RECITATION" - The token generation was stopped as the response was 248 // flagged for unauthorized citations. 249 // "OTHER" - All other reasons that stopped the token generation 250 // "BLOCKLIST" - The token generation was stopped as the response was flagged 251 // for the terms which are included from the terminology blocklist. 252 // "PROHIBITED_CONTENT" - The token generation was stopped as the response 253 // was flagged for the prohibited contents. 254 // "SPII" - The token generation was stopped as the response was flagged for 255 // Sensitive Personally Identifiable Information (SPII) contents. 256 FinishReason string `json:"finishReason,omitempty"` 257 // GroundingMetadata: Output only. Metadata specifies sources used to ground 258 // generated content. 259 GroundingMetadata *GroundingMetadata `json:"groundingMetadata,omitempty"` 260 // Index: Output only. Index of the candidate. 261 Index int64 `json:"index,omitempty"` 262 // SafetyRatings: Output only. List of ratings for the safety of a response 263 // candidate. There is at most one rating per category. 264 SafetyRatings []*SafetyRating `json:"safetyRatings,omitempty"` 265 // ForceSendFields is a list of field names (e.g. "CitationMetadata") to 266 // unconditionally include in API requests. By default, fields with empty or 267 // default values are omitted from API requests. See 268 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 269 // details. 270 ForceSendFields []string `json:"-"` 271 // NullFields is a list of field names (e.g. "CitationMetadata") to include in 272 // API requests with the JSON null value. By default, fields with empty values 273 // are omitted from API requests. See 274 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 275 NullFields []string `json:"-"` 276 } 277 278 func (s *Candidate) MarshalJSON() ([]byte, error) { 279 type NoMethod Candidate 280 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 281 } 282 283 // Citation: Source attributions for content. 284 type Citation struct { 285 // EndIndex: Output only. End index into the content. 286 EndIndex int64 `json:"endIndex,omitempty"` 287 // License: Output only. License of the attribution. 288 License string `json:"license,omitempty"` 289 // PublicationDate: Output only. Publication date of the attribution. 290 PublicationDate *Date `json:"publicationDate,omitempty"` 291 // StartIndex: Output only. Start index into the content. 292 StartIndex int64 `json:"startIndex,omitempty"` 293 // Title: Output only. Title of the attribution. 294 Title string `json:"title,omitempty"` 295 // Uri: Output only. Url reference of the attribution. 296 Uri string `json:"uri,omitempty"` 297 // ForceSendFields is a list of field names (e.g. "EndIndex") to 298 // unconditionally include in API requests. By default, fields with empty or 299 // default values are omitted from API requests. See 300 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 301 // details. 302 ForceSendFields []string `json:"-"` 303 // NullFields is a list of field names (e.g. "EndIndex") to include in API 304 // requests with the JSON null value. By default, fields with empty values are 305 // omitted from API requests. See 306 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 307 NullFields []string `json:"-"` 308 } 309 310 func (s *Citation) MarshalJSON() ([]byte, error) { 311 type NoMethod Citation 312 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 313 } 314 315 // CitationMetadata: A collection of source attributions for a piece of 316 // content. 317 type CitationMetadata struct { 318 // Citations: Output only. List of citations. 319 Citations []*Citation `json:"citations,omitempty"` 320 // ForceSendFields is a list of field names (e.g. "Citations") to 321 // unconditionally include in API requests. By default, fields with empty or 322 // default values are omitted from API requests. See 323 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 324 // details. 325 ForceSendFields []string `json:"-"` 326 // NullFields is a list of field names (e.g. "Citations") to include in API 327 // requests with the JSON null value. By default, fields with empty values are 328 // omitted from API requests. See 329 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 330 NullFields []string `json:"-"` 331 } 332 333 func (s *CitationMetadata) MarshalJSON() ([]byte, error) { 334 type NoMethod CitationMetadata 335 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 336 } 337 338 // Content: The base structured datatype containing multi-part content of a 339 // message. A `Content` includes a `role` field designating the producer of the 340 // `Content` and a `parts` field containing multi-part data that contains the 341 // content of the message turn. 342 type Content struct { 343 // Parts: Required. Ordered `Parts` that constitute a single message. Parts may 344 // have different IANA MIME types. 345 Parts []*Part `json:"parts,omitempty"` 346 // Role: Optional. The producer of the content. Must be either 'user' or 347 // 'model'. Useful to set for multi-turn conversations, otherwise can be left 348 // blank or unset. 349 Role string `json:"role,omitempty"` 350 // ForceSendFields is a list of field names (e.g. "Parts") to unconditionally 351 // include in API requests. By default, fields with empty or default values are 352 // omitted from API requests. See 353 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 354 // details. 355 ForceSendFields []string `json:"-"` 356 // NullFields is a list of field names (e.g. "Parts") to include in API 357 // requests with the JSON null value. By default, fields with empty values are 358 // omitted from API requests. See 359 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 360 NullFields []string `json:"-"` 361 } 362 363 func (s *Content) MarshalJSON() ([]byte, error) { 364 type NoMethod Content 365 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 366 } 367 368 // CountTokensRequest: Request message for PredictionService.CountTokens. 369 type CountTokensRequest struct { 370 // Contents: Required. Input content. 371 Contents []*Content `json:"contents,omitempty"` 372 // Instances: Required. The instances that are the input to token counting 373 // call. Schema is identical to the prediction schema of the underlying model. 374 Instances []interface{} `json:"instances,omitempty"` 375 // Model: Required. The name of the publisher model requested to serve the 376 // prediction. Format: 377 // `projects/{project}/locations/{location}/publishers/*/models/*` 378 Model string `json:"model,omitempty"` 379 // ForceSendFields is a list of field names (e.g. "Contents") to 380 // unconditionally include in API requests. By default, fields with empty or 381 // default values are omitted from API requests. See 382 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 383 // details. 384 ForceSendFields []string `json:"-"` 385 // NullFields is a list of field names (e.g. "Contents") to include in API 386 // requests with the JSON null value. By default, fields with empty values are 387 // omitted from API requests. See 388 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 389 NullFields []string `json:"-"` 390 } 391 392 func (s *CountTokensRequest) MarshalJSON() ([]byte, error) { 393 type NoMethod CountTokensRequest 394 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 395 } 396 397 // CountTokensResponse: Response message for PredictionService.CountTokens. 398 type CountTokensResponse struct { 399 // TotalBillableCharacters: The total number of billable characters counted 400 // across all instances from the request. 401 TotalBillableCharacters int64 `json:"totalBillableCharacters,omitempty"` 402 // TotalTokens: The total number of tokens counted across all instances from 403 // the request. 404 TotalTokens int64 `json:"totalTokens,omitempty"` 405 406 // ServerResponse contains the HTTP response code and headers from the server. 407 googleapi.ServerResponse `json:"-"` 408 // ForceSendFields is a list of field names (e.g. "TotalBillableCharacters") to 409 // unconditionally include in API requests. By default, fields with empty or 410 // default values are omitted from API requests. See 411 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 412 // details. 413 ForceSendFields []string `json:"-"` 414 // NullFields is a list of field names (e.g. "TotalBillableCharacters") to 415 // include in API requests with the JSON null value. By default, fields with 416 // empty values are omitted from API requests. See 417 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 418 NullFields []string `json:"-"` 419 } 420 421 func (s *CountTokensResponse) MarshalJSON() ([]byte, error) { 422 type NoMethod CountTokensResponse 423 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 424 } 425 426 // Date: Represents a whole or partial calendar date, such as a birthday. The 427 // time of day and time zone are either specified elsewhere or are 428 // insignificant. The date is relative to the Gregorian Calendar. This can 429 // represent one of the following: * A full date, with non-zero year, month, 430 // and day values. * A month and day, with a zero year (for example, an 431 // anniversary). * A year on its own, with a zero month and a zero day. * A 432 // year and month, with a zero day (for example, a credit card expiration 433 // date). Related types: * google.type.TimeOfDay * google.type.DateTime * 434 // google.protobuf.Timestamp 435 type Date struct { 436 // Day: Day of a month. Must be from 1 to 31 and valid for the year and month, 437 // or 0 to specify a year by itself or a year and month where the day isn't 438 // significant. 439 Day int64 `json:"day,omitempty"` 440 // Month: Month of a year. Must be from 1 to 12, or 0 to specify a year without 441 // a month and day. 442 Month int64 `json:"month,omitempty"` 443 // Year: Year of the date. Must be from 1 to 9999, or 0 to specify a date 444 // without a year. 445 Year int64 `json:"year,omitempty"` 446 // ForceSendFields is a list of field names (e.g. "Day") to unconditionally 447 // include in API requests. By default, fields with empty or default values are 448 // omitted from API requests. See 449 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 450 // details. 451 ForceSendFields []string `json:"-"` 452 // NullFields is a list of field names (e.g. "Day") to include in API requests 453 // with the JSON null value. By default, fields with empty values are omitted 454 // from API requests. See 455 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 456 NullFields []string `json:"-"` 457 } 458 459 func (s *Date) MarshalJSON() ([]byte, error) { 460 type NoMethod Date 461 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 462 } 463 464 // FileData: URI based data. 465 type FileData struct { 466 // FileUri: Required. URI. 467 FileUri string `json:"fileUri,omitempty"` 468 // MimeType: Required. The IANA standard MIME type of the source data. 469 MimeType string `json:"mimeType,omitempty"` 470 // ForceSendFields is a list of field names (e.g. "FileUri") to unconditionally 471 // include in API requests. By default, fields with empty or default values are 472 // omitted from API requests. See 473 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 474 // details. 475 ForceSendFields []string `json:"-"` 476 // NullFields is a list of field names (e.g. "FileUri") to include in API 477 // requests with the JSON null value. By default, fields with empty values are 478 // omitted from API requests. See 479 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 480 NullFields []string `json:"-"` 481 } 482 483 func (s *FileData) MarshalJSON() ([]byte, error) { 484 type NoMethod FileData 485 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 486 } 487 488 // FunctionCall: A predicted [FunctionCall] returned from the model that 489 // contains a string representing the [FunctionDeclaration.name] and a 490 // structured JSON object containing the parameters and their values. 491 type FunctionCall struct { 492 // Args: Optional. Required. The function parameters and values in JSON object 493 // format. See [FunctionDeclaration.parameters] for parameter details. 494 Args googleapi.RawMessage `json:"args,omitempty"` 495 // Name: Required. The name of the function to call. Matches 496 // [FunctionDeclaration.name]. 497 Name string `json:"name,omitempty"` 498 // ForceSendFields is a list of field names (e.g. "Args") to unconditionally 499 // include in API requests. By default, fields with empty or default values are 500 // omitted from API requests. See 501 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 502 // details. 503 ForceSendFields []string `json:"-"` 504 // NullFields is a list of field names (e.g. "Args") to include in API requests 505 // with the JSON null value. By default, fields with empty values are omitted 506 // from API requests. See 507 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 508 NullFields []string `json:"-"` 509 } 510 511 func (s *FunctionCall) MarshalJSON() ([]byte, error) { 512 type NoMethod FunctionCall 513 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 514 } 515 516 // FunctionCallingConfig: Function calling config. 517 type FunctionCallingConfig struct { 518 // AllowedFunctionNames: Optional. Function names to call. Only set when the 519 // Mode is ANY. Function names should match [FunctionDeclaration.name]. With 520 // mode set to ANY, model will predict a function call from the set of function 521 // names provided. 522 AllowedFunctionNames []string `json:"allowedFunctionNames,omitempty"` 523 // Mode: Optional. Function calling mode. 524 // 525 // Possible values: 526 // "MODE_UNSPECIFIED" - Unspecified function calling mode. This value should 527 // not be used. 528 // "AUTO" - Default model behavior, model decides to predict either a 529 // function call or a natural language repspose. 530 // "ANY" - Model is constrained to always predicting a function call only. If 531 // "allowed_function_names" are set, the predicted function call will be 532 // limited to any one of "allowed_function_names", else the predicted function 533 // call will be any one of the provided "function_declarations". 534 // "NONE" - Model will not predict any function call. Model behavior is same 535 // as when not passing any function declarations. 536 Mode string `json:"mode,omitempty"` 537 // ForceSendFields is a list of field names (e.g. "AllowedFunctionNames") to 538 // unconditionally include in API requests. By default, fields with empty or 539 // default values are omitted from API requests. See 540 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 541 // details. 542 ForceSendFields []string `json:"-"` 543 // NullFields is a list of field names (e.g. "AllowedFunctionNames") to include 544 // in API requests with the JSON null value. By default, fields with empty 545 // values are omitted from API requests. See 546 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 547 NullFields []string `json:"-"` 548 } 549 550 func (s *FunctionCallingConfig) MarshalJSON() ([]byte, error) { 551 type NoMethod FunctionCallingConfig 552 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 553 } 554 555 // FunctionDeclaration: Structured representation of a function declaration as 556 // defined by the OpenAPI 3.0 specification 557 // (https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the 558 // function name and parameters. This FunctionDeclaration is a representation 559 // of a block of code that can be used as a `Tool` by the model and executed by 560 // the client. 561 type FunctionDeclaration struct { 562 // Description: Optional. Description and purpose of the function. Model uses 563 // it to decide how and whether to call the function. 564 Description string `json:"description,omitempty"` 565 // Name: Required. The name of the function to call. Must start with a letter 566 // or an underscore. Must be a-z, A-Z, 0-9, or contain underscores, dots and 567 // dashes, with a maximum length of 64. 568 Name string `json:"name,omitempty"` 569 // Parameters: Optional. Describes the parameters to this function in JSON 570 // Schema Object format. Reflects the Open API 3.03 Parameter Object. string 571 // Key: the name of the parameter. Parameter names are case sensitive. Schema 572 // Value: the Schema defining the type used for the parameter. For function 573 // with no parameters, this can be left unset. Parameter names must start with 574 // a letter or an underscore and must only contain chars a-z, A-Z, 0-9, or 575 // underscores with a maximum length of 64. Example with 1 required and 1 576 // optional parameter: type: OBJECT properties: param1: type: STRING param2: 577 // type: INTEGER required: - param1 578 Parameters *Schema `json:"parameters,omitempty"` 579 // Response: Optional. Describes the output from this function in JSON Schema 580 // format. Reflects the Open API 3.03 Response Object. The Schema defines the 581 // type used for the response value of the function. 582 Response *Schema `json:"response,omitempty"` 583 // ForceSendFields is a list of field names (e.g. "Description") to 584 // unconditionally include in API requests. By default, fields with empty or 585 // default values are omitted from API requests. See 586 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 587 // details. 588 ForceSendFields []string `json:"-"` 589 // NullFields is a list of field names (e.g. "Description") to include in API 590 // requests with the JSON null value. By default, fields with empty values are 591 // omitted from API requests. See 592 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 593 NullFields []string `json:"-"` 594 } 595 596 func (s *FunctionDeclaration) MarshalJSON() ([]byte, error) { 597 type NoMethod FunctionDeclaration 598 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 599 } 600 601 // FunctionResponse: The result output from a [FunctionCall] that contains a 602 // string representing the [FunctionDeclaration.name] and a structured JSON 603 // object containing any output from the function is used as context to the 604 // model. This should contain the result of a [FunctionCall] made based on 605 // model prediction. 606 type FunctionResponse struct { 607 // Name: Required. The name of the function to call. Matches 608 // [FunctionDeclaration.name] and [FunctionCall.name]. 609 Name string `json:"name,omitempty"` 610 // Response: Required. The function response in JSON object format. 611 Response googleapi.RawMessage `json:"response,omitempty"` 612 // ForceSendFields is a list of field names (e.g. "Name") to unconditionally 613 // include in API requests. By default, fields with empty or default values are 614 // omitted from API requests. See 615 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 616 // details. 617 ForceSendFields []string `json:"-"` 618 // NullFields is a list of field names (e.g. "Name") to include in API requests 619 // with the JSON null value. By default, fields with empty values are omitted 620 // from API requests. See 621 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 622 NullFields []string `json:"-"` 623 } 624 625 func (s *FunctionResponse) MarshalJSON() ([]byte, error) { 626 type NoMethod FunctionResponse 627 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 628 } 629 630 // GenerateContentRequest: Request message for 631 // [PredictionService.GenerateContent]. 632 type GenerateContentRequest struct { 633 // Contents: Required. The content of the current conversation with the model. 634 // For single-turn queries, this is a single instance. For multi-turn queries, 635 // this is a repeated field that contains conversation history + latest 636 // request. 637 Contents []*Content `json:"contents,omitempty"` 638 // GenerationConfig: Optional. Generation config. 639 GenerationConfig *GenerationConfig `json:"generationConfig,omitempty"` 640 // SafetySettings: Optional. Per request settings for blocking unsafe content. 641 // Enforced on GenerateContentResponse.candidates. 642 SafetySettings []*SafetySetting `json:"safetySettings,omitempty"` 643 // SystemInstruction: Optional. The user provided system instructions for the 644 // model. Note: only text should be used in parts and content in each part will 645 // be in a separate paragraph. 646 SystemInstruction *Content `json:"systemInstruction,omitempty"` 647 // ToolConfig: Optional. Tool config. This config is shared for all tools 648 // provided in the request. 649 ToolConfig *ToolConfig `json:"toolConfig,omitempty"` 650 // Tools: Optional. A list of `Tools` the model may use to generate the next 651 // response. A `Tool` is a piece of code that enables the system to interact 652 // with external systems to perform an action, or set of actions, outside of 653 // knowledge and scope of the model. 654 Tools []*Tool `json:"tools,omitempty"` 655 // ForceSendFields is a list of field names (e.g. "Contents") to 656 // unconditionally include in API requests. By default, fields with empty or 657 // default values are omitted from API requests. See 658 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 659 // details. 660 ForceSendFields []string `json:"-"` 661 // NullFields is a list of field names (e.g. "Contents") to include in API 662 // requests with the JSON null value. By default, fields with empty values are 663 // omitted from API requests. See 664 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 665 NullFields []string `json:"-"` 666 } 667 668 func (s *GenerateContentRequest) MarshalJSON() ([]byte, error) { 669 type NoMethod GenerateContentRequest 670 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 671 } 672 673 // GenerateContentResponse: Response message for 674 // [PredictionService.GenerateContent]. 675 type GenerateContentResponse struct { 676 // Candidates: Output only. Generated candidates. 677 Candidates []*Candidate `json:"candidates,omitempty"` 678 // PromptFeedback: Output only. Content filter results for a prompt sent in the 679 // request. Note: Sent only in the first stream chunk. Only happens when no 680 // candidates were generated due to content violations. 681 PromptFeedback *PromptFeedback `json:"promptFeedback,omitempty"` 682 // UsageMetadata: Usage metadata about the response(s). 683 UsageMetadata *UsageMetadata `json:"usageMetadata,omitempty"` 684 685 // ServerResponse contains the HTTP response code and headers from the server. 686 googleapi.ServerResponse `json:"-"` 687 // ForceSendFields is a list of field names (e.g. "Candidates") to 688 // unconditionally include in API requests. By default, fields with empty or 689 // default values are omitted from API requests. See 690 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 691 // details. 692 ForceSendFields []string `json:"-"` 693 // NullFields is a list of field names (e.g. "Candidates") to include in API 694 // requests with the JSON null value. By default, fields with empty values are 695 // omitted from API requests. See 696 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 697 NullFields []string `json:"-"` 698 } 699 700 func (s *GenerateContentResponse) MarshalJSON() ([]byte, error) { 701 type NoMethod GenerateContentResponse 702 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 703 } 704 705 // GenerationConfig: Generation config. 706 type GenerationConfig struct { 707 // CandidateCount: Optional. Number of candidates to generate. 708 CandidateCount int64 `json:"candidateCount,omitempty"` 709 // FrequencyPenalty: Optional. Frequency penalties. 710 FrequencyPenalty float64 `json:"frequencyPenalty,omitempty"` 711 // MaxOutputTokens: Optional. The maximum number of output tokens to generate 712 // per message. 713 MaxOutputTokens int64 `json:"maxOutputTokens,omitempty"` 714 // PresencePenalty: Optional. Positive penalties. 715 PresencePenalty float64 `json:"presencePenalty,omitempty"` 716 // ResponseMimeType: Optional. Output response mimetype of the generated 717 // candidate text. Supported mimetype: - `text/plain`: (default) Text output. - 718 // `application/json`: JSON response in the candidates. The model needs to be 719 // prompted to output the appropriate response type, otherwise the behavior is 720 // undefined. This is a preview feature. 721 ResponseMimeType string `json:"responseMimeType,omitempty"` 722 // ResponseStyle: Optional. Control Three levels of creativity in the model 723 // output. Default: RESPONSE_STYLE_BALANCED 724 // 725 // Possible values: 726 // "RESPONSE_STYLE_UNSPECIFIED" - response style unspecified. 727 // "RESPONSE_STYLE_PRECISE" - Precise response. 728 // "RESPONSE_STYLE_BALANCED" - Default response style. 729 // "RESPONSE_STYLE_CREATIVE" - Creative response style. 730 ResponseStyle string `json:"responseStyle,omitempty"` 731 // StopSequences: Optional. Stop sequences. 732 StopSequences []string `json:"stopSequences,omitempty"` 733 // Temperature: Optional. Controls the randomness of predictions. 734 Temperature float64 `json:"temperature,omitempty"` 735 // TopK: Optional. If specified, top-k sampling will be used. 736 TopK float64 `json:"topK,omitempty"` 737 // TopP: Optional. If specified, nucleus sampling will be used. 738 TopP float64 `json:"topP,omitempty"` 739 // ForceSendFields is a list of field names (e.g. "CandidateCount") to 740 // unconditionally include in API requests. By default, fields with empty or 741 // default values are omitted from API requests. See 742 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 743 // details. 744 ForceSendFields []string `json:"-"` 745 // NullFields is a list of field names (e.g. "CandidateCount") to include in 746 // API requests with the JSON null value. By default, fields with empty values 747 // are omitted from API requests. See 748 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 749 NullFields []string `json:"-"` 750 } 751 752 func (s *GenerationConfig) MarshalJSON() ([]byte, error) { 753 type NoMethod GenerationConfig 754 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 755 } 756 757 func (s *GenerationConfig) UnmarshalJSON(data []byte) error { 758 type NoMethod GenerationConfig 759 var s1 struct { 760 FrequencyPenalty gensupport.JSONFloat64 `json:"frequencyPenalty"` 761 PresencePenalty gensupport.JSONFloat64 `json:"presencePenalty"` 762 Temperature gensupport.JSONFloat64 `json:"temperature"` 763 TopK gensupport.JSONFloat64 `json:"topK"` 764 TopP gensupport.JSONFloat64 `json:"topP"` 765 *NoMethod 766 } 767 s1.NoMethod = (*NoMethod)(s) 768 if err := json.Unmarshal(data, &s1); err != nil { 769 return err 770 } 771 s.FrequencyPenalty = float64(s1.FrequencyPenalty) 772 s.PresencePenalty = float64(s1.PresencePenalty) 773 s.Temperature = float64(s1.Temperature) 774 s.TopK = float64(s1.TopK) 775 s.TopP = float64(s1.TopP) 776 return nil 777 } 778 779 // GoogleSearchRetrieval: Tool to retrieve public web data for grounding, 780 // powered by Google. 781 type GoogleSearchRetrieval struct { 782 } 783 784 // GroundingMetadata: Metadata returned to client when grounding is enabled. 785 type GroundingMetadata struct { 786 // RetrievalQueries: Optional. Queries executed by the retrieval tools. 787 RetrievalQueries []string `json:"retrievalQueries,omitempty"` 788 // SearchEntryPoint: Optional. Google search entry for the following-up web 789 // searches. 790 SearchEntryPoint *SearchEntryPoint `json:"searchEntryPoint,omitempty"` 791 // WebSearchQueries: Optional. Web search queries for the following-up web 792 // search. 793 WebSearchQueries []string `json:"webSearchQueries,omitempty"` 794 // ForceSendFields is a list of field names (e.g. "RetrievalQueries") to 795 // unconditionally include in API requests. By default, fields with empty or 796 // default values are omitted from API requests. See 797 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 798 // details. 799 ForceSendFields []string `json:"-"` 800 // NullFields is a list of field names (e.g. "RetrievalQueries") to include in 801 // API requests with the JSON null value. By default, fields with empty values 802 // are omitted from API requests. See 803 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 804 NullFields []string `json:"-"` 805 } 806 807 func (s *GroundingMetadata) MarshalJSON() ([]byte, error) { 808 type NoMethod GroundingMetadata 809 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 810 } 811 812 // ModelOperationMetadata: This is returned in the longrunning operations for 813 // create/update. 814 type ModelOperationMetadata struct { 815 // Possible values: 816 // "BASIC_OPERATION_STATUS_UNSPECIFIED" - The status is unspecified 817 // "BASIC_OPERATION_STATUS_UPLOADING" - The model file is being uploaded 818 // "BASIC_OPERATION_STATUS_VERIFYING" - The model file is being verified 819 BasicOperationStatus string `json:"basicOperationStatus,omitempty"` 820 // Name: The name of the model we are creating/updating The name must have the 821 // form `projects/{project_id}/models/{model_id}` 822 Name string `json:"name,omitempty"` 823 // ForceSendFields is a list of field names (e.g. "BasicOperationStatus") to 824 // unconditionally include in API requests. By default, fields with empty or 825 // default values are omitted from API requests. See 826 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 827 // details. 828 ForceSendFields []string `json:"-"` 829 // NullFields is a list of field names (e.g. "BasicOperationStatus") to include 830 // in API requests with the JSON null value. By default, fields with empty 831 // values are omitted from API requests. See 832 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 833 NullFields []string `json:"-"` 834 } 835 836 func (s *ModelOperationMetadata) MarshalJSON() ([]byte, error) { 837 type NoMethod ModelOperationMetadata 838 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 839 } 840 841 // Part: A datatype containing media that is part of a multi-part `Content` 842 // message. A `Part` consists of data which has an associated datatype. A 843 // `Part` can only contain one of the accepted types in `Part.data`. A `Part` 844 // must have a fixed IANA MIME type identifying the type and subtype of the 845 // media if `inline_data` or `file_data` field is filled with raw bytes. 846 type Part struct { 847 // FileData: Optional. URI based data. 848 FileData *FileData `json:"fileData,omitempty"` 849 // FunctionCall: Optional. A predicted [FunctionCall] returned from the model 850 // that contains a string representing the [FunctionDeclaration.name] with the 851 // parameters and their values. 852 FunctionCall *FunctionCall `json:"functionCall,omitempty"` 853 // FunctionResponse: Optional. The result output of a [FunctionCall] that 854 // contains a string representing the [FunctionDeclaration.name] and a 855 // structured JSON object containing any output from the function call. It is 856 // used as context to the model. 857 FunctionResponse *FunctionResponse `json:"functionResponse,omitempty"` 858 // InlineData: Optional. Inlined bytes data. 859 InlineData *Blob `json:"inlineData,omitempty"` 860 // Text: Optional. Text part (can be code). 861 Text string `json:"text,omitempty"` 862 // VideoMetadata: Optional. Video metadata. The metadata should only be 863 // specified while the video data is presented in inline_data or file_data. 864 VideoMetadata *VideoMetadata `json:"videoMetadata,omitempty"` 865 // ForceSendFields is a list of field names (e.g. "FileData") to 866 // unconditionally include in API requests. By default, fields with empty or 867 // default values are omitted from API requests. See 868 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 869 // details. 870 ForceSendFields []string `json:"-"` 871 // NullFields is a list of field names (e.g. "FileData") to include in API 872 // requests with the JSON null value. By default, fields with empty values are 873 // omitted from API requests. See 874 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 875 NullFields []string `json:"-"` 876 } 877 878 func (s *Part) MarshalJSON() ([]byte, error) { 879 type NoMethod Part 880 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 881 } 882 883 // PromptFeedback: Content filter results for a prompt sent in the request. 884 type PromptFeedback struct { 885 // BlockReason: Output only. Blocked reason. 886 // 887 // Possible values: 888 // "BLOCKED_REASON_UNSPECIFIED" - Unspecified blocked reason. 889 // "SAFETY" - Candidates blocked due to safety. 890 // "OTHER" - Candidates blocked due to other reason. 891 // "BLOCKLIST" - Candidates blocked due to the terms which are included from 892 // the terminology blocklist. 893 // "PROHIBITED_CONTENT" - Candidates blocked due to prohibited content. 894 BlockReason string `json:"blockReason,omitempty"` 895 // BlockReasonMessage: Output only. A readable block reason message. 896 BlockReasonMessage string `json:"blockReasonMessage,omitempty"` 897 // SafetyRatings: Output only. Safety ratings. 898 SafetyRatings []*SafetyRating `json:"safetyRatings,omitempty"` 899 // ForceSendFields is a list of field names (e.g. "BlockReason") to 900 // unconditionally include in API requests. By default, fields with empty or 901 // default values are omitted from API requests. See 902 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 903 // details. 904 ForceSendFields []string `json:"-"` 905 // NullFields is a list of field names (e.g. "BlockReason") to include in API 906 // requests with the JSON null value. By default, fields with empty values are 907 // omitted from API requests. See 908 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 909 NullFields []string `json:"-"` 910 } 911 912 func (s *PromptFeedback) MarshalJSON() ([]byte, error) { 913 type NoMethod PromptFeedback 914 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 915 } 916 917 // RagResource: The definition of the Rag resource. 918 type RagResource struct { 919 // RagCorpus: Optional. RagCorpora resource name. Format: 920 // `projects/{project}/locations/{location}/ragCorpora/{rag_corpus}` 921 RagCorpus string `json:"ragCorpus,omitempty"` 922 // RagFileIds: Optional. rag_file_id. The files should be in the same 923 // rag_corpus set in rag_corpus field. 924 RagFileIds []string `json:"ragFileIds,omitempty"` 925 // ForceSendFields is a list of field names (e.g. "RagCorpus") to 926 // unconditionally include in API requests. By default, fields with empty or 927 // default values are omitted from API requests. See 928 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 929 // details. 930 ForceSendFields []string `json:"-"` 931 // NullFields is a list of field names (e.g. "RagCorpus") to include in API 932 // requests with the JSON null value. By default, fields with empty values are 933 // omitted from API requests. See 934 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 935 NullFields []string `json:"-"` 936 } 937 938 func (s *RagResource) MarshalJSON() ([]byte, error) { 939 type NoMethod RagResource 940 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 941 } 942 943 // Retrieval: Defines a retrieval tool that model can call to access external 944 // knowledge. 945 type Retrieval struct { 946 // DisableAttribution: Optional. Disable using the result from this tool in 947 // detecting grounding attribution. This does not affect how the result is 948 // given to the model for generation. 949 DisableAttribution bool `json:"disableAttribution,omitempty"` 950 // VertexAiSearch: Set to use data source powered by Vertex AI Search. 951 VertexAiSearch *VertexAISearch `json:"vertexAiSearch,omitempty"` 952 // VertexRagStore: Set to use data source powered by Vertex RAG store. User 953 // data is uploaded via the VertexRagDataService. 954 VertexRagStore *VertexRagStore `json:"vertexRagStore,omitempty"` 955 // ForceSendFields is a list of field names (e.g. "DisableAttribution") to 956 // unconditionally include in API requests. By default, fields with empty or 957 // default values are omitted from API requests. See 958 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 959 // details. 960 ForceSendFields []string `json:"-"` 961 // NullFields is a list of field names (e.g. "DisableAttribution") to include 962 // in API requests with the JSON null value. By default, fields with empty 963 // values are omitted from API requests. See 964 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 965 NullFields []string `json:"-"` 966 } 967 968 func (s *Retrieval) MarshalJSON() ([]byte, error) { 969 type NoMethod Retrieval 970 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 971 } 972 973 // SafetyRating: Safety rating corresponding to the generated content. 974 type SafetyRating struct { 975 // Blocked: Output only. Indicates whether the content was filtered out because 976 // of this rating. 977 Blocked bool `json:"blocked,omitempty"` 978 // Category: Output only. Harm category. 979 // 980 // Possible values: 981 // "HARM_CATEGORY_UNSPECIFIED" - The harm category is unspecified. 982 // "HARM_CATEGORY_HATE_SPEECH" - The harm category is hate speech. 983 // "HARM_CATEGORY_DANGEROUS_CONTENT" - The harm category is dangerous 984 // content. 985 // "HARM_CATEGORY_HARASSMENT" - The harm category is harassment. 986 // "HARM_CATEGORY_SEXUALLY_EXPLICIT" - The harm category is sexually explicit 987 // content. 988 Category string `json:"category,omitempty"` 989 // Probability: Output only. Harm probability levels in the content. 990 // 991 // Possible values: 992 // "HARM_PROBABILITY_UNSPECIFIED" - Harm probability unspecified. 993 // "NEGLIGIBLE" - Negligible level of harm. 994 // "LOW" - Low level of harm. 995 // "MEDIUM" - Medium level of harm. 996 // "HIGH" - High level of harm. 997 Probability string `json:"probability,omitempty"` 998 // ProbabilityScore: Output only. Harm probability score. 999 ProbabilityScore float64 `json:"probabilityScore,omitempty"` 1000 // Severity: Output only. Harm severity levels in the content. 1001 // 1002 // Possible values: 1003 // "HARM_SEVERITY_UNSPECIFIED" - Harm severity unspecified. 1004 // "HARM_SEVERITY_NEGLIGIBLE" - Negligible level of harm severity. 1005 // "HARM_SEVERITY_LOW" - Low level of harm severity. 1006 // "HARM_SEVERITY_MEDIUM" - Medium level of harm severity. 1007 // "HARM_SEVERITY_HIGH" - High level of harm severity. 1008 Severity string `json:"severity,omitempty"` 1009 // SeverityScore: Output only. Harm severity score. 1010 SeverityScore float64 `json:"severityScore,omitempty"` 1011 // ForceSendFields is a list of field names (e.g. "Blocked") to unconditionally 1012 // include in API requests. By default, fields with empty or default values are 1013 // omitted from API requests. See 1014 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1015 // details. 1016 ForceSendFields []string `json:"-"` 1017 // NullFields is a list of field names (e.g. "Blocked") to include in API 1018 // requests with the JSON null value. By default, fields with empty values are 1019 // omitted from API requests. See 1020 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1021 NullFields []string `json:"-"` 1022 } 1023 1024 func (s *SafetyRating) MarshalJSON() ([]byte, error) { 1025 type NoMethod SafetyRating 1026 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1027 } 1028 1029 func (s *SafetyRating) UnmarshalJSON(data []byte) error { 1030 type NoMethod SafetyRating 1031 var s1 struct { 1032 ProbabilityScore gensupport.JSONFloat64 `json:"probabilityScore"` 1033 SeverityScore gensupport.JSONFloat64 `json:"severityScore"` 1034 *NoMethod 1035 } 1036 s1.NoMethod = (*NoMethod)(s) 1037 if err := json.Unmarshal(data, &s1); err != nil { 1038 return err 1039 } 1040 s.ProbabilityScore = float64(s1.ProbabilityScore) 1041 s.SeverityScore = float64(s1.SeverityScore) 1042 return nil 1043 } 1044 1045 // SafetySetting: Safety settings. 1046 type SafetySetting struct { 1047 // Category: Required. Harm category. 1048 // 1049 // Possible values: 1050 // "HARM_CATEGORY_UNSPECIFIED" - The harm category is unspecified. 1051 // "HARM_CATEGORY_HATE_SPEECH" - The harm category is hate speech. 1052 // "HARM_CATEGORY_DANGEROUS_CONTENT" - The harm category is dangerous 1053 // content. 1054 // "HARM_CATEGORY_HARASSMENT" - The harm category is harassment. 1055 // "HARM_CATEGORY_SEXUALLY_EXPLICIT" - The harm category is sexually explicit 1056 // content. 1057 Category string `json:"category,omitempty"` 1058 // Method: Optional. Specify if the threshold is used for probability or 1059 // severity score. If not specified, the threshold is used for probability 1060 // score. 1061 // 1062 // Possible values: 1063 // "HARM_BLOCK_METHOD_UNSPECIFIED" - The harm block method is unspecified. 1064 // "SEVERITY" - The harm block method uses both probability and severity 1065 // scores. 1066 // "PROBABILITY" - The harm block method uses the probability score. 1067 Method string `json:"method,omitempty"` 1068 // Threshold: Required. The harm block threshold. 1069 // 1070 // Possible values: 1071 // "HARM_BLOCK_THRESHOLD_UNSPECIFIED" - Unspecified harm block threshold. 1072 // "BLOCK_LOW_AND_ABOVE" - Block low threshold and above (i.e. block more). 1073 // "BLOCK_MEDIUM_AND_ABOVE" - Block medium threshold and above. 1074 // "BLOCK_ONLY_HIGH" - Block only high threshold (i.e. block less). 1075 // "BLOCK_NONE" - Block none. 1076 Threshold string `json:"threshold,omitempty"` 1077 // ForceSendFields is a list of field names (e.g. "Category") to 1078 // unconditionally include in API requests. By default, fields with empty or 1079 // default values are omitted from API requests. See 1080 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1081 // details. 1082 ForceSendFields []string `json:"-"` 1083 // NullFields is a list of field names (e.g. "Category") to include in API 1084 // requests with the JSON null value. By default, fields with empty values are 1085 // omitted from API requests. See 1086 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1087 NullFields []string `json:"-"` 1088 } 1089 1090 func (s *SafetySetting) MarshalJSON() ([]byte, error) { 1091 type NoMethod SafetySetting 1092 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1093 } 1094 1095 // Schema: Schema is used to define the format of input/output data. Represents 1096 // a select subset of an OpenAPI 3.0 schema object 1097 // (https://spec.openapis.org/oas/v3.0.3#schema). More fields may be added in 1098 // the future as needed. 1099 type Schema struct { 1100 // Default: Optional. Default value of the data. 1101 Default interface{} `json:"default,omitempty"` 1102 // Description: Optional. The description of the data. 1103 Description string `json:"description,omitempty"` 1104 // Enum: Optional. Possible values of the element of Type.STRING with enum 1105 // format. For example we can define an Enum Direction as : {type:STRING, 1106 // format:enum, enum:["EAST", NORTH", "SOUTH", "WEST"]} 1107 Enum []string `json:"enum,omitempty"` 1108 // Example: Optional. Example of the object. Will only populated when the 1109 // object is the root. 1110 Example interface{} `json:"example,omitempty"` 1111 // Format: Optional. The format of the data. Supported formats: for NUMBER 1112 // type: "float", "double" for INTEGER type: "int32", "int64" for STRING type: 1113 // "email", "byte", etc 1114 Format string `json:"format,omitempty"` 1115 // Items: Optional. SCHEMA FIELDS FOR TYPE ARRAY Schema of the elements of 1116 // Type.ARRAY. 1117 Items *Schema `json:"items,omitempty"` 1118 // MaxItems: Optional. Maximum number of the elements for Type.ARRAY. 1119 MaxItems int64 `json:"maxItems,omitempty,string"` 1120 // MaxLength: Optional. Maximum length of the Type.STRING 1121 MaxLength int64 `json:"maxLength,omitempty,string"` 1122 // MaxProperties: Optional. Maximum number of the properties for Type.OBJECT. 1123 MaxProperties int64 `json:"maxProperties,omitempty,string"` 1124 // Maximum: Optional. Maximum value of the Type.INTEGER and Type.NUMBER 1125 Maximum float64 `json:"maximum,omitempty"` 1126 // MinItems: Optional. Minimum number of the elements for Type.ARRAY. 1127 MinItems int64 `json:"minItems,omitempty,string"` 1128 // MinLength: Optional. SCHEMA FIELDS FOR TYPE STRING Minimum length of the 1129 // Type.STRING 1130 MinLength int64 `json:"minLength,omitempty,string"` 1131 // MinProperties: Optional. Minimum number of the properties for Type.OBJECT. 1132 MinProperties int64 `json:"minProperties,omitempty,string"` 1133 // Minimum: Optional. SCHEMA FIELDS FOR TYPE INTEGER and NUMBER Minimum value 1134 // of the Type.INTEGER and Type.NUMBER 1135 Minimum float64 `json:"minimum,omitempty"` 1136 // Nullable: Optional. Indicates if the value may be null. 1137 Nullable bool `json:"nullable,omitempty"` 1138 // Pattern: Optional. Pattern of the Type.STRING to restrict a string to a 1139 // regular expression. 1140 Pattern string `json:"pattern,omitempty"` 1141 // Properties: Optional. SCHEMA FIELDS FOR TYPE OBJECT Properties of 1142 // Type.OBJECT. 1143 Properties map[string]Schema `json:"properties,omitempty"` 1144 // Required: Optional. Required properties of Type.OBJECT. 1145 Required []string `json:"required,omitempty"` 1146 // Title: Optional. The title of the Schema. 1147 Title string `json:"title,omitempty"` 1148 // Type: Optional. The type of the data. 1149 // 1150 // Possible values: 1151 // "TYPE_UNSPECIFIED" - Not specified, should not be used. 1152 // "STRING" - OpenAPI string type 1153 // "NUMBER" - OpenAPI number type 1154 // "INTEGER" - OpenAPI integer type 1155 // "BOOLEAN" - OpenAPI boolean type 1156 // "ARRAY" - OpenAPI array type 1157 // "OBJECT" - OpenAPI object type 1158 Type string `json:"type,omitempty"` 1159 // ForceSendFields is a list of field names (e.g. "Default") to unconditionally 1160 // include in API requests. By default, fields with empty or default values are 1161 // omitted from API requests. See 1162 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1163 // details. 1164 ForceSendFields []string `json:"-"` 1165 // NullFields is a list of field names (e.g. "Default") to include in API 1166 // requests with the JSON null value. By default, fields with empty values are 1167 // omitted from API requests. See 1168 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1169 NullFields []string `json:"-"` 1170 } 1171 1172 func (s *Schema) MarshalJSON() ([]byte, error) { 1173 type NoMethod Schema 1174 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1175 } 1176 1177 func (s *Schema) UnmarshalJSON(data []byte) error { 1178 type NoMethod Schema 1179 var s1 struct { 1180 Maximum gensupport.JSONFloat64 `json:"maximum"` 1181 Minimum gensupport.JSONFloat64 `json:"minimum"` 1182 *NoMethod 1183 } 1184 s1.NoMethod = (*NoMethod)(s) 1185 if err := json.Unmarshal(data, &s1); err != nil { 1186 return err 1187 } 1188 s.Maximum = float64(s1.Maximum) 1189 s.Minimum = float64(s1.Minimum) 1190 return nil 1191 } 1192 1193 // SearchEntryPoint: Google search entry point. 1194 type SearchEntryPoint struct { 1195 // RenderedContent: Optional. Web content snippet that can be embedded in a web 1196 // page or an app webview. 1197 RenderedContent string `json:"renderedContent,omitempty"` 1198 // SdkBlob: Optional. Base64 encoded JSON representing array of tuple. 1199 SdkBlob string `json:"sdkBlob,omitempty"` 1200 // ForceSendFields is a list of field names (e.g. "RenderedContent") to 1201 // unconditionally include in API requests. By default, fields with empty or 1202 // default values are omitted from API requests. See 1203 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1204 // details. 1205 ForceSendFields []string `json:"-"` 1206 // NullFields is a list of field names (e.g. "RenderedContent") to include in 1207 // API requests with the JSON null value. By default, fields with empty values 1208 // are omitted from API requests. See 1209 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1210 NullFields []string `json:"-"` 1211 } 1212 1213 func (s *SearchEntryPoint) MarshalJSON() ([]byte, error) { 1214 type NoMethod SearchEntryPoint 1215 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1216 } 1217 1218 // Tool: Tool details that the model may use to generate response. A `Tool` is 1219 // a piece of code that enables the system to interact with external systems to 1220 // perform an action, or set of actions, outside of knowledge and scope of the 1221 // model. A Tool object should contain exactly one type of Tool (e.g 1222 // FunctionDeclaration, Retrieval or GoogleSearchRetrieval). 1223 type Tool struct { 1224 // FunctionDeclarations: Optional. Function tool type. One or more function 1225 // declarations to be passed to the model along with the current user query. 1226 // Model may decide to call a subset of these functions by populating 1227 // FunctionCall in the response. User should provide a FunctionResponse for 1228 // each function call in the next turn. Based on the function responses, Model 1229 // will generate the final response back to the user. Maximum 64 function 1230 // declarations can be provided. 1231 FunctionDeclarations []*FunctionDeclaration `json:"functionDeclarations,omitempty"` 1232 // GoogleSearchRetrieval: Optional. GoogleSearchRetrieval tool type. 1233 // Specialized retrieval tool that is powered by Google search. 1234 GoogleSearchRetrieval *GoogleSearchRetrieval `json:"googleSearchRetrieval,omitempty"` 1235 // Retrieval: Optional. Retrieval tool type. System will always execute the 1236 // provided retrieval tool(s) to get external knowledge to answer the prompt. 1237 // Retrieval results are presented to the model for generation. 1238 Retrieval *Retrieval `json:"retrieval,omitempty"` 1239 // ForceSendFields is a list of field names (e.g. "FunctionDeclarations") to 1240 // unconditionally include in API requests. By default, fields with empty or 1241 // default values are omitted from API requests. See 1242 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1243 // details. 1244 ForceSendFields []string `json:"-"` 1245 // NullFields is a list of field names (e.g. "FunctionDeclarations") to include 1246 // in API requests with the JSON null value. By default, fields with empty 1247 // values are omitted from API requests. See 1248 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1249 NullFields []string `json:"-"` 1250 } 1251 1252 func (s *Tool) MarshalJSON() ([]byte, error) { 1253 type NoMethod Tool 1254 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1255 } 1256 1257 // ToolConfig: Tool config. This config is shared for all tools provided in the 1258 // request. 1259 type ToolConfig struct { 1260 // FunctionCallingConfig: Optional. Function calling config. 1261 FunctionCallingConfig *FunctionCallingConfig `json:"functionCallingConfig,omitempty"` 1262 // ForceSendFields is a list of field names (e.g. "FunctionCallingConfig") to 1263 // unconditionally include in API requests. By default, fields with empty or 1264 // default values are omitted from API requests. See 1265 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1266 // details. 1267 ForceSendFields []string `json:"-"` 1268 // NullFields is a list of field names (e.g. "FunctionCallingConfig") to 1269 // include in API requests with the JSON null value. By default, fields with 1270 // empty values are omitted from API requests. See 1271 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1272 NullFields []string `json:"-"` 1273 } 1274 1275 func (s *ToolConfig) MarshalJSON() ([]byte, error) { 1276 type NoMethod ToolConfig 1277 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1278 } 1279 1280 // UsageMetadata: Usage metadata about response(s). 1281 type UsageMetadata struct { 1282 // CandidatesTokenCount: Number of tokens in the response(s). 1283 CandidatesTokenCount int64 `json:"candidatesTokenCount,omitempty"` 1284 // PromptTokenCount: Number of tokens in the request. 1285 PromptTokenCount int64 `json:"promptTokenCount,omitempty"` 1286 TotalTokenCount int64 `json:"totalTokenCount,omitempty"` 1287 // ForceSendFields is a list of field names (e.g. "CandidatesTokenCount") to 1288 // unconditionally include in API requests. By default, fields with empty or 1289 // default values are omitted from API requests. See 1290 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1291 // details. 1292 ForceSendFields []string `json:"-"` 1293 // NullFields is a list of field names (e.g. "CandidatesTokenCount") to include 1294 // in API requests with the JSON null value. By default, fields with empty 1295 // values are omitted from API requests. See 1296 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1297 NullFields []string `json:"-"` 1298 } 1299 1300 func (s *UsageMetadata) MarshalJSON() ([]byte, error) { 1301 type NoMethod UsageMetadata 1302 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1303 } 1304 1305 // VertexAISearch: Retrieve from Vertex AI Search datastore for grounding. See 1306 // https://cloud.google.com/vertex-ai-search-and-conversation 1307 type VertexAISearch struct { 1308 // Datastore: Required. Fully-qualified Vertex AI Search's datastore resource 1309 // ID. Format: 1310 // `projects/{project}/locations/{location}/collections/{collection}/dataStores/ 1311 // {dataStore}` 1312 Datastore string `json:"datastore,omitempty"` 1313 // ForceSendFields is a list of field names (e.g. "Datastore") to 1314 // unconditionally include in API requests. By default, fields with empty or 1315 // default values are omitted from API requests. See 1316 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1317 // details. 1318 ForceSendFields []string `json:"-"` 1319 // NullFields is a list of field names (e.g. "Datastore") to include in API 1320 // requests with the JSON null value. By default, fields with empty values are 1321 // omitted from API requests. See 1322 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1323 NullFields []string `json:"-"` 1324 } 1325 1326 func (s *VertexAISearch) MarshalJSON() ([]byte, error) { 1327 type NoMethod VertexAISearch 1328 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1329 } 1330 1331 // VertexRagStore: Retrieve from Vertex RAG Store for grounding. 1332 type VertexRagStore struct { 1333 // RagCorpora: Optional. Deprecated. Please use rag_resources instead. 1334 RagCorpora []string `json:"ragCorpora,omitempty"` 1335 // RagResources: Optional. The representation of the rag source. It can be used 1336 // to specify corpus only or ragfiles. Currently only support one corpus or 1337 // multiple files from one corpus. In the future we may open up multiple 1338 // corpora support. 1339 RagResources []*RagResource `json:"ragResources,omitempty"` 1340 // SimilarityTopK: Optional. Number of top k results to return from the 1341 // selected corpora. 1342 SimilarityTopK int64 `json:"similarityTopK,omitempty"` 1343 // VectorDistanceThreshold: Optional. Only return results with vector distance 1344 // smaller than the threshold. 1345 VectorDistanceThreshold float64 `json:"vectorDistanceThreshold,omitempty"` 1346 // ForceSendFields is a list of field names (e.g. "RagCorpora") to 1347 // unconditionally include in API requests. By default, fields with empty or 1348 // default values are omitted from API requests. See 1349 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1350 // details. 1351 ForceSendFields []string `json:"-"` 1352 // NullFields is a list of field names (e.g. "RagCorpora") to include in API 1353 // requests with the JSON null value. By default, fields with empty values are 1354 // omitted from API requests. See 1355 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1356 NullFields []string `json:"-"` 1357 } 1358 1359 func (s *VertexRagStore) MarshalJSON() ([]byte, error) { 1360 type NoMethod VertexRagStore 1361 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1362 } 1363 1364 func (s *VertexRagStore) UnmarshalJSON(data []byte) error { 1365 type NoMethod VertexRagStore 1366 var s1 struct { 1367 VectorDistanceThreshold gensupport.JSONFloat64 `json:"vectorDistanceThreshold"` 1368 *NoMethod 1369 } 1370 s1.NoMethod = (*NoMethod)(s) 1371 if err := json.Unmarshal(data, &s1); err != nil { 1372 return err 1373 } 1374 s.VectorDistanceThreshold = float64(s1.VectorDistanceThreshold) 1375 return nil 1376 } 1377 1378 // VideoMetadata: Metadata describes the input video content. 1379 type VideoMetadata struct { 1380 // EndOffset: Optional. The end offset of the video. 1381 EndOffset string `json:"endOffset,omitempty"` 1382 // StartOffset: Optional. The start offset of the video. 1383 StartOffset string `json:"startOffset,omitempty"` 1384 // ForceSendFields is a list of field names (e.g. "EndOffset") to 1385 // unconditionally include in API requests. By default, fields with empty or 1386 // default values are omitted from API requests. See 1387 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1388 // details. 1389 ForceSendFields []string `json:"-"` 1390 // NullFields is a list of field names (e.g. "EndOffset") to include in API 1391 // requests with the JSON null value. By default, fields with empty values are 1392 // omitted from API requests. See 1393 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1394 NullFields []string `json:"-"` 1395 } 1396 1397 func (s *VideoMetadata) MarshalJSON() ([]byte, error) { 1398 type NoMethod VideoMetadata 1399 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1400 } 1401 1402 type ProjectsLocationsPublishersModelsCountTokensCall struct { 1403 s *Service 1404 endpoint string 1405 counttokensrequest *CountTokensRequest 1406 urlParams_ gensupport.URLParams 1407 ctx_ context.Context 1408 header_ http.Header 1409 } 1410 1411 // CountTokens: Perform a token counting. 1412 // 1413 // - endpoint: The name of the Endpoint requested to perform token counting. 1414 // Format: `projects/{project}/locations/{location}/endpoints/{endpoint}`. 1415 func (r *ProjectsLocationsPublishersModelsService) CountTokens(endpoint string, counttokensrequest *CountTokensRequest) *ProjectsLocationsPublishersModelsCountTokensCall { 1416 c := &ProjectsLocationsPublishersModelsCountTokensCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1417 c.endpoint = endpoint 1418 c.counttokensrequest = counttokensrequest 1419 return c 1420 } 1421 1422 // Fields allows partial responses to be retrieved. See 1423 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 1424 // details. 1425 func (c *ProjectsLocationsPublishersModelsCountTokensCall) Fields(s ...googleapi.Field) *ProjectsLocationsPublishersModelsCountTokensCall { 1426 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1427 return c 1428 } 1429 1430 // Context sets the context to be used in this call's Do method. 1431 func (c *ProjectsLocationsPublishersModelsCountTokensCall) Context(ctx context.Context) *ProjectsLocationsPublishersModelsCountTokensCall { 1432 c.ctx_ = ctx 1433 return c 1434 } 1435 1436 // Header returns a http.Header that can be modified by the caller to add 1437 // headers to the request. 1438 func (c *ProjectsLocationsPublishersModelsCountTokensCall) Header() http.Header { 1439 if c.header_ == nil { 1440 c.header_ = make(http.Header) 1441 } 1442 return c.header_ 1443 } 1444 1445 func (c *ProjectsLocationsPublishersModelsCountTokensCall) doRequest(alt string) (*http.Response, error) { 1446 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) 1447 var body io.Reader = nil 1448 body, err := googleapi.WithoutDataWrapper.JSONReader(c.counttokensrequest) 1449 if err != nil { 1450 return nil, err 1451 } 1452 c.urlParams_.Set("alt", alt) 1453 c.urlParams_.Set("prettyPrint", "false") 1454 urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta/{+endpoint}:countTokens") 1455 urls += "?" + c.urlParams_.Encode() 1456 req, err := http.NewRequest("POST", urls, body) 1457 if err != nil { 1458 return nil, err 1459 } 1460 req.Header = reqHeaders 1461 googleapi.Expand(req.URL, map[string]string{ 1462 "endpoint": c.endpoint, 1463 }) 1464 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1465 } 1466 1467 // Do executes the "firebaseml.projects.locations.publishers.models.countTokens" call. 1468 // Any non-2xx status code is an error. Response headers are in either 1469 // *CountTokensResponse.ServerResponse.Header or (if a response was returned at 1470 // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to 1471 // check whether the returned error was because http.StatusNotModified was 1472 // returned. 1473 func (c *ProjectsLocationsPublishersModelsCountTokensCall) Do(opts ...googleapi.CallOption) (*CountTokensResponse, error) { 1474 gensupport.SetOptions(c.urlParams_, opts...) 1475 res, err := c.doRequest("json") 1476 if res != nil && res.StatusCode == http.StatusNotModified { 1477 if res.Body != nil { 1478 res.Body.Close() 1479 } 1480 return nil, gensupport.WrapError(&googleapi.Error{ 1481 Code: res.StatusCode, 1482 Header: res.Header, 1483 }) 1484 } 1485 if err != nil { 1486 return nil, err 1487 } 1488 defer googleapi.CloseBody(res) 1489 if err := googleapi.CheckResponse(res); err != nil { 1490 return nil, gensupport.WrapError(err) 1491 } 1492 ret := &CountTokensResponse{ 1493 ServerResponse: googleapi.ServerResponse{ 1494 Header: res.Header, 1495 HTTPStatusCode: res.StatusCode, 1496 }, 1497 } 1498 target := &ret 1499 if err := gensupport.DecodeResponse(target, res); err != nil { 1500 return nil, err 1501 } 1502 return ret, nil 1503 } 1504 1505 type ProjectsLocationsPublishersModelsGenerateContentCall struct { 1506 s *Service 1507 model string 1508 generatecontentrequest *GenerateContentRequest 1509 urlParams_ gensupport.URLParams 1510 ctx_ context.Context 1511 header_ http.Header 1512 } 1513 1514 // GenerateContent: Generate content with multimodal inputs. 1515 // 1516 // - model: The name of the publisher model requested to serve the prediction. 1517 // Format: `projects/{project}/locations/{location}/publishers/*/models/*`. 1518 func (r *ProjectsLocationsPublishersModelsService) GenerateContent(model string, generatecontentrequest *GenerateContentRequest) *ProjectsLocationsPublishersModelsGenerateContentCall { 1519 c := &ProjectsLocationsPublishersModelsGenerateContentCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1520 c.model = model 1521 c.generatecontentrequest = generatecontentrequest 1522 return c 1523 } 1524 1525 // Fields allows partial responses to be retrieved. See 1526 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 1527 // details. 1528 func (c *ProjectsLocationsPublishersModelsGenerateContentCall) Fields(s ...googleapi.Field) *ProjectsLocationsPublishersModelsGenerateContentCall { 1529 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1530 return c 1531 } 1532 1533 // Context sets the context to be used in this call's Do method. 1534 func (c *ProjectsLocationsPublishersModelsGenerateContentCall) Context(ctx context.Context) *ProjectsLocationsPublishersModelsGenerateContentCall { 1535 c.ctx_ = ctx 1536 return c 1537 } 1538 1539 // Header returns a http.Header that can be modified by the caller to add 1540 // headers to the request. 1541 func (c *ProjectsLocationsPublishersModelsGenerateContentCall) Header() http.Header { 1542 if c.header_ == nil { 1543 c.header_ = make(http.Header) 1544 } 1545 return c.header_ 1546 } 1547 1548 func (c *ProjectsLocationsPublishersModelsGenerateContentCall) doRequest(alt string) (*http.Response, error) { 1549 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) 1550 var body io.Reader = nil 1551 body, err := googleapi.WithoutDataWrapper.JSONReader(c.generatecontentrequest) 1552 if err != nil { 1553 return nil, err 1554 } 1555 c.urlParams_.Set("alt", alt) 1556 c.urlParams_.Set("prettyPrint", "false") 1557 urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta/{+model}:generateContent") 1558 urls += "?" + c.urlParams_.Encode() 1559 req, err := http.NewRequest("POST", urls, body) 1560 if err != nil { 1561 return nil, err 1562 } 1563 req.Header = reqHeaders 1564 googleapi.Expand(req.URL, map[string]string{ 1565 "model": c.model, 1566 }) 1567 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1568 } 1569 1570 // Do executes the "firebaseml.projects.locations.publishers.models.generateContent" call. 1571 // Any non-2xx status code is an error. Response headers are in either 1572 // *GenerateContentResponse.ServerResponse.Header or (if a response was 1573 // returned at all) in error.(*googleapi.Error).Header. Use 1574 // googleapi.IsNotModified to check whether the returned error was because 1575 // http.StatusNotModified was returned. 1576 func (c *ProjectsLocationsPublishersModelsGenerateContentCall) Do(opts ...googleapi.CallOption) (*GenerateContentResponse, error) { 1577 gensupport.SetOptions(c.urlParams_, opts...) 1578 res, err := c.doRequest("json") 1579 if res != nil && res.StatusCode == http.StatusNotModified { 1580 if res.Body != nil { 1581 res.Body.Close() 1582 } 1583 return nil, gensupport.WrapError(&googleapi.Error{ 1584 Code: res.StatusCode, 1585 Header: res.Header, 1586 }) 1587 } 1588 if err != nil { 1589 return nil, err 1590 } 1591 defer googleapi.CloseBody(res) 1592 if err := googleapi.CheckResponse(res); err != nil { 1593 return nil, gensupport.WrapError(err) 1594 } 1595 ret := &GenerateContentResponse{ 1596 ServerResponse: googleapi.ServerResponse{ 1597 Header: res.Header, 1598 HTTPStatusCode: res.StatusCode, 1599 }, 1600 } 1601 target := &ret 1602 if err := gensupport.DecodeResponse(target, res); err != nil { 1603 return nil, err 1604 } 1605 return ret, nil 1606 } 1607 1608 type ProjectsLocationsPublishersModelsStreamGenerateContentCall struct { 1609 s *Service 1610 model string 1611 generatecontentrequest *GenerateContentRequest 1612 urlParams_ gensupport.URLParams 1613 ctx_ context.Context 1614 header_ http.Header 1615 } 1616 1617 // StreamGenerateContent: Generate content with multimodal inputs with 1618 // streaming support. 1619 // 1620 // - model: The name of the publisher model requested to serve the prediction. 1621 // Format: `projects/{project}/locations/{location}/publishers/*/models/*`. 1622 func (r *ProjectsLocationsPublishersModelsService) StreamGenerateContent(model string, generatecontentrequest *GenerateContentRequest) *ProjectsLocationsPublishersModelsStreamGenerateContentCall { 1623 c := &ProjectsLocationsPublishersModelsStreamGenerateContentCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1624 c.model = model 1625 c.generatecontentrequest = generatecontentrequest 1626 return c 1627 } 1628 1629 // Fields allows partial responses to be retrieved. See 1630 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 1631 // details. 1632 func (c *ProjectsLocationsPublishersModelsStreamGenerateContentCall) Fields(s ...googleapi.Field) *ProjectsLocationsPublishersModelsStreamGenerateContentCall { 1633 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1634 return c 1635 } 1636 1637 // Context sets the context to be used in this call's Do method. 1638 func (c *ProjectsLocationsPublishersModelsStreamGenerateContentCall) Context(ctx context.Context) *ProjectsLocationsPublishersModelsStreamGenerateContentCall { 1639 c.ctx_ = ctx 1640 return c 1641 } 1642 1643 // Header returns a http.Header that can be modified by the caller to add 1644 // headers to the request. 1645 func (c *ProjectsLocationsPublishersModelsStreamGenerateContentCall) Header() http.Header { 1646 if c.header_ == nil { 1647 c.header_ = make(http.Header) 1648 } 1649 return c.header_ 1650 } 1651 1652 func (c *ProjectsLocationsPublishersModelsStreamGenerateContentCall) doRequest(alt string) (*http.Response, error) { 1653 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) 1654 var body io.Reader = nil 1655 body, err := googleapi.WithoutDataWrapper.JSONReader(c.generatecontentrequest) 1656 if err != nil { 1657 return nil, err 1658 } 1659 c.urlParams_.Set("alt", alt) 1660 c.urlParams_.Set("prettyPrint", "false") 1661 urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta/{+model}:streamGenerateContent") 1662 urls += "?" + c.urlParams_.Encode() 1663 req, err := http.NewRequest("POST", urls, body) 1664 if err != nil { 1665 return nil, err 1666 } 1667 req.Header = reqHeaders 1668 googleapi.Expand(req.URL, map[string]string{ 1669 "model": c.model, 1670 }) 1671 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1672 } 1673 1674 // Do executes the "firebaseml.projects.locations.publishers.models.streamGenerateContent" call. 1675 // Any non-2xx status code is an error. Response headers are in either 1676 // *GenerateContentResponse.ServerResponse.Header or (if a response was 1677 // returned at all) in error.(*googleapi.Error).Header. Use 1678 // googleapi.IsNotModified to check whether the returned error was because 1679 // http.StatusNotModified was returned. 1680 func (c *ProjectsLocationsPublishersModelsStreamGenerateContentCall) Do(opts ...googleapi.CallOption) (*GenerateContentResponse, error) { 1681 gensupport.SetOptions(c.urlParams_, opts...) 1682 res, err := c.doRequest("json") 1683 if res != nil && res.StatusCode == http.StatusNotModified { 1684 if res.Body != nil { 1685 res.Body.Close() 1686 } 1687 return nil, gensupport.WrapError(&googleapi.Error{ 1688 Code: res.StatusCode, 1689 Header: res.Header, 1690 }) 1691 } 1692 if err != nil { 1693 return nil, err 1694 } 1695 defer googleapi.CloseBody(res) 1696 if err := googleapi.CheckResponse(res); err != nil { 1697 return nil, gensupport.WrapError(err) 1698 } 1699 ret := &GenerateContentResponse{ 1700 ServerResponse: googleapi.ServerResponse{ 1701 Header: res.Header, 1702 HTTPStatusCode: res.StatusCode, 1703 }, 1704 } 1705 target := &ret 1706 if err := gensupport.DecodeResponse(target, res); err != nil { 1707 return nil, err 1708 } 1709 return ret, nil 1710 } 1711