View Source WiseGPTEx.MistralHTTPClient (WiseGPTEx v0.8.0)
Provides functionalities to interact with the Mistral API for chat completions. Sends prompts to the API and receives responses, with various customizable parameters.
Summary
Functions
Completes a chat prompt using Mistral.
Functions
Completes a chat prompt using Mistral.
Parameters
messages
- An array of objects representing the chat prompts. Each object should have arole
(either 'user' or 'system') andcontent
which is the actual text of the prompt. This is the input for the Mistral model to generate completions.opts
- Optional parameters for the request, which allow customization of the API call. These include::model
- A string representing the ID of the model to use. Different models might have different capabilities or performance characteristics.:temperature
- A number between 0.0 and 1.0 that controls the randomness of the completion. Higher values increase randomness, while lower values produce more deterministic outputs.:top_p
- Nucleus sampling parameter, a number between 0 and 1, representing the cumulative probability of the considered tokens for completion. Lower values focus on more likely tokens.:max_tokens
- The maximum number of tokens to generate for the completion. This limits the length of the response.:stream
- A boolean that, if set to true, streams back partial progress of the completion. Otherwise, the server waits until the completion is fully generated before responding.:safe_mode
- A boolean to decide whether to inject a safety prompt before all conversations for content moderation.:random_seed
- An integer that sets the seed for random sampling, allowing for deterministic results if set.:timeout
- The timeout for the HTTP request in milliseconds.:extract_fn
- A function for extracting the desired data from the API response. By default, it usesUtils.extract_complete/1
.
Returns
{:ok, completion}
on successful generation of completion.{:error, reason}
on failure, with details of the error.