Documentation ¶
Overview ¶
Package generativelanguage is an auto-generated package for the Generative Language API.
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.
NOTE: This package is in beta. It is not stable, and may be subject to changes.
General documentation ¶
For information that is relevant for all client libraries please reference https://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on this page includes:
- Authentication and Authorization
- Timeouts and Cancellation
- Testing against Client Libraries
- Debugging Client Libraries
- Inspecting errors
Example usage ¶
To get started with this package, create a client.
ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewDiscussClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close()
The client will use your default application credentials. Clients should be reused instead of created as needed. The methods of Client are safe for concurrent use by multiple goroutines. The returned client must be Closed when it is done being used.
Using the Client ¶
The following is an example of making an API call with the newly created client.
ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewDiscussClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.CountMessageTokensRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#CountMessageTokensRequest. } resp, err := c.CountMessageTokens(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Use of Context ¶
The ctx passed to NewDiscussClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.
To close the open connection, use the Close() method.
Index ¶
- func DefaultAuthScopes() []string
- type ChunkIterator
- type CorpusIterator
- type CreateTunedModelOperation
- func (op *CreateTunedModelOperation) Done() bool
- func (op *CreateTunedModelOperation) Metadata() (*generativelanguagepb.CreateTunedModelMetadata, error)
- func (op *CreateTunedModelOperation) Name() string
- func (op *CreateTunedModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*generativelanguagepb.TunedModel, error)
- func (op *CreateTunedModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*generativelanguagepb.TunedModel, error)
- type DiscussCallOptions
- type DiscussClient
- func (c *DiscussClient) Close() error
- func (c *DiscussClient) Connection() *grpc.ClientConndeprecated
- func (c *DiscussClient) CountMessageTokens(ctx context.Context, req *generativelanguagepb.CountMessageTokensRequest, ...) (*generativelanguagepb.CountMessageTokensResponse, error)
- func (c *DiscussClient) GenerateMessage(ctx context.Context, req *generativelanguagepb.GenerateMessageRequest, ...) (*generativelanguagepb.GenerateMessageResponse, error)
- type DocumentIterator
- type FileCallOptions
- type FileClient
- func (c *FileClient) Close() error
- func (c *FileClient) Connection() *grpc.ClientConndeprecated
- func (c *FileClient) CreateFile(ctx context.Context, req *generativelanguagepb.CreateFileRequest, ...) (*generativelanguagepb.CreateFileResponse, error)
- func (c *FileClient) DeleteFile(ctx context.Context, req *generativelanguagepb.DeleteFileRequest, ...) error
- func (c *FileClient) GetFile(ctx context.Context, req *generativelanguagepb.GetFileRequest, ...) (*generativelanguagepb.File, error)
- func (c *FileClient) ListFiles(ctx context.Context, req *generativelanguagepb.ListFilesRequest, ...) *FileIterator
- type FileIterator
- type GenerativeCallOptions
- type GenerativeClient
- func (c *GenerativeClient) BatchEmbedContents(ctx context.Context, req *generativelanguagepb.BatchEmbedContentsRequest, ...) (*generativelanguagepb.BatchEmbedContentsResponse, error)
- func (c *GenerativeClient) Close() error
- func (c *GenerativeClient) Connection() *grpc.ClientConndeprecated
- func (c *GenerativeClient) CountTokens(ctx context.Context, req *generativelanguagepb.CountTokensRequest, ...) (*generativelanguagepb.CountTokensResponse, error)
- func (c *GenerativeClient) EmbedContent(ctx context.Context, req *generativelanguagepb.EmbedContentRequest, ...) (*generativelanguagepb.EmbedContentResponse, error)
- func (c *GenerativeClient) GenerateAnswer(ctx context.Context, req *generativelanguagepb.GenerateAnswerRequest, ...) (*generativelanguagepb.GenerateAnswerResponse, error)
- func (c *GenerativeClient) GenerateContent(ctx context.Context, req *generativelanguagepb.GenerateContentRequest, ...) (*generativelanguagepb.GenerateContentResponse, error)
- func (c *GenerativeClient) SetGoogleClientInfo(keyval ...string)
- func (c *GenerativeClient) StreamGenerateContent(ctx context.Context, req *generativelanguagepb.GenerateContentRequest, ...) (generativelanguagepb.GenerativeService_StreamGenerateContentClient, error)
- type ModelCallOptions
- type ModelClient
- func (c *ModelClient) Close() error
- func (c *ModelClient) Connection() *grpc.ClientConndeprecated
- func (c *ModelClient) CreateTunedModel(ctx context.Context, req *generativelanguagepb.CreateTunedModelRequest, ...) (*CreateTunedModelOperation, error)
- func (c *ModelClient) CreateTunedModelOperation(name string) *CreateTunedModelOperation
- func (c *ModelClient) DeleteTunedModel(ctx context.Context, req *generativelanguagepb.DeleteTunedModelRequest, ...) error
- func (c *ModelClient) GetModel(ctx context.Context, req *generativelanguagepb.GetModelRequest, ...) (*generativelanguagepb.Model, error)
- func (c *ModelClient) GetTunedModel(ctx context.Context, req *generativelanguagepb.GetTunedModelRequest, ...) (*generativelanguagepb.TunedModel, error)
- func (c *ModelClient) ListModels(ctx context.Context, req *generativelanguagepb.ListModelsRequest, ...) *ModelIterator
- func (c *ModelClient) ListTunedModels(ctx context.Context, req *generativelanguagepb.ListTunedModelsRequest, ...) *TunedModelIterator
- func (c *ModelClient) UpdateTunedModel(ctx context.Context, req *generativelanguagepb.UpdateTunedModelRequest, ...) (*generativelanguagepb.TunedModel, error)
- type ModelIterator
- type PermissionCallOptions
- type PermissionClient
- func (c *PermissionClient) Close() error
- func (c *PermissionClient) Connection() *grpc.ClientConndeprecated
- func (c *PermissionClient) CreatePermission(ctx context.Context, req *generativelanguagepb.CreatePermissionRequest, ...) (*generativelanguagepb.Permission, error)
- func (c *PermissionClient) DeletePermission(ctx context.Context, req *generativelanguagepb.DeletePermissionRequest, ...) error
- func (c *PermissionClient) GetPermission(ctx context.Context, req *generativelanguagepb.GetPermissionRequest, ...) (*generativelanguagepb.Permission, error)
- func (c *PermissionClient) ListPermissions(ctx context.Context, req *generativelanguagepb.ListPermissionsRequest, ...) *PermissionIterator
- func (c *PermissionClient) TransferOwnership(ctx context.Context, req *generativelanguagepb.TransferOwnershipRequest, ...) (*generativelanguagepb.TransferOwnershipResponse, error)
- func (c *PermissionClient) UpdatePermission(ctx context.Context, req *generativelanguagepb.UpdatePermissionRequest, ...) (*generativelanguagepb.Permission, error)
- type PermissionIterator
- type RetrieverCallOptions
- type RetrieverClient
- func (c *RetrieverClient) BatchCreateChunks(ctx context.Context, req *generativelanguagepb.BatchCreateChunksRequest, ...) (*generativelanguagepb.BatchCreateChunksResponse, error)
- func (c *RetrieverClient) BatchDeleteChunks(ctx context.Context, req *generativelanguagepb.BatchDeleteChunksRequest, ...) error
- func (c *RetrieverClient) BatchUpdateChunks(ctx context.Context, req *generativelanguagepb.BatchUpdateChunksRequest, ...) (*generativelanguagepb.BatchUpdateChunksResponse, error)
- func (c *RetrieverClient) Close() error
- func (c *RetrieverClient) Connection() *grpc.ClientConndeprecated
- func (c *RetrieverClient) CreateChunk(ctx context.Context, req *generativelanguagepb.CreateChunkRequest, ...) (*generativelanguagepb.Chunk, error)
- func (c *RetrieverClient) CreateCorpus(ctx context.Context, req *generativelanguagepb.CreateCorpusRequest, ...) (*generativelanguagepb.Corpus, error)
- func (c *RetrieverClient) CreateDocument(ctx context.Context, req *generativelanguagepb.CreateDocumentRequest, ...) (*generativelanguagepb.Document, error)
- func (c *RetrieverClient) DeleteChunk(ctx context.Context, req *generativelanguagepb.DeleteChunkRequest, ...) error
- func (c *RetrieverClient) DeleteCorpus(ctx context.Context, req *generativelanguagepb.DeleteCorpusRequest, ...) error
- func (c *RetrieverClient) DeleteDocument(ctx context.Context, req *generativelanguagepb.DeleteDocumentRequest, ...) error
- func (c *RetrieverClient) GetChunk(ctx context.Context, req *generativelanguagepb.GetChunkRequest, ...) (*generativelanguagepb.Chunk, error)
- func (c *RetrieverClient) GetCorpus(ctx context.Context, req *generativelanguagepb.GetCorpusRequest, ...) (*generativelanguagepb.Corpus, error)
- func (c *RetrieverClient) GetDocument(ctx context.Context, req *generativelanguagepb.GetDocumentRequest, ...) (*generativelanguagepb.Document, error)
- func (c *RetrieverClient) ListChunks(ctx context.Context, req *generativelanguagepb.ListChunksRequest, ...) *ChunkIterator
- func (c *RetrieverClient) ListCorpora(ctx context.Context, req *generativelanguagepb.ListCorporaRequest, ...) *CorpusIterator
- func (c *RetrieverClient) ListDocuments(ctx context.Context, req *generativelanguagepb.ListDocumentsRequest, ...) *DocumentIterator
- func (c *RetrieverClient) QueryCorpus(ctx context.Context, req *generativelanguagepb.QueryCorpusRequest, ...) (*generativelanguagepb.QueryCorpusResponse, error)
- func (c *RetrieverClient) QueryDocument(ctx context.Context, req *generativelanguagepb.QueryDocumentRequest, ...) (*generativelanguagepb.QueryDocumentResponse, error)
- func (c *RetrieverClient) UpdateChunk(ctx context.Context, req *generativelanguagepb.UpdateChunkRequest, ...) (*generativelanguagepb.Chunk, error)
- func (c *RetrieverClient) UpdateCorpus(ctx context.Context, req *generativelanguagepb.UpdateCorpusRequest, ...) (*generativelanguagepb.Corpus, error)
- func (c *RetrieverClient) UpdateDocument(ctx context.Context, req *generativelanguagepb.UpdateDocumentRequest, ...) (*generativelanguagepb.Document, error)
- type TextCallOptions
- type TextClient
- func (c *TextClient) BatchEmbedText(ctx context.Context, req *generativelanguagepb.BatchEmbedTextRequest, ...) (*generativelanguagepb.BatchEmbedTextResponse, error)
- func (c *TextClient) Close() error
- func (c *TextClient) Connection() *grpc.ClientConndeprecated
- func (c *TextClient) CountTextTokens(ctx context.Context, req *generativelanguagepb.CountTextTokensRequest, ...) (*generativelanguagepb.CountTextTokensResponse, error)
- func (c *TextClient) EmbedText(ctx context.Context, req *generativelanguagepb.EmbedTextRequest, ...) (*generativelanguagepb.EmbedTextResponse, error)
- func (c *TextClient) GenerateText(ctx context.Context, req *generativelanguagepb.GenerateTextRequest, ...) (*generativelanguagepb.GenerateTextResponse, error)
- type TunedModelIterator
Examples ¶
- DiscussClient.CountMessageTokens
- DiscussClient.GenerateMessage
- FileClient.CreateFile
- FileClient.DeleteFile
- FileClient.GetFile
- FileClient.ListFiles
- GenerativeClient.BatchEmbedContents
- GenerativeClient.CountTokens
- GenerativeClient.EmbedContent
- GenerativeClient.GenerateAnswer
- GenerativeClient.GenerateContent
- ModelClient.CreateTunedModel
- ModelClient.DeleteTunedModel
- ModelClient.GetModel
- ModelClient.GetTunedModel
- ModelClient.ListModels
- ModelClient.ListTunedModels
- ModelClient.UpdateTunedModel
- NewDiscussClient
- NewDiscussRESTClient
- NewFileClient
- NewFileRESTClient
- NewGenerativeClient
- NewGenerativeRESTClient
- NewModelClient
- NewModelRESTClient
- NewPermissionClient
- NewPermissionRESTClient
- NewRetrieverClient
- NewRetrieverRESTClient
- NewTextClient
- NewTextRESTClient
- PermissionClient.CreatePermission
- PermissionClient.DeletePermission
- PermissionClient.GetPermission
- PermissionClient.ListPermissions
- PermissionClient.TransferOwnership
- PermissionClient.UpdatePermission
- RetrieverClient.BatchCreateChunks
- RetrieverClient.BatchDeleteChunks
- RetrieverClient.BatchUpdateChunks
- RetrieverClient.CreateChunk
- RetrieverClient.CreateCorpus
- RetrieverClient.CreateDocument
- RetrieverClient.DeleteChunk
- RetrieverClient.DeleteCorpus
- RetrieverClient.DeleteDocument
- RetrieverClient.GetChunk
- RetrieverClient.GetCorpus
- RetrieverClient.GetDocument
- RetrieverClient.ListChunks
- RetrieverClient.ListCorpora
- RetrieverClient.ListDocuments
- RetrieverClient.QueryCorpus
- RetrieverClient.QueryDocument
- RetrieverClient.UpdateChunk
- RetrieverClient.UpdateCorpus
- RetrieverClient.UpdateDocument
- TextClient.BatchEmbedText
- TextClient.CountTextTokens
- TextClient.EmbedText
- TextClient.GenerateText
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultAuthScopes ¶
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
Types ¶
type ChunkIterator ¶
type ChunkIterator struct { // Response is the raw response for the current page. // It must be cast to the RPC response type. // Calling Next() or InternalFetch() updates this value. Response interface{} // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []*generativelanguagepb.Chunk, nextPageToken string, err error) // contains filtered or unexported fields }
ChunkIterator manages a stream of *generativelanguagepb.Chunk.
func (*ChunkIterator) Next ¶
func (it *ChunkIterator) Next() (*generativelanguagepb.Chunk, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*ChunkIterator) PageInfo ¶
func (it *ChunkIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type CorpusIterator ¶
type CorpusIterator struct { // Response is the raw response for the current page. // It must be cast to the RPC response type. // Calling Next() or InternalFetch() updates this value. Response interface{} // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []*generativelanguagepb.Corpus, nextPageToken string, err error) // contains filtered or unexported fields }
CorpusIterator manages a stream of *generativelanguagepb.Corpus.
func (*CorpusIterator) Next ¶
func (it *CorpusIterator) Next() (*generativelanguagepb.Corpus, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*CorpusIterator) PageInfo ¶
func (it *CorpusIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type CreateTunedModelOperation ¶
type CreateTunedModelOperation struct {
// contains filtered or unexported fields
}
CreateTunedModelOperation manages a long-running operation from CreateTunedModel.
func (*CreateTunedModelOperation) Done ¶
func (op *CreateTunedModelOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*CreateTunedModelOperation) Metadata ¶
func (op *CreateTunedModelOperation) Metadata() (*generativelanguagepb.CreateTunedModelMetadata, error)
Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.
func (*CreateTunedModelOperation) Name ¶
func (op *CreateTunedModelOperation) Name() string
Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.
func (*CreateTunedModelOperation) Poll ¶
func (op *CreateTunedModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*generativelanguagepb.TunedModel, error)
Poll fetches the latest state of the long-running operation.
Poll also fetches the latest metadata, which can be retrieved by Metadata.
If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (*CreateTunedModelOperation) Wait ¶
func (op *CreateTunedModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*generativelanguagepb.TunedModel, error)
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
type DiscussCallOptions ¶
type DiscussCallOptions struct { GenerateMessage []gax.CallOption CountMessageTokens []gax.CallOption }
DiscussCallOptions contains the retry settings for each method of DiscussClient.
type DiscussClient ¶
type DiscussClient struct { // The call options for this service. CallOptions *DiscussCallOptions // contains filtered or unexported fields }
DiscussClient is a client for interacting with Generative Language API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
An API for using Generative Language Models (GLMs) in dialog applications.
Also known as large language models (LLMs), this API provides models that are trained for multi-turn dialog.
func NewDiscussClient ¶
func NewDiscussClient(ctx context.Context, opts ...option.ClientOption) (*DiscussClient, error)
NewDiscussClient creates a new discuss service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
An API for using Generative Language Models (GLMs) in dialog applications.
Also known as large language models (LLMs), this API provides models that are trained for multi-turn dialog.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewDiscussClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func NewDiscussRESTClient ¶
func NewDiscussRESTClient(ctx context.Context, opts ...option.ClientOption) (*DiscussClient, error)
NewDiscussRESTClient creates a new discuss service rest client.
An API for using Generative Language Models (GLMs) in dialog applications.
Also known as large language models (LLMs), this API provides models that are trained for multi-turn dialog.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewDiscussRESTClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func (*DiscussClient) Close ¶
func (c *DiscussClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*DiscussClient) Connection
deprecated
func (c *DiscussClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*DiscussClient) CountMessageTokens ¶
func (c *DiscussClient) CountMessageTokens(ctx context.Context, req *generativelanguagepb.CountMessageTokensRequest, opts ...gax.CallOption) (*generativelanguagepb.CountMessageTokensResponse, error)
CountMessageTokens runs a model’s tokenizer on a string and returns the token count.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewDiscussClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.CountMessageTokensRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#CountMessageTokensRequest. } resp, err := c.CountMessageTokens(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*DiscussClient) GenerateMessage ¶
func (c *DiscussClient) GenerateMessage(ctx context.Context, req *generativelanguagepb.GenerateMessageRequest, opts ...gax.CallOption) (*generativelanguagepb.GenerateMessageResponse, error)
GenerateMessage generates a response from the model given an input MessagePrompt.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewDiscussClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.GenerateMessageRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#GenerateMessageRequest. } resp, err := c.GenerateMessage(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
type DocumentIterator ¶
type DocumentIterator struct { // Response is the raw response for the current page. // It must be cast to the RPC response type. // Calling Next() or InternalFetch() updates this value. Response interface{} // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []*generativelanguagepb.Document, nextPageToken string, err error) // contains filtered or unexported fields }
DocumentIterator manages a stream of *generativelanguagepb.Document.
func (*DocumentIterator) Next ¶
func (it *DocumentIterator) Next() (*generativelanguagepb.Document, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*DocumentIterator) PageInfo ¶
func (it *DocumentIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type FileCallOptions ¶
type FileCallOptions struct { CreateFile []gax.CallOption ListFiles []gax.CallOption GetFile []gax.CallOption DeleteFile []gax.CallOption }
FileCallOptions contains the retry settings for each method of FileClient.
type FileClient ¶
type FileClient struct { // The call options for this service. CallOptions *FileCallOptions // contains filtered or unexported fields }
FileClient is a client for interacting with Generative Language API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
An API for uploading and managing files.
func NewFileClient ¶
func NewFileClient(ctx context.Context, opts ...option.ClientOption) (*FileClient, error)
NewFileClient creates a new file service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
An API for uploading and managing files.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewFileClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func NewFileRESTClient ¶
func NewFileRESTClient(ctx context.Context, opts ...option.ClientOption) (*FileClient, error)
NewFileRESTClient creates a new file service rest client.
An API for uploading and managing files.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewFileRESTClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func (*FileClient) Close ¶
func (c *FileClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*FileClient) Connection
deprecated
func (c *FileClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*FileClient) CreateFile ¶
func (c *FileClient) CreateFile(ctx context.Context, req *generativelanguagepb.CreateFileRequest, opts ...gax.CallOption) (*generativelanguagepb.CreateFileResponse, error)
CreateFile creates a File.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewFileClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.CreateFileRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#CreateFileRequest. } resp, err := c.CreateFile(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FileClient) DeleteFile ¶
func (c *FileClient) DeleteFile(ctx context.Context, req *generativelanguagepb.DeleteFileRequest, opts ...gax.CallOption) error
DeleteFile deletes the File.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewFileClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.DeleteFileRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#DeleteFileRequest. } err = c.DeleteFile(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*FileClient) GetFile ¶
func (c *FileClient) GetFile(ctx context.Context, req *generativelanguagepb.GetFileRequest, opts ...gax.CallOption) (*generativelanguagepb.File, error)
GetFile gets the metadata for the given File.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewFileClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.GetFileRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#GetFileRequest. } resp, err := c.GetFile(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FileClient) ListFiles ¶
func (c *FileClient) ListFiles(ctx context.Context, req *generativelanguagepb.ListFilesRequest, opts ...gax.CallOption) *FileIterator
ListFiles lists the metadata for Files owned by the requesting project.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" "google.golang.org/api/iterator" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewFileClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.ListFilesRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#ListFilesRequest. } it := c.ListFiles(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*generativelanguagepb.ListFilesResponse) } }
Output:
type FileIterator ¶
type FileIterator struct { // Response is the raw response for the current page. // It must be cast to the RPC response type. // Calling Next() or InternalFetch() updates this value. Response interface{} // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []*generativelanguagepb.File, nextPageToken string, err error) // contains filtered or unexported fields }
FileIterator manages a stream of *generativelanguagepb.File.
func (*FileIterator) Next ¶
func (it *FileIterator) Next() (*generativelanguagepb.File, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*FileIterator) PageInfo ¶
func (it *FileIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type GenerativeCallOptions ¶
type GenerativeCallOptions struct { GenerateContent []gax.CallOption GenerateAnswer []gax.CallOption StreamGenerateContent []gax.CallOption EmbedContent []gax.CallOption BatchEmbedContents []gax.CallOption CountTokens []gax.CallOption }
GenerativeCallOptions contains the retry settings for each method of GenerativeClient.
type GenerativeClient ¶
type GenerativeClient struct { // The call options for this service. CallOptions *GenerativeCallOptions // contains filtered or unexported fields }
GenerativeClient is a client for interacting with Generative Language API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
API for using Large Models that generate multimodal content and have additional capabilities beyond text generation.
func NewGenerativeClient ¶
func NewGenerativeClient(ctx context.Context, opts ...option.ClientOption) (*GenerativeClient, error)
NewGenerativeClient creates a new generative service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
API for using Large Models that generate multimodal content and have additional capabilities beyond text generation.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewGenerativeClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func NewGenerativeRESTClient ¶
func NewGenerativeRESTClient(ctx context.Context, opts ...option.ClientOption) (*GenerativeClient, error)
NewGenerativeRESTClient creates a new generative service rest client.
API for using Large Models that generate multimodal content and have additional capabilities beyond text generation.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewGenerativeRESTClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func (*GenerativeClient) BatchEmbedContents ¶
func (c *GenerativeClient) BatchEmbedContents(ctx context.Context, req *generativelanguagepb.BatchEmbedContentsRequest, opts ...gax.CallOption) (*generativelanguagepb.BatchEmbedContentsResponse, error)
BatchEmbedContents generates multiple embeddings from the model given input text in a synchronous call.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewGenerativeClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.BatchEmbedContentsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#BatchEmbedContentsRequest. } resp, err := c.BatchEmbedContents(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*GenerativeClient) Close ¶
func (c *GenerativeClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*GenerativeClient) Connection
deprecated
func (c *GenerativeClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*GenerativeClient) CountTokens ¶
func (c *GenerativeClient) CountTokens(ctx context.Context, req *generativelanguagepb.CountTokensRequest, opts ...gax.CallOption) (*generativelanguagepb.CountTokensResponse, error)
CountTokens runs a model’s tokenizer on input content and returns the token count.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewGenerativeClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.CountTokensRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#CountTokensRequest. } resp, err := c.CountTokens(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*GenerativeClient) EmbedContent ¶
func (c *GenerativeClient) EmbedContent(ctx context.Context, req *generativelanguagepb.EmbedContentRequest, opts ...gax.CallOption) (*generativelanguagepb.EmbedContentResponse, error)
EmbedContent generates an embedding from the model given an input Content.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewGenerativeClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.EmbedContentRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#EmbedContentRequest. } resp, err := c.EmbedContent(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*GenerativeClient) GenerateAnswer ¶
func (c *GenerativeClient) GenerateAnswer(ctx context.Context, req *generativelanguagepb.GenerateAnswerRequest, opts ...gax.CallOption) (*generativelanguagepb.GenerateAnswerResponse, error)
GenerateAnswer generates a grounded answer from the model given an input GenerateAnswerRequest.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewGenerativeClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.GenerateAnswerRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#GenerateAnswerRequest. } resp, err := c.GenerateAnswer(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*GenerativeClient) GenerateContent ¶
func (c *GenerativeClient) GenerateContent(ctx context.Context, req *generativelanguagepb.GenerateContentRequest, opts ...gax.CallOption) (*generativelanguagepb.GenerateContentResponse, error)
GenerateContent generates a response from the model given an input GenerateContentRequest.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewGenerativeClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.GenerateContentRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#GenerateContentRequest. } resp, err := c.GenerateContent(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*GenerativeClient) SetGoogleClientInfo ¶
func (c *GenerativeClient) SetGoogleClientInfo(keyval ...string)
func (*GenerativeClient) StreamGenerateContent ¶
func (c *GenerativeClient) StreamGenerateContent(ctx context.Context, req *generativelanguagepb.GenerateContentRequest, opts ...gax.CallOption) (generativelanguagepb.GenerativeService_StreamGenerateContentClient, error)
StreamGenerateContent generates a streamed response from the model given an input GenerateContentRequest.
type ModelCallOptions ¶
type ModelCallOptions struct { GetModel []gax.CallOption ListModels []gax.CallOption GetTunedModel []gax.CallOption ListTunedModels []gax.CallOption CreateTunedModel []gax.CallOption UpdateTunedModel []gax.CallOption DeleteTunedModel []gax.CallOption }
ModelCallOptions contains the retry settings for each method of ModelClient.
type ModelClient ¶
type ModelClient struct { // The call options for this service. CallOptions *ModelCallOptions // LROClient is used internally to handle long-running operations. // It is exposed so that its CallOptions can be modified if required. // Users should not Close this client. LROClient *lroauto.OperationsClient // contains filtered or unexported fields }
ModelClient is a client for interacting with Generative Language API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Provides methods for getting metadata information about Generative Models.
func NewModelClient ¶
func NewModelClient(ctx context.Context, opts ...option.ClientOption) (*ModelClient, error)
NewModelClient creates a new model service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Provides methods for getting metadata information about Generative Models.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewModelClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func NewModelRESTClient ¶
func NewModelRESTClient(ctx context.Context, opts ...option.ClientOption) (*ModelClient, error)
NewModelRESTClient creates a new model service rest client.
Provides methods for getting metadata information about Generative Models.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewModelRESTClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func (*ModelClient) Close ¶
func (c *ModelClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*ModelClient) Connection
deprecated
func (c *ModelClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*ModelClient) CreateTunedModel ¶
func (c *ModelClient) CreateTunedModel(ctx context.Context, req *generativelanguagepb.CreateTunedModelRequest, opts ...gax.CallOption) (*CreateTunedModelOperation, error)
CreateTunedModel 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
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewModelClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.CreateTunedModelRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#CreateTunedModelRequest. } op, err := c.CreateTunedModel(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ModelClient) CreateTunedModelOperation ¶
func (c *ModelClient) CreateTunedModelOperation(name string) *CreateTunedModelOperation
CreateTunedModelOperation returns a new CreateTunedModelOperation from a given name. The name must be that of a previously created CreateTunedModelOperation, possibly from a different process.
func (*ModelClient) DeleteTunedModel ¶
func (c *ModelClient) DeleteTunedModel(ctx context.Context, req *generativelanguagepb.DeleteTunedModelRequest, opts ...gax.CallOption) error
DeleteTunedModel deletes a tuned model.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewModelClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.DeleteTunedModelRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#DeleteTunedModelRequest. } err = c.DeleteTunedModel(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*ModelClient) GetModel ¶
func (c *ModelClient) GetModel(ctx context.Context, req *generativelanguagepb.GetModelRequest, opts ...gax.CallOption) (*generativelanguagepb.Model, error)
GetModel gets information about a specific Model.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewModelClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.GetModelRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#GetModelRequest. } resp, err := c.GetModel(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ModelClient) GetTunedModel ¶
func (c *ModelClient) GetTunedModel(ctx context.Context, req *generativelanguagepb.GetTunedModelRequest, opts ...gax.CallOption) (*generativelanguagepb.TunedModel, error)
GetTunedModel gets information about a specific TunedModel.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewModelClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.GetTunedModelRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#GetTunedModelRequest. } resp, err := c.GetTunedModel(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ModelClient) ListModels ¶
func (c *ModelClient) ListModels(ctx context.Context, req *generativelanguagepb.ListModelsRequest, opts ...gax.CallOption) *ModelIterator
ListModels lists models available through the API.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" "google.golang.org/api/iterator" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewModelClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.ListModelsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#ListModelsRequest. } it := c.ListModels(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*generativelanguagepb.ListModelsResponse) } }
Output:
func (*ModelClient) ListTunedModels ¶
func (c *ModelClient) ListTunedModels(ctx context.Context, req *generativelanguagepb.ListTunedModelsRequest, opts ...gax.CallOption) *TunedModelIterator
ListTunedModels lists tuned models owned by the user.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" "google.golang.org/api/iterator" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewModelClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.ListTunedModelsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#ListTunedModelsRequest. } it := c.ListTunedModels(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*generativelanguagepb.ListTunedModelsResponse) } }
Output:
func (*ModelClient) UpdateTunedModel ¶
func (c *ModelClient) UpdateTunedModel(ctx context.Context, req *generativelanguagepb.UpdateTunedModelRequest, opts ...gax.CallOption) (*generativelanguagepb.TunedModel, error)
UpdateTunedModel updates a tuned model.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewModelClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.UpdateTunedModelRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#UpdateTunedModelRequest. } resp, err := c.UpdateTunedModel(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
type ModelIterator ¶
type ModelIterator struct { // Response is the raw response for the current page. // It must be cast to the RPC response type. // Calling Next() or InternalFetch() updates this value. Response interface{} // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []*generativelanguagepb.Model, nextPageToken string, err error) // contains filtered or unexported fields }
ModelIterator manages a stream of *generativelanguagepb.Model.
func (*ModelIterator) Next ¶
func (it *ModelIterator) Next() (*generativelanguagepb.Model, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*ModelIterator) PageInfo ¶
func (it *ModelIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type PermissionCallOptions ¶
type PermissionCallOptions struct { CreatePermission []gax.CallOption GetPermission []gax.CallOption ListPermissions []gax.CallOption UpdatePermission []gax.CallOption DeletePermission []gax.CallOption TransferOwnership []gax.CallOption }
PermissionCallOptions contains the retry settings for each method of PermissionClient.
type PermissionClient ¶
type PermissionClient struct { // The call options for this service. CallOptions *PermissionCallOptions // contains filtered or unexported fields }
PermissionClient is a client for interacting with Generative Language API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Provides methods for managing permissions to PaLM API resources.
func NewPermissionClient ¶
func NewPermissionClient(ctx context.Context, opts ...option.ClientOption) (*PermissionClient, error)
NewPermissionClient creates a new permission service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Provides methods for managing permissions to PaLM API resources.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewPermissionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func NewPermissionRESTClient ¶
func NewPermissionRESTClient(ctx context.Context, opts ...option.ClientOption) (*PermissionClient, error)
NewPermissionRESTClient creates a new permission service rest client.
Provides methods for managing permissions to PaLM API resources.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewPermissionRESTClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func (*PermissionClient) Close ¶
func (c *PermissionClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*PermissionClient) Connection
deprecated
func (c *PermissionClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*PermissionClient) CreatePermission ¶
func (c *PermissionClient) CreatePermission(ctx context.Context, req *generativelanguagepb.CreatePermissionRequest, opts ...gax.CallOption) (*generativelanguagepb.Permission, error)
CreatePermission create a permission to a specific resource.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewPermissionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.CreatePermissionRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#CreatePermissionRequest. } resp, err := c.CreatePermission(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*PermissionClient) DeletePermission ¶
func (c *PermissionClient) DeletePermission(ctx context.Context, req *generativelanguagepb.DeletePermissionRequest, opts ...gax.CallOption) error
DeletePermission deletes the permission.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewPermissionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.DeletePermissionRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#DeletePermissionRequest. } err = c.DeletePermission(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*PermissionClient) GetPermission ¶
func (c *PermissionClient) GetPermission(ctx context.Context, req *generativelanguagepb.GetPermissionRequest, opts ...gax.CallOption) (*generativelanguagepb.Permission, error)
GetPermission gets information about a specific Permission.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewPermissionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.GetPermissionRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#GetPermissionRequest. } resp, err := c.GetPermission(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*PermissionClient) ListPermissions ¶
func (c *PermissionClient) ListPermissions(ctx context.Context, req *generativelanguagepb.ListPermissionsRequest, opts ...gax.CallOption) *PermissionIterator
ListPermissions lists permissions for the specific resource.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" "google.golang.org/api/iterator" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewPermissionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.ListPermissionsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#ListPermissionsRequest. } it := c.ListPermissions(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*generativelanguagepb.ListPermissionsResponse) } }
Output:
func (*PermissionClient) TransferOwnership ¶
func (c *PermissionClient) TransferOwnership(ctx context.Context, req *generativelanguagepb.TransferOwnershipRequest, opts ...gax.CallOption) (*generativelanguagepb.TransferOwnershipResponse, error)
TransferOwnership 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.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewPermissionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.TransferOwnershipRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#TransferOwnershipRequest. } resp, err := c.TransferOwnership(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*PermissionClient) UpdatePermission ¶
func (c *PermissionClient) UpdatePermission(ctx context.Context, req *generativelanguagepb.UpdatePermissionRequest, opts ...gax.CallOption) (*generativelanguagepb.Permission, error)
UpdatePermission updates the permission.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewPermissionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.UpdatePermissionRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#UpdatePermissionRequest. } resp, err := c.UpdatePermission(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
type PermissionIterator ¶
type PermissionIterator struct { // Response is the raw response for the current page. // It must be cast to the RPC response type. // Calling Next() or InternalFetch() updates this value. Response interface{} // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []*generativelanguagepb.Permission, nextPageToken string, err error) // contains filtered or unexported fields }
PermissionIterator manages a stream of *generativelanguagepb.Permission.
func (*PermissionIterator) Next ¶
func (it *PermissionIterator) Next() (*generativelanguagepb.Permission, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*PermissionIterator) PageInfo ¶
func (it *PermissionIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type RetrieverCallOptions ¶
type RetrieverCallOptions struct { CreateCorpus []gax.CallOption GetCorpus []gax.CallOption UpdateCorpus []gax.CallOption DeleteCorpus []gax.CallOption ListCorpora []gax.CallOption QueryCorpus []gax.CallOption CreateDocument []gax.CallOption GetDocument []gax.CallOption UpdateDocument []gax.CallOption DeleteDocument []gax.CallOption ListDocuments []gax.CallOption QueryDocument []gax.CallOption CreateChunk []gax.CallOption BatchCreateChunks []gax.CallOption GetChunk []gax.CallOption UpdateChunk []gax.CallOption BatchUpdateChunks []gax.CallOption DeleteChunk []gax.CallOption BatchDeleteChunks []gax.CallOption ListChunks []gax.CallOption }
RetrieverCallOptions contains the retry settings for each method of RetrieverClient.
type RetrieverClient ¶
type RetrieverClient struct { // The call options for this service. CallOptions *RetrieverCallOptions // contains filtered or unexported fields }
RetrieverClient is a client for interacting with Generative Language API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
An API for semantic search over a corpus of user uploaded content.
func NewRetrieverClient ¶
func NewRetrieverClient(ctx context.Context, opts ...option.ClientOption) (*RetrieverClient, error)
NewRetrieverClient creates a new retriever service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
An API for semantic search over a corpus of user uploaded content.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func NewRetrieverRESTClient ¶
func NewRetrieverRESTClient(ctx context.Context, opts ...option.ClientOption) (*RetrieverClient, error)
NewRetrieverRESTClient creates a new retriever service rest client.
An API for semantic search over a corpus of user uploaded content.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverRESTClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func (*RetrieverClient) BatchCreateChunks ¶
func (c *RetrieverClient) BatchCreateChunks(ctx context.Context, req *generativelanguagepb.BatchCreateChunksRequest, opts ...gax.CallOption) (*generativelanguagepb.BatchCreateChunksResponse, error)
BatchCreateChunks batch create Chunks.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.BatchCreateChunksRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#BatchCreateChunksRequest. } resp, err := c.BatchCreateChunks(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RetrieverClient) BatchDeleteChunks ¶
func (c *RetrieverClient) BatchDeleteChunks(ctx context.Context, req *generativelanguagepb.BatchDeleteChunksRequest, opts ...gax.CallOption) error
BatchDeleteChunks batch delete Chunks.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.BatchDeleteChunksRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#BatchDeleteChunksRequest. } err = c.BatchDeleteChunks(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*RetrieverClient) BatchUpdateChunks ¶
func (c *RetrieverClient) BatchUpdateChunks(ctx context.Context, req *generativelanguagepb.BatchUpdateChunksRequest, opts ...gax.CallOption) (*generativelanguagepb.BatchUpdateChunksResponse, error)
BatchUpdateChunks batch update Chunks.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.BatchUpdateChunksRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#BatchUpdateChunksRequest. } resp, err := c.BatchUpdateChunks(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RetrieverClient) Close ¶
func (c *RetrieverClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*RetrieverClient) Connection
deprecated
func (c *RetrieverClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*RetrieverClient) CreateChunk ¶
func (c *RetrieverClient) CreateChunk(ctx context.Context, req *generativelanguagepb.CreateChunkRequest, opts ...gax.CallOption) (*generativelanguagepb.Chunk, error)
CreateChunk creates a Chunk.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.CreateChunkRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#CreateChunkRequest. } resp, err := c.CreateChunk(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RetrieverClient) CreateCorpus ¶
func (c *RetrieverClient) CreateCorpus(ctx context.Context, req *generativelanguagepb.CreateCorpusRequest, opts ...gax.CallOption) (*generativelanguagepb.Corpus, error)
CreateCorpus creates an empty Corpus.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.CreateCorpusRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#CreateCorpusRequest. } resp, err := c.CreateCorpus(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RetrieverClient) CreateDocument ¶
func (c *RetrieverClient) CreateDocument(ctx context.Context, req *generativelanguagepb.CreateDocumentRequest, opts ...gax.CallOption) (*generativelanguagepb.Document, error)
CreateDocument creates an empty Document.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.CreateDocumentRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#CreateDocumentRequest. } resp, err := c.CreateDocument(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RetrieverClient) DeleteChunk ¶
func (c *RetrieverClient) DeleteChunk(ctx context.Context, req *generativelanguagepb.DeleteChunkRequest, opts ...gax.CallOption) error
DeleteChunk deletes a Chunk.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.DeleteChunkRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#DeleteChunkRequest. } err = c.DeleteChunk(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*RetrieverClient) DeleteCorpus ¶
func (c *RetrieverClient) DeleteCorpus(ctx context.Context, req *generativelanguagepb.DeleteCorpusRequest, opts ...gax.CallOption) error
DeleteCorpus deletes a Corpus.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.DeleteCorpusRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#DeleteCorpusRequest. } err = c.DeleteCorpus(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*RetrieverClient) DeleteDocument ¶
func (c *RetrieverClient) DeleteDocument(ctx context.Context, req *generativelanguagepb.DeleteDocumentRequest, opts ...gax.CallOption) error
DeleteDocument deletes a Document.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.DeleteDocumentRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#DeleteDocumentRequest. } err = c.DeleteDocument(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*RetrieverClient) GetChunk ¶
func (c *RetrieverClient) GetChunk(ctx context.Context, req *generativelanguagepb.GetChunkRequest, opts ...gax.CallOption) (*generativelanguagepb.Chunk, error)
GetChunk gets information about a specific Chunk.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.GetChunkRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#GetChunkRequest. } resp, err := c.GetChunk(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RetrieverClient) GetCorpus ¶
func (c *RetrieverClient) GetCorpus(ctx context.Context, req *generativelanguagepb.GetCorpusRequest, opts ...gax.CallOption) (*generativelanguagepb.Corpus, error)
GetCorpus gets information about a specific Corpus.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.GetCorpusRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#GetCorpusRequest. } resp, err := c.GetCorpus(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RetrieverClient) GetDocument ¶
func (c *RetrieverClient) GetDocument(ctx context.Context, req *generativelanguagepb.GetDocumentRequest, opts ...gax.CallOption) (*generativelanguagepb.Document, error)
GetDocument gets information about a specific Document.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.GetDocumentRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#GetDocumentRequest. } resp, err := c.GetDocument(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RetrieverClient) ListChunks ¶
func (c *RetrieverClient) ListChunks(ctx context.Context, req *generativelanguagepb.ListChunksRequest, opts ...gax.CallOption) *ChunkIterator
ListChunks lists all Chunks in a Document.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" "google.golang.org/api/iterator" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.ListChunksRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#ListChunksRequest. } it := c.ListChunks(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*generativelanguagepb.ListChunksResponse) } }
Output:
func (*RetrieverClient) ListCorpora ¶
func (c *RetrieverClient) ListCorpora(ctx context.Context, req *generativelanguagepb.ListCorporaRequest, opts ...gax.CallOption) *CorpusIterator
ListCorpora lists all Corpora owned by the user.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" "google.golang.org/api/iterator" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.ListCorporaRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#ListCorporaRequest. } it := c.ListCorpora(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*generativelanguagepb.ListCorporaResponse) } }
Output:
func (*RetrieverClient) ListDocuments ¶
func (c *RetrieverClient) ListDocuments(ctx context.Context, req *generativelanguagepb.ListDocumentsRequest, opts ...gax.CallOption) *DocumentIterator
ListDocuments lists all Documents in a Corpus.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" "google.golang.org/api/iterator" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.ListDocumentsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#ListDocumentsRequest. } it := c.ListDocuments(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*generativelanguagepb.ListDocumentsResponse) } }
Output:
func (*RetrieverClient) QueryCorpus ¶
func (c *RetrieverClient) QueryCorpus(ctx context.Context, req *generativelanguagepb.QueryCorpusRequest, opts ...gax.CallOption) (*generativelanguagepb.QueryCorpusResponse, error)
QueryCorpus performs semantic search over a Corpus.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.QueryCorpusRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#QueryCorpusRequest. } resp, err := c.QueryCorpus(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RetrieverClient) QueryDocument ¶
func (c *RetrieverClient) QueryDocument(ctx context.Context, req *generativelanguagepb.QueryDocumentRequest, opts ...gax.CallOption) (*generativelanguagepb.QueryDocumentResponse, error)
QueryDocument performs semantic search over a Document.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.QueryDocumentRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#QueryDocumentRequest. } resp, err := c.QueryDocument(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RetrieverClient) UpdateChunk ¶
func (c *RetrieverClient) UpdateChunk(ctx context.Context, req *generativelanguagepb.UpdateChunkRequest, opts ...gax.CallOption) (*generativelanguagepb.Chunk, error)
UpdateChunk updates a Chunk.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.UpdateChunkRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#UpdateChunkRequest. } resp, err := c.UpdateChunk(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RetrieverClient) UpdateCorpus ¶
func (c *RetrieverClient) UpdateCorpus(ctx context.Context, req *generativelanguagepb.UpdateCorpusRequest, opts ...gax.CallOption) (*generativelanguagepb.Corpus, error)
UpdateCorpus updates a Corpus.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.UpdateCorpusRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#UpdateCorpusRequest. } resp, err := c.UpdateCorpus(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RetrieverClient) UpdateDocument ¶
func (c *RetrieverClient) UpdateDocument(ctx context.Context, req *generativelanguagepb.UpdateDocumentRequest, opts ...gax.CallOption) (*generativelanguagepb.Document, error)
UpdateDocument updates a Document.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewRetrieverClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.UpdateDocumentRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#UpdateDocumentRequest. } resp, err := c.UpdateDocument(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
type TextCallOptions ¶
type TextCallOptions struct { GenerateText []gax.CallOption EmbedText []gax.CallOption BatchEmbedText []gax.CallOption CountTextTokens []gax.CallOption }
TextCallOptions contains the retry settings for each method of TextClient.
type TextClient ¶
type TextClient struct { // The call options for this service. CallOptions *TextCallOptions // contains filtered or unexported fields }
TextClient is a client for interacting with Generative Language API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
API for using Generative Language Models (GLMs) trained to generate text.
Also known as Large Language Models (LLM)s, these generate text given an input prompt from the user.
func NewTextClient ¶
func NewTextClient(ctx context.Context, opts ...option.ClientOption) (*TextClient, error)
NewTextClient creates a new text service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
API for using Generative Language Models (GLMs) trained to generate text.
Also known as Large Language Models (LLM)s, these generate text given an input prompt from the user.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewTextClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func NewTextRESTClient ¶
func NewTextRESTClient(ctx context.Context, opts ...option.ClientOption) (*TextClient, error)
NewTextRESTClient creates a new text service rest client.
API for using Generative Language Models (GLMs) trained to generate text.
Also known as Large Language Models (LLM)s, these generate text given an input prompt from the user.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewTextRESTClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func (*TextClient) BatchEmbedText ¶
func (c *TextClient) BatchEmbedText(ctx context.Context, req *generativelanguagepb.BatchEmbedTextRequest, opts ...gax.CallOption) (*generativelanguagepb.BatchEmbedTextResponse, error)
BatchEmbedText generates multiple embeddings from the model given input text in a synchronous call.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewTextClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.BatchEmbedTextRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#BatchEmbedTextRequest. } resp, err := c.BatchEmbedText(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*TextClient) Close ¶
func (c *TextClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*TextClient) Connection
deprecated
func (c *TextClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*TextClient) CountTextTokens ¶
func (c *TextClient) CountTextTokens(ctx context.Context, req *generativelanguagepb.CountTextTokensRequest, opts ...gax.CallOption) (*generativelanguagepb.CountTextTokensResponse, error)
CountTextTokens runs a model’s tokenizer on a text and returns the token count.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewTextClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.CountTextTokensRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#CountTextTokensRequest. } resp, err := c.CountTextTokens(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*TextClient) EmbedText ¶
func (c *TextClient) EmbedText(ctx context.Context, req *generativelanguagepb.EmbedTextRequest, opts ...gax.CallOption) (*generativelanguagepb.EmbedTextResponse, error)
EmbedText generates an embedding from the model given an input message.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewTextClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.EmbedTextRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#EmbedTextRequest. } resp, err := c.EmbedText(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*TextClient) GenerateText ¶
func (c *TextClient) GenerateText(ctx context.Context, req *generativelanguagepb.GenerateTextRequest, opts ...gax.CallOption) (*generativelanguagepb.GenerateTextResponse, error)
GenerateText generates a response from the model given an input message.
Example ¶
package main import ( "context" generativelanguage "cloud.google.com/go/ai/generativelanguage/apiv1beta" generativelanguagepb "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := generativelanguage.NewTextClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &generativelanguagepb.GenerateTextRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb#GenerateTextRequest. } resp, err := c.GenerateText(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
type TunedModelIterator ¶
type TunedModelIterator struct { // Response is the raw response for the current page. // It must be cast to the RPC response type. // Calling Next() or InternalFetch() updates this value. Response interface{} // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []*generativelanguagepb.TunedModel, nextPageToken string, err error) // contains filtered or unexported fields }
TunedModelIterator manages a stream of *generativelanguagepb.TunedModel.
func (*TunedModelIterator) Next ¶
func (it *TunedModelIterator) Next() (*generativelanguagepb.TunedModel, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*TunedModelIterator) PageInfo ¶
func (it *TunedModelIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.