MistralClient.API.Jobs (mistralex_ai v0.1.0)
View SourceJobs API for managing fine-tuning jobs.
This module provides a dedicated interface for fine-tuning job operations,
maintaining API parity with the Python SDK's mistral.fine_tuning.jobs
interface.
Examples
# List fine-tuning jobs
{:ok, jobs} = MistralClient.API.Jobs.list()
# Create a fine-tuning job
request = %MistralClient.Models.FineTuningJobRequest{
model: "open-mistral-7b",
hyperparameters: %MistralClient.Models.CompletionTrainingParameters{
learning_rate: 0.0001
}
}
{:ok, job} = MistralClient.API.Jobs.create(request)
# Get job details
{:ok, job} = MistralClient.API.Jobs.get("job-123")
# Start a job
{:ok, job} = MistralClient.API.Jobs.start("job-123")
# Cancel a job
{:ok, job} = MistralClient.API.Jobs.cancel("job-123")
Summary
Functions
Request the cancellation of a fine tuning job.
Create a new fine-tuning job, it will be queued for processing.
Get a fine-tuned job details by its UUID.
Get a list of fine-tuning jobs for your organization and user.
Request the start of a validated fine tuning job.
Types
@type job_status() ::
:queued
| :started
| :validating
| :validated
| :running
| :failed_validation
| :failed
| :success
| :cancelled
| :cancellation_requested
@type list_options() :: %{ page: integer() | nil, page_size: integer() | nil, model: String.t() | nil, created_after: Date.t() | nil, created_before: Date.t() | nil, created_by_me: boolean() | nil, status: job_status() | nil, wandb_project: String.t() | nil, wandb_name: String.t() | nil, suffix: String.t() | nil }
Functions
@spec cancel(String.t()) :: {:ok, MistralClient.Models.FineTuningJobResponse.t()} | {:error, term()}
Request the cancellation of a fine tuning job.
Parameters
config
- Client configuration (optional, uses default if not provided)job_id
- The ID of the job to cancel
Examples
{:ok, job} = MistralClient.API.Jobs.cancel("job-123")
# With custom config
config = MistralClient.Config.new(api_key: "custom-key")
{:ok, job} = MistralClient.API.Jobs.cancel(config, "job-123")
@spec cancel(MistralClient.Config.t(), String.t()) :: {:ok, MistralClient.Models.FineTuningJobResponse.t()} | {:error, term()}
@spec create(MistralClient.Models.FineTuningJobRequest.t()) :: {:ok, MistralClient.Models.FineTuningJobResponse.t()} | {:error, term()}
Create a new fine-tuning job, it will be queued for processing.
Parameters
config
- Client configuration (optional, uses default if not provided)request
- Fine-tuning job request parameters
Request Parameters
model
(required) - The name of the model to fine-tunehyperparameters
(required) - Training hyperparameterstraining_files
- List of training file IDsvalidation_files
- List of validation file IDssuffix
- String to add to fine-tuned model nameintegrations
- List of integrations (e.g., Weights & Biases)auto_start
- Whether to automatically start the jobinvalid_sample_skip_percentage
- Percentage of invalid samples to skipjob_type
- Type of fine-tuning jobrepositories
- List of GitHub repositoriesclassifier_targets
- Classifier targets (for classifier jobs)
Examples
request = %MistralClient.Models.FineTuningJobRequest{
model: "open-mistral-7b",
hyperparameters: %MistralClient.Models.CompletionTrainingParameters{
learning_rate: 0.0001,
training_steps: 1000
}
}
{:ok, job} = MistralClient.API.Jobs.create(request)
# With custom config
config = MistralClient.Config.new(api_key: "custom-key")
{:ok, job} = MistralClient.API.Jobs.create(config, request)
@spec create(MistralClient.Config.t(), MistralClient.Models.FineTuningJobRequest.t()) :: {:ok, MistralClient.Models.FineTuningJobResponse.t()} | {:error, term()}
@spec get(String.t()) :: {:ok, MistralClient.Models.FineTuningJobResponse.t()} | {:error, term()}
Get a fine-tuned job details by its UUID.
Parameters
config
- Client configuration (optional, uses default if not provided)job_id
- The ID of the job to retrieve
Examples
{:ok, job} = MistralClient.API.Jobs.get("job-123")
# With custom config
config = MistralClient.Config.new(api_key: "custom-key")
{:ok, job} = MistralClient.API.Jobs.get(config, "job-123")
@spec get(MistralClient.Config.t(), String.t()) :: {:ok, MistralClient.Models.FineTuningJobResponse.t()} | {:error, term()}
@spec list(MistralClient.Config.t(), map()) :: {:ok, MistralClient.Models.FineTuningJobsResponse.t()} | {:error, term()}
Get a list of fine-tuning jobs for your organization and user.
Parameters
config
- Client configuration (optional, uses default if not provided)options
- Filtering and pagination options
Options
page
- The page number of the results to be returnedpage_size
- The number of items to return per pagemodel
- The model name used for fine-tuning to filter oncreated_after
- Filter jobs created after this datecreated_before
- Filter jobs created before this datecreated_by_me
- When true, only return results for jobs created by the API callerstatus
- The current job state to filter onwandb_project
- The Weights and Biases project to filter onwandb_name
- The Weight and Biases run name to filter onsuffix
- The model suffix to filter on
Examples
# List all jobs
{:ok, jobs} = MistralClient.API.Jobs.list()
# List with filtering
{:ok, jobs} = MistralClient.API.Jobs.list(%{
status: :running,
model: "open-mistral-7b",
page_size: 10
})
# With custom config
config = MistralClient.Config.new(api_key: "custom-key")
{:ok, jobs} = MistralClient.API.Jobs.list(config, %{created_by_me: true})
@spec start(String.t()) :: {:ok, MistralClient.Models.FineTuningJobResponse.t()} | {:error, term()}
Request the start of a validated fine tuning job.
Parameters
config
- Client configuration (optional, uses default if not provided)job_id
- The ID of the job to start
Examples
{:ok, job} = MistralClient.API.Jobs.start("job-123")
# With custom config
config = MistralClient.Config.new(api_key: "custom-key")
{:ok, job} = MistralClient.API.Jobs.start(config, "job-123")
@spec start(MistralClient.Config.t(), String.t()) :: {:ok, MistralClient.Models.FineTuningJobResponse.t()} | {:error, term()}