@@ -400,6 +400,74 @@ func (FunctionCall) fromProto(p *pb.FunctionCall) *FunctionCall {
400
400
}
401
401
}
402
402
403
+ // FunctionCallingConfig holds configuration for function calling.
404
+ type FunctionCallingConfig struct {
405
+ // Optional. Specifies the mode in which function calling should execute. If
406
+ // unspecified, the default value will be set to AUTO.
407
+ Mode FunctionCallingMode
408
+ // Optional. A set of function names that, when provided, limits the functions
409
+ // the model will call.
410
+ //
411
+ // This should only be set when the Mode is ANY. Function names
412
+ // should match [FunctionDeclaration.name]. With mode set to ANY, model will
413
+ // predict a function call from the set of function names provided.
414
+ AllowedFunctionNames []string
415
+ }
416
+
417
+ func (v * FunctionCallingConfig ) toProto () * pb.FunctionCallingConfig {
418
+ if v == nil {
419
+ return nil
420
+ }
421
+ return & pb.FunctionCallingConfig {
422
+ Mode : pb .FunctionCallingConfig_Mode (v .Mode ),
423
+ AllowedFunctionNames : v .AllowedFunctionNames ,
424
+ }
425
+ }
426
+
427
+ func (FunctionCallingConfig ) fromProto (p * pb.FunctionCallingConfig ) * FunctionCallingConfig {
428
+ if p == nil {
429
+ return nil
430
+ }
431
+ return & FunctionCallingConfig {
432
+ Mode : FunctionCallingMode (p .Mode ),
433
+ AllowedFunctionNames : p .AllowedFunctionNames ,
434
+ }
435
+ }
436
+
437
+ // FunctionCallingMode is defines the execution behavior for function calling by defining the
438
+ // execution mode.
439
+ type FunctionCallingMode int32
440
+
441
+ const (
442
+ // FunctionCallingUnspecified means unspecified function calling mode. This value should not be used.
443
+ FunctionCallingUnspecified FunctionCallingMode = 0
444
+ // FunctionCallingAuto means default model behavior, model decides to predict either a function call
445
+ // or a natural language repspose.
446
+ FunctionCallingAuto FunctionCallingMode = 1
447
+ // FunctionCallingAny means model is constrained to always predicting a function call only.
448
+ // If "allowed_function_names" are set, the predicted function call will be
449
+ // limited to any one of "allowed_function_names", else the predicted
450
+ // function call will be any one of the provided "function_declarations".
451
+ FunctionCallingAny FunctionCallingMode = 2
452
+ // FunctionCallingNone means model will not predict any function call. Model behavior is same as when
453
+ // not passing any function declarations.
454
+ FunctionCallingNone FunctionCallingMode = 3
455
+ )
456
+
457
+ var namesForFunctionCallingMode = map [FunctionCallingMode ]string {
458
+ FunctionCallingUnspecified : "FunctionCallingUnspecified" ,
459
+ FunctionCallingAuto : "FunctionCallingAuto" ,
460
+ FunctionCallingAny : "FunctionCallingAny" ,
461
+ FunctionCallingNone : "FunctionCallingNone" ,
462
+ }
463
+
464
+ func (v FunctionCallingMode ) String () string {
465
+ if n , ok := namesForFunctionCallingMode [v ]; ok {
466
+ return n
467
+ }
468
+ return fmt .Sprintf ("FunctionCallingMode(%d)" , v )
469
+ }
470
+
403
471
// FunctionDeclaration is structured representation of a function declaration as defined by the
404
472
// [OpenAPI 3.03 specification](https://spec.openapis.org/oas/v3.0.3). Included
405
473
// in this declaration are the function name and parameters. This
@@ -517,7 +585,7 @@ func (GenerateContentResponse) fromProto(p *pb.GenerateContentResponse) *Generat
517
585
type GenerationConfig struct {
518
586
// Optional. Number of generated responses to return.
519
587
//
520
- // This value must be between [1, 8], inclusive . If unset, this will default
588
+ // Currently, this value can only be set to 1 . If unset, this will default
521
589
// to 1.
522
590
CandidateCount * int32
523
591
// Optional. The set of character sequences (up to 5) that will stop output
@@ -527,17 +595,15 @@ type GenerationConfig struct {
527
595
StopSequences []string
528
596
// Optional. The maximum number of tokens to include in a candidate.
529
597
//
530
- // If unset, this will default to output_token_limit specified in the `Model`
531
- // specification .
598
+ // Note: The default value varies by model, see the `Model.output_token_limit `
599
+ // attribute of the `Model` returned from the `getModel` function .
532
600
MaxOutputTokens * int32
533
601
// Optional. Controls the randomness of the output.
602
+ //
534
603
// Note: The default value varies by model, see the `Model.temperature`
535
- // attribute of the `Model` returned the `getModel` function.
604
+ // attribute of the `Model` returned from the `getModel` function.
536
605
//
537
- // Values can range from [0.0,1.0],
538
- // inclusive. A value closer to 1.0 will produce responses that are more
539
- // varied and creative, while a value closer to 0.0 will typically result in
540
- // more straightforward responses from the model.
606
+ // Values can range from [0.0, infinity).
541
607
Temperature * float32
542
608
// Optional. The maximum cumulative probability of tokens to consider when
543
609
// sampling.
@@ -550,17 +616,16 @@ type GenerationConfig struct {
550
616
// of tokens based on the cumulative probability.
551
617
//
552
618
// Note: The default value varies by model, see the `Model.top_p`
553
- // attribute of the `Model` returned the `getModel` function.
619
+ // attribute of the `Model` returned from the `getModel` function.
554
620
TopP * float32
555
621
// Optional. The maximum number of tokens to consider when sampling.
556
622
//
557
623
// The model uses combined Top-k and nucleus sampling.
558
624
//
559
625
// Top-k sampling considers the set of `top_k` most probable tokens.
560
- // Defaults to 40.
561
626
//
562
627
// Note: The default value varies by model, see the `Model.top_k`
563
- // attribute of the `Model` returned the `getModel` function.
628
+ // attribute of the `Model` returned from the `getModel` function.
564
629
TopK * int32
565
630
}
566
631
@@ -634,9 +699,9 @@ const (
634
699
HarmCategoryUnspecified HarmCategory = 0
635
700
// HarmCategoryDerogatory means negative or harmful comments targeting identity and/or protected attribute.
636
701
HarmCategoryDerogatory HarmCategory = 1
637
- // HarmCategoryToxicity means content that is rude, disrepspectful , or profane.
702
+ // HarmCategoryToxicity means content that is rude, disrespectful , or profane.
638
703
HarmCategoryToxicity HarmCategory = 2
639
- // HarmCategoryViolence means describes scenarios depictng violence against an individual or group, or
704
+ // HarmCategoryViolence means describes scenarios depicting violence against an individual or group, or
640
705
// general descriptions of gore.
641
706
HarmCategoryViolence HarmCategory = 3
642
707
// HarmCategorySexual means contains references to sexual acts or other lewd content.
@@ -1044,6 +1109,31 @@ func (Tool) fromProto(p *pb.Tool) *Tool {
1044
1109
}
1045
1110
}
1046
1111
1112
+ // ToolConfig is the Tool configuration containing parameters for specifying `Tool` use
1113
+ // in the request.
1114
+ type ToolConfig struct {
1115
+ // Optional. Function calling config.
1116
+ FunctionCallingConfig * FunctionCallingConfig
1117
+ }
1118
+
1119
+ func (v * ToolConfig ) toProto () * pb.ToolConfig {
1120
+ if v == nil {
1121
+ return nil
1122
+ }
1123
+ return & pb.ToolConfig {
1124
+ FunctionCallingConfig : v .FunctionCallingConfig .toProto (),
1125
+ }
1126
+ }
1127
+
1128
+ func (ToolConfig ) fromProto (p * pb.ToolConfig ) * ToolConfig {
1129
+ if p == nil {
1130
+ return nil
1131
+ }
1132
+ return & ToolConfig {
1133
+ FunctionCallingConfig : (FunctionCallingConfig {}).fromProto (p .FunctionCallingConfig ),
1134
+ }
1135
+ }
1136
+
1047
1137
// Type contains the list of OpenAPI data types as defined by
1048
1138
// https://spec.openapis.org/oas/v3.0.3#data-types
1049
1139
type Type int32
0 commit comments