mistral_client¶
Classes
|
A minimal Mistral client that inherits from |
- class MistralClient(api_key: str | None = None, base_url: str = 'https://api.mistral.ai/v1', input_type: Literal['text', 'messages'] = 'text', env_api_key_name: str = 'MISTRAL_API_KEY', chat_completion_parser: Callable[[Completion], Any] = None)[source]¶
Bases:
OpenAIClient
A minimal Mistral client that inherits from
OpenAIClient
.This client is designed to work with Mistral’s API by setting: - The API base URL to
https://api.mistral.ai/v1
. - The API key is fetched from the environment variableMISTRAL_API_KEY
if not provided. - The input format is supported as either"text"
or"messages"
. - The AdalFlow Generator is expected to supply additional model parameters (such as model name, temperature, and max_tokens)in a single configuration point.
Example usage with the AdalFlow Generator:
import os from adalflow.core import Generator from adalflow.components.model_client.mistral_client import MistralClient from adalflow.utils import setup_env setup_env() generator = Generator( model_client=MistralClient(), model_kwargs={ "model": "mistral-large-latest", "temperature": 0.7, "max_tokens": 2000, } ) prompt_kwargs = {"input_str": "Explain the concept of machine learning."} response = generator(prompt_kwargs)