-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchat_formatting_example.cpp
More file actions
78 lines (66 loc) · 4.19 KB
/
chat_formatting_example.cpp
File metadata and controls
78 lines (66 loc) · 4.19 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
╔═════════════════════════════════════════════════════════════════════╗
║ ThemisDB - Hybrid Database System ║
╠═════════════════════════════════════════════════════════════════════╣
File: chat_formatting_example.cpp ║
Version: 0.0.34 ║
Last Modified: 2026-03-09 03:52:17 ║
Author: unknown ║
╠═════════════════════════════════════════════════════════════════════╣
Quality Metrics: ║
• Maturity Level: 🟢 PRODUCTION-READY ║
• Quality Score: 100.0/100 ║
• Total Lines: 77 ║
• Open Issues: TODOs: 0, Stubs: 0 ║
╠═════════════════════════════════════════════════════════════════════╣
Revision History: ║
• 2a1fb0423 2026-03-03 Merge branch 'develop' into copilot/audit-src-module-docu... ║
• a629043ab 2026-02-22 Audit: document gaps found - benchmarks and stale annotat... ║
╠═════════════════════════════════════════════════════════════════════╣
Status: ✅ Production Ready ║
╚═════════════════════════════════════════════════════════════════════╝
*/
/**
* Chat Formatting Examples for LlamaWrapper
*
* This demonstrates how to use the new chat formatting functionality
* added to support multi-turn conversations.
*/
#include <iostream>
#include <vector>
#include "llm/llama_wrapper.h"
using namespace themis::llm;
int main() {
// Example 1: ChatML format (default)
std::vector<ChatMessage> messages = {
{"system", "You are a helpful AI assistant."},
{"user", "What is the capital of France?"},
{"assistant", "The capital of France is Paris."},
{"user", "What is its population?"}
};
LlamaWrapper wrapper(LlamaWrapper::Config{});
std::cout << "=== ChatML Format ===" << std::endl;
std::string chatML = wrapper.formatChatMessages(messages, ChatFormat::ChatML);
std::cout << chatML << std::endl << std::endl;
std::cout << "=== Llama-2 Format ===" << std::endl;
std::string llama2 = wrapper.formatChatMessages(messages, ChatFormat::Llama2);
std::cout << llama2 << std::endl << std::endl;
std::cout << "=== Vicuna Format ===" << std::endl;
std::string vicuna = wrapper.formatChatMessages(messages, ChatFormat::Vicuna);
std::cout << vicuna << std::endl << std::endl;
std::cout << "=== Alpaca Format ===" << std::endl;
std::string alpaca = wrapper.formatChatMessages(messages, ChatFormat::Alpaca);
std::cout << alpaca << std::endl << std::endl;
// Example 2: Using with generate()
// This shows how to integrate chat formatting with inference
/*
InferenceRequest request;
request.prompt = wrapper.formatChatMessages(messages, ChatFormat::ChatML);
request.max_tokens = 100;
request.temperature = 0.7f;
// This would call the real llama.cpp inference
// auto response = wrapper.generate(request);
// std::cout << "Response: " << response.text << std::endl;
*/
return 0;
}