This example assumes using Ollama; is in scope and apiKey contains your Ollama API key.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 | await using var container = await Environment.PrepareAsync(TestModels.Chat);
var chat = container.Client.Chat(
model: TestModels.Chat,
systemMessage: "You are a helpful weather assistant. Use the provided tools for weather questions.",
autoCallTools: true);
chat.Options = new ModelOptions
{
Temperature = 0,
Seed = 1,
};
var service = new WeatherService();
chat.AddToolService(service.AsTools().AsOllamaTools(), service.AsCalls());
try
{
_ = await chat.SendAsync("What is the current temperature in Dubai, UAE in Celsius?");
}
finally
{
Console.WriteLine(chat.PrintMessages());
}
|