Documentation
¶
Overview ¶
package googleai implements a langchaingo provider for Google AI LLMs. See https://ai.google.dev/ for more details.
Index ¶
- Constants
- Variables
- type GoogleAI
- type Option
- func WithAPIKey(apiKey string) Option
- func WithCloudLocation(l string) Option
- func WithCloudProject(p string) Option
- func WithCredentials(credentials *auth.Credentials) Option
- func WithDefaultCandidateCount(defaultCandidateCount int) Option
- func WithDefaultEmbeddingModel(defaultEmbeddingModel string) Option
- func WithDefaultMaxTokens(maxTokens int) Option
- func WithDefaultModel(defaultModel string) Option
- func WithDefaultTemperature(defaultTemperature float64) Option
- func WithDefaultTopK(defaultTopK int) Option
- func WithDefaultTopP(defaultTopP float64) Option
- func WithHTTPClient(httpClient *http.Client) Option
- func WithHarmThreshold(ht genai.HarmBlockThreshold) Option
- type Options
Constants ¶
const ( CITATIONS = "citations" SAFETY = "safety" RoleSystem = "system" RoleModel = "model" RoleUser = "user" RoleTool = "tool" ResponseMIMETypeJson = "application/json" )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type GoogleAI ¶
type GoogleAI struct {
// contains filtered or unexported fields
}
GoogleAI is a type that represents a Google AI API client.
func (*GoogleAI) GenerateContent ¶
func (g *GoogleAI) GenerateContent( ctx context.Context, messages []llms.Message, options ...llms.CallOption, ) (*llms.ContentResponse, error)
GenerateContent implements the llms.Model interface.
func (*GoogleAI) GetProviderType ¶ added in v0.10.54
func (g *GoogleAI) GetProviderType() llms.ProviderType
GetProviderType implements the Model interface.
type Option ¶
type Option func(*Options)
func WithAPIKey ¶
WithAPIKey passes the API KEY (token) to the client. This is useful for googleai clients.
func WithCloudLocation ¶
WithCloudLocation passes the GCP cloud location (region) name to the client. This is useful for vertex clients.
func WithCloudProject ¶
WithCloudProject passes the GCP cloud project name to the client. This is useful for vertex clients.
func WithCredentials ¶ added in v0.13.68
func WithCredentials(credentials *auth.Credentials) Option
WithCredentialsJSON append a ClientOption that authenticates API calls with the given service account or refresh token JSON credentials.
func WithDefaultCandidateCount ¶
WithDefaultCandidateCount sets the candidate count for the model.
func WithDefaultEmbeddingModel ¶
WithDefaultModel passes a default embedding model name to the client. This model name is used if not explicitly provided in specific client invocations.
func WithDefaultMaxTokens ¶
WithDefaultMaxTokens sets the maximum token count for the model.
func WithDefaultModel ¶
WithDefaultModel passes a default content model name to the client. This model name is used if not explicitly provided in specific client invocations.
func WithDefaultTemperature ¶
WithDefaultTemperature sets the maximum token count for the model.
func WithDefaultTopK ¶
WithDefaultTopK sets the TopK for the model.
func WithDefaultTopP ¶
WithDefaultTopP sets the TopP for the model.
func WithHTTPClient ¶
WithHTTPClient append a ClientOption that uses the provided HTTP client to make requests. This is useful for vertex clients.
func WithHarmThreshold ¶
func WithHarmThreshold(ht genai.HarmBlockThreshold) Option
WithHarmThreshold sets the safety/harm setting for the model, potentially limiting any harmful content it may generate.
type Options ¶
type Options struct {
CloudProject string
CloudLocation string
DefaultModel string
DefaultEmbeddingModel string
DefaultCandidateCount int
DefaultMaxTokens int
DefaultTemperature float64
DefaultTopK int
DefaultTopP float64
HarmThreshold genai.HarmBlockThreshold
APIKey string
Credentials *auth.Credentials
HTTPClient *http.Client
}
Options is a set of options for GoogleAI and Vertex clients.
func DefaultOptions ¶
func DefaultOptions() Options
func (*Options) EnsureAuthPresent ¶
func (o *Options) EnsureAuthPresent()
EnsureAuthPresent attempts to ensure that the client has authentication information. If it does not, it will attempt to use the GOOGLE_API_KEY environment variable.