-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathChatFromExistingExample.cs
More file actions
35 lines (28 loc) · 946 Bytes
/
ChatFromExistingExample.cs
File metadata and controls
35 lines (28 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Text.Json;
using MaIN.Core.Hub;
using MaIN.Domain.Exceptions.Chats;
using MaIN.Domain.Models.Concrete;
namespace Examples.Chat;
public class ChatFromExistingExample : IExample
{
public async Task Start()
{
Console.WriteLine("ChatExample with files is running!");
var result = AIHub.Chat()
.WithModel<Qwen2_5_0_5b>();
await result.WithMessage("What do you think about math theories?")
.CompleteAsync();
await result.WithMessage("And about physics?")
.CompleteAsync();
try
{
var chatNewContext = await AIHub.Chat().FromExisting(result.GetChatId());
var messages = chatNewContext.GetChatHistory();
Console.WriteLine(JsonSerializer.Serialize(messages));
}
catch (ChatNotFoundException ex)
{
Console.WriteLine(ex.PublicErrorMessage);
}
}
}