View Source LangChain.ChatModels.ChatGoogleAI (LangChain v0.2.0)

Parses and validates inputs for making a request for the Google AI Chat API.

Converts response into more specialized LangChain data structures.

Summary

Functions

Calls the Google AI API passing the ChatGoogleAI struct with configuration, plus either a simple message or the list of messages to act as the prompt.

Return the content parts for the message.

Setup a ChatGoogleAI client configuration.

Setup a ChatGoogleAI client configuration and return it or raise an error if invalid.

Types

@type t() :: %LangChain.ChatModels.ChatGoogleAI{
  api_key: term(),
  endpoint: term(),
  model: term(),
  receive_timeout: term(),
  stream: term(),
  temperature: term(),
  top_k: term(),
  top_p: term(),
  version: term()
}

Functions

Link to this function

call(openai, prompt, tools \\ [], callback_fn \\ nil)

View Source

Calls the Google AI API passing the ChatGoogleAI struct with configuration, plus either a simple message or the list of messages to act as the prompt.

Optionally pass in a list of tools available to the LLM for requesting execution in response.

Optionally pass in a callback function that can be executed as data is received from the API.

NOTE: This function can be used directly, but the primary interface should be through LangChain.Chains.LLMChain. The ChatGoogleAI module is more focused on translating the LangChain data structures to and from the OpenAI API.

Another benefit of using LangChain.Chains.LLMChain is that it combines the storage of messages, adding tools, adding custom context that should be passed to tools, and automatically applying LangChain.MessageDelta structs as they are are received, then converting those to the full LangChain.Message once fully complete.

Link to this function

complete_final_delta(data)

View Source
Link to this function

do_process_response(response, message_type \\ Message)

View Source
Link to this function

for_api(google_ai, messages, functions)

View Source
Link to this function

get_message_contents(message)

View Source
@spec get_message_contents(LangChain.MessageDelta.t() | LangChain.Message.t()) :: [
  %{required(String.t()) => any()}
]

Return the content parts for the message.

@spec new(attrs :: map()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}

Setup a ChatGoogleAI client configuration.

@spec new!(attrs :: map()) :: t() | no_return()

Setup a ChatGoogleAI client configuration and return it or raise an error if invalid.