From bffd28bb15f43448701f1a81eb88dccc8b9ab38d Mon Sep 17 00:00:00 2001 From: Jonathan Amsterdam Date: Sun, 23 Jun 2024 13:43:50 -0400 Subject: [PATCH] genai: remove support package (#142) Remove the support package. The latest version of protoveneer (see googleapis/google-cloud-go#10416) adds the support functions to the generated code. --- genai/client.go | 26 +- genai/config.yaml | 1 - genai/generativelanguagepb_veneer.gen.go | 177 +- .../v1beta/generativelanguage-api.json | 6250 +++++++++-------- .../v1beta/generativelanguage-gen.go | 711 +- internal/support/README.md | 2 - internal/support/support.go | 160 - internal/support/support_test.go | 79 - 8 files changed, 4095 insertions(+), 3311 deletions(-) delete mode 100644 internal/support/README.md delete mode 100644 internal/support/support.go delete mode 100644 internal/support/support_test.go diff --git a/genai/client.go b/genai/client.go index a8e9c21..55ddd3d 100644 --- a/genai/client.go +++ b/genai/client.go @@ -21,6 +21,12 @@ // Set the environment variable GOOGLE_CLOUD_GO to the path to the above repo on your machine. // For example: // export GOOGLE_CLOUD_GO=$HOME/repos/google-cloud-go +// +// Ensure that the working directory of that repo is at the version of cloud.google.com/go/ai in +// this repo's go.mod file. For example, if the go.mod contains +// cloud.google.com/go/ai v0.6.0 +// then from the root of the google-cloud-go repo, run +// git switch -d ai/v0.6.0 //go:generate protoveneer -license license.txt config.yaml $GOOGLE_CLOUD_GO/ai/generativelanguage/apiv1beta/generativelanguagepb @@ -39,7 +45,6 @@ import ( "github.com/google/generative-ai-go/genai/internal" gld "github.com/google/generative-ai-go/genai/internal/generativelanguage/v1beta" // discovery client - "github.com/google/generative-ai-go/internal/support" "google.golang.org/api/iterator" "google.golang.org/api/option" ) @@ -190,9 +195,9 @@ func (m *GenerativeModel) generateContent(ctx context.Context, req *pb.GenerateC func (m *GenerativeModel) newGenerateContentRequest(contents ...*Content) *pb.GenerateContentRequest { return &pb.GenerateContentRequest{ Model: m.fullName, - Contents: support.TransformSlice(contents, (*Content).toProto), - SafetySettings: support.TransformSlice(m.SafetySettings, (*SafetySetting).toProto), - Tools: support.TransformSlice(m.Tools, (*Tool).toProto), + Contents: transformSlice(contents, (*Content).toProto), + SafetySettings: transformSlice(m.SafetySettings, (*SafetySetting).toProto), + Tools: transformSlice(m.Tools, (*Tool).toProto), ToolConfig: m.ToolConfig.toProto(), GenerationConfig: m.GenerationConfig.toProto(), SystemInstruction: m.SystemInstruction.toProto(), @@ -406,3 +411,16 @@ func mergeTexts(in []Part) []Part { } return out } + +// transformSlice applies f to each element of from and returns +// a new slice with the results. +func transformSlice[From, To any](from []From, f func(From) To) []To { + if from == nil { + return nil + } + to := make([]To, len(from)) + for i, e := range from { + to[i] = f(e) + } + return to +} diff --git a/genai/config.yaml b/genai/config.yaml index 34388fd..a29b88a 100644 --- a/genai/config.yaml +++ b/genai/config.yaml @@ -17,7 +17,6 @@ package: genai protoImportPath: cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb -supportImportPath: github.com/google/generative-ai-go/internal/support types: HarmCategory: diff --git a/genai/generativelanguagepb_veneer.gen.go b/genai/generativelanguagepb_veneer.gen.go index 7a94ceb..b29a0bd 100644 --- a/genai/generativelanguagepb_veneer.gen.go +++ b/genai/generativelanguagepb_veneer.gen.go @@ -21,9 +21,12 @@ import ( "time" pb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" - "github.com/google/generative-ai-go/internal/support" "github.com/googleapis/gax-go/v2/apierror" + spb "google.golang.org/genproto/googleapis/rpc/status" + gstatus "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/durationpb" + "google.golang.org/protobuf/types/known/structpb" + "google.golang.org/protobuf/types/known/timestamppb" ) // BatchEmbedContentsResponse is the response to a `BatchEmbedContentsRequest`. @@ -38,7 +41,7 @@ func (v *BatchEmbedContentsResponse) toProto() *pb.BatchEmbedContentsResponse { return nil } return &pb.BatchEmbedContentsResponse{ - Embeddings: support.TransformSlice(v.Embeddings, (*ContentEmbedding).toProto), + Embeddings: transformSlice(v.Embeddings, (*ContentEmbedding).toProto), } } @@ -47,7 +50,7 @@ func (BatchEmbedContentsResponse) fromProto(p *pb.BatchEmbedContentsResponse) *B return nil } return &BatchEmbedContentsResponse{ - Embeddings: support.TransformSlice(p.Embeddings, (ContentEmbedding{}).fromProto), + Embeddings: transformSlice(p.Embeddings, (ContentEmbedding{}).fromProto), } } @@ -143,10 +146,10 @@ func (v *Candidate) toProto() *pb.Candidate { return nil } return &pb.Candidate{ - Index: support.AddrOrNil(v.Index), + Index: pvAddrOrNil(v.Index), Content: v.Content.toProto(), FinishReason: pb.Candidate_FinishReason(v.FinishReason), - SafetyRatings: support.TransformSlice(v.SafetyRatings, (*SafetyRating).toProto), + SafetyRatings: transformSlice(v.SafetyRatings, (*SafetyRating).toProto), CitationMetadata: v.CitationMetadata.toProto(), TokenCount: v.TokenCount, } @@ -157,10 +160,10 @@ func (Candidate) fromProto(p *pb.Candidate) *Candidate { return nil } return &Candidate{ - Index: support.DerefOrZero(p.Index), + Index: pvDerefOrZero(p.Index), Content: (Content{}).fromProto(p.Content), FinishReason: FinishReason(p.FinishReason), - SafetyRatings: support.TransformSlice(p.SafetyRatings, (SafetyRating{}).fromProto), + SafetyRatings: transformSlice(p.SafetyRatings, (SafetyRating{}).fromProto), CitationMetadata: (CitationMetadata{}).fromProto(p.CitationMetadata), TokenCount: p.TokenCount, } @@ -177,7 +180,7 @@ func (v *CitationMetadata) toProto() *pb.CitationMetadata { return nil } return &pb.CitationMetadata{ - CitationSources: support.TransformSlice(v.CitationSources, (*CitationSource).toProto), + CitationSources: transformSlice(v.CitationSources, (*CitationSource).toProto), } } @@ -186,7 +189,7 @@ func (CitationMetadata) fromProto(p *pb.CitationMetadata) *CitationMetadata { return nil } return &CitationMetadata{ - CitationSources: support.TransformSlice(p.CitationSources, (CitationSource{}).fromProto), + CitationSources: transformSlice(p.CitationSources, (CitationSource{}).fromProto), } } @@ -216,7 +219,7 @@ func (v *CitationSource) toProto() *pb.CitationSource { StartIndex: v.StartIndex, EndIndex: v.EndIndex, Uri: v.URI, - License: support.AddrOrNil(v.License), + License: pvAddrOrNil(v.License), } } @@ -228,7 +231,7 @@ func (CitationSource) fromProto(p *pb.CitationSource) *CitationSource { StartIndex: p.StartIndex, EndIndex: p.EndIndex, URI: p.Uri, - License: support.DerefOrZero(p.License), + License: pvDerefOrZero(p.License), } } @@ -253,7 +256,7 @@ func (v *Content) toProto() *pb.Content { return nil } return &pb.Content{ - Parts: support.TransformSlice(v.Parts, partToProto), + Parts: transformSlice(v.Parts, partToProto), Role: v.Role, } } @@ -263,7 +266,7 @@ func (Content) fromProto(p *pb.Content) *Content { return nil } return &Content{ - Parts: support.TransformSlice(p.Parts, partFromProto), + Parts: transformSlice(p.Parts, partFromProto), Role: p.Role, } } @@ -388,13 +391,13 @@ func (v *File) toProto() *pb.File { DisplayName: v.DisplayName, MimeType: v.MIMEType, SizeBytes: v.SizeBytes, - CreateTime: support.TimeToProto(v.CreateTime), - UpdateTime: support.TimeToProto(v.UpdateTime), - ExpirationTime: support.TimeToProto(v.ExpirationTime), + CreateTime: pvTimeToProto(v.CreateTime), + UpdateTime: pvTimeToProto(v.UpdateTime), + ExpirationTime: pvTimeToProto(v.ExpirationTime), Sha256Hash: v.Sha256Hash, Uri: v.URI, State: pb.File_State(v.State), - Error: support.APIErrorToProto(v.Error), + Error: pvAPIErrorToProto(v.Error), } populateFileTo(p, v) return p @@ -409,13 +412,13 @@ func (File) fromProto(p *pb.File) *File { DisplayName: p.DisplayName, MIMEType: p.MimeType, SizeBytes: p.SizeBytes, - CreateTime: support.TimeFromProto(p.CreateTime), - UpdateTime: support.TimeFromProto(p.UpdateTime), - ExpirationTime: support.TimeFromProto(p.ExpirationTime), + CreateTime: pvTimeFromProto(p.CreateTime), + UpdateTime: pvTimeFromProto(p.UpdateTime), + ExpirationTime: pvTimeFromProto(p.ExpirationTime), Sha256Hash: p.Sha256Hash, URI: p.Uri, State: FileState(p.State), - Error: support.APIErrorFromProto(p.Error), + Error: pvAPIErrorFromProto(p.Error), } populateFileFrom(v, p) return v @@ -529,7 +532,7 @@ func (v *FunctionCall) toProto() *pb.FunctionCall { } return &pb.FunctionCall{ Name: v.Name, - Args: support.MapToStructPB(v.Args), + Args: pvMapToStructPB(v.Args), } } @@ -539,7 +542,7 @@ func (FunctionCall) fromProto(p *pb.FunctionCall) *FunctionCall { } return &FunctionCall{ Name: p.Name, - Args: support.MapFromStructPB(p.Args), + Args: pvMapFromStructPB(p.Args), } } @@ -672,7 +675,7 @@ func (v *FunctionResponse) toProto() *pb.FunctionResponse { } return &pb.FunctionResponse{ Name: v.Name, - Response: support.MapToStructPB(v.Response), + Response: pvMapToStructPB(v.Response), } } @@ -682,7 +685,7 @@ func (FunctionResponse) fromProto(p *pb.FunctionResponse) *FunctionResponse { } return &FunctionResponse{ Name: p.Name, - Response: support.MapFromStructPB(p.Response), + Response: pvMapFromStructPB(p.Response), } } @@ -710,7 +713,7 @@ func (v *GenerateContentResponse) toProto() *pb.GenerateContentResponse { return nil } return &pb.GenerateContentResponse{ - Candidates: support.TransformSlice(v.Candidates, (*Candidate).toProto), + Candidates: transformSlice(v.Candidates, (*Candidate).toProto), PromptFeedback: v.PromptFeedback.toProto(), UsageMetadata: v.UsageMetadata.toProto(), } @@ -721,7 +724,7 @@ func (GenerateContentResponse) fromProto(p *pb.GenerateContentResponse) *Generat return nil } return &GenerateContentResponse{ - Candidates: support.TransformSlice(p.Candidates, (Candidate{}).fromProto), + Candidates: transformSlice(p.Candidates, (Candidate{}).fromProto), PromptFeedback: (PromptFeedback{}).fromProto(p.PromptFeedback), UsageMetadata: (UsageMetadata{}).fromProto(p.UsageMetadata), } @@ -1018,9 +1021,9 @@ func (v *ModelInfo) toProto() *pb.Model { InputTokenLimit: v.InputTokenLimit, OutputTokenLimit: v.OutputTokenLimit, SupportedGenerationMethods: v.SupportedGenerationMethods, - Temperature: support.AddrOrNil(v.Temperature), - TopP: support.AddrOrNil(v.TopP), - TopK: support.AddrOrNil(v.TopK), + Temperature: pvAddrOrNil(v.Temperature), + TopP: pvAddrOrNil(v.TopP), + TopK: pvAddrOrNil(v.TopK), } } @@ -1037,9 +1040,9 @@ func (ModelInfo) fromProto(p *pb.Model) *ModelInfo { InputTokenLimit: p.InputTokenLimit, OutputTokenLimit: p.OutputTokenLimit, SupportedGenerationMethods: p.SupportedGenerationMethods, - Temperature: support.DerefOrZero(p.Temperature), - TopP: support.DerefOrZero(p.TopP), - TopK: support.DerefOrZero(p.TopK), + Temperature: pvDerefOrZero(p.Temperature), + TopP: pvDerefOrZero(p.TopP), + TopK: pvDerefOrZero(p.TopK), } } @@ -1060,7 +1063,7 @@ func (v *PromptFeedback) toProto() *pb.GenerateContentResponse_PromptFeedback { } return &pb.GenerateContentResponse_PromptFeedback{ BlockReason: pb.GenerateContentResponse_PromptFeedback_BlockReason(v.BlockReason), - SafetyRatings: support.TransformSlice(v.SafetyRatings, (*SafetyRating).toProto), + SafetyRatings: transformSlice(v.SafetyRatings, (*SafetyRating).toProto), } } @@ -1070,7 +1073,7 @@ func (PromptFeedback) fromProto(p *pb.GenerateContentResponse_PromptFeedback) *P } return &PromptFeedback{ BlockReason: BlockReason(p.BlockReason), - SafetyRatings: support.TransformSlice(p.SafetyRatings, (SafetyRating{}).fromProto), + SafetyRatings: transformSlice(p.SafetyRatings, (SafetyRating{}).fromProto), } } @@ -1184,7 +1187,7 @@ func (v *Schema) toProto() *pb.Schema { Nullable: v.Nullable, Enum: v.Enum, Items: v.Items.toProto(), - Properties: support.TransformMapValues(v.Properties, (*Schema).toProto), + Properties: pvTransformMapValues(v.Properties, (*Schema).toProto), Required: v.Required, } } @@ -1200,7 +1203,7 @@ func (Schema) fromProto(p *pb.Schema) *Schema { Nullable: p.Nullable, Enum: p.Enum, Items: (Schema{}).fromProto(p.Items), - Properties: support.TransformMapValues(p.Properties, (Schema{}).fromProto), + Properties: pvTransformMapValues(p.Properties, (Schema{}).fromProto), Required: p.Required, } } @@ -1265,7 +1268,7 @@ func (v *Tool) toProto() *pb.Tool { return nil } return &pb.Tool{ - FunctionDeclarations: support.TransformSlice(v.FunctionDeclarations, (*FunctionDeclaration).toProto), + FunctionDeclarations: transformSlice(v.FunctionDeclarations, (*FunctionDeclaration).toProto), } } @@ -1274,7 +1277,7 @@ func (Tool) fromProto(p *pb.Tool) *Tool { return nil } return &Tool{ - FunctionDeclarations: support.TransformSlice(p.FunctionDeclarations, (FunctionDeclaration{}).fromProto), + FunctionDeclarations: transformSlice(p.FunctionDeclarations, (FunctionDeclaration{}).fromProto), } } @@ -1393,6 +1396,100 @@ func (VideoMetadata) fromProto(p *pb.VideoMetadata) *VideoMetadata { return nil } return &VideoMetadata{ - Duration: support.DurationFromProto(p.VideoDuration), + Duration: pvDurationFromProto(p.VideoDuration), } } + +func pvTransformSlice[From, To any](from []From, f func(From) To) []To { + if from == nil { + return nil + } + to := make([]To, len(from)) + for i, e := range from { + to[i] = f(e) + } + return to +} + +func pvTransformMapValues[K comparable, VFrom, VTo any](from map[K]VFrom, f func(VFrom) VTo) map[K]VTo { + if from == nil { + return nil + } + to := map[K]VTo{} + for k, v := range from { + to[k] = f(v) + } + return to +} + +func pvAddrOrNil[T comparable](x T) *T { + var z T + if x == z { + return nil + } + return &x +} + +func pvDerefOrZero[T any](x *T) T { + if x == nil { + var z T + return z + } + return *x +} + +func pvMapToStructPB(m map[string]any) *structpb.Struct { + if m == nil { + return nil + } + s, err := structpb.NewStruct(m) + if err != nil { + panic(fmt.Errorf("support.MapToProto: %w", err)) + } + return s +} + +func pvMapFromStructPB(p *structpb.Struct) map[string]any { + if p == nil { + return nil + } + return p.AsMap() +} + +func pvTimeToProto(t time.Time) *timestamppb.Timestamp { + if t.IsZero() { + return nil + } + return timestamppb.New(t) +} + +func pvTimeFromProto(ts *timestamppb.Timestamp) time.Time { + if ts == nil { + return time.Time{} + } + return ts.AsTime() +} + +func pvAPIErrorToProto(ae *apierror.APIError) *spb.Status { + if ae == nil { + return nil + } + return ae.GRPCStatus().Proto() +} + +func pvAPIErrorFromProto(s *spb.Status) *apierror.APIError { + err := gstatus.ErrorProto(s) + aerr, ok := apierror.ParseError(err, true) + if !ok { + // Should be impossible. + return nil + } + return aerr +} + +func pvDurationFromProto(d *durationpb.Duration) time.Duration { + if d == nil { + return 0 + } + return d.AsDuration() +} diff --git a/genai/internal/generativelanguage/v1beta/generativelanguage-api.json b/genai/internal/generativelanguage/v1beta/generativelanguage-api.json index ffb645d..ebc4cfd 100644 --- a/genai/internal/generativelanguage/v1beta/generativelanguage-api.json +++ b/genai/internal/generativelanguage/v1beta/generativelanguage-api.json @@ -1,1877 +1,1571 @@ { - "id": "generativelanguage:v1beta", - "rootUrl": "https://generativelanguage.googleapis.com/", - "ownerName": "Google", + "kind": "discovery#restDescription", + "mtlsRootUrl": "https://generativelanguage.mtls.googleapis.com/", + "version": "v1beta", + "batchPath": "batch", "schemas": { - "Chunk": { + "ChunkData": { + "type": "object", + "description": "Extracted data that represents the `Chunk` content.", + "id": "ChunkData", "properties": { - "state": { - "description": "Output only. Current state of the `Chunk`.", - "enum": [ - "STATE_UNSPECIFIED", - "STATE_PENDING_PROCESSING", - "STATE_ACTIVE", - "STATE_FAILED" - ], - "type": "string", - "enumDescriptions": [ - "The default value. This value is used if the state is omitted.", - "`Chunk` is being processed (embedding and vector storage).", - "`Chunk` is processed and available for querying.", - "`Chunk` failed processing." - ], - "readOnly": true - }, - "name": { - "type": "string", - "description": "Immutable. Identifier. The `Chunk` resource name. The ID (name excluding the \"corpora/*/documents/*/chunks/\" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a random 12-character unique ID will be generated. Example: `corpora/{corpus_id}/documents/{document_id}/chunks/123a456b789c`" - }, - "createTime": { - "description": "Output only. The Timestamp of when the `Chunk` was created.", - "readOnly": true, + "stringValue": { "type": "string", - "format": "google-datetime" - }, - "data": { - "$ref": "ChunkData", - "description": "Required. The content for the `Chunk`, such as the text string. The maximum number of tokens per chunk is 2043." - }, - "customMetadata": { - "description": "Optional. User provided custom metadata stored as key-value pairs. The maximum number of `CustomMetadata` per chunk is 20.", + "description": "The `Chunk` content as a string. The maximum number of tokens per chunk is 2043." + } + } + }, + "BatchUpdateChunksResponse": { + "description": "Response from `BatchUpdateChunks` containing a list of updated `Chunk`s.", + "properties": { + "chunks": { + "description": "`Chunk`s updated.", "type": "array", "items": { - "$ref": "CustomMetadata" + "$ref": "Chunk" } - }, - "updateTime": { - "format": "google-datetime", - "type": "string", - "description": "Output only. The Timestamp of when the `Chunk` was last updated.", - "readOnly": true } }, "type": "object", - "id": "Chunk", - "description": "A `Chunk` is a subpart of a `Document` that is treated as an independent unit for the purposes of vector representation and storage. A `Corpus` can have a maximum of 1 million `Chunk`s." + "id": "BatchUpdateChunksResponse" }, - "TunedModel": { + "RelevantChunk": { + "description": "The information for a chunk relevant to a query.", "properties": { - "updateTime": { - "description": "Output only. The timestamp when this model was updated.", - "readOnly": true, - "type": "string", - "format": "google-datetime" + "chunk": { + "$ref": "Chunk", + "description": "`Chunk` associated with the query." }, - "topP": { + "chunkRelevanceScore": { "type": "number", - "description": "Optional. For Nucleus sampling. Nucleus sampling considers the smallest set of tokens whose probability sum is at least `top_p`. This value specifies default to be the one used by the base model while creating the model.", - "format": "float" - }, - "displayName": { - "description": "Optional. The name to display for this model in user interfaces. The display name must be up to 40 characters including spaces.", - "type": "string" - }, - "state": { - "enumDescriptions": [ - "The default value. This value is unused.", - "The model is being created.", - "The model is ready to be used.", - "The model failed to be created." - ], + "format": "float", + "description": "`Chunk` relevance to the query." + } + }, + "type": "object", + "id": "RelevantChunk" + }, + "Permission": { + "properties": { + "granteeType": { "enum": [ - "STATE_UNSPECIFIED", - "CREATING", - "ACTIVE", - "FAILED" + "GRANTEE_TYPE_UNSPECIFIED", + "USER", + "GROUP", + "EVERYONE" ], - "readOnly": true, + "description": "Optional. Immutable. The type of the grantee.", "type": "string", - "description": "Output only. The state of the tuned model." - }, - "name": { - "readOnly": true, - "description": "Output only. The tuned model name. A unique name will be generated on create. Example: `tunedModels/az2mb0bpw6i` If display_name is set on create, the id portion of the name will be set by concatenating the words of the display_name with hyphens and adding a random portion for uniqueness. Example: display_name = \"Sentence Translator\" name = \"tunedModels/sentence-translator-u3b7m\"", - "type": "string" - }, - "tunedModelSource": { - "description": "Optional. TunedModel to use as the starting point for training the new model.", - "$ref": "TunedModelSource" - }, - "temperature": { - "type": "number", - "description": "Optional. Controls the randomness of the output. Values can range over `[0.0,1.0]`, inclusive. A value closer to `1.0` will produce responses that are more varied, while a value closer to `0.0` will typically result in less surprising responses from the model. This value specifies default to be the one used by the base model while creating the model.", - "format": "float" - }, - "topK": { - "format": "int32", - "description": "Optional. For Top-k sampling. Top-k sampling considers the set of `top_k` most probable tokens. This value specifies default to be used by the backend while making the call to the model. This value specifies default to be the one used by the base model while creating the model.", - "type": "integer" + "enumDescriptions": [ + "The default value. This value is unused.", + "Represents a user. When set, you must provide email_address for the user.", + "Represents a group. When set, you must provide email_address for the group.", + "Represents access to everyone. No extra information is required." + ] }, - "description": { + "emailAddress": { "type": "string", - "description": "Optional. A short description of this model." + "description": "Optional. Immutable. The email address of the user of group which this permission refers. Field is not set when permission's grantee type is EVERYONE." }, - "createTime": { + "name": { "type": "string", - "format": "google-datetime", "readOnly": true, - "description": "Output only. The timestamp when this model was created." + "description": "Output only. Identifier. The permission name. A unique name will be generated on create. Examples: tunedModels/{tuned_model}/permissions/{permission} corpora/{corpus}/permissions/{permission} Output only." }, - "baseModel": { - "type": "string", - "description": "Immutable. The name of the `Model` to tune. Example: `models/text-bison-001`" - }, - "tuningTask": { - "$ref": "TuningTask", - "description": "Required. The tuning task that creates the tuned model." + "role": { + "enum": [ + "ROLE_UNSPECIFIED", + "OWNER", + "WRITER", + "READER" + ], + "description": "Required. The role granted by this permission.", + "enumDescriptions": [ + "The default value. This value is unused.", + "Owner can use, update, share and delete the resource.", + "Writer can use, update and share the resource.", + "Reader can use the resource." + ], + "type": "string" } }, - "id": "TunedModel", + "description": "Permission resource grants user, group or the rest of the world access to the PaLM API resource (e.g. a tuned model, corpus). A role is a collection of permitted operations that allows users to perform specific actions on PaLM API resources. To make them available to users, groups, or service accounts, you assign roles. When you assign a role, you grant permissions that the role contains. There are three concentric roles. Each role is a superset of the previous role's permitted operations: - reader can use the resource (e.g. tuned model, corpus) for inference - writer has reader's permissions and additionally can edit and share - owner has writer's permissions and additionally can delete", "type": "object", - "description": "A fine-tuned model created using ModelService.CreateTunedModel." + "id": "Permission" }, - "CountMessageTokensResponse": { - "description": "A response from `CountMessageTokens`. It returns the model's `token_count` for the `prompt`.", + "TunedModelSource": { + "id": "TunedModelSource", "properties": { - "tokenCount": { - "description": "The number of tokens that the `model` tokenizes the `prompt` into. Always non-negative.", - "format": "int32", - "type": "integer" + "baseModel": { + "readOnly": true, + "description": "Output only. The name of the base `Model` this `TunedModel` was tuned from. Example: `models/text-bison-001`", + "type": "string" + }, + "tunedModel": { + "description": "Immutable. The name of the `TunedModel` to use as the starting point for training the new model. Example: `tunedModels/my-tuned-model`", + "type": "string" } }, "type": "object", - "id": "CountMessageTokensResponse" + "description": "Tuned model as a source for training a new model." }, - "GenerateMessageRequest": { - "description": "Request to generate a message response from the model.", + "BatchEmbedTextResponse": { "properties": { - "temperature": { - "description": "Optional. Controls the randomness of the output. Values can range over `[0.0,1.0]`, inclusive. A value closer to `1.0` will produce responses that are more varied, while a value closer to `0.0` will typically result in less surprising responses from the model.", - "type": "number", - "format": "float" - }, - "prompt": { - "description": "Required. The structured textual input given to the model as a prompt. Given a prompt, the model will return what it predicts is the next message in the discussion.", - "$ref": "MessagePrompt" - }, - "topP": { - "format": "float", - "description": "Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Nucleus sampling considers the smallest set of tokens whose probability sum is at least `top_p`.", - "type": "number" - }, - "topK": { - "description": "Optional. The maximum number of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Top-k sampling considers the set of `top_k` most probable tokens.", - "format": "int32", - "type": "integer" - }, - "candidateCount": { - "format": "int32", - "description": "Optional. The number of generated response messages to return. This value must be between `[1, 8]`, inclusive. If unset, this will default to `1`.", - "type": "integer" + "embeddings": { + "readOnly": true, + "type": "array", + "items": { + "$ref": "Embedding" + }, + "description": "Output only. The embeddings generated from the input text." } }, - "id": "GenerateMessageRequest", - "type": "object" + "type": "object", + "description": "The response to a EmbedTextRequest.", + "id": "BatchEmbedTextResponse" }, - "CountTextTokensRequest": { + "FileData": { + "type": "object", "properties": { - "prompt": { - "description": "Required. The free-form input text given to the model as a prompt.", - "$ref": "TextPrompt" + "fileUri": { + "type": "string", + "description": "Required. URI." + }, + "mimeType": { + "type": "string", + "description": "Optional. The IANA standard MIME type of the source data." } }, - "type": "object", - "id": "CountTextTokensRequest", - "description": "Counts the number of tokens in the `prompt` sent to a model. Models may tokenize text differently, so each model may return a different `token_count`." + "description": "URI based data.", + "id": "FileData" }, - "ListFilesResponse": { - "type": "object", - "id": "ListFilesResponse", - "description": "Response for `ListFiles`.", + "QueryDocumentRequest": { + "id": "QueryDocumentRequest", "properties": { - "nextPageToken": { - "description": "A token that can be sent as a `page_token` into a subsequent `ListFiles` call.", + "query": { + "description": "Required. Query string to perform semantic search.", "type": "string" }, - "files": { + "metadataFilters": { "items": { - "$ref": "File" + "$ref": "MetadataFilter" }, - "description": "The list of `File`s.", + "description": "Optional. Filter for `Chunk` metadata. Each `MetadataFilter` object should correspond to a unique key. Multiple `MetadataFilter` objects are joined by logical \"AND\"s. Note: `Document`-level filtering is not supported for this request because a `Document` name is already specified. Example query: (year \u003e= 2020 OR year \u003c 2010) AND (genre = drama OR genre = action) `MetadataFilter` object list: metadata_filters = [ {key = \"chunk.custom_metadata.year\" conditions = [{int_value = 2020, operation = GREATER_EQUAL}, {int_value = 2010, operation = LESS}}, {key = \"chunk.custom_metadata.genre\" conditions = [{string_value = \"drama\", operation = EQUAL}, {string_value = \"action\", operation = EQUAL}}] Example query for a numeric range of values: (year \u003e 2015 AND year \u003c= 2020) `MetadataFilter` object list: metadata_filters = [ {key = \"chunk.custom_metadata.year\" conditions = [{int_value = 2015, operation = GREATER}]}, {key = \"chunk.custom_metadata.year\" conditions = [{int_value = 2020, operation = LESS_EQUAL}]}] Note: \"AND\"s for the same key are only supported for numeric values. String values only support \"OR\"s for the same key.", "type": "array" + }, + "resultsCount": { + "type": "integer", + "description": "Optional. The maximum number of `Chunk`s to return. The service may return fewer `Chunk`s. If unspecified, at most 10 `Chunk`s will be returned. The maximum specified result count is 100.", + "format": "int32" } - } + }, + "description": "Request for querying a `Document`.", + "type": "object" }, - "Dataset": { + "BatchEmbedContentsResponse": { "type": "object", - "id": "Dataset", - "description": "Dataset for training or validation.", + "id": "BatchEmbedContentsResponse", + "description": "The response to a `BatchEmbedContentsRequest`.", "properties": { - "examples": { - "$ref": "TuningExamples", - "description": "Optional. Inline examples." + "embeddings": { + "type": "array", + "items": { + "$ref": "ContentEmbedding" + }, + "description": "Output only. The embeddings for each request, in the same order as provided in the batch request.", + "readOnly": true } } }, - "Part": { - "type": "object", - "id": "Part", + "TextPrompt": { + "id": "TextPrompt", + "description": "Text given to the model as a prompt. The Model will use this TextPrompt to Generate a text completion.", "properties": { - "inlineData": { - "$ref": "Blob", - "description": "Inline media bytes." - }, - "fileData": { - "description": "URI based data.", - "$ref": "FileData" - }, - "functionResponse": { - "description": "The result output of a `FunctionCall` that contains a string representing the `FunctionDeclaration.name` and a structured JSON object containing any output from the function is used as context to the model.", - "$ref": "FunctionResponse" - }, - "functionCall": { - "$ref": "FunctionCall", - "description": "A predicted `FunctionCall` returned from the model that contains a string representing the `FunctionDeclaration.name` with the arguments and their values." - }, "text": { - "description": "Inline text.", + "description": "Required. The prompt text.", "type": "string" } }, - "description": "A datatype containing media that is part of a multi-part `Content` message. A `Part` consists of data which has an associated datatype. A `Part` can only contain one of the accepted types in `Part.data`. A `Part` must have a fixed IANA MIME type identifying the type and subtype of the media if the `inline_data` field is filled with raw bytes." + "type": "object" }, - "Permission": { - "description": "Permission resource grants user, group or the rest of the world access to the PaLM API resource (e.g. a tuned model, corpus). A role is a collection of permitted operations that allows users to perform specific actions on PaLM API resources. To make them available to users, groups, or service accounts, you assign roles. When you assign a role, you grant permissions that the role contains. There are three concentric roles. Each role is a superset of the previous role's permitted operations: - reader can use the resource (e.g. tuned model, corpus) for inference - writer has reader's permissions and additionally can edit and share - owner has writer's permissions and additionally can delete", - "id": "Permission", + "SafetySetting": { + "type": "object", + "id": "SafetySetting", "properties": { - "role": { + "threshold": { + "type": "string", + "description": "Required. Controls the probability threshold at which harm is blocked.", "enum": [ - "ROLE_UNSPECIFIED", - "OWNER", - "WRITER", - "READER" + "HARM_BLOCK_THRESHOLD_UNSPECIFIED", + "BLOCK_LOW_AND_ABOVE", + "BLOCK_MEDIUM_AND_ABOVE", + "BLOCK_ONLY_HIGH", + "BLOCK_NONE" ], - "description": "Required. The role granted by this permission.", - "type": "string", "enumDescriptions": [ - "The default value. This value is unused.", - "Owner can use, update, share and delete the resource.", - "Writer can use, update and share the resource.", - "Reader can use the resource." + "Threshold is unspecified.", + "Content with NEGLIGIBLE will be allowed.", + "Content with NEGLIGIBLE and LOW will be allowed.", + "Content with NEGLIGIBLE, LOW, and MEDIUM will be allowed.", + "All content will be allowed." ] }, - "name": { - "readOnly": true, - "description": "Output only. Identifier. The permission name. A unique name will be generated on create. Examples: tunedModels/{tuned_model}/permissions/{permission} corpora/{corpus}/permissions/{permission} Output only.", - "type": "string" - }, - "granteeType": { + "category": { + "enum": [ + "HARM_CATEGORY_UNSPECIFIED", + "HARM_CATEGORY_DEROGATORY", + "HARM_CATEGORY_TOXICITY", + "HARM_CATEGORY_VIOLENCE", + "HARM_CATEGORY_SEXUAL", + "HARM_CATEGORY_MEDICAL", + "HARM_CATEGORY_DANGEROUS", + "HARM_CATEGORY_HARASSMENT", + "HARM_CATEGORY_HATE_SPEECH", + "HARM_CATEGORY_SEXUALLY_EXPLICIT", + "HARM_CATEGORY_DANGEROUS_CONTENT" + ], + "description": "Required. The category for this setting.", "type": "string", "enumDescriptions": [ - "The default value. This value is unused.", - "Represents a user. When set, you must provide email_address for the user.", - "Represents a group. When set, you must provide email_address for the group.", - "Represents access to everyone. No extra information is required." - ], - "description": "Optional. Immutable. The type of the grantee.", - "enum": [ - "GRANTEE_TYPE_UNSPECIFIED", - "USER", - "GROUP", - "EVERYONE" + "Category is unspecified.", + "Negative or harmful comments targeting identity and/or protected attribute.", + "Content that is rude, disrespectful, or profane.", + "Describes scenarios depicting violence against an individual or group, or general descriptions of gore.", + "Contains references to sexual acts or other lewd content.", + "Promotes unchecked medical advice.", + "Dangerous content that promotes, facilitates, or encourages harmful acts.", + "Harasment content.", + "Hate speech and content.", + "Sexually explicit content.", + "Dangerous content." ] - }, - "emailAddress": { - "type": "string", - "description": "Optional. Immutable. The email address of the user of group which this permission refers. Field is not set when permission's grantee type is EVERYONE." } }, - "type": "object" + "description": "Safety setting, affecting the safety-blocking behavior. Passing a safety setting for a category changes the allowed probability that content is blocked." }, - "UsageMetadata": { + "TuningSnapshot": { "properties": { - "totalTokenCount": { - "description": "Total token count for the generation request (prompt + candidates).", - "format": "int32", - "type": "integer" + "computeTime": { + "type": "string", + "readOnly": true, + "description": "Output only. The timestamp when this metric was computed.", + "format": "google-datetime" }, - "promptTokenCount": { + "epoch": { "format": "int32", "type": "integer", - "description": "Number of tokens in the prompt." + "readOnly": true, + "description": "Output only. The epoch this step was part of." }, - "candidatesTokenCount": { + "step": { "format": "int32", - "description": "Total number of tokens across the generated candidates.", - "type": "integer" + "description": "Output only. The tuning step.", + "type": "integer", + "readOnly": true + }, + "meanLoss": { + "readOnly": true, + "type": "number", + "description": "Output only. The mean loss of the training examples for this step.", + "format": "float" } }, - "type": "object", - "description": "Metadata on the generation request's token usage.", - "id": "UsageMetadata" + "id": "TuningSnapshot", + "description": "Record for a single tuning step.", + "type": "object" }, - "Operation": { - "id": "Operation", + "BatchUpdateChunksRequest": { "properties": { - "name": { - "type": "string", - "description": "The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`." - }, - "error": { - "$ref": "Status", - "description": "The error result of the operation in case of failure or cancellation." - }, - "response": { - "description": "The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.", - "additionalProperties": { - "description": "Properties of the object. Contains field @type with type URL.", - "type": "any" + "requests": { + "items": { + "$ref": "UpdateChunkRequest" }, - "type": "object" - }, - "done": { - "description": "If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.", - "type": "boolean" - }, - "metadata": { - "description": "Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.", - "type": "object", - "additionalProperties": { - "description": "Properties of the object. Contains field @type with type URL.", - "type": "any" - } + "type": "array", + "description": "Required. The request messages specifying the `Chunk`s to update. A maximum of 100 `Chunk`s can be updated in a batch." } }, - "description": "This resource represents a long-running operation that is the result of a network API call.", + "id": "BatchUpdateChunksRequest", + "description": "Request to batch update `Chunk`s.", "type": "object" }, - "EmbedTextResponse": { + "ListModelsResponse": { "properties": { - "embedding": { - "description": "Output only. The embedding generated from the input text.", - "$ref": "Embedding", - "readOnly": true + "nextPageToken": { + "type": "string", + "description": "A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages." + }, + "models": { + "type": "array", + "items": { + "$ref": "Model" + }, + "description": "The returned Models." } }, - "id": "EmbedTextResponse", + "id": "ListModelsResponse", "type": "object", - "description": "The response to a EmbedTextRequest." + "description": "Response from `ListModel` containing a paginated list of Models." }, - "SafetyFeedback": { - "id": "SafetyFeedback", - "type": "object", - "description": "Safety feedback for an entire request. This field is populated if content in the input and/or response is blocked due to safety settings. SafetyFeedback may not exist for every HarmCategory. Each SafetyFeedback will return the safety settings used by the request as well as the lowest HarmProbability that should be allowed in order to return a result.", + "ListCorporaResponse": { "properties": { - "rating": { - "$ref": "SafetyRating", - "description": "Safety rating evaluated from content." + "nextPageToken": { + "type": "string", + "description": "A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages." }, - "setting": { - "description": "Safety settings applied to the request.", - "$ref": "SafetySetting" + "corpora": { + "items": { + "$ref": "Corpus" + }, + "description": "The returned corpora.", + "type": "array" } - } + }, + "description": "Response from `ListCorpora` containing a paginated list of `Corpora`. The results are sorted by ascending `corpus.create_time`.", + "id": "ListCorporaResponse", + "type": "object" }, - "GenerateTextResponse": { - "id": "GenerateTextResponse", - "type": "object", + "MessagePrompt": { + "description": "All of the structured input text passed to the model as a prompt. A `MessagePrompt` contains a structured set of fields that provide context for the conversation, examples of user input/model output message pairs that prime the model to respond in different ways, and the conversation history or list of messages representing the alternating turns of the conversation between the user and the model.", + "id": "MessagePrompt", "properties": { - "safetyFeedback": { + "context": { + "type": "string", + "description": "Optional. Text that should be provided to the model first to ground the response. If not empty, this `context` will be given to the model first before the `examples` and `messages`. When using a `context` be sure to provide it with every request to maintain continuity. This field can be a description of your prompt to the model to help provide context and guide the responses. Examples: \"Translate the phrase from English to French.\" or \"Given a statement, classify the sentiment as happy, sad or neutral.\" Anything included in this field will take precedence over message history if the total input size exceeds the model's `input_token_limit` and the input request is truncated." + }, + "messages": { + "description": "Required. A snapshot of the recent conversation history sorted chronologically. Turns alternate between two authors. If the total input size exceeds the model's `input_token_limit` the input will be truncated: The oldest items will be dropped from `messages`.", "type": "array", - "description": "Returns any safety feedback related to content filtering.", "items": { - "$ref": "SafetyFeedback" + "$ref": "Message" } }, - "candidates": { + "examples": { + "description": "Optional. Examples of what the model should generate. This includes both user input and the response that the model should emulate. These `examples` are treated identically to conversation messages except that they take precedence over the history in `messages`: If the total input size exceeds the model's `input_token_limit` the input will be truncated. Items will be dropped from `messages` before `examples`.", "type": "array", "items": { - "$ref": "TextCompletion" + "$ref": "Example" + } + } + }, + "type": "object" + }, + "GenerateContentResponse": { + "properties": { + "usageMetadata": { + "$ref": "UsageMetadata", + "description": "Output only. Metadata on the generation requests' token usage.", + "readOnly": true + }, + "candidates": { + "items": { + "$ref": "Candidate" }, - "description": "Candidate responses from the model." + "description": "Candidate responses from the model.", + "type": "array" }, - "filters": { + "promptFeedback": { + "$ref": "PromptFeedback", + "description": "Returns the prompt's feedback related to the content filters." + } + }, + "type": "object", + "description": "Response from the model supporting multiple candidates. Note on safety ratings and content filtering. They are reported for both prompt in `GenerateContentResponse.prompt_feedback` and for each candidate in `finish_reason` and in `safety_ratings`. The API contract is that: - either all requested candidates are returned or no candidates at all - no candidates are returned only if there was something wrong with the prompt (see `prompt_feedback`) - feedback on each candidate is reported on `finish_reason` and `safety_ratings`.", + "id": "GenerateContentResponse" + }, + "TuningExamples": { + "description": "A set of tuning examples. Can be training or validation data.", + "type": "object", + "properties": { + "examples": { "type": "array", - "description": "A set of content filtering metadata for the prompt and response text. This indicates which `SafetyCategory`(s) blocked a candidate from this response, the lowest `HarmProbability` that triggered a block, and the HarmThreshold setting for that category. This indicates the smallest change to the `SafetySettings` that would be necessary to unblock at least 1 response. The blocking is configured by the `SafetySettings` in the request (or the default `SafetySettings` of the API).", + "description": "Required. The examples. Example input can be for text or discuss, but all examples in a set must be of the same type.", "items": { - "$ref": "ContentFilter" + "$ref": "TuningExample" } } }, - "description": "The response from the model, including candidate completions." + "id": "TuningExamples" }, - "File": { - "description": "A file uploaded to the API.", + "CreateFileResponse": { "type": "object", - "id": "File", + "id": "CreateFileResponse", "properties": { - "expirationTime": { - "readOnly": true, - "type": "string", - "format": "google-datetime", - "description": "Output only. The timestamp of when the `File` will be deleted. Only set if the `File` is scheduled to expire." - }, - "sizeBytes": { - "readOnly": true, - "format": "int64", - "type": "string", - "description": "Output only. Size of the file in bytes." - }, - "createTime": { - "description": "Output only. The timestamp of when the `File` was created.", - "readOnly": true, - "type": "string", - "format": "google-datetime" - }, - "uri": { - "type": "string", - "description": "Output only. The uri of the `File`.", - "readOnly": true - }, - "displayName": { - "type": "string", - "description": "Optional. The human-readable display name for the `File`. The display name must be no more than 512 characters in length, including spaces. Example: \"Welcome Image\"" - }, - "mimeType": { - "readOnly": true, - "type": "string", - "description": "Output only. MIME type of the file." - }, - "videoMetadata": { - "readOnly": true, - "description": "Output only. Metadata for a video.", - "$ref": "VideoMetadata" - }, - "error": { - "$ref": "Status", - "description": "Output only. Error status if File processing failed.", - "readOnly": true - }, - "state": { - "type": "string", - "description": "Output only. Processing state of the File.", - "enum": [ - "STATE_UNSPECIFIED", - "PROCESSING", - "ACTIVE", - "FAILED" - ], - "readOnly": true, - "enumDescriptions": [ - "The default value. This value is used if the state is omitted.", - "File is being processed and cannot be used for inference yet.", - "File is processed and available for inference.", - "File failed processing." - ] - }, - "name": { - "description": "Immutable. Identifier. The `File` resource name. The ID (name excluding the \"files/\" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be generated. Example: `files/123-456`", - "type": "string" - }, - "sha256Hash": { - "type": "string", - "format": "byte", - "readOnly": true, - "description": "Output only. SHA-256 hash of the uploaded bytes." - }, - "updateTime": { - "format": "google-datetime", - "readOnly": true, - "description": "Output only. The timestamp of when the `File` was last updated.", - "type": "string" - } - } - }, - "ChunkData": { - "id": "ChunkData", - "properties": { - "stringValue": { - "type": "string", - "description": "The `Chunk` content as a string. The maximum number of tokens per chunk is 2043." + "file": { + "$ref": "File", + "description": "Metadata for the created file." } }, - "type": "object", - "description": "Extracted data that represents the `Chunk` content." + "description": "Response for `CreateFile`." }, - "TuningExamples": { - "id": "TuningExamples", + "QueryDocumentResponse": { "properties": { - "examples": { + "relevantChunks": { + "description": "The returned relevant chunks.", "type": "array", - "description": "Required. The examples. Example input can be for text or discuss, but all examples in a set must be of the same type.", "items": { - "$ref": "TuningExample" + "$ref": "RelevantChunk" } } }, - "description": "A set of tuning examples. Can be training or validation data.", - "type": "object" - }, - "AttributionSourceId": { - "description": "Identifier for the source contributing to this attribution.", - "properties": { - "groundingPassage": { - "description": "Identifier for an inline passage.", - "$ref": "GroundingPassageId" - }, - "semanticRetrieverChunk": { - "$ref": "SemanticRetrieverChunk", - "description": "Identifier for a `Chunk` fetched via Semantic Retriever." - } - }, "type": "object", - "id": "AttributionSourceId" + "id": "QueryDocumentResponse", + "description": "Response from `QueryDocument` containing a list of relevant chunks." }, - "ListPermissionsResponse": { + "CachedContent": { "type": "object", "properties": { - "permissions": { + "ttl": { + "format": "google-duration", + "type": "string", + "description": "Input only. New TTL for this resource, input only." + }, + "createTime": { + "readOnly": true, + "format": "google-datetime", + "description": "Output only. Creation time of the cache entry.", + "type": "string" + }, + "model": { + "type": "string", + "description": "Required. Immutable. The name of the `Model` to use for cached content Format: `models/{model}`" + }, + "contents": { + "type": "array", "items": { - "$ref": "Permission" + "$ref": "Content" }, - "type": "array", - "description": "Returned permissions." + "description": "Optional. Input only. Immutable. The content to cache." }, - "nextPageToken": { - "description": "A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages.", - "type": "string" - } - }, - "id": "ListPermissionsResponse", - "description": "Response from `ListPermissions` containing a paginated list of permissions." - }, - "CreateChunkRequest": { - "description": "Request to create a `Chunk`.", - "id": "CreateChunkRequest", - "type": "object", - "properties": { - "parent": { - "description": "Required. The name of the `Document` where this `Chunk` will be created. Example: `corpora/my-corpus-123/documents/the-doc-abc`", + "displayName": { + "description": "Optional. Immutable. The user-generated meaningful display name of the cached content. Maximum 128 Unicode characters.", "type": "string" }, - "chunk": { - "$ref": "Chunk", - "description": "Required. The `Chunk` to create." - } - } - }, - "TuningTask": { - "id": "TuningTask", - "description": "Tuning tasks that create tuned models.", - "type": "object", - "properties": { - "hyperparameters": { - "description": "Immutable. Hyperparameters controlling the tuning process. If not provided, default values will be used.", - "$ref": "Hyperparameters" + "toolConfig": { + "$ref": "ToolConfig", + "description": "Optional. Input only. Immutable. Tool config. This config is shared for all tools." }, - "completeTime": { - "readOnly": true, + "expireTime": { "format": "google-datetime", - "description": "Output only. The timestamp when tuning this model completed.", + "description": "Timestamp in UTC of when this resource is considered expired. This is *always* provided on output, regardless of what was sent on input.", "type": "string" }, - "startTime": { - "description": "Output only. The timestamp when tuning this model started.", - "readOnly": true, + "updateTime": { + "description": "Output only. When the cache entry was last updated in UTC time.", + "type": "string", "format": "google-datetime", + "readOnly": true + }, + "name": { + "description": "Optional. Identifier. The resource name referring to the cached content. Format: `cachedContents/{id}`", "type": "string" }, - "snapshots": { - "items": { - "$ref": "TuningSnapshot" - }, - "description": "Output only. Metrics collected during tuning.", - "type": "array", - "readOnly": true + "systemInstruction": { + "$ref": "Content", + "description": "Optional. Input only. Immutable. Developer set system instruction. Currently text only." }, - "trainingData": { - "description": "Required. Input only. Immutable. The model training data.", - "$ref": "Dataset" - } - } - }, - "BatchEmbedContentsRequest": { - "description": "Batch request to get embeddings from the model for a list of prompts.", - "type": "object", - "id": "BatchEmbedContentsRequest", - "properties": { - "requests": { + "tools": { "type": "array", + "description": "Optional. Input only. Immutable. A list of `Tools` the model may use to generate the next response", "items": { - "$ref": "EmbedContentRequest" - }, - "description": "Required. Embed requests for the batch. The model in each of these requests must match the model specified `BatchEmbedContentsRequest.model`." - } - } - }, - "ContentEmbedding": { - "description": "A list of floats representing an embedding.", - "properties": { - "values": { - "items": { - "type": "number", - "format": "float" - }, - "type": "array", - "description": "The embedding values." + "$ref": "Tool" + } + }, + "usageMetadata": { + "description": "Output only. Metadata on the usage of the cached content.", + "readOnly": true, + "$ref": "CachedContentUsageMetadata" } }, - "type": "object", - "id": "ContentEmbedding" + "description": "Content that has been preprocessed and can be used in subsequent request to GenerativeService. Cached content can be only used with model it was created for.", + "id": "CachedContent" }, "PromptFeedback": { "properties": { "safetyRatings": { - "description": "Ratings for safety of the prompt. There is at most one rating per category.", + "type": "array", "items": { "$ref": "SafetyRating" }, - "type": "array" + "description": "Ratings for safety of the prompt. There is at most one rating per category." }, "blockReason": { - "enum": [ - "BLOCK_REASON_UNSPECIFIED", - "SAFETY", - "OTHER" - ], - "description": "Optional. If set, the prompt was blocked and no candidates are returned. Rephrase your prompt.", "enumDescriptions": [ "Default value. This value is unused.", "Prompt was blocked due to safety reasons. You can inspect `safety_ratings` to understand which safety category blocked it.", - "Prompt was blocked due to unknown reaasons." + "Prompt was blocked due to unknown reasons." ], - "type": "string" + "description": "Optional. If set, the prompt was blocked and no candidates are returned. Rephrase your prompt.", + "type": "string", + "enum": [ + "BLOCK_REASON_UNSPECIFIED", + "SAFETY", + "OTHER" + ] } }, - "type": "object", "id": "PromptFeedback", - "description": "A set of the feedback metadata the prompt specified in `GenerateContentRequest.content`." + "description": "A set of the feedback metadata the prompt specified in `GenerateContentRequest.content`.", + "type": "object" }, - "ListDocumentsResponse": { - "id": "ListDocumentsResponse", + "FunctionCall": { "type": "object", "properties": { - "documents": { - "items": { - "$ref": "Document" + "args": { + "description": "Optional. The function parameters and values in JSON object format.", + "additionalProperties": { + "description": "Properties of the object.", + "type": "any" }, - "description": "The returned `Document`s.", - "type": "array" + "type": "object" }, - "nextPageToken": { + "name": { "type": "string", - "description": "A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages." + "description": "Required. The name of the function to call. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 63." } }, - "description": "Response from `ListDocuments` containing a paginated list of `Document`s. The `Document`s are sorted by ascending `document.create_time`." + "description": "A predicted `FunctionCall` returned from the model that contains a string representing the `FunctionDeclaration.name` with the arguments and their values.", + "id": "FunctionCall" }, - "MessagePrompt": { - "id": "MessagePrompt", + "Schema": { + "description": "The `Schema` object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. Represents a select subset of an [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema).", "type": "object", - "description": "All of the structured input text passed to the model as a prompt. A `MessagePrompt` contains a structured set of fields that provide context for the conversation, examples of user input/model output message pairs that prime the model to respond in different ways, and the conversation history or list of messages representing the alternating turns of the conversation between the user and the model.", "properties": { - "context": { - "type": "string", - "description": "Optional. Text that should be provided to the model first to ground the response. If not empty, this `context` will be given to the model first before the `examples` and `messages`. When using a `context` be sure to provide it with every request to maintain continuity. This field can be a description of your prompt to the model to help provide context and guide the responses. Examples: \"Translate the phrase from English to French.\" or \"Given a statement, classify the sentiment as happy, sad or neutral.\" Anything included in this field will take precedence over message history if the total input size exceeds the model's `input_token_limit` and the input request is truncated." - }, - "examples": { + "enum": { "type": "array", - "description": "Optional. Examples of what the model should generate. This includes both user input and the response that the model should emulate. These `examples` are treated identically to conversation messages except that they take precedence over the history in `messages`: If the total input size exceeds the model's `input_token_limit` the input will be truncated. Items will be dropped from `messages` before `examples`.", + "description": "Optional. Possible values of the element of Type.STRING with enum format. For example we can define an Enum Direction as : {type:STRING, format:enum, enum:[\"EAST\", NORTH\", \"SOUTH\", \"WEST\"]}", "items": { - "$ref": "Example" + "type": "string" } }, - "messages": { - "description": "Required. A snapshot of the recent conversation history sorted chronologically. Turns alternate between two authors. If the total input size exceeds the model's `input_token_limit` the input will be truncated: The oldest items will be dropped from `messages`.", - "type": "array", - "items": { - "$ref": "Message" - } - } - } - }, - "FunctionResponse": { - "id": "FunctionResponse", - "type": "object", - "description": "The result output from a `FunctionCall` that contains a string representing the `FunctionDeclaration.name` and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a`FunctionCall` made based on model prediction.", - "properties": { - "name": { - "type": "string", - "description": "Required. The name of the function to call. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 63." - }, - "response": { + "properties": { + "type": "object", "additionalProperties": { - "type": "any", - "description": "Properties of the object." - }, - "description": "Required. The function response in JSON object format.", - "type": "object" - } - } - }, - "QueryCorpusRequest": { - "properties": { - "metadataFilters": { - "type": "array", - "items": { - "$ref": "MetadataFilter" + "$ref": "Schema" }, - "description": "Optional. Filter for `Chunk` and `Document` metadata. Each `MetadataFilter` object should correspond to a unique key. Multiple `MetadataFilter` objects are joined by logical \"AND\"s. Example query at document level: (year \u003e= 2020 OR year \u003c 2010) AND (genre = drama OR genre = action) `MetadataFilter` object list: metadata_filters = [ {key = \"document.custom_metadata.year\" conditions = [{int_value = 2020, operation = GREATER_EQUAL}, {int_value = 2010, operation = LESS}]}, {key = \"document.custom_metadata.year\" conditions = [{int_value = 2020, operation = GREATER_EQUAL}, {int_value = 2010, operation = LESS}]}, {key = \"document.custom_metadata.genre\" conditions = [{string_value = \"drama\", operation = EQUAL}, {string_value = \"action\", operation = EQUAL}]}] Example query at chunk level for a numeric range of values: (year \u003e 2015 AND year \u003c= 2020) `MetadataFilter` object list: metadata_filters = [ {key = \"chunk.custom_metadata.year\" conditions = [{int_value = 2015, operation = GREATER}]}, {key = \"chunk.custom_metadata.year\" conditions = [{int_value = 2020, operation = LESS_EQUAL}]}] Note: \"AND\"s for the same key are only supported for numeric values. String values only support \"OR\"s for the same key." + "description": "Optional. Properties of Type.OBJECT." }, - "query": { - "description": "Required. Query string to perform semantic search.", + "format": { + "type": "string", + "description": "Optional. The format of the data. This is used only for primitive datatypes. Supported formats: for NUMBER type: float, double for INTEGER type: int32, int64" + }, + "description": { + "description": "Optional. A brief description of the parameter. This could contain examples of use. Parameter description may be formatted as Markdown.", "type": "string" }, - "resultsCount": { - "description": "Optional. The maximum number of `Chunk`s to return. The service may return fewer `Chunk`s. If unspecified, at most 10 `Chunk`s will be returned. The maximum specified result count is 100.", - "type": "integer", - "format": "int32" - } - }, - "description": "Request for querying a `Corpus`.", - "id": "QueryCorpusRequest", - "type": "object" - }, - "GenerateMessageResponse": { - "description": "The response from the model. This includes candidate messages and conversation history in the form of chronologically-ordered messages.", - "id": "GenerateMessageResponse", - "properties": { - "messages": { + "required": { "type": "array", - "description": "The conversation history used by the model.", + "description": "Optional. Required properties of Type.OBJECT.", "items": { - "$ref": "Message" + "type": "string" } }, - "candidates": { - "items": { - "$ref": "Message" - }, - "description": "Candidate response messages from the model.", - "type": "array" + "items": { + "description": "Optional. Schema of the elements of Type.ARRAY.", + "$ref": "Schema" }, - "filters": { - "type": "array", - "items": { - "$ref": "ContentFilter" - }, - "description": "A set of content filtering metadata for the prompt and response text. This indicates which `SafetyCategory`(s) blocked a candidate from this response, the lowest `HarmProbability` that triggered a block, and the HarmThreshold setting for that category." - } - }, - "type": "object" - }, - "Example": { - "description": "An input/output example used to instruct the Model. It demonstrates how the model should respond or format its response.", - "id": "Example", - "type": "object", - "properties": { - "output": { - "$ref": "Message", - "description": "Required. An example of what the model should output given the input." + "nullable": { + "type": "boolean", + "description": "Optional. Indicates if the value may be null." }, - "input": { - "$ref": "Message", - "description": "Required. An example of an input `Message` from the user." - } - } - }, - "Condition": { - "id": "Condition", - "description": "Filter condition applicable to a single key.", - "properties": { - "operation": { + "type": { "enum": [ - "OPERATOR_UNSPECIFIED", - "LESS", - "LESS_EQUAL", - "EQUAL", - "GREATER_EQUAL", - "GREATER", - "NOT_EQUAL", - "INCLUDES", - "EXCLUDES" + "TYPE_UNSPECIFIED", + "STRING", + "NUMBER", + "INTEGER", + "BOOLEAN", + "ARRAY", + "OBJECT" ], - "description": "Required. Operator applied to the given key-value pair to trigger the condition.", + "description": "Required. Data type.", "type": "string", "enumDescriptions": [ - "The default value. This value is unused.", - "Supported by numeric.", - "Supported by numeric.", - "Supported by numeric & string.", - "Supported by numeric.", - "Supported by numeric.", - "Supported by numeric & string.", - "Supported by string only when `CustomMetadata` value type for the given key has a `string_list_value`.", - "Supported by string only when `CustomMetadata` value type for the given key has a `string_list_value`." + "Not specified, should not be used.", + "String type.", + "Number type.", + "Integer type.", + "Boolean type.", + "Array type.", + "Object type." ] - }, - "numericValue": { - "format": "float", - "type": "number", - "description": "The numeric value to filter the metadata on." - }, - "stringValue": { - "description": "The string value to filter the metadata on.", - "type": "string" } }, - "type": "object" + "id": "Schema" }, - "StringList": { + "CreateFileRequest": { "properties": { - "values": { - "type": "array", - "description": "The string values of the metadata to store.", - "items": { - "type": "string" - } + "file": { + "$ref": "File", + "description": "Optional. Metadata for the file to create." } }, "type": "object", - "description": "User provided string values assigned to a single metadata key.", - "id": "StringList" + "id": "CreateFileRequest", + "description": "Request for `CreateFile`." }, - "EmbedTextRequest": { - "description": "Request to get a text embedding from the model.", - "id": "EmbedTextRequest", - "type": "object", + "Operation": { + "description": "This resource represents a long-running operation that is the result of a network API call.", "properties": { - "model": { - "type": "string", - "description": "Required. The model name to use with the format model=models/{model}." + "error": { + "$ref": "Status", + "description": "The error result of the operation in case of failure or cancellation." }, - "text": { + "metadata": { + "description": "Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.", + "type": "object", + "additionalProperties": { + "type": "any", + "description": "Properties of the object. Contains field @type with type URL." + } + }, + "response": { + "description": "The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.", + "additionalProperties": { + "type": "any", + "description": "Properties of the object. Contains field @type with type URL." + }, + "type": "object" + }, + "done": { + "type": "boolean", + "description": "If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available." + }, + "name": { "type": "string", - "description": "Optional. The free-form input text that the model will turn into an embedding." + "description": "The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`." } - } + }, + "id": "Operation", + "type": "object" }, - "Hyperparameters": { - "type": "object", - "description": "Hyperparameters controlling the tuning process. Read more at https://ai.google.dev/docs/model_tuning_guidance", - "id": "Hyperparameters", + "Dataset": { + "id": "Dataset", "properties": { - "learningRateMultiplier": { - "type": "number", - "description": "Optional. Immutable. The learning rate multiplier is used to calculate a final learning_rate based on the default (recommended) value. Actual learning rate := learning_rate_multiplier * default learning rate Default learning rate is dependent on base model and dataset size. If not set, a default of 1.0 will be used.", - "format": "float" - }, - "learningRate": { - "format": "float", - "description": "Optional. Immutable. The learning rate hyperparameter for tuning. If not set, a default of 0.001 or 0.0002 will be calculated based on the number of training examples.", - "type": "number" - }, - "batchSize": { - "type": "integer", - "format": "int32", - "description": "Immutable. The batch size hyperparameter for tuning. If not set, a default of 4 or 16 will be used based on the number of training examples." - }, - "epochCount": { - "format": "int32", - "description": "Immutable. The number of training epochs. An epoch is one pass through the training data. If not set, a default of 5 will be used.", - "type": "integer" + "examples": { + "$ref": "TuningExamples", + "description": "Optional. Inline examples." } - } + }, + "description": "Dataset for training or validation.", + "type": "object" }, "ListTunedModelsResponse": { "description": "Response from `ListTunedModels` containing a paginated list of Models.", + "type": "object", "properties": { - "nextPageToken": { - "description": "A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages.", - "type": "string" - }, "tunedModels": { - "description": "The returned Models.", "items": { "$ref": "TunedModel" }, + "description": "The returned Models.", "type": "array" + }, + "nextPageToken": { + "type": "string", + "description": "A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages." } }, - "id": "ListTunedModelsResponse", - "type": "object" + "id": "ListTunedModelsResponse" }, - "Status": { - "description": "The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).", + "CitationMetadata": { + "id": "CitationMetadata", + "description": "A collection of source attributions for a piece of content.", "type": "object", "properties": { - "message": { - "description": "A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.", - "type": "string" - }, - "code": { - "format": "int32", - "type": "integer", - "description": "The status code, which should be an enum value of google.rpc.Code." - }, - "details": { - "type": "array", - "description": "A list of messages that carry the error details. There is a common set of message types for APIs to use.", + "citationSources": { "items": { - "type": "object", - "additionalProperties": { - "description": "Properties of the object. Contains field @type with type URL.", - "type": "any" - } - } + "$ref": "CitationSource" + }, + "description": "Citations to sources for a specific response.", + "type": "array" } - }, - "id": "Status" + } }, - "RelevantChunk": { - "id": "RelevantChunk", + "CachedContentUsageMetadata": { + "description": "Metadata on the usage of the cached content.", + "id": "CachedContentUsageMetadata", "type": "object", "properties": { - "chunkRelevanceScore": { - "type": "number", - "description": "`Chunk` relevance to the query.", - "format": "float" - }, - "chunk": { - "$ref": "Chunk", - "description": "`Chunk` associated with the query." + "totalTokenCount": { + "type": "integer", + "description": "Total number of tokens that the cached content consumes.", + "format": "int32" } - }, - "description": "The information for a chunk relevant to a query." + } }, - "CountTokensResponse": { - "type": "object", + "VideoMetadata": { + "description": "Metadata for a video `File`.", + "id": "VideoMetadata", "properties": { - "totalTokens": { - "format": "int32", - "description": "The number of tokens that the `model` tokenizes the `prompt` into. Always non-negative.", - "type": "integer" + "videoDuration": { + "format": "google-duration", + "description": "Duration of the video.", + "type": "string" } }, - "id": "CountTokensResponse", - "description": "A response from `CountTokens`. It returns the model's `token_count` for the `prompt`." + "type": "object" }, - "SafetySetting": { - "type": "object", + "ListFilesResponse": { + "id": "ListFilesResponse", "properties": { - "threshold": { - "type": "string", - "description": "Required. Controls the probability threshold at which harm is blocked.", - "enumDescriptions": [ - "Threshold is unspecified.", - "Content with NEGLIGIBLE will be allowed.", - "Content with NEGLIGIBLE and LOW will be allowed.", - "Content with NEGLIGIBLE, LOW, and MEDIUM will be allowed.", - "All content will be allowed." - ], - "enum": [ - "HARM_BLOCK_THRESHOLD_UNSPECIFIED", - "BLOCK_LOW_AND_ABOVE", - "BLOCK_MEDIUM_AND_ABOVE", - "BLOCK_ONLY_HIGH", - "BLOCK_NONE" - ] + "files": { + "items": { + "$ref": "File" + }, + "description": "The list of `File`s.", + "type": "array" }, - "category": { - "description": "Required. The category for this setting.", + "nextPageToken": { "type": "string", - "enumDescriptions": [ - "Category is unspecified.", - "Negative or harmful comments targeting identity and/or protected attribute.", - "Content that is rude, disrespectful, or profane.", - "Describes scenarios depicting violence against an individual or group, or general descriptions of gore.", - "Contains references to sexual acts or other lewd content.", - "Promotes unchecked medical advice.", - "Dangerous content that promotes, facilitates, or encourages harmful acts.", - "Harasment content.", - "Hate speech and content.", - "Sexually explicit content.", - "Dangerous content." - ], - "enum": [ - "HARM_CATEGORY_UNSPECIFIED", - "HARM_CATEGORY_DEROGATORY", - "HARM_CATEGORY_TOXICITY", - "HARM_CATEGORY_VIOLENCE", - "HARM_CATEGORY_SEXUAL", - "HARM_CATEGORY_MEDICAL", - "HARM_CATEGORY_DANGEROUS", - "HARM_CATEGORY_HARASSMENT", - "HARM_CATEGORY_HATE_SPEECH", - "HARM_CATEGORY_SEXUALLY_EXPLICIT", - "HARM_CATEGORY_DANGEROUS_CONTENT" - ] + "description": "A token that can be sent as a `page_token` into a subsequent `ListFiles` call." } }, - "description": "Safety setting, affecting the safety-blocking behavior. Passing a safety setting for a category changes the allowed probability that content is blocked.", - "id": "SafetySetting" + "type": "object", + "description": "Response for `ListFiles`." }, - "CountTextTokensResponse": { - "id": "CountTextTokensResponse", - "description": "A response from `CountTextTokens`. It returns the model's `token_count` for the `prompt`.", + "QueryCorpusResponse": { + "description": "Response from `QueryCorpus` containing a list of relevant chunks.", + "id": "QueryCorpusResponse", "properties": { - "tokenCount": { - "format": "int32", - "description": "The number of tokens that the `model` tokenizes the `prompt` into. Always non-negative.", - "type": "integer" + "relevantChunks": { + "description": "The relevant chunks.", + "items": { + "$ref": "RelevantChunk" + }, + "type": "array" } }, "type": "object" }, - "BatchEmbedTextResponse": { + "Empty": { + "type": "object", + "description": "A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }", + "id": "Empty", + "properties": {} + }, + "FunctionDeclaration": { + "description": "Structured representation of a function declaration as defined by the [OpenAPI 3.03 specification](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a `Tool` by the model and executed by the client.", "type": "object", + "id": "FunctionDeclaration", "properties": { - "embeddings": { - "type": "array", - "items": { - "$ref": "Embedding" - }, - "description": "Output only. The embeddings generated from the input text.", - "readOnly": true + "name": { + "description": "Required. The name of the function. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 63.", + "type": "string" + }, + "parameters": { + "$ref": "Schema", + "description": "Optional. Describes the parameters to this function. Reflects the Open API 3.03 Parameter Object string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter." + }, + "description": { + "type": "string", + "description": "Required. A brief description of the function." } - }, - "description": "The response to a EmbedTextRequest.", - "id": "BatchEmbedTextResponse" + } }, - "BatchEmbedTextRequest": { - "description": "Batch request to get a text embedding from the model.", + "BatchCreateChunksRequest": { + "description": "Request to batch create `Chunk`s.", "properties": { - "texts": { - "items": { - "type": "string" - }, - "type": "array", - "description": "Optional. The free-form input texts that the model will turn into an embedding. The current limit is 100 texts, over which an error will be thrown." - }, "requests": { - "type": "array", + "description": "Required. The request messages specifying the `Chunk`s to create. A maximum of 100 `Chunk`s can be created in a batch.", "items": { - "$ref": "EmbedTextRequest" + "$ref": "CreateChunkRequest" }, - "description": "Optional. Embed requests for the batch. Only one of `texts` or `requests` can be set." + "type": "array" } }, - "id": "BatchEmbedTextRequest", - "type": "object" + "type": "object", + "id": "BatchCreateChunksRequest" }, - "FunctionCallingConfig": { + "StringList": { "type": "object", - "id": "FunctionCallingConfig", "properties": { - "allowedFunctionNames": { + "values": { + "type": "array", "items": { "type": "string" }, - "description": "Optional. A set of function names that, when provided, limits the functions the model will call. This should only be set when the Mode is ANY. Function names should match [FunctionDeclaration.name]. With mode set to ANY, model will predict a function call from the set of function names provided.", - "type": "array" - }, - "mode": { - "enum": [ - "MODE_UNSPECIFIED", - "AUTO", - "ANY", - "NONE" - ], - "description": "Optional. Specifies the mode in which function calling should execute. If unspecified, the default value will be set to AUTO.", - "enumDescriptions": [ - "Unspecified function calling mode. This value should not be used.", - "Default model behavior, model decides to predict either a function call or a natural language response.", - "Model is constrained to always predicting a function call only. If \"allowed_function_names\" are set, the predicted function call will be limited to any one of \"allowed_function_names\", else the predicted function call will be any one of the provided \"function_declarations\".", - "Model will not predict any function call. Model behavior is same as when not passing any function declarations." - ], - "type": "string" + "description": "The string values of the metadata to store." } }, - "description": "Configuration for specifying function calling behavior." + "description": "User provided string values assigned to a single metadata key.", + "id": "StringList" }, - "GenerateAnswerRequest": { + "GroundingPassages": { "type": "object", - "description": "Request to generate a grounded answer from the model.", - "id": "GenerateAnswerRequest", "properties": { - "answerStyle": { - "enum": [ - "ANSWER_STYLE_UNSPECIFIED", - "ABSTRACTIVE", - "EXTRACTIVE", - "VERBOSE" - ], - "type": "string", - "enumDescriptions": [ - "Unspecified answer style.", - "Succint but abstract style.", - "Very brief and extractive style.", - "Verbose style including extra details. The response may be formatted as a sentence, paragraph, multiple paragraphs, or bullet points, etc." - ], - "description": "Required. Style in which answers should be returned." - }, - "safetySettings": { + "passages": { "items": { - "$ref": "SafetySetting" + "$ref": "GroundingPassage" }, - "description": "Optional. A list of unique `SafetySetting` instances for blocking unsafe content. This will be enforced on the `GenerateAnswerRequest.contents` and `GenerateAnswerResponse.candidate`. There should not be more than one setting for each `SafetyCategory` type. The API will block any contents and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each `SafetyCategory` specified in the safety_settings. If there is no `SafetySetting` for a given `SafetyCategory` provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_HARASSMENT are supported.", - "type": "array" - }, - "inlinePassages": { - "description": "Passages provided inline with the request.", - "$ref": "GroundingPassages" - }, - "contents": { "type": "array", - "description": "Required. The content of the current conversation with the model. For single-turn queries, this is a single question to answer. For multi-turn queries, this is a repeated field that contains conversation history and the last `Content` in the list containing the question. Note: GenerateAnswer currently only supports queries in English.", - "items": { - "$ref": "Content" - } - }, - "temperature": { - "description": "Optional. Controls the randomness of the output. Values can range from [0.0,1.0], inclusive. A value closer to 1.0 will produce responses that are more varied and creative, while a value closer to 0.0 will typically result in more straightforward responses from the model. A low temperature (~0.2) is usually recommended for Attributed-Question-Answering use cases.", - "format": "float", - "type": "number" - }, - "semanticRetriever": { - "description": "Content retrieved from resources created via the Semantic Retriever API.", - "$ref": "SemanticRetrieverConfig" + "description": "List of passages." } - } + }, + "description": "A repeated list of passages.", + "id": "GroundingPassages" }, - "BatchUpdateChunksRequest": { + "GroundingAttribution": { + "type": "object", + "id": "GroundingAttribution", "properties": { - "requests": { - "items": { - "$ref": "UpdateChunkRequest" - }, - "type": "array", - "description": "Required. The request messages specifying the `Chunk`s to update. A maximum of 100 `Chunk`s can be updated in a batch." + "content": { + "description": "Grounding source content that makes up this attribution.", + "$ref": "Content" + }, + "sourceId": { + "$ref": "AttributionSourceId", + "description": "Output only. Identifier for the source contributing to this attribution.", + "readOnly": true } }, - "type": "object", - "description": "Request to batch update `Chunk`s.", - "id": "BatchUpdateChunksRequest" + "description": "Attribution for a source that contributed to an answer." }, - "ToolConfig": { + "BatchDeleteChunksRequest": { + "type": "object", "properties": { - "functionCallingConfig": { - "$ref": "FunctionCallingConfig", - "description": "Optional. Function calling config." + "requests": { + "type": "array", + "description": "Required. The request messages specifying the `Chunk`s to delete.", + "items": { + "$ref": "DeleteChunkRequest" + } } }, - "id": "ToolConfig", - "description": "The Tool configuration containing parameters for specifying `Tool` use in the request.", + "description": "Request to batch delete `Chunk`s.", + "id": "BatchDeleteChunksRequest" + }, + "TransferOwnershipResponse": { + "id": "TransferOwnershipResponse", + "description": "Response from `TransferOwnership`.", + "properties": {}, "type": "object" }, - "QueryDocumentRequest": { + "Document": { "type": "object", - "id": "QueryDocumentRequest", + "description": "A `Document` is a collection of `Chunk`s. A `Corpus` can have a maximum of 10,000 `Document`s.", "properties": { - "query": { - "description": "Required. Query string to perform semantic search.", + "updateTime": { + "format": "google-datetime", + "description": "Output only. The Timestamp of when the `Document` was last updated.", + "readOnly": true, "type": "string" }, - "metadataFilters": { + "customMetadata": { "items": { - "$ref": "MetadataFilter" + "$ref": "CustomMetadata" }, "type": "array", - "description": "Optional. Filter for `Chunk` metadata. Each `MetadataFilter` object should correspond to a unique key. Multiple `MetadataFilter` objects are joined by logical \"AND\"s. Note: `Document`-level filtering is not supported for this request because a `Document` name is already specified. Example query: (year \u003e= 2020 OR year \u003c 2010) AND (genre = drama OR genre = action) `MetadataFilter` object list: metadata_filters = [ {key = \"chunk.custom_metadata.year\" conditions = [{int_value = 2020, operation = GREATER_EQUAL}, {int_value = 2010, operation = LESS}}, {key = \"chunk.custom_metadata.genre\" conditions = [{string_value = \"drama\", operation = EQUAL}, {string_value = \"action\", operation = EQUAL}}] Example query for a numeric range of values: (year \u003e 2015 AND year \u003c= 2020) `MetadataFilter` object list: metadata_filters = [ {key = \"chunk.custom_metadata.year\" conditions = [{int_value = 2015, operation = GREATER}]}, {key = \"chunk.custom_metadata.year\" conditions = [{int_value = 2020, operation = LESS_EQUAL}]}] Note: \"AND\"s for the same key are only supported for numeric values. String values only support \"OR\"s for the same key." + "description": "Optional. User provided custom metadata stored as key-value pairs used for querying. A `Document` can have a maximum of 20 `CustomMetadata`." }, - "resultsCount": { - "format": "int32", - "description": "Optional. The maximum number of `Chunk`s to return. The service may return fewer `Chunk`s. If unspecified, at most 10 `Chunk`s will be returned. The maximum specified result count is 100.", - "type": "integer" - } - }, - "description": "Request for querying a `Document`." - }, - "ContentFilter": { - "id": "ContentFilter", - "description": "Content filtering metadata associated with processing a single request. ContentFilter contains a reason and an optional supporting string. The reason may be unspecified.", - "type": "object", - "properties": { - "message": { + "createTime": { "type": "string", - "description": "A string that describes the filtering behavior in more detail." + "description": "Output only. The Timestamp of when the `Document` was created.", + "format": "google-datetime", + "readOnly": true }, - "reason": { - "description": "The reason content was blocked during request processing.", - "enumDescriptions": [ - "A blocked reason was not specified.", - "Content was blocked by safety settings.", - "Content was blocked, but the reason is uncategorized." - ], - "enum": [ - "BLOCKED_REASON_UNSPECIFIED", - "SAFETY", - "OTHER" - ], + "displayName": { + "description": "Optional. The human-readable display name for the `Document`. The display name must be no more than 512 characters in length, including spaces. Example: \"Semantic Retriever Documentation\"", "type": "string" + }, + "name": { + "type": "string", + "description": "Immutable. Identifier. The `Document` resource name. The ID (name excluding the \"corpora/*/documents/\" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be derived from `display_name` along with a 12 character random suffix. Example: `corpora/{corpus_id}/documents/my-awesome-doc-123a456b789c`" } - } + }, + "id": "Document" }, - "CustomMetadata": { + "TunedModel": { + "description": "A fine-tuned model created using ModelService.CreateTunedModel.", + "type": "object", + "id": "TunedModel", "properties": { - "stringValue": { - "description": "The string value of the metadata to store.", + "tunedModelSource": { + "$ref": "TunedModelSource", + "description": "Optional. TunedModel to use as the starting point for training the new model." + }, + "updateTime": { + "format": "google-datetime", + "type": "string", + "description": "Output only. The timestamp when this model was updated.", + "readOnly": true + }, + "state": { + "enum": [ + "STATE_UNSPECIFIED", + "CREATING", + "ACTIVE", + "FAILED" + ], + "description": "Output only. The state of the tuned model.", + "type": "string", + "readOnly": true, + "enumDescriptions": [ + "The default value. This value is unused.", + "The model is being created.", + "The model is ready to be used.", + "The model failed to be created." + ] + }, + "name": { + "type": "string", + "description": "Output only. The tuned model name. A unique name will be generated on create. Example: `tunedModels/az2mb0bpw6i` If display_name is set on create, the id portion of the name will be set by concatenating the words of the display_name with hyphens and adding a random portion for uniqueness. Example: display_name = \"Sentence Translator\" name = \"tunedModels/sentence-translator-u3b7m\"", + "readOnly": true + }, + "description": { + "type": "string", + "description": "Optional. A short description of this model." + }, + "topK": { + "format": "int32", + "type": "integer", + "description": "Optional. For Top-k sampling. Top-k sampling considers the set of `top_k` most probable tokens. This value specifies default to be used by the backend while making the call to the model. This value specifies default to be the one used by the base model while creating the model." + }, + "createTime": { + "description": "Output only. The timestamp when this model was created.", + "format": "google-datetime", + "type": "string", + "readOnly": true + }, + "baseModel": { + "description": "Immutable. The name of the `Model` to tune. Example: `models/text-bison-001`", "type": "string" }, - "numericValue": { + "tuningTask": { + "$ref": "TuningTask", + "description": "Required. The tuning task that creates the tuned model." + }, + "topP": { + "type": "number", + "description": "Optional. For Nucleus sampling. Nucleus sampling considers the smallest set of tokens whose probability sum is at least `top_p`. This value specifies default to be the one used by the base model while creating the model.", + "format": "float" + }, + "temperature": { + "description": "Optional. Controls the randomness of the output. Values can range over `[0.0,1.0]`, inclusive. A value closer to `1.0` will produce responses that are more varied, while a value closer to `0.0` will typically result in less surprising responses from the model. This value specifies default to be the one used by the base model while creating the model.", "format": "float", - "description": "The numeric value of the metadata to store.", "type": "number" }, - "stringListValue": { - "$ref": "StringList", - "description": "The StringList value of the metadata to store." - }, - "key": { - "type": "string", - "description": "Required. The key of the metadata to store." + "displayName": { + "description": "Optional. The name to display for this model in user interfaces. The display name must be up to 40 characters including spaces.", + "type": "string" } - }, - "id": "CustomMetadata", - "description": "User provided metadata stored as key-value pairs.", - "type": "object" + } }, - "EmbedContentResponse": { + "TuningTask": { + "type": "object", + "description": "Tuning tasks that create tuned models.", + "id": "TuningTask", "properties": { - "embedding": { - "$ref": "ContentEmbedding", + "startTime": { + "type": "string", + "readOnly": true, + "description": "Output only. The timestamp when tuning this model started.", + "format": "google-datetime" + }, + "trainingData": { + "description": "Required. Input only. Immutable. The model training data.", + "$ref": "Dataset" + }, + "snapshots": { + "type": "array", + "description": "Output only. Metrics collected during tuning.", + "items": { + "$ref": "TuningSnapshot" + }, + "readOnly": true + }, + "completeTime": { "readOnly": true, - "description": "Output only. The embedding generated from the input content." + "format": "google-datetime", + "type": "string", + "description": "Output only. The timestamp when tuning this model completed." + }, + "hyperparameters": { + "$ref": "Hyperparameters", + "description": "Immutable. Hyperparameters controlling the tuning process. If not provided, default values will be used." } - }, - "description": "The response to an `EmbedContentRequest`.", - "id": "EmbedContentResponse", - "type": "object" + } }, - "GroundingPassageId": { + "UpdateChunkRequest": { "type": "object", - "id": "GroundingPassageId", + "id": "UpdateChunkRequest", "properties": { - "partIndex": { - "type": "integer", - "format": "int32", - "description": "Output only. Index of the part within the `GenerateAnswerRequest`'s `GroundingPassage.content`.", - "readOnly": true + "updateMask": { + "format": "google-fieldmask", + "description": "Required. The list of fields to update. Currently, this only supports updating `custom_metadata` and `data`.", + "type": "string" }, - "passageId": { - "description": "Output only. ID of the passage matching the `GenerateAnswerRequest`'s `GroundingPassage.id`.", - "type": "string", - "readOnly": true + "chunk": { + "description": "Required. The `Chunk` to update.", + "$ref": "Chunk" } }, - "description": "Identifier for a part within a `GroundingPassage`." + "description": "Request to update a `Chunk`." }, - "GroundingAttribution": { - "id": "GroundingAttribution", + "GenerateContentRequest": { + "id": "GenerateContentRequest", "properties": { - "sourceId": { - "$ref": "AttributionSourceId", - "readOnly": true, - "description": "Output only. Identifier for the source contributing to this attribution." + "model": { + "type": "string", + "description": "Required. The name of the `Model` to use for generating the completion. Format: `name=models/{model}`." }, - "content": { + "tools": { + "items": { + "$ref": "Tool" + }, + "type": "array", + "description": "Optional. A list of `Tools` the model may use to generate the next response. A `Tool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. The only supported tool is currently `Function`." + }, + "generationConfig": { + "description": "Optional. Configuration options for model generation and outputs.", + "$ref": "GenerationConfig" + }, + "contents": { + "items": { + "$ref": "Content" + }, + "type": "array", + "description": "Required. The content of the current conversation with the model. For single-turn queries, this is a single instance. For multi-turn queries, this is a repeated field that contains conversation history + latest request." + }, + "safetySettings": { + "items": { + "$ref": "SafetySetting" + }, + "description": "Optional. A list of unique `SafetySetting` instances for blocking unsafe content. This will be enforced on the `GenerateContentRequest.contents` and `GenerateContentResponse.candidates`. There should not be more than one setting for each `SafetyCategory` type. The API will block any contents and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each `SafetyCategory` specified in the safety_settings. If there is no `SafetySetting` for a given `SafetyCategory` provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_HARASSMENT are supported.", + "type": "array" + }, + "toolConfig": { + "$ref": "ToolConfig", + "description": "Optional. Tool configuration for any `Tool` specified in the request." + }, + "systemInstruction": { "$ref": "Content", - "description": "Grounding source content that makes up this attribution." + "description": "Optional. Developer set system instruction. Currently, text only." + }, + "cachedContent": { + "type": "string", + "description": "Optional. The name of the cached content used as context to serve the prediction. Note: only used in explicit caching, where users can have control over caching (e.g. what content to cache) and enjoy guaranteed cost savings. Format: `cachedContents/{cachedContent}`" } }, - "description": "Attribution for a source that contributed to an answer.", - "type": "object" + "type": "object", + "description": "Request to generate a completion from the model." }, - "CreateFileResponse": { - "description": "Response for `CreateFile`.", + "CountTokensResponse": { + "description": "A response from `CountTokens`. It returns the model's `token_count` for the `prompt`.", "type": "object", - "id": "CreateFileResponse", + "id": "CountTokensResponse", "properties": { - "file": { - "$ref": "File", - "description": "Metadata for the created file." + "totalTokens": { + "description": "The number of tokens that the `model` tokenizes the `prompt` into. Always non-negative. When cached_content is set, this is still the total effective prompt size. I.e. this includes the number of tokens in the cached content.", + "format": "int32", + "type": "integer" } } }, - "MetadataFilter": { - "id": "MetadataFilter", - "description": "User provided filter to limit retrieval based on `Chunk` or `Document` level metadata values. Example (genre = drama OR genre = action): key = \"document.custom_metadata.genre\" conditions = [{string_value = \"drama\", operation = EQUAL}, {string_value = \"action\", operation = EQUAL}]", + "QueryCorpusRequest": { + "description": "Request for querying a `Corpus`.", + "id": "QueryCorpusRequest", "properties": { - "key": { - "description": "Required. The key of the metadata to filter on.", + "query": { + "description": "Required. Query string to perform semantic search.", "type": "string" }, - "conditions": { - "type": "array", + "metadataFilters": { "items": { - "$ref": "Condition" + "$ref": "MetadataFilter" }, - "description": "Required. The `Condition`s for the given key that will trigger this filter. Multiple `Condition`s are joined by logical ORs." + "description": "Optional. Filter for `Chunk` and `Document` metadata. Each `MetadataFilter` object should correspond to a unique key. Multiple `MetadataFilter` objects are joined by logical \"AND\"s. Example query at document level: (year \u003e= 2020 OR year \u003c 2010) AND (genre = drama OR genre = action) `MetadataFilter` object list: metadata_filters = [ {key = \"document.custom_metadata.year\" conditions = [{int_value = 2020, operation = GREATER_EQUAL}, {int_value = 2010, operation = LESS}]}, {key = \"document.custom_metadata.year\" conditions = [{int_value = 2020, operation = GREATER_EQUAL}, {int_value = 2010, operation = LESS}]}, {key = \"document.custom_metadata.genre\" conditions = [{string_value = \"drama\", operation = EQUAL}, {string_value = \"action\", operation = EQUAL}]}] Example query at chunk level for a numeric range of values: (year \u003e 2015 AND year \u003c= 2020) `MetadataFilter` object list: metadata_filters = [ {key = \"chunk.custom_metadata.year\" conditions = [{int_value = 2015, operation = GREATER}]}, {key = \"chunk.custom_metadata.year\" conditions = [{int_value = 2020, operation = LESS_EQUAL}]}] Note: \"AND\"s for the same key are only supported for numeric values. String values only support \"OR\"s for the same key.", + "type": "array" + }, + "resultsCount": { + "format": "int32", + "description": "Optional. The maximum number of `Chunk`s to return. The service may return fewer `Chunk`s. If unspecified, at most 10 `Chunk`s will be returned. The maximum specified result count is 100.", + "type": "integer" } }, "type": "object" }, - "Embedding": { + "TransferOwnershipRequest": { "type": "object", "properties": { - "value": { - "description": "The embedding values.", - "type": "array", - "items": { - "type": "number", - "format": "float" - } + "emailAddress": { + "type": "string", + "description": "Required. The email address of the user to whom the tuned model is being transferred to." } }, - "id": "Embedding", - "description": "A list of floats representing the embedding." + "id": "TransferOwnershipRequest", + "description": "Request to transfer the ownership of the tuned model." }, - "TunedModelSource": { - "type": "object", - "id": "TunedModelSource", + "Model": { "properties": { - "baseModel": { - "description": "Output only. The name of the base `Model` this `TunedModel` was tuned from. Example: `models/text-bison-001`", + "version": { "type": "string", - "readOnly": true + "description": "Required. The version number of the model. This represents the major version" }, - "tunedModel": { - "description": "Immutable. The name of the `TunedModel` to use as the starting point for training the new model. Example: `tunedModels/my-tuned-model`", + "displayName": { + "description": "The human-readable name of the model. E.g. \"Chat Bison\". The name can be up to 128 characters long and can consist of any UTF-8 characters.", "type": "string" - } - }, - "description": "Tuned model as a source for training a new model." - }, - "Corpus": { - "description": "A `Corpus` is a collection of `Document`s. A project can create up to 5 corpora.", - "type": "object", - "id": "Corpus", - "properties": { - "createTime": { - "type": "string", - "description": "Output only. The Timestamp of when the `Corpus` was created.", - "format": "google-datetime", - "readOnly": true }, - "displayName": { + "baseModelId": { "type": "string", - "description": "Optional. The human-readable display name for the `Corpus`. The display name must be no more than 512 characters in length, including spaces. Example: \"Docs on Semantic Retriever\"" + "description": "Required. The name of the base model, pass this to the generation request. Examples: * `chat-bison`" }, - "name": { - "type": "string", - "description": "Immutable. Identifier. The `Corpus` resource name. The ID (name excluding the \"corpora/\" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be derived from `display_name` along with a 12 character random suffix. Example: `corpora/my-awesome-corpora-123a456b789c`" + "maxTemperature": { + "type": "number", + "format": "float", + "description": "The maximum temperature this model can use." }, - "updateTime": { - "description": "Output only. The Timestamp of when the `Corpus` was last updated.", - "readOnly": true, - "type": "string", - "format": "google-datetime" - } - } - }, - "QueryCorpusResponse": { - "description": "Response from `QueryCorpus` containing a list of relevant chunks.", - "properties": { - "relevantChunks": { - "items": { - "$ref": "RelevantChunk" - }, - "description": "The relevant chunks.", - "type": "array" - } - }, - "type": "object", - "id": "QueryCorpusResponse" - }, - "FileData": { - "type": "object", - "description": "URI based data.", - "id": "FileData", - "properties": { - "fileUri": { - "type": "string", - "description": "Required. URI." + "topP": { + "type": "number", + "description": "For Nucleus sampling. Nucleus sampling considers the smallest set of tokens whose probability sum is at least `top_p`. This value specifies default to be used by the backend while making the call to the model.", + "format": "float" }, - "mimeType": { - "type": "string", - "description": "Optional. The IANA standard MIME type of the source data." - } - } - }, - "FunctionCall": { - "properties": { - "args": { - "type": "object", - "additionalProperties": { - "description": "Properties of the object.", - "type": "any" - }, - "description": "Optional. The function parameters and values in JSON object format." + "inputTokenLimit": { + "type": "integer", + "description": "Maximum number of input tokens allowed for this model.", + "format": "int32" }, - "name": { - "description": "Required. The name of the function to call. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 63.", - "type": "string" - } - }, - "type": "object", - "id": "FunctionCall", - "description": "A predicted `FunctionCall` returned from the model that contains a string representing the `FunctionDeclaration.name` with the arguments and their values." - }, - "FunctionDeclaration": { - "type": "object", - "id": "FunctionDeclaration", - "description": "Structured representation of a function declaration as defined by the [OpenAPI 3.03 specification](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a `Tool` by the model and executed by the client.", - "properties": { - "description": { - "type": "string", - "description": "Required. A brief description of the function." + "temperature": { + "format": "float", + "type": "number", + "description": "Controls the randomness of the output. Values can range over `[0.0,max_temperature]`, inclusive. A higher value will produce responses that are more varied, while a value closer to `0.0` will typically result in less surprising responses from the model. This value specifies default to be used by the backend while making the call to the model." }, - "parameters": { - "$ref": "Schema", - "description": "Optional. Describes the parameters to this function. Reflects the Open API 3.03 Parameter Object string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter." + "topK": { + "type": "integer", + "description": "For Top-k sampling. Top-k sampling considers the set of `top_k` most probable tokens. This value specifies default to be used by the backend while making the call to the model. If empty, indicates the model doesn't use top-k sampling, and `top_k` isn't allowed as a generation parameter.", + "format": "int32" }, "name": { - "description": "Required. The name of the function. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 63.", - "type": "string" - } - } - }, - "ListModelsResponse": { - "id": "ListModelsResponse", - "type": "object", - "description": "Response from `ListModel` containing a paginated list of Models.", - "properties": { - "nextPageToken": { "type": "string", - "description": "A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages." + "description": "Required. The resource name of the `Model`. Format: `models/{model}` with a `{model}` naming convention of: * \"{base_model_id}-{version}\" Examples: * `models/chat-bison-001`" }, - "models": { + "outputTokenLimit": { + "type": "integer", + "format": "int32", + "description": "Maximum number of output tokens available for this model." + }, + "supportedGenerationMethods": { "type": "array", "items": { - "$ref": "Model" + "type": "string" }, - "description": "The returned Models." + "description": "The model's supported generation methods. The method names are defined as Pascal case strings, such as `generateMessage` which correspond to API methods." + }, + "description": { + "description": "A short description of the model.", + "type": "string" } - } - }, - "SafetyRating": { - "id": "SafetyRating", - "description": "Safety rating for a piece of content. The safety rating contains the category of harm and the harm probability level in that category for a piece of content. Content is classified for safety across a number of harm categories and the probability of the harm classification is included here.", + }, "type": "object", + "id": "Model", + "description": "Information about a Generative Language Model." + }, + "Condition": { "properties": { - "category": { + "operation": { + "description": "Required. Operator applied to the given key-value pair to trigger the condition.", "type": "string", - "enumDescriptions": [ - "Category is unspecified.", - "Negative or harmful comments targeting identity and/or protected attribute.", - "Content that is rude, disrespectful, or profane.", - "Describes scenarios depicting violence against an individual or group, or general descriptions of gore.", - "Contains references to sexual acts or other lewd content.", - "Promotes unchecked medical advice.", - "Dangerous content that promotes, facilitates, or encourages harmful acts.", - "Harasment content.", - "Hate speech and content.", - "Sexually explicit content.", - "Dangerous content." - ], - "description": "Required. The category for this rating.", "enum": [ - "HARM_CATEGORY_UNSPECIFIED", - "HARM_CATEGORY_DEROGATORY", - "HARM_CATEGORY_TOXICITY", - "HARM_CATEGORY_VIOLENCE", - "HARM_CATEGORY_SEXUAL", - "HARM_CATEGORY_MEDICAL", - "HARM_CATEGORY_DANGEROUS", - "HARM_CATEGORY_HARASSMENT", - "HARM_CATEGORY_HATE_SPEECH", - "HARM_CATEGORY_SEXUALLY_EXPLICIT", - "HARM_CATEGORY_DANGEROUS_CONTENT" + "OPERATOR_UNSPECIFIED", + "LESS", + "LESS_EQUAL", + "EQUAL", + "GREATER_EQUAL", + "GREATER", + "NOT_EQUAL", + "INCLUDES", + "EXCLUDES" + ], + "enumDescriptions": [ + "The default value. This value is unused.", + "Supported by numeric.", + "Supported by numeric.", + "Supported by numeric & string.", + "Supported by numeric.", + "Supported by numeric.", + "Supported by numeric & string.", + "Supported by string only when `CustomMetadata` value type for the given key has a `string_list_value`.", + "Supported by string only when `CustomMetadata` value type for the given key has a `string_list_value`." ] }, - "blocked": { - "description": "Was this content blocked because of this rating?", - "type": "boolean" + "stringValue": { + "description": "The string value to filter the metadata on.", + "type": "string" }, - "probability": { - "type": "string", - "enumDescriptions": [ - "Probability is unspecified.", - "Content has a negligible chance of being unsafe.", - "Content has a low chance of being unsafe.", - "Content has a medium chance of being unsafe.", - "Content has a high chance of being unsafe." - ], - "enum": [ - "HARM_PROBABILITY_UNSPECIFIED", - "NEGLIGIBLE", - "LOW", - "MEDIUM", - "HIGH" - ], - "description": "Required. The probability of harm for this content." + "numericValue": { + "description": "The numeric value to filter the metadata on.", + "type": "number", + "format": "float" } - } + }, + "type": "object", + "description": "Filter condition applicable to a single key.", + "id": "Condition" }, - "InputFeedback": { - "id": "InputFeedback", + "CountMessageTokensRequest": { + "properties": { + "prompt": { + "description": "Required. The prompt, whose token count is to be returned.", + "$ref": "MessagePrompt" + } + }, + "description": "Counts the number of tokens in the `prompt` sent to a model. Models may tokenize text differently, so each model may return a different `token_count`.", "type": "object", + "id": "CountMessageTokensRequest" + }, + "InputFeedback": { "properties": { "safetyRatings": { - "description": "Ratings for safety of the input. There is at most one rating per category.", "items": { "$ref": "SafetyRating" }, + "description": "Ratings for safety of the input. There is at most one rating per category.", "type": "array" }, "blockReason": { - "enum": [ - "BLOCK_REASON_UNSPECIFIED", - "SAFETY", - "OTHER" - ], - "type": "string", "description": "Optional. If set, the input was blocked and no candidates are returned. Rephrase your input.", + "type": "string", "enumDescriptions": [ "Default value. This value is unused.", "Input was blocked due to safety reasons. You can inspect `safety_ratings` to understand which safety category blocked it.", "Input was blocked due to other reasons." + ], + "enum": [ + "BLOCK_REASON_UNSPECIFIED", + "SAFETY", + "OTHER" ] } }, - "description": "Feedback related to the input data used to answer the question, as opposed to model-generated response to the question." + "description": "Feedback related to the input data used to answer the question, as opposed to model-generated response to the question.", + "id": "InputFeedback", + "type": "object" }, - "Model": { + "CountTextTokensResponse": { "type": "object", + "description": "A response from `CountTextTokens`. It returns the model's `token_count` for the `prompt`.", "properties": { - "supportedGenerationMethods": { - "description": "The model's supported generation methods. The method names are defined as Pascal case strings, such as `generateMessage` which correspond to API methods.", - "type": "array", - "items": { - "type": "string" - } - }, - "temperature": { - "type": "number", - "description": "Controls the randomness of the output. Values can range over `[0.0,2.0]`, inclusive. A higher value will produce responses that are more varied, while a value closer to `0.0` will typically result in less surprising responses from the model. This value specifies default to be used by the backend while making the call to the model.", - "format": "float" - }, - "inputTokenLimit": { - "description": "Maximum number of input tokens allowed for this model.", + "tokenCount": { + "format": "int32", "type": "integer", - "format": "int32" - }, - "baseModelId": { + "description": "The number of tokens that the `model` tokenizes the `prompt` into. Always non-negative." + } + }, + "id": "CountTextTokensResponse" + }, + "Chunk": { + "type": "object", + "description": "A `Chunk` is a subpart of a `Document` that is treated as an independent unit for the purposes of vector representation and storage. A `Corpus` can have a maximum of 1 million `Chunk`s.", + "properties": { + "name": { "type": "string", - "description": "Required. The name of the base model, pass this to the generation request. Examples: * `chat-bison`" + "description": "Immutable. Identifier. The `Chunk` resource name. The ID (name excluding the \"corpora/*/documents/*/chunks/\" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a random 12-character unique ID will be generated. Example: `corpora/{corpus_id}/documents/{document_id}/chunks/123a456b789c`" }, - "topP": { - "format": "float", - "description": "For Nucleus sampling. Nucleus sampling considers the smallest set of tokens whose probability sum is at least `top_p`. This value specifies default to be used by the backend while making the call to the model.", - "type": "number" + "updateTime": { + "format": "google-datetime", + "type": "string", + "readOnly": true, + "description": "Output only. The Timestamp of when the `Chunk` was last updated." }, - "description": { + "customMetadata": { + "description": "Optional. User provided custom metadata stored as key-value pairs. The maximum number of `CustomMetadata` per chunk is 20.", + "items": { + "$ref": "CustomMetadata" + }, + "type": "array" + }, + "createTime": { + "description": "Output only. The Timestamp of when the `Chunk` was created.", + "readOnly": true, "type": "string", - "description": "A short description of the model." + "format": "google-datetime" }, - "displayName": { - "description": "The human-readable name of the model. E.g. \"Chat Bison\". The name can be up to 128 characters long and can consist of any UTF-8 characters.", - "type": "string" + "state": { + "type": "string", + "readOnly": true, + "enum": [ + "STATE_UNSPECIFIED", + "STATE_PENDING_PROCESSING", + "STATE_ACTIVE", + "STATE_FAILED" + ], + "enumDescriptions": [ + "The default value. This value is used if the state is omitted.", + "`Chunk` is being processed (embedding and vector storage).", + "`Chunk` is processed and available for querying.", + "`Chunk` failed processing." + ], + "description": "Output only. Current state of the `Chunk`." }, - "outputTokenLimit": { - "description": "Maximum number of output tokens available for this model.", - "format": "int32", - "type": "integer" + "data": { + "description": "Required. The content for the `Chunk`, such as the text string. The maximum number of tokens per chunk is 2043.", + "$ref": "ChunkData" + } + }, + "id": "Chunk" + }, + "GenerationConfig": { + "properties": { + "topP": { + "format": "float", + "description": "Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Tokens are sorted based on their assigned probabilities so that only the most likely tokens are considered. Top-k sampling directly limits the maximum number of tokens to consider, while Nucleus sampling limits number of tokens based on the cumulative probability. Note: The default value varies by model, see the `Model.top_p` attribute of the `Model` returned from the `getModel` function.", + "type": "number" }, - "topK": { + "stopSequences": { + "description": "Optional. The set of character sequences (up to 5) that will stop output generation. If specified, the API will stop at the first appearance of a stop sequence. The stop sequence will not be included as part of the response.", + "items": { + "type": "string" + }, + "type": "array" + }, + "temperature": { + "description": "Optional. Controls the randomness of the output. Note: The default value varies by model, see the `Model.temperature` attribute of the `Model` returned from the `getModel` function. Values can range from [0.0, 2.0].", + "type": "number", + "format": "float" + }, + "candidateCount": { "format": "int32", "type": "integer", - "description": "For Top-k sampling. Top-k sampling considers the set of `top_k` most probable tokens. This value specifies default to be used by the backend while making the call to the model. If empty, indicates the model doesn't use top-k sampling, and `top_k` isn't allowed as a generation parameter." + "description": "Optional. Number of generated responses to return. Currently, this value can only be set to 1. If unset, this will default to 1." }, - "version": { - "description": "Required. The version number of the model. This represents the major version", - "type": "string" + "maxOutputTokens": { + "type": "integer", + "description": "Optional. The maximum number of tokens to include in a candidate. Note: The default value varies by model, see the `Model.output_token_limit` attribute of the `Model` returned from the `getModel` function.", + "format": "int32" }, - "name": { + "responseMimeType": { "type": "string", - "description": "Required. The resource name of the `Model`. Format: `models/{model}` with a `{model}` naming convention of: * \"{base_model_id}-{version}\" Examples: * `models/chat-bison-001`" + "description": "Optional. Output response mimetype of the generated candidate text. Supported mimetype: `text/plain`: (default) Text output. `application/json`: JSON response in the candidates." + }, + "responseSchema": { + "$ref": "Schema", + "description": "Optional. Output response schema of the generated candidate text when response mime type can have schema. Schema can be objects, primitives or arrays and is a subset of [OpenAPI schema](https://spec.openapis.org/oas/v3.0.3#schema). If set, a compatible response_mime_type must also be set. Compatible mimetypes: `application/json`: Schema for JSON response." + }, + "topK": { + "description": "Optional. The maximum number of tokens to consider when sampling. Models use nucleus sampling or combined Top-k and nucleus sampling. Top-k sampling considers the set of `top_k` most probable tokens. Models running with nucleus sampling don't allow top_k setting. Note: The default value varies by model, see the `Model.top_k` attribute of the `Model` returned from the `getModel` function. Empty `top_k` field in `Model` indicates the model doesn't apply top-k sampling and doesn't allow setting `top_k` on requests.", + "type": "integer", + "format": "int32" } }, - "description": "Information about a Generative Language Model.", - "id": "Model" - }, - "Schema": { "type": "object", + "description": "Configuration options for model generation and outputs. Not all parameters may be configurable for every model.", + "id": "GenerationConfig" + }, + "MetadataFilter": { "properties": { - "type": { - "type": "string", - "enum": [ - "TYPE_UNSPECIFIED", - "STRING", - "NUMBER", - "INTEGER", - "BOOLEAN", - "ARRAY", - "OBJECT" - ], - "enumDescriptions": [ - "Not specified, should not be used.", - "String type.", - "Number type.", - "Integer type.", - "Boolean type.", - "Array type.", - "Object type." - ], - "description": "Required. Data type." - }, - "format": { - "description": "Optional. The format of the data. This is used only for primitive datatypes. Supported formats: for NUMBER type: float, double for INTEGER type: int32, int64", - "type": "string" - }, - "properties": { - "description": "Optional. Properties of Type.OBJECT.", - "additionalProperties": { - "$ref": "Schema" - }, - "type": "object" - }, - "enum": { - "description": "Optional. Possible values of the element of Type.STRING with enum format. For example we can define an Enum Direction as : {type:STRING, format:enum, enum:[\"EAST\", NORTH\", \"SOUTH\", \"WEST\"]}", + "conditions": { "items": { - "type": "string" + "$ref": "Condition" }, + "description": "Required. The `Condition`s for the given key that will trigger this filter. Multiple `Condition`s are joined by logical ORs.", "type": "array" }, - "description": { + "key": { + "description": "Required. The key of the metadata to filter on.", + "type": "string" + } + }, + "id": "MetadataFilter", + "description": "User provided filter to limit retrieval based on `Chunk` or `Document` level metadata values. Example (genre = drama OR genre = action): key = \"document.custom_metadata.genre\" conditions = [{string_value = \"drama\", operation = EQUAL}, {string_value = \"action\", operation = EQUAL}]", + "type": "object" + }, + "SemanticRetrieverConfig": { + "properties": { + "source": { "type": "string", - "description": "Optional. A brief description of the parameter. This could contain examples of use. Parameter description may be formatted as Markdown." - }, - "items": { - "description": "Optional. Schema of the elements of Type.ARRAY.", - "$ref": "Schema" + "description": "Required. Name of the resource for retrieval, e.g. corpora/123 or corpora/123/documents/abc." }, - "nullable": { - "description": "Optional. Indicates if the value may be null.", - "type": "boolean" + "maxChunksCount": { + "format": "int32", + "type": "integer", + "description": "Optional. Maximum number of relevant `Chunk`s to retrieve." }, - "required": { - "description": "Optional. Required properties of Type.OBJECT.", + "metadataFilters": { "type": "array", + "description": "Optional. Filters for selecting `Document`s and/or `Chunk`s from the resource.", "items": { - "type": "string" + "$ref": "MetadataFilter" } + }, + "query": { + "$ref": "Content", + "description": "Required. Query to use for similarity matching `Chunk`s in the given resource." + }, + "minimumRelevanceScore": { + "format": "float", + "description": "Optional. Minimum relevance score for retrieved relevant `Chunk`s.", + "type": "number" } }, - "id": "Schema", - "description": "The `Schema` object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. Represents a select subset of an [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema)." + "id": "SemanticRetrieverConfig", + "description": "Configuration for retrieving grounding content from a `Corpus` or `Document` created using the Semantic Retriever API.", + "type": "object" }, - "QueryDocumentResponse": { + "Embedding": { + "description": "A list of floats representing the embedding.", "properties": { - "relevantChunks": { + "value": { "items": { - "$ref": "RelevantChunk" + "type": "number", + "format": "float" }, - "description": "The returned relevant chunks.", + "description": "The embedding values.", "type": "array" } }, - "description": "Response from `QueryDocument` containing a list of relevant chunks.", - "type": "object", - "id": "QueryDocumentResponse" + "id": "Embedding", + "type": "object" }, - "DeleteChunkRequest": { + "Content": { "properties": { - "name": { + "role": { "type": "string", - "description": "Required. The resource name of the `Chunk` to delete. Example: `corpora/my-corpus-123/documents/the-doc-abc/chunks/some-chunk`" + "description": "Optional. The producer of the content. Must be either 'user' or 'model'. Useful to set for multi-turn conversations, otherwise can be left blank or unset." + }, + "parts": { + "description": "Ordered `Parts` that constitute a single message. Parts may have different MIME types.", + "type": "array", + "items": { + "$ref": "Part" + } } }, + "description": "The base structured datatype containing multi-part content of a message. A `Content` includes a `role` field designating the producer of the `Content` and a `parts` field containing multi-part data that contains the content of the message turn.", "type": "object", - "description": "Request to delete a `Chunk`.", - "id": "DeleteChunkRequest" + "id": "Content" }, - "CreateFileRequest": { + "EmbedContentResponse": { + "type": "object", "properties": { - "file": { - "description": "Optional. Metadata for the file to create.", - "$ref": "File" + "embedding": { + "$ref": "ContentEmbedding", + "description": "Output only. The embedding generated from the input content.", + "readOnly": true } }, - "id": "CreateFileRequest", + "description": "The response to an `EmbedContentRequest`.", + "id": "EmbedContentResponse" + }, + "FunctionResponse": { "type": "object", - "description": "Request for `CreateFile`." + "properties": { + "response": { + "additionalProperties": { + "description": "Properties of the object.", + "type": "any" + }, + "description": "Required. The function response in JSON object format.", + "type": "object" + }, + "name": { + "description": "Required. The name of the function to call. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 63.", + "type": "string" + } + }, + "id": "FunctionResponse", + "description": "The result output from a `FunctionCall` that contains a string representing the `FunctionDeclaration.name` and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a`FunctionCall` made based on model prediction." }, - "TransferOwnershipRequest": { + "BatchCreateChunksResponse": { + "type": "object", "properties": { - "emailAddress": { - "type": "string", - "description": "Required. The email address of the user to whom the tuned model is being transferred to." + "chunks": { + "type": "array", + "description": "`Chunk`s created.", + "items": { + "$ref": "Chunk" + } } }, - "id": "TransferOwnershipRequest", - "description": "Request to transfer the ownership of the tuned model.", - "type": "object" + "id": "BatchCreateChunksResponse", + "description": "Response from `BatchCreateChunks` containing a list of created `Chunk`s." }, - "Candidate": { - "id": "Candidate", - "description": "A response candidate generated from the model.", + "GenerateMessageResponse": { + "description": "The response from the model. This includes candidate messages and conversation history in the form of chronologically-ordered messages.", "properties": { - "index": { - "type": "integer", - "format": "int32", - "description": "Output only. Index of the candidate in the list of candidates.", - "readOnly": true - }, - "citationMetadata": { - "readOnly": true, - "$ref": "CitationMetadata", - "description": "Output only. Citation information for model-generated candidate. This field may be populated with recitation information for any text included in the `content`. These are passages that are \"recited\" from copyrighted material in the foundational LLM's training data." - }, - "groundingAttributions": { + "candidates": { "type": "array", - "description": "Output only. Attribution information for sources that contributed to a grounded answer. This field is populated for `GenerateAnswer` calls.", - "readOnly": true, + "description": "Candidate response messages from the model.", "items": { - "$ref": "GroundingAttribution" + "$ref": "Message" } }, - "content": { - "$ref": "Content", - "readOnly": true, - "description": "Output only. Generated content returned from the model." + "filters": { + "items": { + "$ref": "ContentFilter" + }, + "type": "array", + "description": "A set of content filtering metadata for the prompt and response text. This indicates which `SafetyCategory`(s) blocked a candidate from this response, the lowest `HarmProbability` that triggered a block, and the HarmThreshold setting for that category." }, - "finishReason": { - "type": "string", - "description": "Optional. Output only. The reason why the model stopped generating tokens. If empty, the model has not stopped generating the tokens.", - "enum": [ - "FINISH_REASON_UNSPECIFIED", - "STOP", - "MAX_TOKENS", - "SAFETY", - "RECITATION", - "OTHER" - ], - "enumDescriptions": [ - "Default value. This value is unused.", - "Natural stop point of the model or provided stop sequence.", - "The maximum number of tokens as specified in the request was reached.", - "The candidate content was flagged for safety reasons.", - "The candidate content was flagged for recitation reasons.", - "Unknown reason." - ], - "readOnly": true - }, - "safetyRatings": { + "messages": { + "type": "array", + "description": "The conversation history used by the model.", "items": { - "$ref": "SafetyRating" - }, - "description": "List of ratings for the safety of a response candidate. There is at most one rating per category.", - "type": "array" - }, - "tokenCount": { - "format": "int32", - "description": "Output only. Token count for this candidate.", - "type": "integer", - "readOnly": true + "$ref": "Message" + } } }, + "id": "GenerateMessageResponse", "type": "object" }, - "BatchEmbedContentsResponse": { - "id": "BatchEmbedContentsResponse", - "type": "object", + "TextCompletion": { + "description": "Output text returned from a model.", "properties": { - "embeddings": { + "output": { "readOnly": true, - "items": { - "$ref": "ContentEmbedding" - }, - "type": "array", - "description": "Output only. The embeddings for each request, in the same order as provided in the batch request." - } - }, - "description": "The response to a `BatchEmbedContentsRequest`." - }, - "GenerateAnswerResponse": { - "description": "Response from the model for a grounded answer.", - "type": "object", - "properties": { - "answer": { - "description": "Candidate answer from the model. Note: The model *always* attempts to provide a grounded answer, even when the answer is unlikely to be answerable from the given passages. In that case, a low-quality or ungrounded answer may be provided, along with a low `answerable_probability`.", - "$ref": "Candidate" + "description": "Output only. The generated text returned from the model.", + "type": "string" }, - "answerableProbability": { - "description": "Output only. The model's estimate of the probability that its answer is correct and grounded in the input passages. A low answerable_probability indicates that the answer might not be grounded in the sources. When `answerable_probability` is low, some clients may wish to: * Display a message to the effect of \"We couldn’t answer that question\" to the user. * Fall back to a general-purpose LLM that answers the question from world knowledge. The threshold and nature of such fallbacks will depend on individual clients’ use cases. 0.5 is a good starting threshold.", - "type": "number", + "citationMetadata": { "readOnly": true, - "format": "float" + "description": "Output only. Citation information for model-generated `output` in this `TextCompletion`. This field may be populated with attribution information for any text included in the `output`.", + "$ref": "CitationMetadata" }, - "inputFeedback": { - "readOnly": true, - "$ref": "InputFeedback", - "description": "Output only. Feedback related to the input data used to answer the question, as opposed to model-generated response to the question. \"Input data\" can be one or more of the following: - Question specified by the last entry in `GenerateAnswerRequest.content` - Conversation history specified by the other entries in `GenerateAnswerRequest.content` - Grounding sources (`GenerateAnswerRequest.semantic_retriever` or `GenerateAnswerRequest.inline_passages`)" + "safetyRatings": { + "description": "Ratings for the safety of a response. There is at most one rating per category.", + "type": "array", + "items": { + "$ref": "SafetyRating" + } } }, - "id": "GenerateAnswerResponse" + "id": "TextCompletion", + "type": "object" }, - "GenerateTextRequest": { - "description": "Request to generate a text completion response from the model.", + "DeleteChunkRequest": { + "id": "DeleteChunkRequest", "properties": { - "topK": { - "description": "Optional. The maximum number of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Top-k sampling considers the set of `top_k` most probable tokens. Defaults to 40. Note: The default value varies by model, see the `Model.top_k` attribute of the `Model` returned the `getModel` function.", - "format": "int32", - "type": "integer" - }, - "temperature": { - "format": "float", - "type": "number", - "description": "Optional. Controls the randomness of the output. Note: The default value varies by model, see the `Model.temperature` attribute of the `Model` returned the `getModel` function. Values can range from [0.0,1.0], inclusive. A value closer to 1.0 will produce responses that are more varied and creative, while a value closer to 0.0 will typically result in more straightforward responses from the model." - }, - "candidateCount": { - "type": "integer", - "description": "Optional. Number of generated responses to return. This value must be between [1, 8], inclusive. If unset, this will default to 1.", - "format": "int32" - }, - "maxOutputTokens": { - "format": "int32", - "description": "Optional. The maximum number of tokens to include in a candidate. If unset, this will default to output_token_limit specified in the `Model` specification.", - "type": "integer" - }, - "prompt": { - "$ref": "TextPrompt", - "description": "Required. The free-form input text given to the model as a prompt. Given a prompt, the model will generate a TextCompletion response it predicts as the completion of the input text." - }, - "stopSequences": { - "items": { - "type": "string" - }, - "type": "array", - "description": "The set of character sequences (up to 5) that will stop output generation. If specified, the API will stop at the first appearance of a stop sequence. The stop sequence will not be included as part of the response." - }, - "safetySettings": { - "items": { - "$ref": "SafetySetting" - }, - "description": "Optional. A list of unique `SafetySetting` instances for blocking unsafe content. that will be enforced on the `GenerateTextRequest.prompt` and `GenerateTextResponse.candidates`. There should not be more than one setting for each `SafetyCategory` type. The API will block any prompts and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each `SafetyCategory` specified in the safety_settings. If there is no `SafetySetting` for a given `SafetyCategory` provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_DEROGATORY, HARM_CATEGORY_TOXICITY, HARM_CATEGORY_VIOLENCE, HARM_CATEGORY_SEXUAL, HARM_CATEGORY_MEDICAL, HARM_CATEGORY_DANGEROUS are supported in text service.", - "type": "array" - }, - "topP": { - "format": "float", - "description": "Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Tokens are sorted based on their assigned probabilities so that only the most likely tokens are considered. Top-k sampling directly limits the maximum number of tokens to consider, while Nucleus sampling limits number of tokens based on the cumulative probability. Note: The default value varies by model, see the `Model.top_p` attribute of the `Model` returned the `getModel` function.", - "type": "number" + "name": { + "type": "string", + "description": "Required. The resource name of the `Chunk` to delete. Example: `corpora/my-corpus-123/documents/the-doc-abc/chunks/some-chunk`" } }, "type": "object", - "id": "GenerateTextRequest" + "description": "Request to delete a `Chunk`." }, - "BatchDeleteChunksRequest": { - "type": "object", - "id": "BatchDeleteChunksRequest", + "CustomMetadata": { + "description": "User provided metadata stored as key-value pairs.", + "id": "CustomMetadata", "properties": { - "requests": { - "items": { - "$ref": "DeleteChunkRequest" - }, - "description": "Required. The request messages specifying the `Chunk`s to delete.", - "type": "array" + "stringListValue": { + "$ref": "StringList", + "description": "The StringList value of the metadata to store." + }, + "stringValue": { + "description": "The string value of the metadata to store.", + "type": "string" + }, + "numericValue": { + "type": "number", + "description": "The numeric value of the metadata to store.", + "format": "float" + }, + "key": { + "description": "Required. The key of the metadata to store.", + "type": "string" } }, - "description": "Request to batch delete `Chunk`s." + "type": "object" }, "GroundingPassage": { - "description": "Passage included inline with a grounding configuration.", - "type": "object", "properties": { "id": { "description": "Identifier for the passage for attributing this passage in grounded answers.", @@ -1882,1536 +1576,1634 @@ "$ref": "Content" } }, - "id": "GroundingPassage" - }, - "BatchUpdateChunksResponse": { - "id": "BatchUpdateChunksResponse", - "properties": { - "chunks": { - "type": "array", - "description": "`Chunk`s updated.", - "items": { - "$ref": "Chunk" - } - } - }, - "type": "object", - "description": "Response from `BatchUpdateChunks` containing a list of updated `Chunk`s." + "description": "Passage included inline with a grounding configuration.", + "id": "GroundingPassage", + "type": "object" }, - "CountTokensRequest": { - "id": "CountTokensRequest", - "description": "Counts the number of tokens in the `prompt` sent to a model. Models may tokenize text differently, so each model may return a different `token_count`.", - "type": "object", + "GenerateTextResponse": { + "id": "GenerateTextResponse", "properties": { - "contents": { - "description": "Optional. The input given to the model as a prompt. This field is ignored when `generate_content_request` is set.", + "filters": { + "description": "A set of content filtering metadata for the prompt and response text. This indicates which `SafetyCategory`(s) blocked a candidate from this response, the lowest `HarmProbability` that triggered a block, and the HarmThreshold setting for that category. This indicates the smallest change to the `SafetySettings` that would be necessary to unblock at least 1 response. The blocking is configured by the `SafetySettings` in the request (or the default `SafetySettings` of the API).", "items": { - "$ref": "Content" + "$ref": "ContentFilter" }, "type": "array" }, - "generateContentRequest": { - "description": "Optional. The overall input given to the model. CountTokens will count prompt, function calling, etc.", - "$ref": "GenerateContentRequest" - } - } - }, - "ListChunksResponse": { - "properties": { - "nextPageToken": { - "description": "A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages.", - "type": "string" + "candidates": { + "items": { + "$ref": "TextCompletion" + }, + "description": "Candidate responses from the model.", + "type": "array" }, - "chunks": { - "type": "array", - "description": "The returned `Chunk`s.", + "safetyFeedback": { "items": { - "$ref": "Chunk" - } + "$ref": "SafetyFeedback" + }, + "description": "Returns any safety feedback related to content filtering.", + "type": "array" } }, "type": "object", - "id": "ListChunksResponse", - "description": "Response from `ListChunks` containing a paginated list of `Chunk`s. The `Chunk`s are sorted by ascending `chunk.create_time`." + "description": "The response from the model, including candidate completions." }, - "ListCorporaResponse": { - "id": "ListCorporaResponse", + "Blob": { "type": "object", + "id": "Blob", + "description": "Raw media bytes. Text should not be sent as raw bytes, use the 'text' field.", "properties": { - "corpora": { - "description": "The returned corpora.", - "items": { - "$ref": "Corpus" - }, - "type": "array" + "mimeType": { + "description": "The IANA standard MIME type of the source data. Examples: - image/png - image/jpeg If an unsupported MIME type is provided, an error will be returned. For a complete list of supported types, see [Supported file formats](https://ai.google.dev/gemini-api/docs/prompting_with_media#supported_file_formats).", + "type": "string" }, - "nextPageToken": { + "data": { + "description": "Raw bytes for media formats.", "type": "string", - "description": "A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages." + "format": "byte" } - }, - "description": "Response from `ListCorpora` containing a paginated list of `Corpora`. The results are sorted by ascending `corpus.create_time`." + } }, - "Empty": { + "File": { "type": "object", - "properties": {}, - "description": "A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }", - "id": "Empty" - }, - "SemanticRetrieverConfig": { - "description": "Configuration for retrieving grounding content from a `Corpus` or `Document` created using the Semantic Retriever API.", "properties": { - "query": { - "description": "Required. Query to use for similarity matching `Chunk`s in the given resource.", - "$ref": "Content" + "sizeBytes": { + "description": "Output only. Size of the file in bytes.", + "readOnly": true, + "format": "int64", + "type": "string" }, - "maxChunksCount": { - "type": "integer", - "description": "Optional. Maximum number of relevant `Chunk`s to retrieve.", - "format": "int32" + "sha256Hash": { + "readOnly": true, + "format": "byte", + "type": "string", + "description": "Output only. SHA-256 hash of the uploaded bytes." }, - "source": { - "description": "Required. Name of the resource for retrieval, e.g. corpora/123 or corpora/123/documents/abc.", + "expirationTime": { + "description": "Output only. The timestamp of when the `File` will be deleted. Only set if the `File` is scheduled to expire.", + "format": "google-datetime", + "readOnly": true, "type": "string" }, - "metadataFilters": { - "items": { - "$ref": "MetadataFilter" - }, - "description": "Optional. Filters for selecting `Document`s and/or `Chunk`s from the resource.", - "type": "array" + "createTime": { + "format": "google-datetime", + "type": "string", + "readOnly": true, + "description": "Output only. The timestamp of when the `File` was created." }, - "minimumRelevanceScore": { - "description": "Optional. Minimum relevance score for retrieved relevant `Chunk`s.", - "type": "number", - "format": "float" - } - }, - "type": "object", - "id": "SemanticRetrieverConfig" - }, - "EmbedContentRequest": { - "id": "EmbedContentRequest", - "type": "object", - "properties": { - "content": { - "description": "Required. The content to embed. Only the `parts.text` fields will be counted.", - "$ref": "Content" + "updateTime": { + "description": "Output only. The timestamp of when the `File` was last updated.", + "type": "string", + "format": "google-datetime", + "readOnly": true }, - "title": { - "description": "Optional. An optional title for the text. Only applicable when TaskType is `RETRIEVAL_DOCUMENT`. Note: Specifying a `title` for `RETRIEVAL_DOCUMENT` provides better quality embeddings for retrieval.", + "displayName": { + "description": "Optional. The human-readable display name for the `File`. The display name must be no more than 512 characters in length, including spaces. Example: \"Welcome Image\"", "type": "string" }, - "taskType": { + "error": { + "readOnly": true, + "$ref": "Status", + "description": "Output only. Error status if File processing failed." + }, + "uri": { + "description": "Output only. The uri of the `File`.", "type": "string", - "enum": [ - "TASK_TYPE_UNSPECIFIED", - "RETRIEVAL_QUERY", - "RETRIEVAL_DOCUMENT", - "SEMANTIC_SIMILARITY", - "CLASSIFICATION", - "CLUSTERING", - "QUESTION_ANSWERING", - "FACT_VERIFICATION" - ], - "description": "Optional. Optional task type for which the embeddings will be used. Can only be set for `models/embedding-001`.", - "enumDescriptions": [ - "Unset value, which will default to one of the other enum values.", - "Specifies the given text is a query in a search/retrieval setting.", - "Specifies the given text is a document from the corpus being searched.", - "Specifies the given text will be used for STS.", - "Specifies that the given text will be classified.", - "Specifies that the embeddings will be used for clustering.", - "Specifies that the given text will be used for question answering.", - "Specifies that the given text will be used for fact verification." - ] + "readOnly": true }, - "outputDimensionality": { - "format": "int32", - "description": "Optional. Optional reduced dimension for the output embedding. If set, excessive values in the output embedding are truncated from the end. Supported by newer models since 2024, and the earlier model (`models/embedding-001`) cannot specify this value.", - "type": "integer" + "mimeType": { + "readOnly": true, + "description": "Output only. MIME type of the file.", + "type": "string" }, - "model": { + "videoMetadata": { + "readOnly": true, + "description": "Output only. Metadata for a video.", + "$ref": "VideoMetadata" + }, + "name": { "type": "string", - "description": "Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`" + "description": "Immutable. Identifier. The `File` resource name. The ID (name excluding the \"files/\" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be generated. Example: `files/123-456`" + }, + "state": { + "enumDescriptions": [ + "The default value. This value is used if the state is omitted.", + "File is being processed and cannot be used for inference yet.", + "File is processed and available for inference.", + "File failed processing." + ], + "enum": [ + "STATE_UNSPECIFIED", + "PROCESSING", + "ACTIVE", + "FAILED" + ], + "readOnly": true, + "description": "Output only. Processing state of the File.", + "type": "string" } }, - "description": "Request containing the `Content` for the model to embed." + "description": "A file uploaded to the API.", + "id": "File" }, - "BatchCreateChunksRequest": { - "type": "object", - "id": "BatchCreateChunksRequest", + "GenerateTextRequest": { "properties": { - "requests": { - "type": "array", + "topP": { + "format": "float", + "description": "Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Tokens are sorted based on their assigned probabilities so that only the most likely tokens are considered. Top-k sampling directly limits the maximum number of tokens to consider, while Nucleus sampling limits number of tokens based on the cumulative probability. Note: The default value varies by model, see the `Model.top_p` attribute of the `Model` returned the `getModel` function.", + "type": "number" + }, + "prompt": { + "description": "Required. The free-form input text given to the model as a prompt. Given a prompt, the model will generate a TextCompletion response it predicts as the completion of the input text.", + "$ref": "TextPrompt" + }, + "topK": { + "type": "integer", + "format": "int32", + "description": "Optional. The maximum number of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Top-k sampling considers the set of `top_k` most probable tokens. Defaults to 40. Note: The default value varies by model, see the `Model.top_k` attribute of the `Model` returned the `getModel` function." + }, + "maxOutputTokens": { + "format": "int32", + "description": "Optional. The maximum number of tokens to include in a candidate. If unset, this will default to output_token_limit specified in the `Model` specification.", + "type": "integer" + }, + "candidateCount": { + "description": "Optional. Number of generated responses to return. This value must be between [1, 8], inclusive. If unset, this will default to 1.", + "type": "integer", + "format": "int32" + }, + "temperature": { + "type": "number", + "description": "Optional. Controls the randomness of the output. Note: The default value varies by model, see the `Model.temperature` attribute of the `Model` returned the `getModel` function. Values can range from [0.0,1.0], inclusive. A value closer to 1.0 will produce responses that are more varied and creative, while a value closer to 0.0 will typically result in more straightforward responses from the model.", + "format": "float" + }, + "safetySettings": { + "description": "Optional. A list of unique `SafetySetting` instances for blocking unsafe content. that will be enforced on the `GenerateTextRequest.prompt` and `GenerateTextResponse.candidates`. There should not be more than one setting for each `SafetyCategory` type. The API will block any prompts and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each `SafetyCategory` specified in the safety_settings. If there is no `SafetySetting` for a given `SafetyCategory` provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_DEROGATORY, HARM_CATEGORY_TOXICITY, HARM_CATEGORY_VIOLENCE, HARM_CATEGORY_SEXUAL, HARM_CATEGORY_MEDICAL, HARM_CATEGORY_DANGEROUS are supported in text service.", "items": { - "$ref": "CreateChunkRequest" + "$ref": "SafetySetting" }, - "description": "Required. The request messages specifying the `Chunk`s to create. A maximum of 100 `Chunk`s can be created in a batch." + "type": "array" + }, + "stopSequences": { + "type": "array", + "description": "The set of character sequences (up to 5) that will stop output generation. If specified, the API will stop at the first appearance of a stop sequence. The stop sequence will not be included as part of the response.", + "items": { + "type": "string" + } } }, - "description": "Request to batch create `Chunk`s." + "type": "object", + "id": "GenerateTextRequest", + "description": "Request to generate a text completion response from the model." }, - "TuningExample": { - "description": "A single example for tuning.", + "Hyperparameters": { + "id": "Hyperparameters", "properties": { - "output": { - "type": "string", - "description": "Required. The expected model output." + "epochCount": { + "description": "Immutable. The number of training epochs. An epoch is one pass through the training data. If not set, a default of 5 will be used.", + "format": "int32", + "type": "integer" }, - "textInput": { - "type": "string", - "description": "Optional. Text model input." + "learningRate": { + "type": "number", + "format": "float", + "description": "Optional. Immutable. The learning rate hyperparameter for tuning. If not set, a default of 0.001 or 0.0002 will be calculated based on the number of training examples." + }, + "batchSize": { + "description": "Immutable. The batch size hyperparameter for tuning. If not set, a default of 4 or 16 will be used based on the number of training examples.", + "format": "int32", + "type": "integer" + }, + "learningRateMultiplier": { + "description": "Optional. Immutable. The learning rate multiplier is used to calculate a final learning_rate based on the default (recommended) value. Actual learning rate := learning_rate_multiplier * default learning rate Default learning rate is dependent on base model and dataset size. If not set, a default of 1.0 will be used.", + "format": "float", + "type": "number" } }, "type": "object", - "id": "TuningExample" - }, - "CitationMetadata": { - "id": "CitationMetadata", - "description": "A collection of source attributions for a piece of content.", - "type": "object", - "properties": { - "citationSources": { - "items": { - "$ref": "CitationSource" - }, - "description": "Citations to sources for a specific response.", - "type": "array" - } - } + "description": "Hyperparameters controlling the tuning process. Read more at https://ai.google.dev/docs/model_tuning_guidance" }, - "GenerateContentResponse": { + "GenerateAnswerResponse": { + "id": "GenerateAnswerResponse", "properties": { - "usageMetadata": { + "answerableProbability": { + "description": "Output only. The model's estimate of the probability that its answer is correct and grounded in the input passages. A low answerable_probability indicates that the answer might not be grounded in the sources. When `answerable_probability` is low, some clients may wish to: * Display a message to the effect of \"We couldn’t answer that question\" to the user. * Fall back to a general-purpose LLM that answers the question from world knowledge. The threshold and nature of such fallbacks will depend on individual clients’ use cases. 0.5 is a good starting threshold.", + "type": "number", "readOnly": true, - "$ref": "UsageMetadata", - "description": "Output only. Metadata on the generation requests' token usage." + "format": "float" }, - "candidates": { - "type": "array", - "items": { - "$ref": "Candidate" - }, - "description": "Candidate responses from the model." + "inputFeedback": { + "description": "Output only. Feedback related to the input data used to answer the question, as opposed to model-generated response to the question. \"Input data\" can be one or more of the following: - Question specified by the last entry in `GenerateAnswerRequest.content` - Conversation history specified by the other entries in `GenerateAnswerRequest.content` - Grounding sources (`GenerateAnswerRequest.semantic_retriever` or `GenerateAnswerRequest.inline_passages`)", + "readOnly": true, + "$ref": "InputFeedback" }, - "promptFeedback": { - "$ref": "PromptFeedback", - "description": "Returns the prompt's feedback related to the content filters." + "answer": { + "description": "Candidate answer from the model. Note: The model *always* attempts to provide a grounded answer, even when the answer is unlikely to be answerable from the given passages. In that case, a low-quality or ungrounded answer may be provided, along with a low `answerable_probability`.", + "$ref": "Candidate" } }, - "description": "Response from the model supporting multiple candidates. Note on safety ratings and content filtering. They are reported for both prompt in `GenerateContentResponse.prompt_feedback` and for each candidate in `finish_reason` and in `safety_ratings`. The API contract is that: - either all requested candidates are returned or no candidates at all - no candidates are returned only if there was something wrong with the prompt (see `prompt_feedback`) - feedback on each candidate is reported on `finish_reason` and `safety_ratings`.", - "id": "GenerateContentResponse", + "description": "Response from the model for a grounded answer.", "type": "object" }, - "GroundingPassages": { - "description": "A repeated list of passages.", - "id": "GroundingPassages", + "Message": { + "description": "The base unit of structured text. A `Message` includes an `author` and the `content` of the `Message`. The `author` is used to tag messages when they are fed to the model as text.", + "id": "Message", "type": "object", "properties": { - "passages": { - "type": "array", - "description": "List of passages.", - "items": { - "$ref": "GroundingPassage" - } + "citationMetadata": { + "readOnly": true, + "description": "Output only. Citation information for model-generated `content` in this `Message`. If this `Message` was generated as output from the model, this field may be populated with attribution information for any text included in the `content`. This field is used only on output.", + "$ref": "CitationMetadata" + }, + "content": { + "type": "string", + "description": "Required. The text content of the structured `Message`." + }, + "author": { + "description": "Optional. The author of this Message. This serves as a key for tagging the content of this Message when it is fed to the model as text. The author can be any alphanumeric string.", + "type": "string" } } }, - "BatchCreateChunksResponse": { - "description": "Response from `BatchCreateChunks` containing a list of created `Chunk`s.", + "AttributionSourceId": { "type": "object", + "id": "AttributionSourceId", + "description": "Identifier for the source contributing to this attribution.", "properties": { - "chunks": { - "type": "array", - "items": { - "$ref": "Chunk" - }, - "description": "`Chunk`s created." + "semanticRetrieverChunk": { + "description": "Identifier for a `Chunk` fetched via Semantic Retriever.", + "$ref": "SemanticRetrieverChunk" + }, + "groundingPassage": { + "description": "Identifier for an inline passage.", + "$ref": "GroundingPassageId" } - }, - "id": "BatchCreateChunksResponse" + } }, - "GenerationConfig": { + "UsageMetadata": { + "id": "UsageMetadata", "type": "object", "properties": { - "stopSequences": { - "description": "Optional. The set of character sequences (up to 5) that will stop output generation. If specified, the API will stop at the first appearance of a stop sequence. The stop sequence will not be included as part of the response.", - "type": "array", - "items": { - "type": "string" - } - }, - "topK": { + "promptTokenCount": { "type": "integer", "format": "int32", - "description": "Optional. The maximum number of tokens to consider when sampling. Models use nucleus sampling or combined Top-k and nucleus sampling. Top-k sampling considers the set of `top_k` most probable tokens. Models running with nucleus sampling don't allow top_k setting. Note: The default value varies by model, see the `Model.top_k` attribute of the `Model` returned from the `getModel` function. Empty `top_k` field in `Model` indicates the model doesn't apply top-k sampling and doesn't allow setting `top_k` on requests." + "description": "Number of tokens in the prompt. When cached_content is set, this is still the total effective prompt size. I.e. this includes the number of tokens in the cached content." }, - "topP": { - "description": "Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Tokens are sorted based on their assigned probabilities so that only the most likely tokens are considered. Top-k sampling directly limits the maximum number of tokens to consider, while Nucleus sampling limits number of tokens based on the cumulative probability. Note: The default value varies by model, see the `Model.top_p` attribute of the `Model` returned from the `getModel` function.", - "format": "float", - "type": "number" + "cachedContentTokenCount": { + "format": "int32", + "description": "Number of tokens in the cached part of the prompt, i.e. in the cached content.", + "type": "integer" }, - "maxOutputTokens": { - "description": "Optional. The maximum number of tokens to include in a candidate. Note: The default value varies by model, see the `Model.output_token_limit` attribute of the `Model` returned from the `getModel` function.", + "candidatesTokenCount": { + "description": "Total number of tokens across the generated candidates.", "type": "integer", "format": "int32" }, - "responseMimeType": { - "type": "string", - "description": "Optional. Output response mimetype of the generated candidate text. Supported mimetype: `text/plain`: (default) Text output. `application/json`: JSON response in the candidates." - }, - "temperature": { - "type": "number", - "description": "Optional. Controls the randomness of the output. Note: The default value varies by model, see the `Model.temperature` attribute of the `Model` returned from the `getModel` function. Values can range from [0.0, 2.0].", - "format": "float" + "totalTokenCount": { + "format": "int32", + "description": "Total token count for the generation request (prompt + candidates).", + "type": "integer" + } + }, + "description": "Metadata on the generation request's token usage." + }, + "GenerateMessageRequest": { + "properties": { + "topK": { + "format": "int32", + "type": "integer", + "description": "Optional. The maximum number of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Top-k sampling considers the set of `top_k` most probable tokens." }, "candidateCount": { - "description": "Optional. Number of generated responses to return. Currently, this value can only be set to 1. If unset, this will default to 1.", "type": "integer", - "format": "int32" + "format": "int32", + "description": "Optional. The number of generated response messages to return. This value must be between `[1, 8]`, inclusive. If unset, this will default to `1`." }, - "responseSchema": { - "description": "Optional. Output response schema of the generated candidate text when response mime type can have schema. Schema can be objects, primitives or arrays and is a subset of [OpenAPI schema](https://spec.openapis.org/oas/v3.0.3#schema). If set, a compatible response_mime_type must also be set. Compatible mimetypes: `application/json`: Schema for JSON response.", - "$ref": "Schema" - } - }, - "description": "Configuration options for model generation and outputs. Not all parameters may be configurable for every model.", - "id": "GenerationConfig" - }, - "TextPrompt": { - "description": "Text given to the model as a prompt. The Model will use this TextPrompt to Generate a text completion.", - "properties": { - "text": { - "description": "Required. The prompt text.", - "type": "string" + "temperature": { + "type": "number", + "format": "float", + "description": "Optional. Controls the randomness of the output. Values can range over `[0.0,1.0]`, inclusive. A value closer to `1.0` will produce responses that are more varied, while a value closer to `0.0` will typically result in less surprising responses from the model." + }, + "topP": { + "format": "float", + "type": "number", + "description": "Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Nucleus sampling considers the smallest set of tokens whose probability sum is at least `top_p`." + }, + "prompt": { + "description": "Required. The structured textual input given to the model as a prompt. Given a prompt, the model will return what it predicts is the next message in the discussion.", + "$ref": "MessagePrompt" } }, + "description": "Request to generate a message response from the model.", "type": "object", - "id": "TextPrompt" + "id": "GenerateMessageRequest" }, - "VideoMetadata": { + "TuningExample": { + "id": "TuningExample", "properties": { - "videoDuration": { + "output": { "type": "string", - "description": "Duration of the video.", - "format": "google-duration" + "description": "Required. The expected model output." + }, + "textInput": { + "type": "string", + "description": "Optional. Text model input." } }, - "id": "VideoMetadata", "type": "object", - "description": "Metadata for a video `File`." + "description": "A single example for tuning." }, - "Document": { + "SafetyRating": { + "id": "SafetyRating", + "description": "Safety rating for a piece of content. The safety rating contains the category of harm and the harm probability level in that category for a piece of content. Content is classified for safety across a number of harm categories and the probability of the harm classification is included here.", "type": "object", - "description": "A `Document` is a collection of `Chunk`s. A `Corpus` can have a maximum of 10,000 `Document`s.", - "id": "Document", "properties": { - "name": { + "category": { + "enum": [ + "HARM_CATEGORY_UNSPECIFIED", + "HARM_CATEGORY_DEROGATORY", + "HARM_CATEGORY_TOXICITY", + "HARM_CATEGORY_VIOLENCE", + "HARM_CATEGORY_SEXUAL", + "HARM_CATEGORY_MEDICAL", + "HARM_CATEGORY_DANGEROUS", + "HARM_CATEGORY_HARASSMENT", + "HARM_CATEGORY_HATE_SPEECH", + "HARM_CATEGORY_SEXUALLY_EXPLICIT", + "HARM_CATEGORY_DANGEROUS_CONTENT" + ], "type": "string", - "description": "Immutable. Identifier. The `Document` resource name. The ID (name excluding the \"corpora/*/documents/\" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be derived from `display_name` along with a 12 character random suffix. Example: `corpora/{corpus_id}/documents/my-awesome-doc-123a456b789c`" - }, - "updateTime": { - "format": "google-datetime", - "readOnly": true, - "description": "Output only. The Timestamp of when the `Document` was last updated.", - "type": "string" - }, - "displayName": { - "description": "Optional. The human-readable display name for the `Document`. The display name must be no more than 512 characters in length, including spaces. Example: \"Semantic Retriever Documentation\"", - "type": "string" + "description": "Required. The category for this rating.", + "enumDescriptions": [ + "Category is unspecified.", + "Negative or harmful comments targeting identity and/or protected attribute.", + "Content that is rude, disrespectful, or profane.", + "Describes scenarios depicting violence against an individual or group, or general descriptions of gore.", + "Contains references to sexual acts or other lewd content.", + "Promotes unchecked medical advice.", + "Dangerous content that promotes, facilitates, or encourages harmful acts.", + "Harasment content.", + "Hate speech and content.", + "Sexually explicit content.", + "Dangerous content." + ] }, - "createTime": { - "description": "Output only. The Timestamp of when the `Document` was created.", - "readOnly": true, - "format": "google-datetime", + "probability": { + "enumDescriptions": [ + "Probability is unspecified.", + "Content has a negligible chance of being unsafe.", + "Content has a low chance of being unsafe.", + "Content has a medium chance of being unsafe.", + "Content has a high chance of being unsafe." + ], + "description": "Required. The probability of harm for this content.", + "enum": [ + "HARM_PROBABILITY_UNSPECIFIED", + "NEGLIGIBLE", + "LOW", + "MEDIUM", + "HIGH" + ], "type": "string" }, - "customMetadata": { - "description": "Optional. User provided custom metadata stored as key-value pairs used for querying. A `Document` can have a maximum of 20 `CustomMetadata`.", - "type": "array", - "items": { - "$ref": "CustomMetadata" - } + "blocked": { + "description": "Was this content blocked because of this rating?", + "type": "boolean" } } }, - "Tool": { + "ListDocumentsResponse": { + "type": "object", + "id": "ListDocumentsResponse", "properties": { - "functionDeclarations": { + "nextPageToken": { + "description": "A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages.", + "type": "string" + }, + "documents": { + "description": "The returned `Document`s.", "items": { - "$ref": "FunctionDeclaration" + "$ref": "Document" }, - "description": "Optional. A list of `FunctionDeclarations` available to the model that can be used for function calling. The model or system does not execute the function. Instead the defined function may be returned as a FunctionCall with arguments to the client side for execution. The model may decide to call a subset of these functions by populating FunctionCall in the response. The next conversation turn may contain a FunctionResponse with the [content.role] \"function\" generation context for the next model turn.", "type": "array" } }, - "description": "Tool details that the model may use to generate response. A `Tool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model.", - "type": "object", - "id": "Tool" + "description": "Response from `ListDocuments` containing a paginated list of `Document`s. The `Document`s are sorted by ascending `document.create_time`." }, - "TextCompletion": { + "Candidate": { "properties": { - "output": { - "type": "string", - "description": "Output only. The generated text returned from the model.", - "readOnly": true - }, "citationMetadata": { - "$ref": "CitationMetadata", + "description": "Output only. Citation information for model-generated candidate. This field may be populated with recitation information for any text included in the `content`. These are passages that are \"recited\" from copyrighted material in the foundational LLM's training data.", + "readOnly": true, + "$ref": "CitationMetadata" + }, + "content": { + "readOnly": true, + "$ref": "Content", + "description": "Output only. Generated content returned from the model." + }, + "groundingAttributions": { + "items": { + "$ref": "GroundingAttribution" + }, + "readOnly": true, + "type": "array", + "description": "Output only. Attribution information for sources that contributed to a grounded answer. This field is populated for `GenerateAnswer` calls." + }, + "index": { + "description": "Output only. Index of the candidate in the list of candidates.", + "type": "integer", + "readOnly": true, + "format": "int32" + }, + "finishReason": { + "enumDescriptions": [ + "Default value. This value is unused.", + "Natural stop point of the model or provided stop sequence.", + "The maximum number of tokens as specified in the request was reached.", + "The candidate content was flagged for safety reasons.", + "The candidate content was flagged for recitation reasons.", + "Unknown reason." + ], + "enum": [ + "FINISH_REASON_UNSPECIFIED", + "STOP", + "MAX_TOKENS", + "SAFETY", + "RECITATION", + "OTHER" + ], + "readOnly": true, + "description": "Optional. Output only. The reason why the model stopped generating tokens. If empty, the model has not stopped generating the tokens.", + "type": "string" + }, + "tokenCount": { + "description": "Output only. Token count for this candidate.", + "format": "int32", "readOnly": true, - "description": "Output only. Citation information for model-generated `output` in this `TextCompletion`. This field may be populated with attribution information for any text included in the `output`." + "type": "integer" }, "safetyRatings": { "type": "array", - "description": "Ratings for the safety of a response. There is at most one rating per category.", "items": { "$ref": "SafetyRating" - } + }, + "description": "List of ratings for the safety of a response candidate. There is at most one rating per category." } }, + "id": "Candidate", "type": "object", - "description": "Output text returned from a model.", - "id": "TextCompletion" + "description": "A response candidate generated from the model." }, - "SemanticRetrieverChunk": { - "id": "SemanticRetrieverChunk", + "Status": { + "description": "The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).", "type": "object", "properties": { - "source": { - "description": "Output only. Name of the source matching the request's `SemanticRetrieverConfig.source`. Example: `corpora/123` or `corpora/123/documents/abc`", - "readOnly": true, - "type": "string" + "details": { + "items": { + "additionalProperties": { + "type": "any", + "description": "Properties of the object. Contains field @type with type URL." + }, + "type": "object" + }, + "type": "array", + "description": "A list of messages that carry the error details. There is a common set of message types for APIs to use." }, - "chunk": { - "description": "Output only. Name of the `Chunk` containing the attributed text. Example: `corpora/123/documents/abc/chunks/xyz`", - "readOnly": true, - "type": "string" + "code": { + "format": "int32", + "type": "integer", + "description": "The status code, which should be an enum value of google.rpc.Code." + }, + "message": { + "type": "string", + "description": "A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client." } }, - "description": "Identifier for a `Chunk` retrieved via Semantic Retriever specified in the `GenerateAnswerRequest` using `SemanticRetrieverConfig`." + "id": "Status" }, - "Blob": { - "type": "object", - "description": "Raw media bytes. Text should not be sent as raw bytes, use the 'text' field.", - "id": "Blob", + "CountTextTokensRequest": { + "description": "Counts the number of tokens in the `prompt` sent to a model. Models may tokenize text differently, so each model may return a different `token_count`.", + "id": "CountTextTokensRequest", "properties": { - "data": { - "format": "byte", - "type": "string", - "description": "Raw bytes for media formats." - }, - "mimeType": { - "type": "string", - "description": "The IANA standard MIME type of the source data. Examples: - image/png - image/jpeg If an unsupported MIME type is provided, an error will be returned. For a complete list of supported types, see [Supported file formats](https://ai.google.dev/gemini-api/docs/prompting_with_media#supported_file_formats)." + "prompt": { + "description": "Required. The free-form input text given to the model as a prompt.", + "$ref": "TextPrompt" } - } - }, - "TransferOwnershipResponse": { - "description": "Response from `TransferOwnership`.", - "id": "TransferOwnershipResponse", - "properties": {}, + }, "type": "object" }, - "UpdateChunkRequest": { + "Corpus": { + "type": "object", + "description": "A `Corpus` is a collection of `Document`s. A project can create up to 5 corpora.", "properties": { - "chunk": { - "description": "Required. The `Chunk` to update.", - "$ref": "Chunk" + "createTime": { + "readOnly": true, + "format": "google-datetime", + "type": "string", + "description": "Output only. The Timestamp of when the `Corpus` was created." }, - "updateMask": { - "format": "google-fieldmask", + "name": { + "type": "string", + "description": "Immutable. Identifier. The `Corpus` resource name. The ID (name excluding the \"corpora/\" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be derived from `display_name` along with a 12 character random suffix. Example: `corpora/my-awesome-corpora-123a456b789c`" + }, + "displayName": { + "type": "string", + "description": "Optional. The human-readable display name for the `Corpus`. The display name must be no more than 512 characters in length, including spaces. Example: \"Docs on Semantic Retriever\"" + }, + "updateTime": { "type": "string", - "description": "Required. The list of fields to update. Currently, this only supports updating `custom_metadata` and `data`." + "format": "google-datetime", + "readOnly": true, + "description": "Output only. The Timestamp of when the `Corpus` was last updated." } }, - "type": "object", - "id": "UpdateChunkRequest", - "description": "Request to update a `Chunk`." + "id": "Corpus" }, - "Content": { - "id": "Content", + "BatchEmbedTextRequest": { + "type": "object", + "description": "Batch request to get a text embedding from the model.", + "id": "BatchEmbedTextRequest", "properties": { - "role": { - "description": "Optional. The producer of the content. Must be either 'user' or 'model'. Useful to set for multi-turn conversations, otherwise can be left blank or unset.", - "type": "string" - }, - "parts": { + "texts": { + "description": "Optional. The free-form input texts that the model will turn into an embedding. The current limit is 100 texts, over which an error will be thrown.", "type": "array", - "description": "Ordered `Parts` that constitute a single message. Parts may have different MIME types.", "items": { - "$ref": "Part" + "type": "string" } + }, + "requests": { + "items": { + "$ref": "EmbedTextRequest" + }, + "description": "Optional. Embed requests for the batch. Only one of `texts` or `requests` can be set.", + "type": "array" + } + } + }, + "Part": { + "properties": { + "fileData": { + "$ref": "FileData", + "description": "URI based data." + }, + "inlineData": { + "$ref": "Blob", + "description": "Inline media bytes." + }, + "functionResponse": { + "description": "The result output of a `FunctionCall` that contains a string representing the `FunctionDeclaration.name` and a structured JSON object containing any output from the function is used as context to the model.", + "$ref": "FunctionResponse" + }, + "functionCall": { + "description": "A predicted `FunctionCall` returned from the model that contains a string representing the `FunctionDeclaration.name` with the arguments and their values.", + "$ref": "FunctionCall" + }, + "text": { + "description": "Inline text.", + "type": "string" } }, "type": "object", - "description": "The base structured datatype containing multi-part content of a message. A `Content` includes a `role` field designating the producer of the `Content` and a `parts` field containing multi-part data that contains the content of the message turn." + "id": "Part", + "description": "A datatype containing media that is part of a multi-part `Content` message. A `Part` consists of data which has an associated datatype. A `Part` can only contain one of the accepted types in `Part.data`. A `Part` must have a fixed IANA MIME type identifying the type and subtype of the media if the `inline_data` field is filled with raw bytes." }, - "CountMessageTokensRequest": { + "CountTokensRequest": { "properties": { - "prompt": { - "$ref": "MessagePrompt", - "description": "Required. The prompt, whose token count is to be returned." + "generateContentRequest": { + "$ref": "GenerateContentRequest", + "description": "Optional. The overall input given to the model. CountTokens will count prompt, function calling, etc." + }, + "contents": { + "description": "Optional. The input given to the model as a prompt. This field is ignored when `generate_content_request` is set.", + "type": "array", + "items": { + "$ref": "Content" + } } }, + "id": "CountTokensRequest", "description": "Counts the number of tokens in the `prompt` sent to a model. Models may tokenize text differently, so each model may return a different `token_count`.", - "id": "CountMessageTokensRequest", "type": "object" }, - "TuningSnapshot": { + "ListChunksResponse": { "type": "object", - "description": "Record for a single tuning step.", - "id": "TuningSnapshot", + "id": "ListChunksResponse", "properties": { - "epoch": { - "type": "integer", - "format": "int32", - "readOnly": true, - "description": "Output only. The epoch this step was part of." - }, - "computeTime": { - "format": "google-datetime", - "readOnly": true, - "description": "Output only. The timestamp when this metric was computed.", - "type": "string" - }, - "step": { - "readOnly": true, - "type": "integer", - "description": "Output only. The tuning step.", - "format": "int32" + "chunks": { + "items": { + "$ref": "Chunk" + }, + "type": "array", + "description": "The returned `Chunk`s." }, - "meanLoss": { - "description": "Output only. The mean loss of the training examples for this step.", - "format": "float", - "type": "number", - "readOnly": true + "nextPageToken": { + "type": "string", + "description": "A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages." } - } + }, + "description": "Response from `ListChunks` containing a paginated list of `Chunk`s. The `Chunk`s are sorted by ascending `chunk.create_time`." }, - "GenerateContentRequest": { - "id": "GenerateContentRequest", + "FunctionCallingConfig": { + "description": "Configuration for specifying function calling behavior.", + "type": "object", "properties": { - "toolConfig": { - "$ref": "ToolConfig", - "description": "Optional. Tool configuration for any `Tool` specified in the request." - }, - "generationConfig": { - "$ref": "GenerationConfig", - "description": "Optional. Configuration options for model generation and outputs." - }, - "model": { - "description": "Required. The name of the `Model` to use for generating the completion. Format: `name=models/{model}`.", - "type": "string" - }, - "contents": { - "description": "Required. The content of the current conversation with the model. For single-turn queries, this is a single instance. For multi-turn queries, this is a repeated field that contains conversation history + latest request.", - "items": { - "$ref": "Content" - }, - "type": "array" - }, - "tools": { - "type": "array", - "description": "Optional. A list of `Tools` the model may use to generate the next response. A `Tool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. The only supported tool is currently `Function`.", - "items": { - "$ref": "Tool" - } + "mode": { + "enumDescriptions": [ + "Unspecified function calling mode. This value should not be used.", + "Default model behavior, model decides to predict either a function call or a natural language response.", + "Model is constrained to always predicting a function call only. If \"allowed_function_names\" are set, the predicted function call will be limited to any one of \"allowed_function_names\", else the predicted function call will be any one of the provided \"function_declarations\".", + "Model will not predict any function call. Model behavior is same as when not passing any function declarations." + ], + "type": "string", + "enum": [ + "MODE_UNSPECIFIED", + "AUTO", + "ANY", + "NONE" + ], + "description": "Optional. Specifies the mode in which function calling should execute. If unspecified, the default value will be set to AUTO." }, - "safetySettings": { - "description": "Optional. A list of unique `SafetySetting` instances for blocking unsafe content. This will be enforced on the `GenerateContentRequest.contents` and `GenerateContentResponse.candidates`. There should not be more than one setting for each `SafetyCategory` type. The API will block any contents and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each `SafetyCategory` specified in the safety_settings. If there is no `SafetySetting` for a given `SafetyCategory` provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_HARASSMENT are supported.", + "allowedFunctionNames": { "type": "array", + "description": "Optional. A set of function names that, when provided, limits the functions the model will call. This should only be set when the Mode is ANY. Function names should match [FunctionDeclaration.name]. With mode set to ANY, model will predict a function call from the set of function names provided.", "items": { - "$ref": "SafetySetting" + "type": "string" } + } + }, + "id": "FunctionCallingConfig" + }, + "SafetyFeedback": { + "id": "SafetyFeedback", + "properties": { + "setting": { + "description": "Safety settings applied to the request.", + "$ref": "SafetySetting" }, - "systemInstruction": { - "$ref": "Content", - "description": "Optional. Developer set system instruction. Currently, text only." + "rating": { + "description": "Safety rating evaluated from content.", + "$ref": "SafetyRating" } }, "type": "object", - "description": "Request to generate a completion from the model." + "description": "Safety feedback for an entire request. This field is populated if content in the input and/or response is blocked due to safety settings. SafetyFeedback may not exist for every HarmCategory. Each SafetyFeedback will return the safety settings used by the request as well as the lowest HarmProbability that should be allowed in order to return a result." }, - "Message": { - "id": "Message", + "Example": { + "type": "object", + "id": "Example", "properties": { - "author": { - "type": "string", - "description": "Optional. The author of this Message. This serves as a key for tagging the content of this Message when it is fed to the model as text. The author can be any alphanumeric string." + "output": { + "description": "Required. An example of what the model should output given the input.", + "$ref": "Message" }, - "content": { - "type": "string", - "description": "Required. The text content of the structured `Message`." + "input": { + "$ref": "Message", + "description": "Required. An example of an input `Message` from the user." + } + }, + "description": "An input/output example used to instruct the Model. It demonstrates how the model should respond or format its response." + }, + "GroundingPassageId": { + "type": "object", + "properties": { + "partIndex": { + "type": "integer", + "readOnly": true, + "format": "int32", + "description": "Output only. Index of the part within the `GenerateAnswerRequest`'s `GroundingPassage.content`." }, - "citationMetadata": { - "$ref": "CitationMetadata", + "passageId": { "readOnly": true, - "description": "Output only. Citation information for model-generated `content` in this `Message`. If this `Message` was generated as output from the model, this field may be populated with attribution information for any text included in the `content`. This field is used only on output." + "type": "string", + "description": "Output only. ID of the passage matching the `GenerateAnswerRequest`'s `GroundingPassage.id`." } }, - "description": "The base unit of structured text. A `Message` includes an `author` and the `content` of the `Message`. The `author` is used to tag messages when they are fed to the model as text.", - "type": "object" + "description": "Identifier for a part within a `GroundingPassage`.", + "id": "GroundingPassageId" }, - "CitationSource": { + "EmbedContentRequest": { + "id": "EmbedContentRequest", + "description": "Request containing the `Content` for the model to embed.", "type": "object", "properties": { - "endIndex": { - "format": "int32", - "description": "Optional. End of the attributed segment, exclusive.", - "type": "integer" + "model": { + "type": "string", + "description": "Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`" }, - "startIndex": { + "outputDimensionality": { "type": "integer", "format": "int32", - "description": "Optional. Start of segment of the response that is attributed to this source. Index indicates the start of the segment, measured in bytes." + "description": "Optional. Optional reduced dimension for the output embedding. If set, excessive values in the output embedding are truncated from the end. Supported by newer models since 2024, and the earlier model (`models/embedding-001`) cannot specify this value." }, - "license": { - "description": "Optional. License for the GitHub project that is attributed as a source for segment. License info is required for code citations.", + "title": { + "description": "Optional. An optional title for the text. Only applicable when TaskType is `RETRIEVAL_DOCUMENT`. Note: Specifying a `title` for `RETRIEVAL_DOCUMENT` provides better quality embeddings for retrieval.", "type": "string" }, - "uri": { + "content": { + "$ref": "Content", + "description": "Required. The content to embed. Only the `parts.text` fields will be counted." + }, + "taskType": { + "enumDescriptions": [ + "Unset value, which will default to one of the other enum values.", + "Specifies the given text is a query in a search/retrieval setting.", + "Specifies the given text is a document from the corpus being searched.", + "Specifies the given text will be used for STS.", + "Specifies that the given text will be classified.", + "Specifies that the embeddings will be used for clustering.", + "Specifies that the given text will be used for question answering.", + "Specifies that the given text will be used for fact verification." + ], + "enum": [ + "TASK_TYPE_UNSPECIFIED", + "RETRIEVAL_QUERY", + "RETRIEVAL_DOCUMENT", + "SEMANTIC_SIMILARITY", + "CLASSIFICATION", + "CLUSTERING", + "QUESTION_ANSWERING", + "FACT_VERIFICATION" + ], "type": "string", - "description": "Optional. URI that is attributed as a source for a portion of the text." + "description": "Optional. Optional task type for which the embeddings will be used. Can only be set for `models/embedding-001`." } - }, - "id": "CitationSource", - "description": "A citation to a source for a portion of a specific response." - } - }, - "icons": { - "x32": "http://www.google.com/images/icons/product/search-32.gif", - "x16": "http://www.google.com/images/icons/product/search-16.gif" - }, - "kind": "discovery#restDescription", - "title": "Generative Language API", - "description": "The Gemini API allows developers to build generative AI applications using Gemini models. Gemini is our most capable model, built from the ground up to be multimodal. It can generalize and seamlessly understand, operate across, and combine different types of information including language, images, audio, video, and code. You can use the Gemini API for use cases like reasoning across text and images, content generation, dialogue agents, summarization and classification systems, and more.", - "servicePath": "", - "discoveryVersion": "v1", - "parameters": { - "quotaUser": { - "type": "string", - "location": "query", - "description": "Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters." - }, - "uploadType": { - "location": "query", - "type": "string", - "description": "Legacy upload protocol for media (e.g. \"media\", \"multipart\")." - }, - "oauth_token": { - "location": "query", - "type": "string", - "description": "OAuth 2.0 token for the current user." - }, - "fields": { - "type": "string", - "location": "query", - "description": "Selector specifying which fields to include in a partial response." - }, - "callback": { - "type": "string", - "location": "query", - "description": "JSONP" + } }, - "$.xgafv": { - "description": "V1 error format.", - "location": "query", - "enum": [ - "1", - "2" - ], - "enumDescriptions": [ - "v1 error format", - "v2 error format" - ], - "type": "string" + "GenerateAnswerRequest": { + "type": "object", + "description": "Request to generate a grounded answer from the model.", + "id": "GenerateAnswerRequest", + "properties": { + "safetySettings": { + "type": "array", + "items": { + "$ref": "SafetySetting" + }, + "description": "Optional. A list of unique `SafetySetting` instances for blocking unsafe content. This will be enforced on the `GenerateAnswerRequest.contents` and `GenerateAnswerResponse.candidate`. There should not be more than one setting for each `SafetyCategory` type. The API will block any contents and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each `SafetyCategory` specified in the safety_settings. If there is no `SafetySetting` for a given `SafetyCategory` provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_HARASSMENT are supported." + }, + "contents": { + "type": "array", + "description": "Required. The content of the current conversation with the model. For single-turn queries, this is a single question to answer. For multi-turn queries, this is a repeated field that contains conversation history and the last `Content` in the list containing the question. Note: GenerateAnswer currently only supports queries in English.", + "items": { + "$ref": "Content" + } + }, + "temperature": { + "format": "float", + "description": "Optional. Controls the randomness of the output. Values can range from [0.0,1.0], inclusive. A value closer to 1.0 will produce responses that are more varied and creative, while a value closer to 0.0 will typically result in more straightforward responses from the model. A low temperature (~0.2) is usually recommended for Attributed-Question-Answering use cases.", + "type": "number" + }, + "semanticRetriever": { + "description": "Content retrieved from resources created via the Semantic Retriever API.", + "$ref": "SemanticRetrieverConfig" + }, + "answerStyle": { + "type": "string", + "enumDescriptions": [ + "Unspecified answer style.", + "Succint but abstract style.", + "Very brief and extractive style.", + "Verbose style including extra details. The response may be formatted as a sentence, paragraph, multiple paragraphs, or bullet points, etc." + ], + "description": "Required. Style in which answers should be returned.", + "enum": [ + "ANSWER_STYLE_UNSPECIFIED", + "ABSTRACTIVE", + "EXTRACTIVE", + "VERBOSE" + ] + }, + "inlinePassages": { + "$ref": "GroundingPassages", + "description": "Passages provided inline with the request." + } + } }, - "access_token": { - "location": "query", - "description": "OAuth access token.", - "type": "string" + "ListCachedContentsResponse": { + "type": "object", + "description": "Response with CachedContents list.", + "id": "ListCachedContentsResponse", + "properties": { + "nextPageToken": { + "description": "A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.", + "type": "string" + }, + "cachedContents": { + "items": { + "$ref": "CachedContent" + }, + "type": "array", + "description": "List of cached contents." + } + } }, - "prettyPrint": { - "location": "query", - "default": "true", - "type": "boolean", - "description": "Returns response with indentations and line breaks." + "SemanticRetrieverChunk": { + "id": "SemanticRetrieverChunk", + "description": "Identifier for a `Chunk` retrieved via Semantic Retriever specified in the `GenerateAnswerRequest` using `SemanticRetrieverConfig`.", + "properties": { + "source": { + "type": "string", + "readOnly": true, + "description": "Output only. Name of the source matching the request's `SemanticRetrieverConfig.source`. Example: `corpora/123` or `corpora/123/documents/abc`" + }, + "chunk": { + "type": "string", + "description": "Output only. Name of the `Chunk` containing the attributed text. Example: `corpora/123/documents/abc/chunks/xyz`", + "readOnly": true + } + }, + "type": "object" }, - "upload_protocol": { - "type": "string", - "location": "query", - "description": "Upload protocol for media (e.g. \"raw\", \"multipart\")." + "Tool": { + "id": "Tool", + "properties": { + "functionDeclarations": { + "description": "Optional. A list of `FunctionDeclarations` available to the model that can be used for function calling. The model or system does not execute the function. Instead the defined function may be returned as a FunctionCall with arguments to the client side for execution. The model may decide to call a subset of these functions by populating FunctionCall in the response. The next conversation turn may contain a FunctionResponse with the [content.role] \"function\" generation context for the next model turn.", + "items": { + "$ref": "FunctionDeclaration" + }, + "type": "array" + } + }, + "type": "object", + "description": "Tool details that the model may use to generate response. A `Tool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model." }, - "alt": { - "enum": [ - "json", - "media", - "proto" - ], - "location": "query", - "description": "Data format for response.", - "enumDescriptions": [ - "Responses with Content-Type of application/json", - "Media download with context-dependent Content-Type", - "Responses with Content-Type of application/x-protobuf" - ], - "type": "string", - "default": "json" + "CitationSource": { + "type": "object", + "id": "CitationSource", + "properties": { + "license": { + "description": "Optional. License for the GitHub project that is attributed as a source for segment. License info is required for code citations.", + "type": "string" + }, + "uri": { + "type": "string", + "description": "Optional. URI that is attributed as a source for a portion of the text." + }, + "endIndex": { + "description": "Optional. End of the attributed segment, exclusive.", + "type": "integer", + "format": "int32" + }, + "startIndex": { + "type": "integer", + "format": "int32", + "description": "Optional. Start of segment of the response that is attributed to this source. Index indicates the start of the segment, measured in bytes." + } + }, + "description": "A citation to a source for a portion of a specific response." }, - "key": { - "description": "API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.", - "location": "query", - "type": "string" - } - }, - "batchPath": "batch", - "protocol": "rest", - "version": "v1beta", - "basePath": "", - "canonicalName": "Generative Language", - "version_module": true, - "documentationLink": "https://developers.generativeai.google/api", - "baseUrl": "https://generativelanguage.googleapis.com/", - "revision": "20240607", - "ownerDomain": "google.com", - "resources": { - "media": { - "methods": { - "upload": { - "mediaUpload": { - "accept": [ - "*/*" - ], - "protocols": { - "resumable": { - "multipart": true, - "path": "/resumable/upload/v1beta/files" - }, - "simple": { - "path": "/upload/v1beta/files", - "multipart": true - } - }, - "maxSize": "2147483648" + "BatchEmbedContentsRequest": { + "description": "Batch request to get embeddings from the model for a list of prompts.", + "properties": { + "requests": { + "type": "array", + "items": { + "$ref": "EmbedContentRequest" }, - "supportsMediaUpload": true, - "description": "Creates a `File`.", - "parameterOrder": [], - "request": { - "$ref": "CreateFileRequest" + "description": "Required. Embed requests for the batch. The model in each of these requests must match the model specified `BatchEmbedContentsRequest.model`." + } + }, + "type": "object", + "id": "BatchEmbedContentsRequest" + }, + "CountMessageTokensResponse": { + "properties": { + "tokenCount": { + "type": "integer", + "description": "The number of tokens that the `model` tokenizes the `prompt` into. Always non-negative.", + "format": "int32" + } + }, + "id": "CountMessageTokensResponse", + "description": "A response from `CountMessageTokens`. It returns the model's `token_count` for the `prompt`.", + "type": "object" + }, + "CreateChunkRequest": { + "type": "object", + "description": "Request to create a `Chunk`.", + "properties": { + "chunk": { + "$ref": "Chunk", + "description": "Required. The `Chunk` to create." + }, + "parent": { + "type": "string", + "description": "Required. The name of the `Document` where this `Chunk` will be created. Example: `corpora/my-corpus-123/documents/the-doc-abc`" + } + }, + "id": "CreateChunkRequest" + }, + "EmbedTextResponse": { + "properties": { + "embedding": { + "description": "Output only. The embedding generated from the input text.", + "readOnly": true, + "$ref": "Embedding" + } + }, + "type": "object", + "description": "The response to a EmbedTextRequest.", + "id": "EmbedTextResponse" + }, + "ContentEmbedding": { + "description": "A list of floats representing an embedding.", + "id": "ContentEmbedding", + "properties": { + "values": { + "items": { + "format": "float", + "type": "number" }, - "path": "v1beta/files", - "flatPath": "v1beta/files", - "response": { - "$ref": "CreateFileResponse" + "type": "array", + "description": "The embedding values." + } + }, + "type": "object" + }, + "ListPermissionsResponse": { + "id": "ListPermissionsResponse", + "description": "Response from `ListPermissions` containing a paginated list of permissions.", + "type": "object", + "properties": { + "nextPageToken": { + "description": "A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages.", + "type": "string" + }, + "permissions": { + "items": { + "$ref": "Permission" }, - "parameters": {}, - "httpMethod": "POST", - "id": "generativelanguage.media.upload" + "description": "Returned permissions.", + "type": "array" } } }, - "models": { - "methods": { - "embedContent": { - "parameterOrder": [ - "model" + "ContentFilter": { + "description": "Content filtering metadata associated with processing a single request. ContentFilter contains a reason and an optional supporting string. The reason may be unspecified.", + "properties": { + "reason": { + "description": "The reason content was blocked during request processing.", + "enum": [ + "BLOCKED_REASON_UNSPECIFIED", + "SAFETY", + "OTHER" ], - "flatPath": "v1beta/models/{modelsId}:embedContent", + "enumDescriptions": [ + "A blocked reason was not specified.", + "Content was blocked by safety settings.", + "Content was blocked, but the reason is uncategorized." + ], + "type": "string" + }, + "message": { + "type": "string", + "description": "A string that describes the filtering behavior in more detail." + } + }, + "type": "object", + "id": "ContentFilter" + }, + "EmbedTextRequest": { + "type": "object", + "id": "EmbedTextRequest", + "description": "Request to get a text embedding from the model.", + "properties": { + "text": { + "type": "string", + "description": "Optional. The free-form input text that the model will turn into an embedding." + }, + "model": { + "type": "string", + "description": "Required. The model name to use with the format model=models/{model}." + } + } + }, + "ToolConfig": { + "type": "object", + "properties": { + "functionCallingConfig": { + "description": "Optional. Function calling config.", + "$ref": "FunctionCallingConfig" + } + }, + "id": "ToolConfig", + "description": "The Tool configuration containing parameters for specifying `Tool` use in the request." + } + }, + "icons": { + "x16": "http://www.google.com/images/icons/product/search-16.gif", + "x32": "http://www.google.com/images/icons/product/search-32.gif" + }, + "protocol": "rest", + "name": "generativelanguage", + "parameters": { + "oauth_token": { + "location": "query", + "type": "string", + "description": "OAuth 2.0 token for the current user." + }, + "callback": { + "description": "JSONP", + "type": "string", + "location": "query" + }, + "uploadType": { + "type": "string", + "location": "query", + "description": "Legacy upload protocol for media (e.g. \"media\", \"multipart\")." + }, + "upload_protocol": { + "type": "string", + "description": "Upload protocol for media (e.g. \"raw\", \"multipart\").", + "location": "query" + }, + "alt": { + "enum": [ + "json", + "media", + "proto" + ], + "type": "string", + "default": "json", + "location": "query", + "description": "Data format for response.", + "enumDescriptions": [ + "Responses with Content-Type of application/json", + "Media download with context-dependent Content-Type", + "Responses with Content-Type of application/x-protobuf" + ] + }, + "quotaUser": { + "location": "query", + "description": "Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.", + "type": "string" + }, + "prettyPrint": { + "type": "boolean", + "default": "true", + "location": "query", + "description": "Returns response with indentations and line breaks." + }, + "$.xgafv": { + "enumDescriptions": [ + "v1 error format", + "v2 error format" + ], + "type": "string", + "enum": [ + "1", + "2" + ], + "description": "V1 error format.", + "location": "query" + }, + "access_token": { + "type": "string", + "description": "OAuth access token.", + "location": "query" + }, + "key": { + "description": "API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.", + "type": "string", + "location": "query" + }, + "fields": { + "location": "query", + "type": "string", + "description": "Selector specifying which fields to include in a partial response." + } + }, + "baseUrl": "https://generativelanguage.googleapis.com/", + "discoveryVersion": "v1", + "basePath": "", + "title": "Generative Language API", + "resources": { + "corpora": { + "methods": { + "get": { + "flatPath": "v1beta/corpora/{corporaId}", "parameters": { - "model": { + "name": { "location": "path", + "pattern": "^corpora/[^/]+$", "type": "string", - "pattern": "^models/[^/]+$", - "required": true, - "description": "Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`" + "description": "Required. The name of the `Corpus`. Example: `corpora/my-corpus-123`", + "required": true } }, - "request": { - "$ref": "EmbedContentRequest" - }, - "id": "generativelanguage.models.embedContent", + "id": "generativelanguage.corpora.get", "response": { - "$ref": "EmbedContentResponse" + "$ref": "Corpus" }, - "httpMethod": "POST", - "description": "Generates an embedding from the model given an input `Content`.", - "path": "v1beta/{+model}:embedContent" + "parameterOrder": [ + "name" + ], + "description": "Gets information about a specific `Corpus`.", + "path": "v1beta/{+name}", + "httpMethod": "GET" }, - "countTextTokens": { + "delete": { + "flatPath": "v1beta/corpora/{corporaId}", + "id": "generativelanguage.corpora.delete", + "path": "v1beta/{+name}", "parameters": { - "model": { - "description": "Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`", - "required": true, - "pattern": "^models/[^/]+$", + "force": { + "location": "query", + "description": "Optional. If set to true, any `Document`s and objects related to this `Corpus` will also be deleted. If false (the default), a `FAILED_PRECONDITION` error will be returned if `Corpus` contains any `Document`s.", + "type": "boolean" + }, + "name": { "type": "string", - "location": "path" + "location": "path", + "description": "Required. The resource name of the `Corpus`. Example: `corpora/my-corpus-123`", + "pattern": "^corpora/[^/]+$", + "required": true } }, + "description": "Deletes a `Corpus`.", + "httpMethod": "DELETE", "response": { - "$ref": "CountTextTokensResponse" - }, - "description": "Runs a model's tokenizer on a text and returns the token count.", - "httpMethod": "POST", - "request": { - "$ref": "CountTextTokensRequest" + "$ref": "Empty" }, - "flatPath": "v1beta/models/{modelsId}:countTextTokens", "parameterOrder": [ - "model" - ], - "id": "generativelanguage.models.countTextTokens", - "path": "v1beta/{+model}:countTextTokens" + "name" + ] }, - "batchEmbedText": { - "path": "v1beta/{+model}:batchEmbedText", - "httpMethod": "POST", + "patch": { "request": { - "$ref": "BatchEmbedTextRequest" + "$ref": "Corpus" }, + "flatPath": "v1beta/corpora/{corporaId}", + "id": "generativelanguage.corpora.patch", + "parameterOrder": [ + "name" + ], "parameters": { - "model": { - "pattern": "^models/[^/]+$", - "description": "Required. The name of the `Model` to use for generating the embedding. Examples: models/embedding-gecko-001", + "updateMask": { + "description": "Required. The list of fields to update. Currently, this only supports updating `display_name`.", + "format": "google-fieldmask", + "type": "string", + "location": "query" + }, + "name": { + "description": "Immutable. Identifier. The `Corpus` resource name. The ID (name excluding the \"corpora/\" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be derived from `display_name` along with a 12 character random suffix. Example: `corpora/my-awesome-corpora-123a456b789c`", "required": true, + "location": "path", "type": "string", - "location": "path" + "pattern": "^corpora/[^/]+$" } }, - "description": "Generates multiple embeddings from the model given input text in a synchronous call.", "response": { - "$ref": "BatchEmbedTextResponse" + "$ref": "Corpus" }, - "flatPath": "v1beta/models/{modelsId}:batchEmbedText", - "parameterOrder": [ - "model" - ], - "id": "generativelanguage.models.batchEmbedText" + "httpMethod": "PATCH", + "path": "v1beta/{+name}", + "description": "Updates a `Corpus`." }, - "generateAnswer": { - "description": "Generates a grounded answer from the model given an input `GenerateAnswerRequest`.", - "request": { - "$ref": "GenerateAnswerRequest" - }, + "list": { + "path": "v1beta/corpora", "parameters": { - "model": { - "pattern": "^models/[^/]+$", - "required": true, - "description": "Required. The name of the `Model` to use for generating the grounded response. Format: `model=models/{model}`.", + "pageSize": { + "format": "int32", + "description": "Optional. The maximum number of `Corpora` to return (per page). The service may return fewer `Corpora`. If unspecified, at most 10 `Corpora` will be returned. The maximum size limit is 20 `Corpora` per page.", + "type": "integer", + "location": "query" + }, + "pageToken": { + "description": "Optional. A page token, received from a previous `ListCorpora` call. Provide the `next_page_token` returned in the response as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListCorpora` must match the call that provided the page token.", "type": "string", - "location": "path" + "location": "query" } }, - "httpMethod": "POST", - "flatPath": "v1beta/models/{modelsId}:generateAnswer", + "httpMethod": "GET", + "parameterOrder": [], + "description": "Lists all `Corpora` owned by the user.", "response": { - "$ref": "GenerateAnswerResponse" + "$ref": "ListCorporaResponse" }, - "path": "v1beta/{+model}:generateAnswer", - "parameterOrder": [ - "model" - ], - "id": "generativelanguage.models.generateAnswer" + "id": "generativelanguage.corpora.list", + "flatPath": "v1beta/corpora" }, - "countTokens": { - "httpMethod": "POST", - "parameters": { - "model": { - "description": "Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`", - "location": "path", - "required": true, - "type": "string", - "pattern": "^models/[^/]+$" - } - }, - "request": { - "$ref": "CountTokensRequest" - }, - "description": "Runs a model's tokenizer on input content and returns the token count.", - "parameterOrder": [ - "model" - ], - "flatPath": "v1beta/models/{modelsId}:countTokens", - "response": { - "$ref": "CountTokensResponse" - }, - "path": "v1beta/{+model}:countTokens", - "id": "generativelanguage.models.countTokens" - }, - "countMessageTokens": { - "response": { - "$ref": "CountMessageTokensResponse" - }, - "description": "Runs a model's tokenizer on a string and returns the token count.", - "request": { - "$ref": "CountMessageTokensRequest" - }, + "create": { + "parameters": {}, + "description": "Creates an empty `Corpus`.", "httpMethod": "POST", - "flatPath": "v1beta/models/{modelsId}:countMessageTokens", - "parameters": { - "model": { - "description": "Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`", - "location": "path", - "pattern": "^models/[^/]+$", - "required": true, - "type": "string" - } - }, - "parameterOrder": [ - "model" - ], - "id": "generativelanguage.models.countMessageTokens", - "path": "v1beta/{+model}:countMessageTokens" - }, - "generateContent": { - "request": { - "$ref": "GenerateContentRequest" - }, - "flatPath": "v1beta/models/{modelsId}:generateContent", - "response": { - "$ref": "GenerateContentResponse" - }, - "description": "Generates a response from the model given an input `GenerateContentRequest`. Input capabilities differ between models, including tuned models. See the [model guide](https://ai.google.dev/models/gemini) and [tuning guide](https://ai.google.dev/docs/model_tuning_guidance) for details.", - "path": "v1beta/{+model}:generateContent", - "parameterOrder": [ - "model" - ], - "id": "generativelanguage.models.generateContent", - "parameters": { - "model": { - "required": true, - "description": "Required. The name of the `Model` to use for generating the completion. Format: `name=models/{model}`.", - "location": "path", - "type": "string", - "pattern": "^models/[^/]+$" - } - }, - "httpMethod": "POST" - }, - "get": { "response": { - "$ref": "Model" - }, - "httpMethod": "GET", - "flatPath": "v1beta/models/{modelsId}", - "path": "v1beta/{+name}", - "description": "Gets information about a specific Model.", - "id": "generativelanguage.models.get", - "parameters": { - "name": { - "description": "Required. The resource name of the model. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`", - "required": true, - "type": "string", - "pattern": "^models/[^/]+$", - "location": "path" - } - }, - "parameterOrder": [ - "name" - ] - }, - "list": { - "path": "v1beta/models", - "parameters": { - "pageSize": { - "description": "The maximum number of `Models` to return (per page). The service may return fewer models. If unspecified, at most 50 models will be returned per page. This method returns at most 1000 models per page, even if you pass a larger page_size.", - "location": "query", - "format": "int32", - "type": "integer" - }, - "pageToken": { - "type": "string", - "location": "query", - "description": "A page token, received from a previous `ListModels` call. Provide the `page_token` returned by one request as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListModels` must match the call that provided the page token." - } + "$ref": "Corpus" }, - "description": "Lists models available through the API.", + "id": "generativelanguage.corpora.create", "parameterOrder": [], - "response": { - "$ref": "ListModelsResponse" - }, - "flatPath": "v1beta/models", - "httpMethod": "GET", - "id": "generativelanguage.models.list" - }, - "generateMessage": { - "parameterOrder": [ - "model" - ], - "id": "generativelanguage.models.generateMessage", - "path": "v1beta/{+model}:generateMessage", - "response": { - "$ref": "GenerateMessageResponse" - }, - "description": "Generates a response from the model given an input `MessagePrompt`.", - "flatPath": "v1beta/models/{modelsId}:generateMessage", - "request": { - "$ref": "GenerateMessageRequest" - }, - "httpMethod": "POST", - "parameters": { - "model": { - "pattern": "^models/[^/]+$", - "required": true, - "type": "string", - "description": "Required. The name of the model to use. Format: `name=models/{model}`.", - "location": "path" - } - } - }, - "generateText": { - "id": "generativelanguage.models.generateText", - "httpMethod": "POST", - "parameterOrder": [ - "model" - ], "request": { - "$ref": "GenerateTextRequest" - }, - "flatPath": "v1beta/models/{modelsId}:generateText", - "parameters": { - "model": { - "description": "Required. The name of the `Model` or `TunedModel` to use for generating the completion. Examples: models/text-bison-001 tunedModels/sentence-translator-u3b7m", - "required": true, - "type": "string", - "location": "path", - "pattern": "^models/[^/]+$" - } - }, - "response": { - "$ref": "GenerateTextResponse" + "$ref": "Corpus" }, - "description": "Generates a response from the model given an input message.", - "path": "v1beta/{+model}:generateText" + "flatPath": "v1beta/corpora", + "path": "v1beta/corpora" }, - "streamGenerateContent": { - "path": "v1beta/{+model}:streamGenerateContent", - "parameters": { - "model": { - "required": true, - "type": "string", - "location": "path", - "description": "Required. The name of the `Model` to use for generating the completion. Format: `name=models/{model}`.", - "pattern": "^models/[^/]+$" - } - }, - "request": { - "$ref": "GenerateContentRequest" - }, - "parameterOrder": [ - "model" - ], - "response": { - "$ref": "GenerateContentResponse" - }, - "id": "generativelanguage.models.streamGenerateContent", + "query": { "httpMethod": "POST", - "description": "Generates a streamed response from the model given an input `GenerateContentRequest`.", - "flatPath": "v1beta/models/{modelsId}:streamGenerateContent" - }, - "batchEmbedContents": { + "description": "Performs semantic search over a `Corpus`.", "response": { - "$ref": "BatchEmbedContentsResponse" - }, - "request": { - "$ref": "BatchEmbedContentsRequest" - }, - "description": "Generates multiple embeddings from the model given input text in a synchronous call.", - "path": "v1beta/{+model}:batchEmbedContents", - "id": "generativelanguage.models.batchEmbedContents", - "httpMethod": "POST", - "parameters": { - "model": { - "required": true, - "description": "Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`", - "location": "path", - "type": "string", - "pattern": "^models/[^/]+$" - } - }, - "flatPath": "v1beta/models/{modelsId}:batchEmbedContents", - "parameterOrder": [ - "model" - ] - }, - "embedText": { - "httpMethod": "POST", - "path": "v1beta/{+model}:embedText", - "parameters": { - "model": { - "location": "path", - "type": "string", - "description": "Required. The model name to use with the format model=models/{model}.", - "pattern": "^models/[^/]+$", - "required": true - } + "$ref": "QueryCorpusResponse" }, + "flatPath": "v1beta/corpora/{corporaId}:query", "request": { - "$ref": "EmbedTextRequest" - }, - "flatPath": "v1beta/models/{modelsId}:embedText", - "parameterOrder": [ - "model" - ], - "response": { - "$ref": "EmbedTextResponse" + "$ref": "QueryCorpusRequest" }, - "id": "generativelanguage.models.embedText", - "description": "Generates an embedding from the model given an input message." - } - } - }, - "files": { - "methods": { - "delete": { "parameters": { "name": { - "type": "string", "location": "path", - "pattern": "^files/[^/]+$", + "pattern": "^corpora/[^/]+$", "required": true, - "description": "Required. The name of the `File` to delete. Example: `files/abc-123`" + "type": "string", + "description": "Required. The name of the `Corpus` to query. Example: `corpora/my-corpus-123`" } }, - "id": "generativelanguage.files.delete", - "path": "v1beta/{+name}", + "path": "v1beta/{+name}:query", "parameterOrder": [ "name" ], - "description": "Deletes the `File`.", - "response": { - "$ref": "Empty" - }, - "flatPath": "v1beta/files/{filesId}", - "httpMethod": "DELETE" - }, - "list": { - "path": "v1beta/files", - "flatPath": "v1beta/files", - "httpMethod": "GET", - "description": "Lists the metadata for `File`s owned by the requesting project.", - "parameters": { - "pageToken": { - "location": "query", - "type": "string", - "description": "Optional. A page token from a previous `ListFiles` call." - }, - "pageSize": { - "format": "int32", - "description": "Optional. Maximum number of `File`s to return per page. If unspecified, defaults to 10. Maximum `page_size` is 100.", - "location": "query", - "type": "integer" - } - }, - "response": { - "$ref": "ListFilesResponse" - }, - "id": "generativelanguage.files.list", - "parameterOrder": [] - }, - "get": { - "id": "generativelanguage.files.get", - "flatPath": "v1beta/files/{filesId}", - "response": { - "$ref": "File" - }, - "parameterOrder": [ - "name" - ], - "description": "Gets the metadata for the given `File`.", - "parameters": { - "name": { - "description": "Required. The name of the `File` to get. Example: `files/abc-123`", - "type": "string", - "required": true, - "location": "path", - "pattern": "^files/[^/]+$" - } - }, - "httpMethod": "GET", - "path": "v1beta/{+name}" + "id": "generativelanguage.corpora.query" } - } - }, - "corpora": { + }, "resources": { "documents": { "methods": { - "get": { + "list": { + "response": { + "$ref": "ListDocumentsResponse" + }, + "description": "Lists all `Document`s in a `Corpus`.", + "path": "v1beta/{+parent}/documents", + "parameters": { + "pageSize": { + "location": "query", + "description": "Optional. The maximum number of `Document`s to return (per page). The service may return fewer `Document`s. If unspecified, at most 10 `Document`s will be returned. The maximum size limit is 20 `Document`s per page.", + "type": "integer", + "format": "int32" + }, + "pageToken": { + "location": "query", + "type": "string", + "description": "Optional. A page token, received from a previous `ListDocuments` call. Provide the `next_page_token` returned in the response as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListDocuments` must match the call that provided the page token." + }, + "parent": { + "description": "Required. The name of the `Corpus` containing `Document`s. Example: `corpora/my-corpus-123`", + "required": true, + "pattern": "^corpora/[^/]+$", + "location": "path", + "type": "string" + } + }, + "id": "generativelanguage.corpora.documents.list", + "flatPath": "v1beta/corpora/{corporaId}/documents", + "httpMethod": "GET", "parameterOrder": [ - "name" + "parent" + ] + }, + "create": { + "parameterOrder": [ + "parent" ], + "httpMethod": "POST", "parameters": { - "name": { - "pattern": "^corpora/[^/]+/documents/[^/]+$", - "type": "string", - "description": "Required. The name of the `Document` to retrieve. Example: `corpora/my-corpus-123/documents/the-doc-abc`", + "parent": { "required": true, - "location": "path" + "location": "path", + "description": "Required. The name of the `Corpus` where this `Document` will be created. Example: `corpora/my-corpus-123`", + "type": "string", + "pattern": "^corpora/[^/]+$" } }, - "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}", + "flatPath": "v1beta/corpora/{corporaId}/documents", + "request": { + "$ref": "Document" + }, + "id": "generativelanguage.corpora.documents.create", "response": { "$ref": "Document" }, - "httpMethod": "GET", - "description": "Gets information about a specific `Document`.", - "path": "v1beta/{+name}", - "id": "generativelanguage.corpora.documents.get" + "path": "v1beta/{+parent}/documents", + "description": "Creates an empty `Document`." }, - "query": { + "patch": { + "path": "v1beta/{+name}", + "httpMethod": "PATCH", + "description": "Updates a `Document`.", "request": { - "$ref": "QueryDocumentRequest" + "$ref": "Document" }, + "id": "generativelanguage.corpora.documents.patch", "response": { - "$ref": "QueryDocumentResponse" + "$ref": "Document" }, - "path": "v1beta/{+name}:query", - "id": "generativelanguage.corpora.documents.query", - "description": "Performs semantic search over a `Document`.", - "httpMethod": "POST", "parameters": { + "updateMask": { + "location": "query", + "type": "string", + "description": "Required. The list of fields to update. Currently, this only supports updating `display_name` and `custom_metadata`.", + "format": "google-fieldmask" + }, "name": { + "description": "Immutable. Identifier. The `Document` resource name. The ID (name excluding the \"corpora/*/documents/\" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be derived from `display_name` along with a 12 character random suffix. Example: `corpora/{corpus_id}/documents/my-awesome-doc-123a456b789c`", + "type": "string", "location": "path", - "description": "Required. The name of the `Document` to query. Example: `corpora/my-corpus-123/documents/the-doc-abc`", "required": true, - "pattern": "^corpora/[^/]+/documents/[^/]+$", - "type": "string" + "pattern": "^corpora/[^/]+/documents/[^/]+$" } }, - "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}:query", "parameterOrder": [ "name" - ] + ], + "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}" }, - "delete": { - "response": { - "$ref": "Empty" - }, - "httpMethod": "DELETE", - "description": "Deletes a `Document`.", - "id": "generativelanguage.corpora.documents.delete", - "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}", + "get": { + "description": "Gets information about a specific `Document`.", "path": "v1beta/{+name}", - "parameterOrder": [ - "name" - ], + "httpMethod": "GET", + "id": "generativelanguage.corpora.documents.get", "parameters": { - "force": { - "type": "boolean", - "description": "Optional. If set to true, any `Chunk`s and objects related to this `Document` will also be deleted. If false (the default), a `FAILED_PRECONDITION` error will be returned if `Document` contains any `Chunk`s.", - "location": "query" - }, "name": { - "description": "Required. The resource name of the `Document` to delete. Example: `corpora/my-corpus-123/documents/the-doc-abc`", + "description": "Required. The name of the `Document` to retrieve. Example: `corpora/my-corpus-123/documents/the-doc-abc`", "pattern": "^corpora/[^/]+/documents/[^/]+$", - "required": true, "location": "path", + "required": true, "type": "string" } - } + }, + "response": { + "$ref": "Document" + }, + "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}", + "parameterOrder": [ + "name" + ] }, - "list": { + "query": { + "httpMethod": "POST", + "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}:query", + "description": "Performs semantic search over a `Document`.", + "request": { + "$ref": "QueryDocumentRequest" + }, "parameterOrder": [ - "parent" + "name" ], - "path": "v1beta/{+parent}/documents", - "description": "Lists all `Document`s in a `Corpus`.", - "flatPath": "v1beta/corpora/{corporaId}/documents", + "response": { + "$ref": "QueryDocumentResponse" + }, "parameters": { - "pageSize": { - "description": "Optional. The maximum number of `Document`s to return (per page). The service may return fewer `Document`s. If unspecified, at most 10 `Document`s will be returned. The maximum size limit is 20 `Document`s per page.", - "type": "integer", - "format": "int32", - "location": "query" - }, - "pageToken": { - "type": "string", - "location": "query", - "description": "Optional. A page token, received from a previous `ListDocuments` call. Provide the `next_page_token` returned in the response as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListDocuments` must match the call that provided the page token." - }, - "parent": { + "name": { "type": "string", - "description": "Required. The name of the `Corpus` containing `Document`s. Example: `corpora/my-corpus-123`", + "description": "Required. The name of the `Document` to query. Example: `corpora/my-corpus-123/documents/the-doc-abc`", "required": true, - "location": "path", - "pattern": "^corpora/[^/]+$" + "pattern": "^corpora/[^/]+/documents/[^/]+$", + "location": "path" } }, - "id": "generativelanguage.corpora.documents.list", - "httpMethod": "GET", - "response": { - "$ref": "ListDocumentsResponse" - } + "id": "generativelanguage.corpora.documents.query", + "path": "v1beta/{+name}:query" }, - "patch": { + "delete": { + "id": "generativelanguage.corpora.documents.delete", + "httpMethod": "DELETE", "parameters": { - "updateMask": { - "format": "google-fieldmask", - "description": "Required. The list of fields to update. Currently, this only supports updating `display_name` and `custom_metadata`.", - "type": "string", - "location": "query" + "force": { + "location": "query", + "description": "Optional. If set to true, any `Chunk`s and objects related to this `Document` will also be deleted. If false (the default), a `FAILED_PRECONDITION` error will be returned if `Document` contains any `Chunk`s.", + "type": "boolean" }, "name": { - "description": "Immutable. Identifier. The `Document` resource name. The ID (name excluding the \"corpora/*/documents/\" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be derived from `display_name` along with a 12 character random suffix. Example: `corpora/{corpus_id}/documents/my-awesome-doc-123a456b789c`", + "description": "Required. The resource name of the `Document` to delete. Example: `corpora/my-corpus-123/documents/the-doc-abc`", + "pattern": "^corpora/[^/]+/documents/[^/]+$", "type": "string", "location": "path", - "required": true, - "pattern": "^corpora/[^/]+/documents/[^/]+$" + "required": true } }, - "response": { - "$ref": "Document" - }, "parameterOrder": [ "name" ], - "id": "generativelanguage.corpora.documents.patch", - "description": "Updates a `Document`.", - "request": { - "$ref": "Document" - }, + "description": "Deletes a `Document`.", "path": "v1beta/{+name}", - "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}", - "httpMethod": "PATCH" - }, - "create": { - "httpMethod": "POST", - "description": "Creates an empty `Document`.", - "path": "v1beta/{+parent}/documents", - "id": "generativelanguage.corpora.documents.create", - "parameters": { - "parent": { - "required": true, - "pattern": "^corpora/[^/]+$", - "location": "path", - "type": "string", - "description": "Required. The name of the `Corpus` where this `Document` will be created. Example: `corpora/my-corpus-123`" - } - }, "response": { - "$ref": "Document" - }, - "request": { - "$ref": "Document" + "$ref": "Empty" }, - "flatPath": "v1beta/corpora/{corporaId}/documents", - "parameterOrder": [ - "parent" - ] + "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}" } }, "resources": { "chunks": { "methods": { - "batchCreate": { - "response": { - "$ref": "BatchCreateChunksResponse" + "batchUpdate": { + "parameters": { + "parent": { + "pattern": "^corpora/[^/]+/documents/[^/]+$", + "description": "Optional. The name of the `Document` containing the `Chunk`s to update. The parent field in every `UpdateChunkRequest` must match this value. Example: `corpora/my-corpus-123/documents/the-doc-abc`", + "type": "string", + "required": true, + "location": "path" + } }, - "httpMethod": "POST", "parameterOrder": [ "parent" ], + "request": { + "$ref": "BatchUpdateChunksRequest" + }, + "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}/chunks:batchUpdate", + "httpMethod": "POST", + "id": "generativelanguage.corpora.documents.chunks.batchUpdate", + "path": "v1beta/{+parent}/chunks:batchUpdate", + "description": "Batch update `Chunk`s.", + "response": { + "$ref": "BatchUpdateChunksResponse" + } + }, + "batchCreate": { + "request": { + "$ref": "BatchCreateChunksRequest" + }, + "id": "generativelanguage.corpora.documents.chunks.batchCreate", + "path": "v1beta/{+parent}/chunks:batchCreate", "description": "Batch create `Chunk`s.", "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}/chunks:batchCreate", + "response": { + "$ref": "BatchCreateChunksResponse" + }, "parameters": { "parent": { - "description": "Optional. The name of the `Document` where this batch of `Chunk`s will be created. The parent field in every `CreateChunkRequest` must match this value. Example: `corpora/my-corpus-123/documents/the-doc-abc`", - "required": true, "location": "path", - "pattern": "^corpora/[^/]+/documents/[^/]+$", - "type": "string" + "required": true, + "description": "Optional. The name of the `Document` where this batch of `Chunk`s will be created. The parent field in every `CreateChunkRequest` must match this value. Example: `corpora/my-corpus-123/documents/the-doc-abc`", + "type": "string", + "pattern": "^corpora/[^/]+/documents/[^/]+$" } }, - "id": "generativelanguage.corpora.documents.chunks.batchCreate", - "request": { - "$ref": "BatchCreateChunksRequest" - }, - "path": "v1beta/{+parent}/chunks:batchCreate" + "httpMethod": "POST", + "parameterOrder": [ + "parent" + ] }, - "list": { + "patch": { + "id": "generativelanguage.corpora.documents.chunks.patch", + "parameterOrder": [ + "name" + ], + "httpMethod": "PATCH", "parameters": { - "pageSize": { - "location": "query", - "type": "integer", - "format": "int32", - "description": "Optional. The maximum number of `Chunk`s to return (per page). The service may return fewer `Chunk`s. If unspecified, at most 10 `Chunk`s will be returned. The maximum size limit is 100 `Chunk`s per page." + "updateMask": { + "description": "Required. The list of fields to update. Currently, this only supports updating `custom_metadata` and `data`.", + "format": "google-fieldmask", + "type": "string", + "location": "query" }, - "parent": { + "name": { "location": "path", - "description": "Required. The name of the `Document` containing `Chunk`s. Example: `corpora/my-corpus-123/documents/the-doc-abc`", "required": true, - "pattern": "^corpora/[^/]+/documents/[^/]+$", - "type": "string" - }, - "pageToken": { - "description": "Optional. A page token, received from a previous `ListChunks` call. Provide the `next_page_token` returned in the response as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListChunks` must match the call that provided the page token.", - "location": "query", + "pattern": "^corpora/[^/]+/documents/[^/]+/chunks/[^/]+$", + "description": "Immutable. Identifier. The `Chunk` resource name. The ID (name excluding the \"corpora/*/documents/*/chunks/\" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a random 12-character unique ID will be generated. Example: `corpora/{corpus_id}/documents/{document_id}/chunks/123a456b789c`", "type": "string" } }, - "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}/chunks", - "httpMethod": "GET", - "description": "Lists all `Chunk`s in a `Document`.", - "parameterOrder": [ - "parent" - ], "response": { - "$ref": "ListChunksResponse" + "$ref": "Chunk" }, - "path": "v1beta/{+parent}/chunks", - "id": "generativelanguage.corpora.documents.chunks.list" - }, - "create": { - "response": { + "description": "Updates a `Chunk`.", + "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}/chunks/{chunksId}", + "request": { "$ref": "Chunk" }, + "path": "v1beta/{+name}" + }, + "batchDelete": { + "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}/chunks:batchDelete", "parameters": { "parent": { - "required": true, - "type": "string", - "description": "Required. The name of the `Document` where this `Chunk` will be created. Example: `corpora/my-corpus-123/documents/the-doc-abc`", "location": "path", - "pattern": "^corpora/[^/]+/documents/[^/]+$" + "pattern": "^corpora/[^/]+/documents/[^/]+$", + "type": "string", + "description": "Optional. The name of the `Document` containing the `Chunk`s to delete. The parent field in every `DeleteChunkRequest` must match this value. Example: `corpora/my-corpus-123/documents/the-doc-abc`", + "required": true } }, - "httpMethod": "POST", - "description": "Creates a `Chunk`.", - "request": { - "$ref": "Chunk" - }, + "id": "generativelanguage.corpora.documents.chunks.batchDelete", + "path": "v1beta/{+parent}/chunks:batchDelete", + "description": "Batch delete `Chunk`s.", "parameterOrder": [ "parent" ], - "path": "v1beta/{+parent}/chunks", - "id": "generativelanguage.corpora.documents.chunks.create", - "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}/chunks" - }, - "patch": { - "description": "Updates a `Chunk`.", - "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}/chunks/{chunksId}", - "response": { - "$ref": "Chunk" - }, - "id": "generativelanguage.corpora.documents.chunks.patch", - "path": "v1beta/{+name}", "request": { - "$ref": "Chunk" + "$ref": "BatchDeleteChunksRequest" }, - "httpMethod": "PATCH", + "response": { + "$ref": "Empty" + }, + "httpMethod": "POST" + }, + "delete": { + "id": "generativelanguage.corpora.documents.chunks.delete", + "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}/chunks/{chunksId}", + "description": "Deletes a `Chunk`.", + "httpMethod": "DELETE", "parameters": { "name": { + "required": true, + "pattern": "^corpora/[^/]+/documents/[^/]+/chunks/[^/]+$", "location": "path", "type": "string", - "description": "Immutable. Identifier. The `Chunk` resource name. The ID (name excluding the \"corpora/*/documents/*/chunks/\" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a random 12-character unique ID will be generated. Example: `corpora/{corpus_id}/documents/{document_id}/chunks/123a456b789c`", - "required": true, - "pattern": "^corpora/[^/]+/documents/[^/]+/chunks/[^/]+$" - }, - "updateMask": { - "location": "query", - "description": "Required. The list of fields to update. Currently, this only supports updating `custom_metadata` and `data`.", - "format": "google-fieldmask", - "type": "string" + "description": "Required. The resource name of the `Chunk` to delete. Example: `corpora/my-corpus-123/documents/the-doc-abc/chunks/some-chunk`" } }, - "parameterOrder": [ - "name" - ] - }, - "delete": { - "id": "generativelanguage.corpora.documents.chunks.delete", - "path": "v1beta/{+name}", "response": { "$ref": "Empty" }, "parameterOrder": [ "name" ], + "path": "v1beta/{+name}" + }, + "get": { + "httpMethod": "GET", + "path": "v1beta/{+name}", "parameters": { "name": { - "pattern": "^corpora/[^/]+/documents/[^/]+/chunks/[^/]+$", - "required": true, - "description": "Required. The resource name of the `Chunk` to delete. Example: `corpora/my-corpus-123/documents/the-doc-abc/chunks/some-chunk`", "location": "path", + "required": true, + "description": "Required. The name of the `Chunk` to retrieve. Example: `corpora/my-corpus-123/documents/the-doc-abc/chunks/some-chunk`", + "pattern": "^corpora/[^/]+/documents/[^/]+/chunks/[^/]+$", "type": "string" } }, - "httpMethod": "DELETE", "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}/chunks/{chunksId}", - "description": "Deletes a `Chunk`." - }, - "get": { - "id": "generativelanguage.corpora.documents.chunks.get", + "description": "Gets information about a specific `Chunk`.", "response": { "$ref": "Chunk" }, - "httpMethod": "GET", - "description": "Gets information about a specific `Chunk`.", - "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}/chunks/{chunksId}", - "path": "v1beta/{+name}", - "parameters": { - "name": { - "description": "Required. The name of the `Chunk` to retrieve. Example: `corpora/my-corpus-123/documents/the-doc-abc/chunks/some-chunk`", - "required": true, - "location": "path", - "type": "string", - "pattern": "^corpora/[^/]+/documents/[^/]+/chunks/[^/]+$" - } - }, "parameterOrder": [ "name" - ] + ], + "id": "generativelanguage.corpora.documents.chunks.get" }, - "batchDelete": { - "request": { - "$ref": "BatchDeleteChunksRequest" + "list": { + "response": { + "$ref": "ListChunksResponse" }, + "parameterOrder": [ + "parent" + ], + "path": "v1beta/{+parent}/chunks", + "id": "generativelanguage.corpora.documents.chunks.list", + "description": "Lists all `Chunk`s in a `Document`.", + "httpMethod": "GET", + "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}/chunks", "parameters": { "parent": { "required": true, + "pattern": "^corpora/[^/]+/documents/[^/]+$", "location": "path", "type": "string", - "pattern": "^corpora/[^/]+/documents/[^/]+$", - "description": "Optional. The name of the `Document` containing the `Chunk`s to delete. The parent field in every `DeleteChunkRequest` must match this value. Example: `corpora/my-corpus-123/documents/the-doc-abc`" + "description": "Required. The name of the `Document` containing `Chunk`s. Example: `corpora/my-corpus-123/documents/the-doc-abc`" + }, + "pageToken": { + "location": "query", + "type": "string", + "description": "Optional. A page token, received from a previous `ListChunks` call. Provide the `next_page_token` returned in the response as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListChunks` must match the call that provided the page token." + }, + "pageSize": { + "description": "Optional. The maximum number of `Chunk`s to return (per page). The service may return fewer `Chunk`s. If unspecified, at most 10 `Chunk`s will be returned. The maximum size limit is 100 `Chunk`s per page.", + "location": "query", + "type": "integer", + "format": "int32" } - }, - "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}/chunks:batchDelete", - "id": "generativelanguage.corpora.documents.chunks.batchDelete", - "parameterOrder": [ - "parent" - ], - "description": "Batch delete `Chunk`s.", - "httpMethod": "POST", - "path": "v1beta/{+parent}/chunks:batchDelete", - "response": { - "$ref": "Empty" } }, - "batchUpdate": { + "create": { + "description": "Creates a `Chunk`.", + "httpMethod": "POST", + "request": { + "$ref": "Chunk" + }, + "path": "v1beta/{+parent}/chunks", + "response": { + "$ref": "Chunk" + }, "parameters": { "parent": { "type": "string", + "description": "Required. The name of the `Document` where this `Chunk` will be created. Example: `corpora/my-corpus-123/documents/the-doc-abc`", + "pattern": "^corpora/[^/]+/documents/[^/]+$", "location": "path", - "required": true, - "description": "Optional. The name of the `Document` containing the `Chunk`s to update. The parent field in every `UpdateChunkRequest` must match this value. Example: `corpora/my-corpus-123/documents/the-doc-abc`", - "pattern": "^corpora/[^/]+/documents/[^/]+$" + "required": true } }, - "response": { - "$ref": "BatchUpdateChunksResponse" - }, - "httpMethod": "POST", - "request": { - "$ref": "BatchUpdateChunksRequest" - }, - "path": "v1beta/{+parent}/chunks:batchUpdate", - "description": "Batch update `Chunk`s.", - "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}/chunks:batchUpdate", + "id": "generativelanguage.corpora.documents.chunks.create", "parameterOrder": [ "parent" ], - "id": "generativelanguage.corpora.documents.chunks.batchUpdate" + "flatPath": "v1beta/corpora/{corporaId}/documents/{documentsId}/chunks" } } } @@ -3419,368 +3211,890 @@ }, "permissions": { "methods": { - "delete": { - "description": "Deletes the permission.", - "id": "generativelanguage.corpora.permissions.delete", - "response": { - "$ref": "Empty" - }, - "flatPath": "v1beta/corpora/{corporaId}/permissions/{permissionsId}", - "parameters": { - "name": { - "location": "path", - "required": true, - "description": "Required. The resource name of the permission. Formats: `tunedModels/{tuned_model}/permissions/{permission}` `corpora/{corpus}/permissions/{permission}`", - "pattern": "^corpora/[^/]+/permissions/[^/]+$", - "type": "string" - } - }, - "path": "v1beta/{+name}", - "parameterOrder": [ - "name" - ], - "httpMethod": "DELETE" - }, "list": { - "response": { - "$ref": "ListPermissionsResponse" - }, - "id": "generativelanguage.corpora.permissions.list", + "path": "v1beta/{+parent}/permissions", + "flatPath": "v1beta/corpora/{corporaId}/permissions", + "parameters": { + "pageToken": { + "type": "string", + "description": "Optional. A page token, received from a previous `ListPermissions` call. Provide the `page_token` returned by one request as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListPermissions` must match the call that provided the page token.", + "location": "query" + }, + "pageSize": { + "description": "Optional. The maximum number of `Permission`s to return (per page). The service may return fewer permissions. If unspecified, at most 10 permissions will be returned. This method returns at most 1000 permissions per page, even if you pass larger page_size.", + "format": "int32", + "location": "query", + "type": "integer" + }, + "parent": { + "pattern": "^corpora/[^/]+$", + "location": "path", + "required": true, + "description": "Required. The parent resource of the permissions. Formats: `tunedModels/{tuned_model}` `corpora/{corpus}`", + "type": "string" + } + }, + "description": "Lists permissions for the specific resource.", + "httpMethod": "GET", + "id": "generativelanguage.corpora.permissions.list", + "response": { + "$ref": "ListPermissionsResponse" + }, + "parameterOrder": [ + "parent" + ] + }, + "delete": { + "parameterOrder": [ + "name" + ], + "description": "Deletes the permission.", + "parameters": { + "name": { + "type": "string", + "pattern": "^corpora/[^/]+/permissions/[^/]+$", + "required": true, + "description": "Required. The resource name of the permission. Formats: `tunedModels/{tuned_model}/permissions/{permission}` `corpora/{corpus}/permissions/{permission}`", + "location": "path" + } + }, + "flatPath": "v1beta/corpora/{corporaId}/permissions/{permissionsId}", + "httpMethod": "DELETE", + "path": "v1beta/{+name}", + "response": { + "$ref": "Empty" + }, + "id": "generativelanguage.corpora.permissions.delete" + }, + "get": { + "id": "generativelanguage.corpora.permissions.get", + "response": { + "$ref": "Permission" + }, + "description": "Gets information about a specific Permission.", + "parameters": { + "name": { + "required": true, + "description": "Required. The resource name of the permission. Formats: `tunedModels/{tuned_model}/permissions/{permission}` `corpora/{corpus}/permissions/{permission}`", + "location": "path", + "pattern": "^corpora/[^/]+/permissions/[^/]+$", + "type": "string" + } + }, + "httpMethod": "GET", + "path": "v1beta/{+name}", + "flatPath": "v1beta/corpora/{corporaId}/permissions/{permissionsId}", + "parameterOrder": [ + "name" + ] + }, + "create": { + "response": { + "$ref": "Permission" + }, + "request": { + "$ref": "Permission" + }, + "id": "generativelanguage.corpora.permissions.create", + "parameters": { + "parent": { + "description": "Required. The parent resource of the `Permission`. Formats: `tunedModels/{tuned_model}` `corpora/{corpus}`", + "location": "path", + "pattern": "^corpora/[^/]+$", + "required": true, + "type": "string" + } + }, + "parameterOrder": [ + "parent" + ], + "description": "Create a permission to a specific resource.", + "flatPath": "v1beta/corpora/{corporaId}/permissions", + "httpMethod": "POST", + "path": "v1beta/{+parent}/permissions" + }, + "patch": { + "parameters": { + "updateMask": { + "type": "string", + "location": "query", + "format": "google-fieldmask", + "description": "Required. The list of fields to update. Accepted ones: - role (`Permission.role` field)" + }, + "name": { + "description": "Output only. Identifier. The permission name. A unique name will be generated on create. Examples: tunedModels/{tuned_model}/permissions/{permission} corpora/{corpus}/permissions/{permission} Output only.", + "location": "path", + "pattern": "^corpora/[^/]+/permissions/[^/]+$", + "type": "string", + "required": true + } + }, + "id": "generativelanguage.corpora.permissions.patch", + "parameterOrder": [ + "name" + ], + "request": { + "$ref": "Permission" + }, + "flatPath": "v1beta/corpora/{corporaId}/permissions/{permissionsId}", + "response": { + "$ref": "Permission" + }, + "httpMethod": "PATCH", + "description": "Updates the permission.", + "path": "v1beta/{+name}" + } + } + } + } + }, + "media": { + "methods": { + "upload": { + "supportsMediaUpload": true, + "response": { + "$ref": "CreateFileResponse" + }, + "mediaUpload": { + "maxSize": "2147483648", + "protocols": { + "simple": { + "multipart": true, + "path": "/upload/v1beta/files" + }, + "resumable": { + "path": "/resumable/upload/v1beta/files", + "multipart": true + } + }, + "accept": [ + "*/*" + ] + }, + "parameters": {}, + "path": "v1beta/files", + "request": { + "$ref": "CreateFileRequest" + }, + "parameterOrder": [], + "flatPath": "v1beta/files", + "description": "Creates a `File`.", + "id": "generativelanguage.media.upload", + "httpMethod": "POST" + } + } + }, + "models": { + "methods": { + "countTextTokens": { + "httpMethod": "POST", + "path": "v1beta/{+model}:countTextTokens", + "parameters": { + "model": { + "type": "string", + "location": "path", + "required": true, + "pattern": "^models/[^/]+$", + "description": "Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`" + } + }, + "request": { + "$ref": "CountTextTokensRequest" + }, + "parameterOrder": [ + "model" + ], + "description": "Runs a model's tokenizer on a text and returns the token count.", + "id": "generativelanguage.models.countTextTokens", + "response": { + "$ref": "CountTextTokensResponse" + }, + "flatPath": "v1beta/models/{modelsId}:countTextTokens" + }, + "get": { + "flatPath": "v1beta/models/{modelsId}", + "path": "v1beta/{+name}", + "description": "Gets information about a specific Model.", + "id": "generativelanguage.models.get", + "parameters": { + "name": { + "description": "Required. The resource name of the model. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`", + "required": true, + "pattern": "^models/[^/]+$", + "type": "string", + "location": "path" + } + }, + "response": { + "$ref": "Model" + }, + "parameterOrder": [ + "name" + ], + "httpMethod": "GET" + }, + "countTokens": { + "response": { + "$ref": "CountTokensResponse" + }, + "id": "generativelanguage.models.countTokens", + "description": "Runs a model's tokenizer on input content and returns the token count.", + "parameters": { + "model": { + "type": "string", + "description": "Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`", + "location": "path", + "required": true, + "pattern": "^models/[^/]+$" + } + }, + "path": "v1beta/{+model}:countTokens", + "flatPath": "v1beta/models/{modelsId}:countTokens", + "request": { + "$ref": "CountTokensRequest" + }, + "parameterOrder": [ + "model" + ], + "httpMethod": "POST" + }, + "embedText": { + "request": { + "$ref": "EmbedTextRequest" + }, + "httpMethod": "POST", + "description": "Generates an embedding from the model given an input message.", + "id": "generativelanguage.models.embedText", + "flatPath": "v1beta/models/{modelsId}:embedText", + "parameters": { + "model": { + "description": "Required. The model name to use with the format model=models/{model}.", + "required": true, + "pattern": "^models/[^/]+$", + "type": "string", + "location": "path" + } + }, + "parameterOrder": [ + "model" + ], + "response": { + "$ref": "EmbedTextResponse" + }, + "path": "v1beta/{+model}:embedText" + }, + "batchEmbedText": { + "request": { + "$ref": "BatchEmbedTextRequest" + }, + "path": "v1beta/{+model}:batchEmbedText", + "parameters": { + "model": { + "location": "path", + "type": "string", + "description": "Required. The name of the `Model` to use for generating the embedding. Examples: models/embedding-gecko-001", + "pattern": "^models/[^/]+$", + "required": true + } + }, + "flatPath": "v1beta/models/{modelsId}:batchEmbedText", + "id": "generativelanguage.models.batchEmbedText", + "response": { + "$ref": "BatchEmbedTextResponse" + }, + "description": "Generates multiple embeddings from the model given input text in a synchronous call.", + "parameterOrder": [ + "model" + ], + "httpMethod": "POST" + }, + "list": { + "httpMethod": "GET", + "flatPath": "v1beta/models", + "description": "Lists models available through the API.", + "path": "v1beta/models", + "parameters": { + "pageToken": { + "type": "string", + "description": "A page token, received from a previous `ListModels` call. Provide the `page_token` returned by one request as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListModels` must match the call that provided the page token.", + "location": "query" + }, + "pageSize": { + "location": "query", + "description": "The maximum number of `Models` to return (per page). The service may return fewer models. If unspecified, at most 50 models will be returned per page. This method returns at most 1000 models per page, even if you pass a larger page_size.", + "type": "integer", + "format": "int32" + } + }, + "parameterOrder": [], + "response": { + "$ref": "ListModelsResponse" + }, + "id": "generativelanguage.models.list" + }, + "batchEmbedContents": { + "description": "Generates multiple embeddings from the model given input text in a synchronous call.", + "httpMethod": "POST", + "parameterOrder": [ + "model" + ], + "parameters": { + "model": { + "required": true, + "description": "Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`", + "location": "path", + "pattern": "^models/[^/]+$", + "type": "string" + } + }, + "path": "v1beta/{+model}:batchEmbedContents", + "flatPath": "v1beta/models/{modelsId}:batchEmbedContents", + "request": { + "$ref": "BatchEmbedContentsRequest" + }, + "id": "generativelanguage.models.batchEmbedContents", + "response": { + "$ref": "BatchEmbedContentsResponse" + } + }, + "streamGenerateContent": { + "path": "v1beta/{+model}:streamGenerateContent", + "httpMethod": "POST", + "parameterOrder": [ + "model" + ], + "request": { + "$ref": "GenerateContentRequest" + }, + "parameters": { + "model": { + "location": "path", + "description": "Required. The name of the `Model` to use for generating the completion. Format: `name=models/{model}`.", + "type": "string", + "pattern": "^models/[^/]+$", + "required": true + } + }, + "flatPath": "v1beta/models/{modelsId}:streamGenerateContent", + "response": { + "$ref": "GenerateContentResponse" + }, + "id": "generativelanguage.models.streamGenerateContent", + "description": "Generates a streamed response from the model given an input `GenerateContentRequest`." + }, + "generateText": { + "parameterOrder": [ + "model" + ], + "flatPath": "v1beta/models/{modelsId}:generateText", + "response": { + "$ref": "GenerateTextResponse" + }, + "httpMethod": "POST", + "description": "Generates a response from the model given an input message.", + "path": "v1beta/{+model}:generateText", + "request": { + "$ref": "GenerateTextRequest" + }, + "id": "generativelanguage.models.generateText", + "parameters": { + "model": { + "location": "path", + "description": "Required. The name of the `Model` or `TunedModel` to use for generating the completion. Examples: models/text-bison-001 tunedModels/sentence-translator-u3b7m", + "pattern": "^models/[^/]+$", + "required": true, + "type": "string" + } + } + }, + "generateContent": { + "path": "v1beta/{+model}:generateContent", + "httpMethod": "POST", + "flatPath": "v1beta/models/{modelsId}:generateContent", + "id": "generativelanguage.models.generateContent", + "description": "Generates a response from the model given an input `GenerateContentRequest`. Input capabilities differ between models, including tuned models. See the [model guide](https://ai.google.dev/models/gemini) and [tuning guide](https://ai.google.dev/docs/model_tuning_guidance) for details.", + "request": { + "$ref": "GenerateContentRequest" + }, + "parameters": { + "model": { + "required": true, + "pattern": "^models/[^/]+$", + "description": "Required. The name of the `Model` to use for generating the completion. Format: `name=models/{model}`.", + "type": "string", + "location": "path" + } + }, + "parameterOrder": [ + "model" + ], + "response": { + "$ref": "GenerateContentResponse" + } + }, + "countMessageTokens": { + "path": "v1beta/{+model}:countMessageTokens", + "id": "generativelanguage.models.countMessageTokens", + "parameters": { + "model": { + "location": "path", + "type": "string", + "required": true, + "pattern": "^models/[^/]+$", + "description": "Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`" + } + }, + "description": "Runs a model's tokenizer on a string and returns the token count.", + "response": { + "$ref": "CountMessageTokensResponse" + }, + "httpMethod": "POST", + "request": { + "$ref": "CountMessageTokensRequest" + }, + "parameterOrder": [ + "model" + ], + "flatPath": "v1beta/models/{modelsId}:countMessageTokens" + }, + "embedContent": { + "parameterOrder": [ + "model" + ], + "parameters": { + "model": { + "pattern": "^models/[^/]+$", + "location": "path", + "type": "string", + "required": true, + "description": "Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`" + } + }, + "description": "Generates an embedding from the model given an input `Content`.", + "request": { + "$ref": "EmbedContentRequest" + }, + "flatPath": "v1beta/models/{modelsId}:embedContent", + "path": "v1beta/{+model}:embedContent", + "httpMethod": "POST", + "response": { + "$ref": "EmbedContentResponse" + }, + "id": "generativelanguage.models.embedContent" + }, + "generateAnswer": { + "request": { + "$ref": "GenerateAnswerRequest" + }, + "httpMethod": "POST", + "parameterOrder": [ + "model" + ], + "description": "Generates a grounded answer from the model given an input `GenerateAnswerRequest`.", + "path": "v1beta/{+model}:generateAnswer", + "id": "generativelanguage.models.generateAnswer", + "flatPath": "v1beta/models/{modelsId}:generateAnswer", + "response": { + "$ref": "GenerateAnswerResponse" + }, + "parameters": { + "model": { + "type": "string", + "description": "Required. The name of the `Model` to use for generating the grounded response. Format: `model=models/{model}`.", + "location": "path", + "pattern": "^models/[^/]+$", + "required": true + } + } + }, + "generateMessage": { + "request": { + "$ref": "GenerateMessageRequest" + }, + "response": { + "$ref": "GenerateMessageResponse" + }, + "id": "generativelanguage.models.generateMessage", + "httpMethod": "POST", + "parameters": { + "model": { + "type": "string", + "description": "Required. The name of the model to use. Format: `name=models/{model}`.", + "required": true, + "pattern": "^models/[^/]+$", + "location": "path" + } + }, + "parameterOrder": [ + "model" + ], + "path": "v1beta/{+model}:generateMessage", + "flatPath": "v1beta/models/{modelsId}:generateMessage", + "description": "Generates a response from the model given an input `MessagePrompt`." + } + } + }, + "cachedContents": { + "methods": { + "delete": { + "description": "Deletes CachedContent resource.", + "parameterOrder": [ + "name" + ], + "flatPath": "v1beta/cachedContents/{cachedContentsId}", + "parameters": { + "name": { + "required": true, + "description": "Required. The resource name referring to the content cache entry Format: `cachedContents/{id}`", + "pattern": "^cachedContents/[^/]+$", + "type": "string", + "location": "path" + } + }, + "id": "generativelanguage.cachedContents.delete", + "httpMethod": "DELETE", + "path": "v1beta/{+name}", + "response": { + "$ref": "Empty" + } + }, + "list": { + "id": "generativelanguage.cachedContents.list", + "parameterOrder": [], + "response": { + "$ref": "ListCachedContentsResponse" + }, + "description": "Lists CachedContents.", + "path": "v1beta/cachedContents", + "flatPath": "v1beta/cachedContents", + "parameters": { + "pageSize": { + "location": "query", + "description": "Optional. The maximum number of cached contents to return. The service may return fewer than this value. If unspecified, some default (under maximum) number of items will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.", + "type": "integer", + "format": "int32" + }, + "pageToken": { + "location": "query", + "type": "string", + "description": "Optional. A page token, received from a previous `ListCachedContents` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListCachedContents` must match the call that provided the page token." + } + }, + "httpMethod": "GET" + }, + "patch": { + "flatPath": "v1beta/cachedContents/{cachedContentsId}", + "parameters": { + "updateMask": { + "location": "query", + "type": "string", + "description": "The list of fields to update.", + "format": "google-fieldmask" + }, + "name": { + "location": "path", + "required": true, + "description": "Optional. Identifier. The resource name referring to the cached content. Format: `cachedContents/{id}`", + "pattern": "^cachedContents/[^/]+$", + "type": "string" + } + }, + "response": { + "$ref": "CachedContent" + }, + "path": "v1beta/{+name}", + "httpMethod": "PATCH", + "request": { + "$ref": "CachedContent" + }, + "parameterOrder": [ + "name" + ], + "id": "generativelanguage.cachedContents.patch", + "description": "Updates CachedContent resource (only expiration is updatable)." + }, + "create": { + "path": "v1beta/cachedContents", + "parameterOrder": [], + "id": "generativelanguage.cachedContents.create", + "parameters": {}, + "description": "Creates CachedContent resource.", + "request": { + "$ref": "CachedContent" + }, + "httpMethod": "POST", + "response": { + "$ref": "CachedContent" + }, + "flatPath": "v1beta/cachedContents" + }, + "get": { + "parameterOrder": [ + "name" + ], + "httpMethod": "GET", + "flatPath": "v1beta/cachedContents/{cachedContentsId}", + "parameters": { + "name": { + "location": "path", + "required": true, + "type": "string", + "description": "Required. The resource name referring to the content cache entry. Format: `cachedContents/{id}`", + "pattern": "^cachedContents/[^/]+$" + } + }, + "description": "Reads CachedContent resource.", + "id": "generativelanguage.cachedContents.get", + "response": { + "$ref": "CachedContent" + }, + "path": "v1beta/{+name}" + } + } + }, + "tunedModels": { + "resources": { + "permissions": { + "methods": { + "list": { + "description": "Lists permissions for the specific resource.", "httpMethod": "GET", "parameters": { + "pageSize": { + "format": "int32", + "description": "Optional. The maximum number of `Permission`s to return (per page). The service may return fewer permissions. If unspecified, at most 10 permissions will be returned. This method returns at most 1000 permissions per page, even if you pass larger page_size.", + "type": "integer", + "location": "query" + }, "pageToken": { "location": "query", - "type": "string", - "description": "Optional. A page token, received from a previous `ListPermissions` call. Provide the `page_token` returned by one request as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListPermissions` must match the call that provided the page token." + "description": "Optional. A page token, received from a previous `ListPermissions` call. Provide the `page_token` returned by one request as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListPermissions` must match the call that provided the page token.", + "type": "string" }, "parent": { + "pattern": "^tunedModels/[^/]+$", + "required": true, "description": "Required. The parent resource of the permissions. Formats: `tunedModels/{tuned_model}` `corpora/{corpus}`", - "location": "path", "type": "string", - "required": true, - "pattern": "^corpora/[^/]+$" - }, - "pageSize": { - "format": "int32", - "type": "integer", - "description": "Optional. The maximum number of `Permission`s to return (per page). The service may return fewer permissions. If unspecified, at most 10 permissions will be returned. This method returns at most 1000 permissions per page, even if you pass larger page_size.", - "location": "query" + "location": "path" } }, + "response": { + "$ref": "ListPermissionsResponse" + }, "parameterOrder": [ "parent" ], - "description": "Lists permissions for the specific resource.", "path": "v1beta/{+parent}/permissions", - "flatPath": "v1beta/corpora/{corporaId}/permissions" + "flatPath": "v1beta/tunedModels/{tunedModelsId}/permissions", + "id": "generativelanguage.tunedModels.permissions.list" }, - "patch": { - "request": { - "$ref": "Permission" + "delete": { + "id": "generativelanguage.tunedModels.permissions.delete", + "parameters": { + "name": { + "description": "Required. The resource name of the permission. Formats: `tunedModels/{tuned_model}/permissions/{permission}` `corpora/{corpus}/permissions/{permission}`", + "pattern": "^tunedModels/[^/]+/permissions/[^/]+$", + "type": "string", + "required": true, + "location": "path" + } }, + "path": "v1beta/{+name}", + "description": "Deletes the permission.", "response": { - "$ref": "Permission" + "$ref": "Empty" }, - "httpMethod": "PATCH", - "id": "generativelanguage.corpora.permissions.patch", "parameterOrder": [ "name" ], - "description": "Updates the permission.", + "httpMethod": "DELETE", + "flatPath": "v1beta/tunedModels/{tunedModelsId}/permissions/{permissionsId}" + }, + "patch": { + "request": { + "$ref": "Permission" + }, "parameters": { + "name": { + "type": "string", + "pattern": "^tunedModels/[^/]+/permissions/[^/]+$", + "required": true, + "location": "path", + "description": "Output only. Identifier. The permission name. A unique name will be generated on create. Examples: tunedModels/{tuned_model}/permissions/{permission} corpora/{corpus}/permissions/{permission} Output only." + }, "updateMask": { "description": "Required. The list of fields to update. Accepted ones: - role (`Permission.role` field)", - "location": "query", "type": "string", + "location": "query", "format": "google-fieldmask" - }, - "name": { - "required": true, - "description": "Output only. Identifier. The permission name. A unique name will be generated on create. Examples: tunedModels/{tuned_model}/permissions/{permission} corpora/{corpus}/permissions/{permission} Output only.", - "location": "path", - "pattern": "^corpora/[^/]+/permissions/[^/]+$", - "type": "string" } }, - "path": "v1beta/{+name}", - "flatPath": "v1beta/corpora/{corporaId}/permissions/{permissionsId}" - }, - "get": { + "flatPath": "v1beta/tunedModels/{tunedModelsId}/permissions/{permissionsId}", "parameterOrder": [ "name" ], - "description": "Gets information about a specific Permission.", - "id": "generativelanguage.corpora.permissions.get", - "flatPath": "v1beta/corpora/{corporaId}/permissions/{permissionsId}", - "path": "v1beta/{+name}", "response": { "$ref": "Permission" }, + "id": "generativelanguage.tunedModels.permissions.patch", + "httpMethod": "PATCH", + "path": "v1beta/{+name}", + "description": "Updates the permission." + }, + "get": { "httpMethod": "GET", + "id": "generativelanguage.tunedModels.permissions.get", + "flatPath": "v1beta/tunedModels/{tunedModelsId}/permissions/{permissionsId}", + "parameterOrder": [ + "name" + ], + "path": "v1beta/{+name}", "parameters": { "name": { - "required": true, - "description": "Required. The resource name of the permission. Formats: `tunedModels/{tuned_model}/permissions/{permission}` `corpora/{corpus}/permissions/{permission}`", - "pattern": "^corpora/[^/]+/permissions/[^/]+$", + "location": "path", "type": "string", - "location": "path" + "description": "Required. The resource name of the permission. Formats: `tunedModels/{tuned_model}/permissions/{permission}` `corpora/{corpus}/permissions/{permission}`", + "required": true, + "pattern": "^tunedModels/[^/]+/permissions/[^/]+$" } + }, + "description": "Gets information about a specific Permission.", + "response": { + "$ref": "Permission" } }, "create": { - "path": "v1beta/{+parent}/permissions", - "id": "generativelanguage.corpora.permissions.create", - "flatPath": "v1beta/corpora/{corporaId}/permissions", "parameters": { "parent": { - "pattern": "^corpora/[^/]+$", - "type": "string", - "required": true, + "pattern": "^tunedModels/[^/]+$", + "description": "Required. The parent resource of the `Permission`. Formats: `tunedModels/{tuned_model}` `corpora/{corpus}`", "location": "path", - "description": "Required. The parent resource of the `Permission`. Formats: `tunedModels/{tuned_model}` `corpora/{corpus}`" + "type": "string", + "required": true } }, - "response": { + "description": "Create a permission to a specific resource.", + "httpMethod": "POST", + "flatPath": "v1beta/tunedModels/{tunedModelsId}/permissions", + "request": { "$ref": "Permission" }, - "httpMethod": "POST", "parameterOrder": [ "parent" ], - "request": { + "id": "generativelanguage.tunedModels.permissions.create", + "response": { "$ref": "Permission" }, - "description": "Create a permission to a specific resource." + "path": "v1beta/{+parent}/permissions" } } } }, "methods": { - "query": { - "id": "generativelanguage.corpora.query", + "delete": { "parameterOrder": [ "name" ], - "description": "Performs semantic search over a `Corpus`.", - "path": "v1beta/{+name}:query", + "description": "Deletes a tuned model.", + "path": "v1beta/{+name}", "parameters": { "name": { - "pattern": "^corpora/[^/]+$", + "type": "string", + "pattern": "^tunedModels/[^/]+$", "required": true, - "description": "Required. The name of the `Corpus` to query. Example: `corpora/my-corpus-123`", - "location": "path", - "type": "string" + "description": "Required. The resource name of the model. Format: `tunedModels/my-model-id`", + "location": "path" } }, - "httpMethod": "POST", - "request": { - "$ref": "QueryCorpusRequest" - }, - "response": { - "$ref": "QueryCorpusResponse" - }, - "flatPath": "v1beta/corpora/{corporaId}:query" - }, - "patch": { - "description": "Updates a `Corpus`.", - "path": "v1beta/{+name}", - "parameterOrder": [ - "name" - ], - "id": "generativelanguage.corpora.patch", + "flatPath": "v1beta/tunedModels/{tunedModelsId}", + "id": "generativelanguage.tunedModels.delete", + "httpMethod": "DELETE", "response": { - "$ref": "Corpus" - }, - "request": { - "$ref": "Corpus" - }, - "flatPath": "v1beta/corpora/{corporaId}", - "httpMethod": "PATCH", - "parameters": { - "updateMask": { - "description": "Required. The list of fields to update. Currently, this only supports updating `display_name`.", - "type": "string", - "location": "query", - "format": "google-fieldmask" - }, - "name": { - "pattern": "^corpora/[^/]+$", - "location": "path", - "type": "string", - "description": "Immutable. Identifier. The `Corpus` resource name. The ID (name excluding the \"corpora/\" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be derived from `display_name` along with a 12 character random suffix. Example: `corpora/my-awesome-corpora-123a456b789c`", - "required": true - } + "$ref": "Empty" } }, - "get": { - "parameterOrder": [ - "name" - ], - "flatPath": "v1beta/corpora/{corporaId}", - "description": "Gets information about a specific `Corpus`.", + "transferOwnership": { "parameters": { "name": { "required": true, - "description": "Required. The name of the `Corpus`. Example: `corpora/my-corpus-123`", - "location": "path", + "pattern": "^tunedModels/[^/]+$", "type": "string", - "pattern": "^corpora/[^/]+$" + "description": "Required. The resource name of the tuned model to transfer ownership. Format: `tunedModels/my-model-id`", + "location": "path" } }, - "path": "v1beta/{+name}", - "id": "generativelanguage.corpora.get", - "response": { - "$ref": "Corpus" - }, - "httpMethod": "GET" - }, - "create": { - "parameterOrder": [], - "id": "generativelanguage.corpora.create", - "description": "Creates an empty `Corpus`.", - "parameters": {}, + "description": "Transfers ownership of the tuned model. This is the only way to change ownership of the tuned model. The current owner will be downgraded to writer role.", + "parameterOrder": [ + "name" + ], "httpMethod": "POST", + "flatPath": "v1beta/tunedModels/{tunedModelsId}:transferOwnership", + "id": "generativelanguage.tunedModels.transferOwnership", "request": { - "$ref": "Corpus" + "$ref": "TransferOwnershipRequest" }, - "path": "v1beta/corpora", "response": { - "$ref": "Corpus" - }, - "flatPath": "v1beta/corpora" - }, - "list": { - "flatPath": "v1beta/corpora", - "description": "Lists all `Corpora` owned by the user.", - "parameters": { - "pageSize": { - "type": "integer", - "description": "Optional. The maximum number of `Corpora` to return (per page). The service may return fewer `Corpora`. If unspecified, at most 10 `Corpora` will be returned. The maximum size limit is 20 `Corpora` per page.", - "format": "int32", - "location": "query" - }, - "pageToken": { - "type": "string", - "description": "Optional. A page token, received from a previous `ListCorpora` call. Provide the `next_page_token` returned in the response as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListCorpora` must match the call that provided the page token.", - "location": "query" - } + "$ref": "TransferOwnershipResponse" }, - "parameterOrder": [], - "id": "generativelanguage.corpora.list", - "path": "v1beta/corpora", - "httpMethod": "GET", - "response": { - "$ref": "ListCorporaResponse" - } + "path": "v1beta/{+name}:transferOwnership" }, - "delete": { - "path": "v1beta/{+name}", - "httpMethod": "DELETE", - "flatPath": "v1beta/corpora/{corporaId}", - "response": { - "$ref": "Empty" - }, - "id": "generativelanguage.corpora.delete", - "description": "Deletes a `Corpus`.", + "generateContent": { + "description": "Generates a response from the model given an input `GenerateContentRequest`. Input capabilities differ between models, including tuned models. See the [model guide](https://ai.google.dev/models/gemini) and [tuning guide](https://ai.google.dev/docs/model_tuning_guidance) for details.", + "flatPath": "v1beta/tunedModels/{tunedModelsId}:generateContent", + "httpMethod": "POST", "parameters": { - "force": { - "description": "Optional. If set to true, any `Document`s and objects related to this `Corpus` will also be deleted. If false (the default), a `FAILED_PRECONDITION` error will be returned if `Corpus` contains any `Document`s.", - "location": "query", - "type": "boolean" - }, - "name": { - "pattern": "^corpora/[^/]+$", - "description": "Required. The resource name of the `Corpus`. Example: `corpora/my-corpus-123`", + "model": { "location": "path", "required": true, - "type": "string" - } - }, - "parameterOrder": [ - "name" - ] - } - } - }, - "tunedModels": { - "methods": { - "get": { - "httpMethod": "GET", - "response": { - "$ref": "TunedModel" - }, - "id": "generativelanguage.tunedModels.get", - "path": "v1beta/{+name}", - "flatPath": "v1beta/tunedModels/{tunedModelsId}", - "description": "Gets information about a specific TunedModel.", - "parameterOrder": [ - "name" - ], - "parameters": { - "name": { "type": "string", "pattern": "^tunedModels/[^/]+$", - "required": true, - "location": "path", - "description": "Required. The resource name of the model. Format: `tunedModels/my-model-id`" + "description": "Required. The name of the `Model` to use for generating the completion. Format: `name=models/{model}`." } - } - }, - "generateContent": { - "httpMethod": "POST", - "flatPath": "v1beta/tunedModels/{tunedModelsId}:generateContent", - "description": "Generates a response from the model given an input `GenerateContentRequest`. Input capabilities differ between models, including tuned models. See the [model guide](https://ai.google.dev/models/gemini) and [tuning guide](https://ai.google.dev/docs/model_tuning_guidance) for details.", - "id": "generativelanguage.tunedModels.generateContent", - "request": { - "$ref": "GenerateContentRequest" }, "parameterOrder": [ "model" ], - "parameters": { - "model": { - "type": "string", - "description": "Required. The name of the `Model` to use for generating the completion. Format: `name=models/{model}`.", - "pattern": "^tunedModels/[^/]+$", - "location": "path", - "required": true - } + "request": { + "$ref": "GenerateContentRequest" }, + "path": "v1beta/{+model}:generateContent", + "id": "generativelanguage.tunedModels.generateContent", "response": { "$ref": "GenerateContentResponse" - }, - "path": "v1beta/{+model}:generateContent" + } }, "patch": { - "path": "v1beta/{+name}", - "flatPath": "v1beta/tunedModels/{tunedModelsId}", + "description": "Updates a tuned model.", "id": "generativelanguage.tunedModels.patch", - "response": { + "flatPath": "v1beta/tunedModels/{tunedModelsId}", + "path": "v1beta/{+name}", + "httpMethod": "PATCH", + "request": { "$ref": "TunedModel" }, - "request": { + "response": { "$ref": "TunedModel" }, - "httpMethod": "PATCH", - "description": "Updates a tuned model.", + "parameterOrder": [ + "name" + ], "parameters": { "updateMask": { + "type": "string", "location": "query", "format": "google-fieldmask", - "type": "string", "description": "Required. The list of fields to update." }, "name": { - "type": "string", - "description": "Output only. The tuned model name. A unique name will be generated on create. Example: `tunedModels/az2mb0bpw6i` If display_name is set on create, the id portion of the name will be set by concatenating the words of the display_name with hyphens and adding a random portion for uniqueness. Example: display_name = \"Sentence Translator\" name = \"tunedModels/sentence-translator-u3b7m\"", - "required": true, + "location": "path", "pattern": "^tunedModels/[^/]+$", - "location": "path" + "required": true, + "type": "string", + "description": "Output only. The tuned model name. A unique name will be generated on create. Example: `tunedModels/az2mb0bpw6i` If display_name is set on create, the id portion of the name will be set by concatenating the words of the display_name with hyphens and adding a random portion for uniqueness. Example: display_name = \"Sentence Translator\" name = \"tunedModels/sentence-translator-u3b7m\"" } - }, - "parameterOrder": [ - "name" - ] + } }, "list": { "parameters": { @@ -3791,9 +4105,9 @@ }, "pageSize": { "format": "int32", - "type": "integer", + "description": "Optional. The maximum number of `TunedModels` to return (per page). The service may return fewer tuned models. If unspecified, at most 10 tuned models will be returned. This method returns at most 1000 models per page, even if you pass a larger page_size.", "location": "query", - "description": "Optional. The maximum number of `TunedModels` to return (per page). The service may return fewer tuned models. If unspecified, at most 10 tuned models will be returned. This method returns at most 1000 models per page, even if you pass a larger page_size." + "type": "integer" }, "pageToken": { "location": "query", @@ -3801,252 +4115,168 @@ "description": "Optional. A page token, received from a previous `ListTunedModels` call. Provide the `page_token` returned by one request as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListTunedModels` must match the call that provided the page token." } }, - "flatPath": "v1beta/tunedModels", "description": "Lists tuned models owned by the user.", - "path": "v1beta/tunedModels", - "parameterOrder": [], - "id": "generativelanguage.tunedModels.list", "response": { "$ref": "ListTunedModelsResponse" }, + "id": "generativelanguage.tunedModels.list", + "parameterOrder": [], + "flatPath": "v1beta/tunedModels", + "path": "v1beta/tunedModels", "httpMethod": "GET" }, "generateText": { - "flatPath": "v1beta/tunedModels/{tunedModelsId}:generateText", - "httpMethod": "POST", - "description": "Generates a response from the model given an input message.", "response": { "$ref": "GenerateTextResponse" }, - "parameters": { - "model": { - "pattern": "^tunedModels/[^/]+$", - "location": "path", - "type": "string", - "description": "Required. The name of the `Model` or `TunedModel` to use for generating the completion. Examples: models/text-bison-001 tunedModels/sentence-translator-u3b7m", - "required": true - } - }, + "flatPath": "v1beta/tunedModels/{tunedModelsId}:generateText", + "httpMethod": "POST", "request": { "$ref": "GenerateTextRequest" }, + "description": "Generates a response from the model given an input message.", + "id": "generativelanguage.tunedModels.generateText", + "path": "v1beta/{+model}:generateText", "parameterOrder": [ "model" ], - "path": "v1beta/{+model}:generateText", - "id": "generativelanguage.tunedModels.generateText" + "parameters": { + "model": { + "pattern": "^tunedModels/[^/]+$", + "description": "Required. The name of the `Model` or `TunedModel` to use for generating the completion. Examples: models/text-bison-001 tunedModels/sentence-translator-u3b7m", + "type": "string", + "location": "path", + "required": true + } + } }, - "transferOwnership": { + "get": { + "path": "v1beta/{+name}", "parameterOrder": [ "name" ], + "description": "Gets information about a specific TunedModel.", + "response": { + "$ref": "TunedModel" + }, + "httpMethod": "GET", + "flatPath": "v1beta/tunedModels/{tunedModelsId}", "parameters": { "name": { - "location": "path", - "description": "Required. The resource name of the tuned model to transfer ownership. Format: `tunedModels/my-model-id`", "required": true, - "pattern": "^tunedModels/[^/]+$", - "type": "string" + "location": "path", + "type": "string", + "description": "Required. The resource name of the model. Format: `tunedModels/my-model-id`", + "pattern": "^tunedModels/[^/]+$" } }, + "id": "generativelanguage.tunedModels.get" + }, + "create": { + "description": "Creates a tuned model. Intermediate tuning progress (if any) is accessed through the [google.longrunning.Operations] service. Status and results can be accessed through the Operations service. Example: GET /v1/tunedModels/az2mb0bpw6i/operations/000-111-222", + "parameterOrder": [], + "id": "generativelanguage.tunedModels.create", + "path": "v1beta/tunedModels", "request": { - "$ref": "TransferOwnershipRequest" + "$ref": "TunedModel" }, - "flatPath": "v1beta/tunedModels/{tunedModelsId}:transferOwnership", - "description": "Transfers ownership of the tuned model. This is the only way to change ownership of the tuned model. The current owner will be downgraded to writer role.", + "flatPath": "v1beta/tunedModels", + "httpMethod": "POST", "response": { - "$ref": "TransferOwnershipResponse" + "$ref": "Operation" }, - "path": "v1beta/{+name}:transferOwnership", - "httpMethod": "POST", - "id": "generativelanguage.tunedModels.transferOwnership" - }, - "create": { - "parameterOrder": [], - "description": "Creates a tuned model. Intermediate tuning progress (if any) is accessed through the [google.longrunning.Operations] service. Status and results can be accessed through the Operations service. Example: GET /v1/tunedModels/az2mb0bpw6i/operations/000-111-222", "parameters": { "tunedModelId": { "type": "string", "description": "Optional. The unique id for the tuned model if specified. This value should be up to 40 characters, the first character must be a letter, the last could be a letter or a number. The id must match the regular expression: [a-z]([a-z0-9-]{0,38}[a-z0-9])?.", "location": "query" } + } + } + } + }, + "files": { + "methods": { + "list": { + "httpMethod": "GET", + "description": "Lists the metadata for `File`s owned by the requesting project.", + "flatPath": "v1beta/files", + "parameters": { + "pageSize": { + "location": "query", + "format": "int32", + "type": "integer", + "description": "Optional. Maximum number of `File`s to return per page. If unspecified, defaults to 10. Maximum `page_size` is 100." + }, + "pageToken": { + "description": "Optional. A page token from a previous `ListFiles` call.", + "type": "string", + "location": "query" + } }, - "httpMethod": "POST", - "flatPath": "v1beta/tunedModels", - "request": { - "$ref": "TunedModel" - }, - "id": "generativelanguage.tunedModels.create", "response": { - "$ref": "Operation" + "$ref": "ListFilesResponse" }, - "path": "v1beta/tunedModels" + "parameterOrder": [], + "path": "v1beta/files", + "id": "generativelanguage.files.list" }, "delete": { - "parameterOrder": [ - "name" - ], - "flatPath": "v1beta/tunedModels/{tunedModelsId}", - "path": "v1beta/{+name}", - "description": "Deletes a tuned model.", - "httpMethod": "DELETE", + "id": "generativelanguage.files.delete", "response": { "$ref": "Empty" }, + "httpMethod": "DELETE", "parameters": { "name": { "required": true, - "description": "Required. The resource name of the model. Format: `tunedModels/my-model-id`", - "location": "path", - "pattern": "^tunedModels/[^/]+$", - "type": "string" + "pattern": "^files/[^/]+$", + "description": "Required. The name of the `File` to delete. Example: `files/abc-123`", + "type": "string", + "location": "path" } }, - "id": "generativelanguage.tunedModels.delete" - } - }, - "resources": { - "permissions": { - "methods": { - "patch": { - "request": { - "$ref": "Permission" - }, - "httpMethod": "PATCH", - "id": "generativelanguage.tunedModels.permissions.patch", - "parameterOrder": [ - "name" - ], - "description": "Updates the permission.", - "flatPath": "v1beta/tunedModels/{tunedModelsId}/permissions/{permissionsId}", - "parameters": { - "updateMask": { - "type": "string", - "format": "google-fieldmask", - "description": "Required. The list of fields to update. Accepted ones: - role (`Permission.role` field)", - "location": "query" - }, - "name": { - "required": true, - "pattern": "^tunedModels/[^/]+/permissions/[^/]+$", - "description": "Output only. Identifier. The permission name. A unique name will be generated on create. Examples: tunedModels/{tuned_model}/permissions/{permission} corpora/{corpus}/permissions/{permission} Output only.", - "type": "string", - "location": "path" - } - }, - "response": { - "$ref": "Permission" - }, - "path": "v1beta/{+name}" - }, - "list": { - "parameters": { - "pageSize": { - "type": "integer", - "format": "int32", - "location": "query", - "description": "Optional. The maximum number of `Permission`s to return (per page). The service may return fewer permissions. If unspecified, at most 10 permissions will be returned. This method returns at most 1000 permissions per page, even if you pass larger page_size." - }, - "pageToken": { - "type": "string", - "location": "query", - "description": "Optional. A page token, received from a previous `ListPermissions` call. Provide the `page_token` returned by one request as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListPermissions` must match the call that provided the page token." - }, - "parent": { - "pattern": "^tunedModels/[^/]+$", - "required": true, - "type": "string", - "description": "Required. The parent resource of the permissions. Formats: `tunedModels/{tuned_model}` `corpora/{corpus}`", - "location": "path" - } - }, - "flatPath": "v1beta/tunedModels/{tunedModelsId}/permissions", - "description": "Lists permissions for the specific resource.", - "path": "v1beta/{+parent}/permissions", - "parameterOrder": [ - "parent" - ], - "id": "generativelanguage.tunedModels.permissions.list", - "response": { - "$ref": "ListPermissionsResponse" - }, - "httpMethod": "GET" - }, - "delete": { - "parameters": { - "name": { - "location": "path", - "required": true, - "description": "Required. The resource name of the permission. Formats: `tunedModels/{tuned_model}/permissions/{permission}` `corpora/{corpus}/permissions/{permission}`", - "pattern": "^tunedModels/[^/]+/permissions/[^/]+$", - "type": "string" - } - }, - "parameterOrder": [ - "name" - ], - "response": { - "$ref": "Empty" - }, - "path": "v1beta/{+name}", - "flatPath": "v1beta/tunedModels/{tunedModelsId}/permissions/{permissionsId}", - "httpMethod": "DELETE", - "description": "Deletes the permission.", - "id": "generativelanguage.tunedModels.permissions.delete" - }, - "create": { - "request": { - "$ref": "Permission" - }, - "parameters": { - "parent": { - "description": "Required. The parent resource of the `Permission`. Formats: `tunedModels/{tuned_model}` `corpora/{corpus}`", - "pattern": "^tunedModels/[^/]+$", - "location": "path", - "type": "string", - "required": true - } - }, - "id": "generativelanguage.tunedModels.permissions.create", - "path": "v1beta/{+parent}/permissions", - "parameterOrder": [ - "parent" - ], - "flatPath": "v1beta/tunedModels/{tunedModelsId}/permissions", - "description": "Create a permission to a specific resource.", - "httpMethod": "POST", - "response": { - "$ref": "Permission" - } - }, - "get": { - "path": "v1beta/{+name}", - "response": { - "$ref": "Permission" - }, - "parameters": { - "name": { - "description": "Required. The resource name of the permission. Formats: `tunedModels/{tuned_model}/permissions/{permission}` `corpora/{corpus}/permissions/{permission}`", - "type": "string", - "required": true, - "location": "path", - "pattern": "^tunedModels/[^/]+/permissions/[^/]+$" - } - }, - "id": "generativelanguage.tunedModels.permissions.get", - "httpMethod": "GET", - "flatPath": "v1beta/tunedModels/{tunedModelsId}/permissions/{permissionsId}", - "parameterOrder": [ - "name" - ], - "description": "Gets information about a specific Permission." + "path": "v1beta/{+name}", + "description": "Deletes the `File`.", + "flatPath": "v1beta/files/{filesId}", + "parameterOrder": [ + "name" + ] + }, + "get": { + "id": "generativelanguage.files.get", + "description": "Gets the metadata for the given `File`.", + "response": { + "$ref": "File" + }, + "parameterOrder": [ + "name" + ], + "parameters": { + "name": { + "type": "string", + "description": "Required. The name of the `File` to get. Example: `files/abc-123`", + "location": "path", + "pattern": "^files/[^/]+$", + "required": true } - } + }, + "path": "v1beta/{+name}", + "flatPath": "v1beta/files/{filesId}", + "httpMethod": "GET" } } } }, - "name": "generativelanguage", - "mtlsRootUrl": "https://generativelanguage.mtls.googleapis.com/", - "fullyEncodeReservedExpansion": true + "rootUrl": "https://generativelanguage.googleapis.com/", + "revision": "20240619", + "fullyEncodeReservedExpansion": true, + "ownerName": "Google", + "description": "The Gemini API allows developers to build generative AI applications using Gemini models. Gemini is our most capable model, built from the ground up to be multimodal. It can generalize and seamlessly understand, operate across, and combine different types of information including language, images, audio, video, and code. You can use the Gemini API for use cases like reasoning across text and images, content generation, dialogue agents, summarization and classification systems, and more.", + "canonicalName": "Generative Language", + "ownerDomain": "google.com", + "documentationLink": "https://developers.generativeai.google/api", + "servicePath": "", + "version_module": true, + "id": "generativelanguage:v1beta" } diff --git a/genai/internal/generativelanguage/v1beta/generativelanguage-gen.go b/genai/internal/generativelanguage/v1beta/generativelanguage-gen.go index e712f81..32b45e0 100644 --- a/genai/internal/generativelanguage/v1beta/generativelanguage-gen.go +++ b/genai/internal/generativelanguage/v1beta/generativelanguage-gen.go @@ -123,6 +123,7 @@ func New(client *http.Client) (*Service, error) { return nil, errors.New("client is nil") } s := &Service{client: client, BasePath: basePath} + s.CachedContents = NewCachedContentsService(s) s.Corpora = NewCorporaService(s) s.Files = NewFilesService(s) s.Media = NewMediaService(s) @@ -136,6 +137,8 @@ type Service struct { BasePath string // API endpoint base URL UserAgent string // optional additional User-Agent fragment + CachedContents *CachedContentsService + Corpora *CorporaService Files *FilesService @@ -154,6 +157,15 @@ func (s *Service) userAgent() string { return googleapi.UserAgent + " " + s.UserAgent } +func NewCachedContentsService(s *Service) *CachedContentsService { + rs := &CachedContentsService{s: s} + return rs +} + +type CachedContentsService struct { + s *Service +} + func NewCorporaService(s *Service) *CorporaService { rs := &CorporaService{s: s} rs.Documents = NewCorporaDocumentsService(s) @@ -524,6 +536,84 @@ func (s *Blob) MarshalJSON() ([]byte, error) { return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } +// CachedContent: Content that has been preprocessed and can be used in +// subsequent request to GenerativeService. Cached content can be only used +// with model it was created for. +type CachedContent struct { + // Contents: Optional. Input only. Immutable. The content to cache. + Contents []*Content `json:"contents,omitempty"` + // CreateTime: Output only. Creation time of the cache entry. + CreateTime string `json:"createTime,omitempty"` + // DisplayName: Optional. Immutable. The user-generated meaningful display name + // of the cached content. Maximum 128 Unicode characters. + DisplayName string `json:"displayName,omitempty"` + // ExpireTime: Timestamp in UTC of when this resource is considered expired. + // This is *always* provided on output, regardless of what was sent on input. + ExpireTime string `json:"expireTime,omitempty"` + // Model: Required. Immutable. The name of the `Model` to use for cached + // content Format: `models/{model}` + Model string `json:"model,omitempty"` + // Name: Optional. Identifier. The resource name referring to the cached + // content. Format: `cachedContents/{id}` + Name string `json:"name,omitempty"` + // SystemInstruction: Optional. Input only. Immutable. Developer set system + // instruction. Currently text only. + SystemInstruction *Content `json:"systemInstruction,omitempty"` + // ToolConfig: Optional. Input only. Immutable. Tool config. This config is + // shared for all tools. + ToolConfig *ToolConfig `json:"toolConfig,omitempty"` + // Tools: Optional. Input only. Immutable. A list of `Tools` the model may use + // to generate the next response + Tools []*Tool `json:"tools,omitempty"` + // Ttl: Input only. New TTL for this resource, input only. + Ttl string `json:"ttl,omitempty"` + // UpdateTime: Output only. When the cache entry was last updated in UTC time. + UpdateTime string `json:"updateTime,omitempty"` + // UsageMetadata: Output only. Metadata on the usage of the cached content. + UsageMetadata *CachedContentUsageMetadata `json:"usageMetadata,omitempty"` + + // ServerResponse contains the HTTP response code and headers from the server. + googleapi.ServerResponse `json:"-"` + // ForceSendFields is a list of field names (e.g. "Contents") to + // unconditionally include in API requests. By default, fields with empty or + // default values are omitted from API requests. See + // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more + // details. + ForceSendFields []string `json:"-"` + // NullFields is a list of field names (e.g. "Contents") to include in API + // requests with the JSON null value. By default, fields with empty values are + // omitted from API requests. See + // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. + NullFields []string `json:"-"` +} + +func (s *CachedContent) MarshalJSON() ([]byte, error) { + type NoMethod CachedContent + return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) +} + +// CachedContentUsageMetadata: Metadata on the usage of the cached content. +type CachedContentUsageMetadata struct { + // TotalTokenCount: Total number of tokens that the cached content consumes. + TotalTokenCount int64 `json:"totalTokenCount,omitempty"` + // ForceSendFields is a list of field names (e.g. "TotalTokenCount") to + // unconditionally include in API requests. By default, fields with empty or + // default values are omitted from API requests. See + // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more + // details. + ForceSendFields []string `json:"-"` + // NullFields is a list of field names (e.g. "TotalTokenCount") to include in + // API requests with the JSON null value. By default, fields with empty values + // are omitted from API requests. See + // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. + NullFields []string `json:"-"` +} + +func (s *CachedContentUsageMetadata) MarshalJSON() ([]byte, error) { + type NoMethod CachedContentUsageMetadata + return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) +} + // Candidate: A response candidate generated from the model. type Candidate struct { // CitationMetadata: Output only. Citation information for model-generated @@ -1031,7 +1121,9 @@ func (s *CountTokensRequest) MarshalJSON() ([]byte, error) { // `token_count` for the `prompt`. type CountTokensResponse struct { // TotalTokens: The number of tokens that the `model` tokenizes the `prompt` - // into. Always non-negative. + // into. Always non-negative. When cached_content is set, this is still the + // total effective prompt size. I.e. this includes the number of tokens in the + // cached content. TotalTokens int64 `json:"totalTokens,omitempty"` // ServerResponse contains the HTTP response code and headers from the server. @@ -1816,6 +1908,11 @@ func (s *GenerateAnswerResponse) UnmarshalJSON(data []byte) error { // GenerateContentRequest: Request to generate a completion from the model. type GenerateContentRequest struct { + // CachedContent: Optional. The name of the cached content used as context to + // serve the prediction. Note: only used in explicit caching, where users can + // have control over caching (e.g. what content to cache) and enjoy guaranteed + // cost savings. Format: `cachedContents/{cachedContent}` + CachedContent string `json:"cachedContent,omitempty"` // Contents: Required. The content of the current conversation with the model. // For single-turn queries, this is a single instance. For multi-turn queries, // this is a repeated field that contains conversation history + latest @@ -1851,13 +1948,13 @@ type GenerateContentRequest struct { // knowledge and scope of the model. The only supported tool is currently // `Function`. Tools []*Tool `json:"tools,omitempty"` - // ForceSendFields is a list of field names (e.g. "Contents") to + // ForceSendFields is a list of field names (e.g. "CachedContent") to // unconditionally include in API requests. By default, fields with empty or // default values are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` - // NullFields is a list of field names (e.g. "Contents") to include in API + // NullFields is a list of field names (e.g. "CachedContent") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. @@ -2394,6 +2491,34 @@ func (s *InputFeedback) MarshalJSON() ([]byte, error) { return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } +// ListCachedContentsResponse: Response with CachedContents list. +type ListCachedContentsResponse struct { + // CachedContents: List of cached contents. + CachedContents []*CachedContent `json:"cachedContents,omitempty"` + // NextPageToken: A token, which can be sent as `page_token` to retrieve the + // next page. If this field is omitted, there are no subsequent pages. + NextPageToken string `json:"nextPageToken,omitempty"` + + // ServerResponse contains the HTTP response code and headers from the server. + googleapi.ServerResponse `json:"-"` + // ForceSendFields is a list of field names (e.g. "CachedContents") to + // unconditionally include in API requests. By default, fields with empty or + // default values are omitted from API requests. See + // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more + // details. + ForceSendFields []string `json:"-"` + // NullFields is a list of field names (e.g. "CachedContents") to include in + // API requests with the JSON null value. By default, fields with empty values + // are omitted from API requests. See + // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. + NullFields []string `json:"-"` +} + +func (s *ListCachedContentsResponse) MarshalJSON() ([]byte, error) { + type NoMethod ListCachedContentsResponse + return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) +} + // ListChunksResponse: Response from `ListChunks` containing a paginated list // of `Chunk`s. The `Chunk`s are sorted by ascending `chunk.create_time`. type ListChunksResponse struct { @@ -2719,6 +2844,8 @@ type Model struct { DisplayName string `json:"displayName,omitempty"` // InputTokenLimit: Maximum number of input tokens allowed for this model. InputTokenLimit int64 `json:"inputTokenLimit,omitempty"` + // MaxTemperature: The maximum temperature this model can use. + MaxTemperature float64 `json:"maxTemperature,omitempty"` // Name: Required. The resource name of the `Model`. Format: `models/{model}` // with a `{model}` naming convention of: * "{base_model_id}-{version}" // Examples: * `models/chat-bison-001` @@ -2730,10 +2857,10 @@ type Model struct { // which correspond to API methods. SupportedGenerationMethods []string `json:"supportedGenerationMethods,omitempty"` // Temperature: Controls the randomness of the output. Values can range over - // `[0.0,2.0]`, inclusive. A higher value will produce responses that are more - // varied, while a value closer to `0.0` will typically result in less - // surprising responses from the model. This value specifies default to be used - // by the backend while making the call to the model. + // `[0.0,max_temperature]`, inclusive. A higher value will produce responses + // that are more varied, while a value closer to `0.0` will typically result in + // less surprising responses from the model. This value specifies default to be + // used by the backend while making the call to the model. Temperature float64 `json:"temperature,omitempty"` // TopK: For Top-k sampling. Top-k sampling considers the set of `top_k` most // probable tokens. This value specifies default to be used by the backend @@ -2771,14 +2898,16 @@ func (s *Model) MarshalJSON() ([]byte, error) { func (s *Model) UnmarshalJSON(data []byte) error { type NoMethod Model var s1 struct { - Temperature gensupport.JSONFloat64 `json:"temperature"` - TopP gensupport.JSONFloat64 `json:"topP"` + MaxTemperature gensupport.JSONFloat64 `json:"maxTemperature"` + Temperature gensupport.JSONFloat64 `json:"temperature"` + TopP gensupport.JSONFloat64 `json:"topP"` *NoMethod } s1.NoMethod = (*NoMethod)(s) if err := json.Unmarshal(data, &s1); err != nil { return err } + s.MaxTemperature = float64(s1.MaxTemperature) s.Temperature = float64(s1.Temperature) s.TopP = float64(s1.TopP) return nil @@ -2940,7 +3069,7 @@ type PromptFeedback struct { // "BLOCK_REASON_UNSPECIFIED" - Default value. This value is unused. // "SAFETY" - Prompt was blocked due to safety reasons. You can inspect // `safety_ratings` to understand which safety category blocked it. - // "OTHER" - Prompt was blocked due to unknown reaasons. + // "OTHER" - Prompt was blocked due to unknown reasons. BlockReason string `json:"blockReason,omitempty"` // SafetyRatings: Ratings for safety of the prompt. There is at most one rating // per category. @@ -3864,23 +3993,28 @@ func (s *UpdateChunkRequest) MarshalJSON() ([]byte, error) { // UsageMetadata: Metadata on the generation request's token usage. type UsageMetadata struct { + // CachedContentTokenCount: Number of tokens in the cached part of the prompt, + // i.e. in the cached content. + CachedContentTokenCount int64 `json:"cachedContentTokenCount,omitempty"` // CandidatesTokenCount: Total number of tokens across the generated // candidates. CandidatesTokenCount int64 `json:"candidatesTokenCount,omitempty"` - // PromptTokenCount: Number of tokens in the prompt. + // PromptTokenCount: Number of tokens in the prompt. When cached_content is + // set, this is still the total effective prompt size. I.e. this includes the + // number of tokens in the cached content. PromptTokenCount int64 `json:"promptTokenCount,omitempty"` // TotalTokenCount: Total token count for the generation request (prompt + // candidates). TotalTokenCount int64 `json:"totalTokenCount,omitempty"` - // ForceSendFields is a list of field names (e.g. "CandidatesTokenCount") to + // ForceSendFields is a list of field names (e.g. "CachedContentTokenCount") to // unconditionally include in API requests. By default, fields with empty or // default values are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` - // NullFields is a list of field names (e.g. "CandidatesTokenCount") to include - // in API requests with the JSON null value. By default, fields with empty - // values are omitted from API requests. See + // NullFields is a list of field names (e.g. "CachedContentTokenCount") to + // include in API requests with the JSON null value. By default, fields with + // empty values are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } @@ -3912,6 +4046,553 @@ func (s *VideoMetadata) MarshalJSON() ([]byte, error) { return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } +type CachedContentsCreateCall struct { + s *Service + cachedcontent *CachedContent + urlParams_ gensupport.URLParams + ctx_ context.Context + header_ http.Header +} + +// Create: Creates CachedContent resource. +func (r *CachedContentsService) Create(cachedcontent *CachedContent) *CachedContentsCreateCall { + c := &CachedContentsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.cachedcontent = cachedcontent + return c +} + +// Fields allows partial responses to be retrieved. See +// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more +// details. +func (c *CachedContentsCreateCall) Fields(s ...googleapi.Field) *CachedContentsCreateCall { + c.urlParams_.Set("fields", googleapi.CombineFields(s)) + return c +} + +// Context sets the context to be used in this call's Do method. +func (c *CachedContentsCreateCall) Context(ctx context.Context) *CachedContentsCreateCall { + c.ctx_ = ctx + return c +} + +// Header returns a http.Header that can be modified by the caller to add +// headers to the request. +func (c *CachedContentsCreateCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + +func (c *CachedContentsCreateCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) + var body io.Reader = nil + body, err := googleapi.WithoutDataWrapper.JSONReader(c.cachedcontent) + if err != nil { + return nil, err + } + c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") + urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/cachedContents") + urls += "?" + c.urlParams_.Encode() + req, err := http.NewRequest("POST", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders + return gensupport.SendRequest(c.ctx_, c.s.client, req) +} + +// Do executes the "generativelanguage.cachedContents.create" call. +// Any non-2xx status code is an error. Response headers are in either +// *CachedContent.ServerResponse.Header or (if a response was returned at all) +// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check +// whether the returned error was because http.StatusNotModified was returned. +func (c *CachedContentsCreateCall) Do(opts ...googleapi.CallOption) (*CachedContent, error) { + gensupport.SetOptions(c.urlParams_, opts...) + res, err := c.doRequest("json") + if res != nil && res.StatusCode == http.StatusNotModified { + if res.Body != nil { + res.Body.Close() + } + return nil, gensupport.WrapError(&googleapi.Error{ + Code: res.StatusCode, + Header: res.Header, + }) + } + if err != nil { + return nil, err + } + defer googleapi.CloseBody(res) + if err := googleapi.CheckResponse(res); err != nil { + return nil, gensupport.WrapError(err) + } + ret := &CachedContent{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { + return nil, err + } + return ret, nil +} + +type CachedContentsDeleteCall struct { + s *Service + name string + urlParams_ gensupport.URLParams + ctx_ context.Context + header_ http.Header +} + +// Delete: Deletes CachedContent resource. +// +// - name: The resource name referring to the content cache entry Format: +// `cachedContents/{id}`. +func (r *CachedContentsService) Delete(name string) *CachedContentsDeleteCall { + c := &CachedContentsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.name = name + return c +} + +// Fields allows partial responses to be retrieved. See +// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more +// details. +func (c *CachedContentsDeleteCall) Fields(s ...googleapi.Field) *CachedContentsDeleteCall { + c.urlParams_.Set("fields", googleapi.CombineFields(s)) + return c +} + +// Context sets the context to be used in this call's Do method. +func (c *CachedContentsDeleteCall) Context(ctx context.Context) *CachedContentsDeleteCall { + c.ctx_ = ctx + return c +} + +// Header returns a http.Header that can be modified by the caller to add +// headers to the request. +func (c *CachedContentsDeleteCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + +func (c *CachedContentsDeleteCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") + urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}") + urls += "?" + c.urlParams_.Encode() + req, err := http.NewRequest("DELETE", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders + googleapi.Expand(req.URL, map[string]string{ + "name": c.name, + }) + return gensupport.SendRequest(c.ctx_, c.s.client, req) +} + +// Do executes the "generativelanguage.cachedContents.delete" call. +// Any non-2xx status code is an error. Response headers are in either +// *Empty.ServerResponse.Header or (if a response was returned at all) in +// error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check +// whether the returned error was because http.StatusNotModified was returned. +func (c *CachedContentsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) { + gensupport.SetOptions(c.urlParams_, opts...) + res, err := c.doRequest("json") + if res != nil && res.StatusCode == http.StatusNotModified { + if res.Body != nil { + res.Body.Close() + } + return nil, gensupport.WrapError(&googleapi.Error{ + Code: res.StatusCode, + Header: res.Header, + }) + } + if err != nil { + return nil, err + } + defer googleapi.CloseBody(res) + if err := googleapi.CheckResponse(res); err != nil { + return nil, gensupport.WrapError(err) + } + ret := &Empty{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { + return nil, err + } + return ret, nil +} + +type CachedContentsGetCall struct { + s *Service + name string + urlParams_ gensupport.URLParams + ifNoneMatch_ string + ctx_ context.Context + header_ http.Header +} + +// Get: Reads CachedContent resource. +// +// - name: The resource name referring to the content cache entry. Format: +// `cachedContents/{id}`. +func (r *CachedContentsService) Get(name string) *CachedContentsGetCall { + c := &CachedContentsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.name = name + return c +} + +// Fields allows partial responses to be retrieved. See +// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more +// details. +func (c *CachedContentsGetCall) Fields(s ...googleapi.Field) *CachedContentsGetCall { + c.urlParams_.Set("fields", googleapi.CombineFields(s)) + return c +} + +// IfNoneMatch sets an optional parameter which makes the operation fail if the +// object's ETag matches the given value. This is useful for getting updates +// only after the object has changed since the last request. +func (c *CachedContentsGetCall) IfNoneMatch(entityTag string) *CachedContentsGetCall { + c.ifNoneMatch_ = entityTag + return c +} + +// Context sets the context to be used in this call's Do method. +func (c *CachedContentsGetCall) Context(ctx context.Context) *CachedContentsGetCall { + c.ctx_ = ctx + return c +} + +// Header returns a http.Header that can be modified by the caller to add +// headers to the request. +func (c *CachedContentsGetCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + +func (c *CachedContentsGetCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) + if c.ifNoneMatch_ != "" { + reqHeaders.Set("If-None-Match", c.ifNoneMatch_) + } + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") + urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}") + urls += "?" + c.urlParams_.Encode() + req, err := http.NewRequest("GET", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders + googleapi.Expand(req.URL, map[string]string{ + "name": c.name, + }) + return gensupport.SendRequest(c.ctx_, c.s.client, req) +} + +// Do executes the "generativelanguage.cachedContents.get" call. +// Any non-2xx status code is an error. Response headers are in either +// *CachedContent.ServerResponse.Header or (if a response was returned at all) +// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check +// whether the returned error was because http.StatusNotModified was returned. +func (c *CachedContentsGetCall) Do(opts ...googleapi.CallOption) (*CachedContent, error) { + gensupport.SetOptions(c.urlParams_, opts...) + res, err := c.doRequest("json") + if res != nil && res.StatusCode == http.StatusNotModified { + if res.Body != nil { + res.Body.Close() + } + return nil, gensupport.WrapError(&googleapi.Error{ + Code: res.StatusCode, + Header: res.Header, + }) + } + if err != nil { + return nil, err + } + defer googleapi.CloseBody(res) + if err := googleapi.CheckResponse(res); err != nil { + return nil, gensupport.WrapError(err) + } + ret := &CachedContent{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { + return nil, err + } + return ret, nil +} + +type CachedContentsListCall struct { + s *Service + urlParams_ gensupport.URLParams + ifNoneMatch_ string + ctx_ context.Context + header_ http.Header +} + +// List: Lists CachedContents. +func (r *CachedContentsService) List() *CachedContentsListCall { + c := &CachedContentsListCall{s: r.s, urlParams_: make(gensupport.URLParams)} + return c +} + +// PageSize sets the optional parameter "pageSize": The maximum number of +// cached contents to return. The service may return fewer than this value. If +// unspecified, some default (under maximum) number of items will be returned. +// The maximum value is 1000; values above 1000 will be coerced to 1000. +func (c *CachedContentsListCall) PageSize(pageSize int64) *CachedContentsListCall { + c.urlParams_.Set("pageSize", fmt.Sprint(pageSize)) + return c +} + +// PageToken sets the optional parameter "pageToken": A page token, received +// from a previous `ListCachedContents` call. Provide this to retrieve the +// subsequent page. When paginating, all other parameters provided to +// `ListCachedContents` must match the call that provided the page token. +func (c *CachedContentsListCall) PageToken(pageToken string) *CachedContentsListCall { + c.urlParams_.Set("pageToken", pageToken) + return c +} + +// Fields allows partial responses to be retrieved. See +// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more +// details. +func (c *CachedContentsListCall) Fields(s ...googleapi.Field) *CachedContentsListCall { + c.urlParams_.Set("fields", googleapi.CombineFields(s)) + return c +} + +// IfNoneMatch sets an optional parameter which makes the operation fail if the +// object's ETag matches the given value. This is useful for getting updates +// only after the object has changed since the last request. +func (c *CachedContentsListCall) IfNoneMatch(entityTag string) *CachedContentsListCall { + c.ifNoneMatch_ = entityTag + return c +} + +// Context sets the context to be used in this call's Do method. +func (c *CachedContentsListCall) Context(ctx context.Context) *CachedContentsListCall { + c.ctx_ = ctx + return c +} + +// Header returns a http.Header that can be modified by the caller to add +// headers to the request. +func (c *CachedContentsListCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + +func (c *CachedContentsListCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) + if c.ifNoneMatch_ != "" { + reqHeaders.Set("If-None-Match", c.ifNoneMatch_) + } + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") + urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/cachedContents") + urls += "?" + c.urlParams_.Encode() + req, err := http.NewRequest("GET", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders + return gensupport.SendRequest(c.ctx_, c.s.client, req) +} + +// Do executes the "generativelanguage.cachedContents.list" call. +// Any non-2xx status code is an error. Response headers are in either +// *ListCachedContentsResponse.ServerResponse.Header or (if a response was +// returned at all) in error.(*googleapi.Error).Header. Use +// googleapi.IsNotModified to check whether the returned error was because +// http.StatusNotModified was returned. +func (c *CachedContentsListCall) Do(opts ...googleapi.CallOption) (*ListCachedContentsResponse, error) { + gensupport.SetOptions(c.urlParams_, opts...) + res, err := c.doRequest("json") + if res != nil && res.StatusCode == http.StatusNotModified { + if res.Body != nil { + res.Body.Close() + } + return nil, gensupport.WrapError(&googleapi.Error{ + Code: res.StatusCode, + Header: res.Header, + }) + } + if err != nil { + return nil, err + } + defer googleapi.CloseBody(res) + if err := googleapi.CheckResponse(res); err != nil { + return nil, gensupport.WrapError(err) + } + ret := &ListCachedContentsResponse{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { + return nil, err + } + return ret, nil +} + +// Pages invokes f for each page of results. +// A non-nil error returned from f will halt the iteration. +// The provided context supersedes any context provided to the Context method. +func (c *CachedContentsListCall) Pages(ctx context.Context, f func(*ListCachedContentsResponse) error) error { + c.ctx_ = ctx + defer c.PageToken(c.urlParams_.Get("pageToken")) + for { + x, err := c.Do() + if err != nil { + return err + } + if err := f(x); err != nil { + return err + } + if x.NextPageToken == "" { + return nil + } + c.PageToken(x.NextPageToken) + } +} + +type CachedContentsPatchCall struct { + s *Service + name string + cachedcontent *CachedContent + urlParams_ gensupport.URLParams + ctx_ context.Context + header_ http.Header +} + +// Patch: Updates CachedContent resource (only expiration is updatable). +// +// - name: Optional. Identifier. The resource name referring to the cached +// content. Format: `cachedContents/{id}`. +func (r *CachedContentsService) Patch(name string, cachedcontent *CachedContent) *CachedContentsPatchCall { + c := &CachedContentsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.name = name + c.cachedcontent = cachedcontent + return c +} + +// UpdateMask sets the optional parameter "updateMask": The list of fields to +// update. +func (c *CachedContentsPatchCall) UpdateMask(updateMask string) *CachedContentsPatchCall { + c.urlParams_.Set("updateMask", updateMask) + return c +} + +// Fields allows partial responses to be retrieved. See +// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more +// details. +func (c *CachedContentsPatchCall) Fields(s ...googleapi.Field) *CachedContentsPatchCall { + c.urlParams_.Set("fields", googleapi.CombineFields(s)) + return c +} + +// Context sets the context to be used in this call's Do method. +func (c *CachedContentsPatchCall) Context(ctx context.Context) *CachedContentsPatchCall { + c.ctx_ = ctx + return c +} + +// Header returns a http.Header that can be modified by the caller to add +// headers to the request. +func (c *CachedContentsPatchCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + +func (c *CachedContentsPatchCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) + var body io.Reader = nil + body, err := googleapi.WithoutDataWrapper.JSONReader(c.cachedcontent) + if err != nil { + return nil, err + } + c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") + urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}") + urls += "?" + c.urlParams_.Encode() + req, err := http.NewRequest("PATCH", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders + googleapi.Expand(req.URL, map[string]string{ + "name": c.name, + }) + return gensupport.SendRequest(c.ctx_, c.s.client, req) +} + +// Do executes the "generativelanguage.cachedContents.patch" call. +// Any non-2xx status code is an error. Response headers are in either +// *CachedContent.ServerResponse.Header or (if a response was returned at all) +// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check +// whether the returned error was because http.StatusNotModified was returned. +func (c *CachedContentsPatchCall) Do(opts ...googleapi.CallOption) (*CachedContent, error) { + gensupport.SetOptions(c.urlParams_, opts...) + res, err := c.doRequest("json") + if res != nil && res.StatusCode == http.StatusNotModified { + if res.Body != nil { + res.Body.Close() + } + return nil, gensupport.WrapError(&googleapi.Error{ + Code: res.StatusCode, + Header: res.Header, + }) + } + if err != nil { + return nil, err + } + defer googleapi.CloseBody(res) + if err := googleapi.CheckResponse(res); err != nil { + return nil, gensupport.WrapError(err) + } + ret := &CachedContent{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { + return nil, err + } + return ret, nil +} + type CorporaCreateCall struct { s *Service corpus *Corpus diff --git a/internal/support/README.md b/internal/support/README.md deleted file mode 100644 index ee16723..0000000 --- a/internal/support/README.md +++ /dev/null @@ -1,2 +0,0 @@ -These files are copied from -https://github.com/googleapis/google-cloud-go/tree/main/internal/protoveneer/support. diff --git a/internal/support/support.go b/internal/support/support.go deleted file mode 100644 index a59c4c8..0000000 --- a/internal/support/support.go +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright 2024 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package support provides support functions for protoveneer. -package support - -import ( - "fmt" - "time" - - "cloud.google.com/go/civil" - "github.com/googleapis/gax-go/v2/apierror" - spb "google.golang.org/genproto/googleapis/rpc/status" - "google.golang.org/genproto/googleapis/type/date" - gstatus "google.golang.org/grpc/status" - "google.golang.org/protobuf/types/known/durationpb" - "google.golang.org/protobuf/types/known/structpb" - "google.golang.org/protobuf/types/known/timestamppb" -) - -// TransformSlice applies f to each element of from and returns -// a new slice with the results. -func TransformSlice[From, To any](from []From, f func(From) To) []To { - if from == nil { - return nil - } - to := make([]To, len(from)) - for i, e := range from { - to[i] = f(e) - } - return to -} - -// TransformMapValues applies f to each value of from, returning a new map. -// It does not change the keys. -func TransformMapValues[K comparable, VFrom, VTo any](from map[K]VFrom, f func(VFrom) VTo) map[K]VTo { - if from == nil { - return nil - } - to := map[K]VTo{} - for k, v := range from { - to[k] = f(v) - } - return to -} - -// AddrOrNil returns nil if x is the zero value for T, -// or &x otherwise. -func AddrOrNil[T comparable](x T) *T { - var z T - if x == z { - return nil - } - return &x -} - -// DerefOrZero returns the zero value for T if x is nil, -// or *x otherwise. -func DerefOrZero[T any](x *T) T { - if x == nil { - var z T - return z - } - return *x -} - -// CivilDateToProto converts a civil.Date to a date.Date. -func CivilDateToProto(d civil.Date) *date.Date { - return &date.Date{ - Year: int32(d.Year), - Month: int32(d.Month), - Day: int32(d.Day), - } -} - -// CivilDateFromProto converts a date.Date to a civil.Date. -func CivilDateFromProto(p *date.Date) civil.Date { - if p == nil { - return civil.Date{} - } - return civil.Date{ - Year: int(p.Year), - Month: time.Month(p.Month), - Day: int(p.Day), - } -} - -// MapToStructPB converts a map into a structpb.Struct. -func MapToStructPB(m map[string]any) *structpb.Struct { - if m == nil { - return nil - } - s, err := structpb.NewStruct(m) - if err != nil { - panic(fmt.Errorf("support.MapToProto: %w", err)) - } - return s -} - -// MapFromStructPB converts a structpb.Struct to a map. -func MapFromStructPB(p *structpb.Struct) map[string]any { - if p == nil { - return nil - } - return p.AsMap() -} - -// TimeToProto converts a time.Time into a Timestamp. -func TimeToProto(t time.Time) *timestamppb.Timestamp { - if t.IsZero() { - return nil - } - return timestamppb.New(t) -} - -// TimeFromProto converts a Timestamp into a time.Time. -func TimeFromProto(ts *timestamppb.Timestamp) time.Time { - if ts == nil { - return time.Time{} - } - return ts.AsTime() -} - -// APIErrorToProto converts an APIError to a proto Status. -func APIErrorToProto(ae *apierror.APIError) *spb.Status { - if ae == nil { - return nil - } - return ae.GRPCStatus().Proto() -} - -// APIErrorFromProto converts a proto Status to an APIError. -func APIErrorFromProto(s *spb.Status) *apierror.APIError { - err := gstatus.ErrorProto(s) - aerr, ok := apierror.ParseError(err, true) - if !ok { - // Should be impossible. - return nil - } - return aerr -} - -// DurationFromProto converts a Duration proto to a time.Duration. -func DurationFromProto(d *durationpb.Duration) time.Duration { - if d == nil { - return 0 - } - return d.AsDuration() -} diff --git a/internal/support/support_test.go b/internal/support/support_test.go deleted file mode 100644 index 347dd0d..0000000 --- a/internal/support/support_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2024 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package support - -import ( - "reflect" - "strconv" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" - "google.golang.org/genproto/googleapis/rpc/errdetails" - spb "google.golang.org/genproto/googleapis/rpc/status" - "google.golang.org/protobuf/types/known/anypb" -) - -func TestTransformMapValues(t *testing.T) { - var from map[string]int - got := TransformMapValues(from, strconv.Itoa) - if got != nil { - t.Fatalf("got %v, want nil", got) - } - from = map[string]int{"one": 1, "two": 2} - got = TransformMapValues(from, strconv.Itoa) - want := map[string]string{"one": "1", "two": "2"} - if !reflect.DeepEqual(got, want) { - t.Errorf("got %v, want %v", got, want) - } -} - -func TestAPIError(t *testing.T) { - const ( - code = 3 // gRPC "invalid argument" - msg = "message" - reason = "reason" - ) - ei := &errdetails.ErrorInfo{Reason: reason} - pbany, err := anypb.New(ei) - if err != nil { - t.Fatal(err) - } - s := &spb.Status{ - Code: code, - Message: msg, - Details: []*anypb.Any{pbany}, - } - - ae := APIErrorFromProto(s) - if ae == nil { - t.Fatal("got nil") - } - gs := ae.GRPCStatus() - if g := gs.Code(); g != code { - t.Errorf("got %d, want %d", g, code) - } - if g := gs.Message(); g != msg { - t.Errorf("got %q, want %q", g, msg) - } - if g := ae.Reason(); g != reason { - t.Errorf("got %q, want %q", g, reason) - } - - gps := APIErrorToProto(ae) - if !cmp.Equal(gps, s, cmpopts.IgnoreUnexported(spb.Status{}, anypb.Any{})) { - t.Errorf("\ngot %s\nwant %s", gps, s) - } -}