MCPcopy Create free account
hub / github.com/ClickHouse/ai-sdk-cpp / main

Function main

examples/multi_provider.cpp:76–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76int main() {
77 std::cout << "AI SDK C++ - Multi-Provider Comparison\n";
78 std::cout << "======================================\n\n";
79
80 // Test 1: Simple question comparison
81 std::cout << "Test 1: Simple factual question\n";
82 std::cout << "Question: What is the largest planet in our solar system?\n\n";
83
84 std::string simple_question =
85 "What is the largest planet in our solar system? Give a brief answer.";
86
87 std::vector<ProviderResult> results1;
88
89 // Test OpenAI models
90 results1.push_back(
91 test_provider("OpenAI", ai::openai::models::kGpt54, simple_question));
92 results1.push_back(
93 test_provider("OpenAI", ai::openai::models::kGpt54Mini, simple_question));
94
95 // Test Anthropic models
96 results1.push_back(test_provider(
97 "Anthropic", ai::anthropic::models::kClaudeSonnet46, simple_question));
98 results1.push_back(test_provider(
99 "Anthropic", ai::anthropic::models::kClaudeHaiku45, simple_question));
100
101 for (const auto& result : results1) {
102 print_result(result);
103 }
104
105 // Test 2: Creative writing comparison
106 std::cout << "Test 2: Creative writing task\n";
107 std::cout
108 << "Prompt: Write a creative short story opening about time travel.\n\n";
109
110 std::string creative_prompt =
111 "Write a creative opening paragraph for a short story about someone who "
112 "discovers they can time travel, but only to the exact same location 24 "
113 "hours in the past.";
114
115 std::vector<ProviderResult> results2;
116
117 // Test with different providers for creativity
118 results2.push_back(
119 test_provider("OpenAI", ai::openai::models::kGpt54, creative_prompt));
120 results2.push_back(test_provider(
121 "Anthropic", ai::anthropic::models::kClaudeSonnet46, creative_prompt));
122
123 for (const auto& result : results2) {
124 print_result(result);
125 }
126
127 // Test 3: Technical explanation comparison
128 std::cout << "Test 3: Technical explanation\n";
129 std::cout << "Prompt: Explain the concept of RAII in C++.\n\n";
130
131 std::string technical_prompt =
132 "Explain the concept of RAII (Resource Acquisition Is Initialization) in "
133 "C++ with a simple example.";

Callers

nothing calls this directly

Calls 8

test_providerFunction · 0.85
print_resultFunction · 0.85
beginMethod · 0.80
create_clientFunction · 0.50
endMethod · 0.45
is_validMethod · 0.45
provider_nameMethod · 0.45
supported_modelsMethod · 0.45

Tested by

no test coverage detected