-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02_triage_ticket.cpp
More file actions
66 lines (53 loc) · 1.95 KB
/
Copy path02_triage_ticket.cpp
File metadata and controls
66 lines (53 loc) · 1.95 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
// Copyright 2026 Bontal LLC
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
/**
* @file 02_triage_ticket.cpp
* @brief Ticket triage combining Choice, Score, and Noul questions.
*/
#include <typesafe/typesafe.h>
#include <iostream>
#include "openrouter_helper.h"
int main()
{
try
{
auto client = typesafe::examples::createClient();
typesafe::SystemOneRequest request;
request.state = nlohmann::json{
{"subject", "Duplicate charge"},
{"message", "I was charged twice. Please fix this ASAP."}};
request.add("billing",
typesafe::Noul{"Is this about billing?", std::nullopt});
request.add("category",
typesafe::Choice{
"What is this ticket about?",
{{"billing", "A charge, refund or invoice problem"},
{"technical", "Something is broken or slow"},
{"other", std::nullopt}}});
request.add("urgency",
typesafe::Score{"How urgent is this?",
{"can wait", "this week", "today"}});
const typesafe::SystemOneResponse answer = client.systemOne(request);
const auto &category = answer.choices.at("category");
const auto &urgency = answer.scores.at("urgency");
std::cout << "billing: " << answer.nouls.at("billing").noul << "\n";
std::cout << "category: " << category.choice << " (confidence "
<< category.confidence << ")\n";
for (const auto &[name, chance] : category.probabilities)
std::cout << " " << name << ": " << chance << "\n";
std::cout << "urgency: " << urgency.score << " (";
for (const auto &[level, meaning] : urgency.legend)
std::cout << level << "=" << meaning.dump() << " ";
std::cout << ")\n";
std::cout << "model: " << answer.model << "\n";
return (0);
}
catch (const typesafe::TypeSafeError &error)
{
std::cerr << "TypeSafe: " << error.what() << "\n";
return (1);
}
}