Skip to content

Latest commit

 

History

History
89 lines (76 loc) · 9.45 KB

generative-ai.md

File metadata and controls

89 lines (76 loc) · 9.45 KB

Home > @google/generative-ai

generative-ai package

Classes

Class Description
ChatSession ChatSession class that enables sending chat messages and stores history of sent and received messages so far.
GenerativeModel Class for generative model APIs.
GoogleGenerativeAI Top-level class for this SDK
GoogleGenerativeAIError Basic error type for this SDK.
GoogleGenerativeAIFetchError Error class covering HTTP errors when calling the server. Includes HTTP status, statusText, and optional details, if provided in the server response.
GoogleGenerativeAIRequestInputError Errors in the contents of a request originating from user input.
GoogleGenerativeAIResponseError Errors in the contents of a response from the model. This includes parsing errors, or responses including a safety block reason.

Enumerations

Enumeration Description
BlockReason Reason that a prompt was blocked.
FinishReason Reason that a candidate finished.
FunctionCallingMode
FunctionDeclarationSchemaType Contains the list of OpenAPI data types as defined by https://swagger.io/docs/specification/data-models/data-types/
HarmBlockThreshold Threshold above which a prompt or candidate will be blocked.
HarmCategory Harm categories that would cause prompts or candidates to be blocked.
HarmProbability Probability that a prompt or candidate matches a harm category.
TaskType Task type for embedding content.

Interfaces

Interface Description
BaseParams Base parameters for a number of methods.
BatchEmbedContentsRequest Params for calling GenerativeModel.batchEmbedContents()
BatchEmbedContentsResponse Response from calling GenerativeModel.batchEmbedContents().
CitationMetadata Citation metadata that may be found on a GenerateContentCandidate.
CitationSource A single citation source.
Content Content type for both prompts and response candidates.
ContentEmbedding A single content embedding.
CountTokensRequest Params for calling GenerativeModel.countTokens()
CountTokensResponse Response from calling GenerativeModel.countTokens().
EmbedContentRequest Params for calling GenerativeModel.embedContent()
EmbedContentResponse Response from calling GenerativeModel.embedContent().
EnhancedGenerateContentResponse Response object wrapped with helper methods.
FileData Data pointing to a file uploaded with the Files API.
FileDataPart Content part interface if the part represents FunctionResponse.
FunctionCall A predicted [FunctionCall] returned from the model that contains a string representing the [FunctionDeclaration.name] and a structured JSON object containing the parameters and their values.
FunctionCallingConfig
FunctionCallPart Content part interface if the part represents FunctionResponse.
FunctionDeclaration Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a Tool by the model and executed by the client.
FunctionDeclarationSchema Schema for parameters passed to FunctionDeclaration.parameters.
FunctionDeclarationSchemaProperty Schema is used to define the format of input/output data. Represents a select subset of an OpenAPI 3.0 schema object. More fields may be added in the future as needed.
FunctionDeclarationsTool A FunctionDeclarationsTool is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model.
FunctionResponse The result output from a [FunctionCall] that contains a string representing the [FunctionDeclaration.name] and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a [FunctionCall] made based on model prediction.
FunctionResponsePart Content part interface if the part represents FunctionResponse.
GenerateContentCandidate A candidate returned as part of a GenerateContentResponse.
GenerateContentRequest Request sent to generateContent endpoint.
GenerateContentResponse Individual response from GenerativeModel.generateContent() and GenerativeModel.generateContentStream(). generateContentStream() will return one in each chunk until the stream is done.
GenerateContentResult Result object returned from generateContent() call.
GenerateContentStreamResult Result object returned from generateContentStream() call. Iterate over stream to get chunks as they come in and/or use the response promise to get the aggregated response when the stream is done.
GenerationConfig Config options for content-related requests
GenerativeContentBlob Interface for sending an image.
InlineDataPart Content part interface if the part represents an image.
ModelParams Params passed to GoogleGenerativeAI.getGenerativeModel().
PromptFeedback If the prompt was blocked, this will be populated with blockReason and the relevant safetyRatings.
RequestOptions Params passed to getGenerativeModel() or GoogleAIFileManager().
SafetyRating A safety rating associated with a GenerateContentCandidate
SafetySetting Safety setting that can be sent as part of request parameters.
StartChatParams Params for GenerativeModel.startChat().
TextPart Content part interface if the part represents a text string.
ToolConfig Tool config. This config is shared for all tools provided in the request.
UsageMetadata Metadata on the generation request's token usage.

Variables

Variable Description
POSSIBLE_ROLES Possible roles.

Type Aliases

Type Alias Description
Part Content part - includes text or image part types.
Tool Defines a tool that model can call to access external knowledge.