ExLLM.Providers.Gemini.Tuning (ex_llm v0.8.1)
View SourceGoogle Gemini Fine-tuning API implementation.
This module provides functionality for creating and managing tuned models using the Gemini API.
Summary
Functions
Creates a tuned model.
Deletes a tuned model.
Generates content using a tuned model.
Gets information about a specific tuned model.
Lists tuned models.
Streams content generation using a tuned model.
Updates a tuned model.
Waits for a tuning operation to complete.
Types
Functions
Creates a tuned model.
Parameters
request
- The tuned model creation request containing::base_model
- The base model to tune (required):tuning_task
- The tuning task configuration (required):display_name
- Optional display name:description
- Optional description:temperature
- Optional temperature setting:top_p
- Optional nucleus sampling parameter:top_k
- Optional top-k sampling parameter
opts
- Options including::api_key
- Google API key:tuned_model_id
- Optional custom ID for the tuned model
Returns
{:ok, operation}
- The long-running operation for tracking tuning progress{:error, reason}
- Error details
Deletes a tuned model.
Parameters
name
- The resource name of the modelopts
- Options including:api_key
Returns
{:ok, %{}}
- Empty response on success{:error, reason}
- Error details
Generates content using a tuned model.
Parameters
model
- The tuned model name (e.g., "tunedModels/my-model")request
- The generation requestopts
- Options including:api_key
Returns
{:ok, response}
- The generation response{:error, reason}
- Error details
@spec get_tuned_model(String.t(), options()) :: {:ok, ExLLM.Providers.Gemini.Tuning.TunedModel.t()} | {:error, term()}
Gets information about a specific tuned model.
Parameters
name
- The resource name of the model (e.g., "tunedModels/my-model-id")opts
- Options including:api_key
Returns
{:ok, model}
- The tuned model details{:error, reason}
- Error details
@spec list_tuned_models(options()) :: {:ok, ExLLM.Providers.Gemini.Tuning.ListTunedModelsResponse.t()} | {:error, term()}
Lists tuned models.
Parameters
opts
- Options including::api_key
- Google API key:page_size
- Maximum number of models to return:page_token
- Token for pagination:filter
- Filter expression
Returns
{:ok, response}
- List of tuned models{:error, reason}
- Error details
@spec stream_generate_content(String.t(), map(), options()) :: {:ok, Enumerable.t()} | {:error, term()}
Streams content generation using a tuned model.
Parameters
model
- The tuned model namerequest
- The generation requestopts
- Options including:api_key
Returns
{:ok, stream}
- Stream of response chunks{:error, reason}
- Error details
@spec update_tuned_model(String.t(), map(), options()) :: {:ok, ExLLM.Providers.Gemini.Tuning.TunedModel.t()} | {:error, term()}
Updates a tuned model.
Parameters
name
- The resource name of the modelupdate
- Map of fields to updateopts
- Options including::api_key
- Google API key:update_mask
- Field mask specifying which fields to update
Returns
{:ok, model}
- The updated model{:error, reason}
- Error details
@spec wait_for_tuning(String.t(), options()) :: {:ok, ExLLM.Providers.Gemini.Tuning.TunedModel.t()} | {:error, term()}
Waits for a tuning operation to complete.
Parameters
operation_name
- The operation name from create_tuned_modelopts
- Options including::api_key
- Google API key:timeout
- Maximum time to wait in milliseconds (default: 300_000)
Returns
{:ok, model}
- The completed tuned model{:error, reason}
- Error details