1using ElBruno.LocalLLMs;
2using Microsoft.Extensions.AI;
3
4// Configure the fine-tuned model
5var options = new LocalLLMsOptions
6{
7 Model = new ModelDefinition
8 {
9 Id = "Qwen2.5-0.5B-LocalLLMs-ToolCalling".ToLower(),
10 HuggingFaceRepoId = "elbruno/Qwen2.5-0.5B-LocalLLMs-ToolCalling",
11 RequiredFiles = ["*"],
12 ModelType = OnnxModelType.GenAI,
13 ChatTemplate = ChatTemplateFormat.Qwen,
14 SupportsToolCalling = true
15 }
16};
17
18// Create the chat client (downloads model automatically on first use)
19using var client = await LocalChatClient.CreateAsync(options);
20
21// --- Tool Calling Example ---
22var tools = new List<AITool>
23{
24 AIFunctionFactory.Create(
25 (string city) => $"{{\"temp\": 22, \"condition\": \"sunny\"}}",
26 "get_weather",
27 "Get current weather for a city"
28 )
29};
30
31var response = await client.GetResponseAsync(
32 new[] { new ChatMessage(ChatRole.User, "What's the weather in Paris?") },
33 new ChatOptions { Tools = tools }
34);
35Console.WriteLine(response);
36
37// --- RAG Example ---
38var ragMessages = new[]
39{
40 new ChatMessage(ChatRole.System, "Answer based on the provided context."),
41 new ChatMessage(ChatRole.User,
42 "Context:\n[1] ONNX Runtime GenAI enables local LLM inference.\n\n"
43 + "Question: What does ONNX Runtime GenAI do?")
44};
45var ragResponse = await client.GetResponseAsync(ragMessages);
46Console.WriteLine(ragResponse);
All scripts are available at:
scripts/finetune/
1@misc{{{MODEL_NAME.lower().replace('-', '_').replace('.', '_')}}},
2 author = {{Bruno Capuano}},
3 title = {Qwen2.5-0.5B-LocalLLMs-ToolCalling},
4 year = {2026},
5 publisher = {HuggingFace},
6 url = {https://huggingface.co/elbruno/Qwen2.5-0.5B-LocalLLMs-ToolCalling}
7}