generativelanguage

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 25 Imported by: 3

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:

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

Examples

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

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

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

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

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

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

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

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

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 added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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

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

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

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

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

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 added in v0.3.0

func (c *GenerativeClient) SetGoogleClientInfo(keyval ...string)

func (*GenerativeClient) StreamGenerateContent

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL