This example assumes using Mistral; is in scope and apiKey contains your Mistral API key.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 | using var client = new MistralClient(apiKey);
var getWeatherTool = Meai.AIFunctionFactory.Create(
(string location) => $"The weather in {location} is 72°F and sunny.",
name: "get_weather",
description: "Gets the current weather for a given location.");
Meai.IChatClient chatClient = client;
var response = await chatClient.GetResponseAsync(
[
new Meai.ChatMessage(Meai.ChatRole.User, "What is the weather in Paris?")
],
new Meai.ChatOptions
{
ModelId = "mistral-small-latest",
Tools = [getWeatherTool],
});
var functionCall = response.Messages
.SelectMany(m => m.Contents)
.OfType<Meai.FunctionCallContent>()
.FirstOrDefault();
|