AutoGen.Mistral overview
AutoGen.Mistral provides the following agent(s) to connect to Mistral.AI platform.
- Mistral
Client : A slim wrapper agent over MistralAgent Client .
Get started with AutoGen.Mistral
To get started with AutoGen.Mistral, follow the installation guide to make sure you add the AutoGen feed correctly. Then add the AutoGen.Mistral
package to your project file.
dotnet add package AutoGen.Mistral
Note
You need to provide an api-key to use Mistral models which will bring additional cost while using. you can get the api key from Mistral.AI.
Example
Import the required namespace
using AutoGen.Core;
using AutoGen.Mistral;
using AutoGen.Mistral.Extension;
using FluentAssertions;
Create a Mistral
var apiKey = Environment.GetEnvironmentVariable("MISTRAL_API_KEY") ?? throw new Exception("Missing MISTRAL_API_KEY environment variable");
var client = new MistralClient(apiKey: apiKey);
var agent = new MistralClientAgent(
client: client,
name: "MistralAI",
model: MistralAIModelID.OPEN_MISTRAL_7B)
.RegisterMessageConnector(); // support more AutoGen built-in message types.
await agent.SendAsync("Hello, how are you?");
Use Generate
var reply = agent.GenerateStreamingReplyAsync(
messages: [new TextMessage(Role.User, "Hello, how are you?")]
);
await foreach (var message in reply)
{
if (message is TextMessageUpdate textMessageUpdate && textMessageUpdate.Content is string content)
{
Console.WriteLine(content);
}
}