-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathChatGrammarExampleGemini.cs
More file actions
50 lines (46 loc) · 1.78 KB
/
ChatGrammarExampleGemini.cs
File metadata and controls
50 lines (46 loc) · 1.78 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using Examples.Utils;
using MaIN.Core.Hub;
using MaIN.Domain.Entities;
using MaIN.Domain.Models;
using MaIN.Domain.Models.Concrete;
namespace Examples.Chat;
public class ChatGrammarExampleGemini : IExample
{
public async Task Start()
{
GeminiExample.Setup(); //We need to provide Gemini API key
Console.WriteLine("(Gemini) ChatExample is running!");
var grammarValue = """
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "User",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Full name of the user."
},
"age": {
"type": "integer",
"minimum": 0,
"description": "User's age in years."
},
"email": {
"type": "string",
"format": "email",
"description": "User's email address."
}
},
"required": ["name", "email"]
}
""";
await AIHub.Chat()
.WithModel<Gemini2_5Flash>()
.WithMessage("Generate random person")
.WithInferenceParams(new InferenceParams
{
Grammar = new Grammar(grammarValue, GrammarFormat.JSONSchema)
})
.CompleteAsync(interactive: true);
}
}