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

Function main

examples/components/anthropic/main.cpp:5–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include <ai/ai.h>
4
5int main() {
6 std::cout << "AI SDK C++ - Anthropic Component Demo\n";
7 std::cout << "====================================\n\n";
8
9 std::cout << "Available components:\n";
10 std::cout << "- Core: YES\n";
11
12#ifdef AI_SDK_HAS_OPENAI
13 std::cout << "- OpenAI: YES\n";
14#else
15 std::cout << "- OpenAI: NO\n";
16#endif
17
18#ifdef AI_SDK_HAS_ANTHROPIC
19 std::cout << "- Anthropic: YES\n";
20#else
21 std::cout << "- Anthropic: NO\n";
22#endif
23
24 std::cout << "\n";
25
26 // Test core functionality
27 std::cout << "Testing core functionality...\n";
28 ai::GenerateOptions options;
29 options.model = "claude-sonnet-4-6";
30 options.prompt = "Hello world";
31 std::cout << "✓ Core types work fine\n\n";
32
33 // Test Anthropic functionality
34#ifdef AI_SDK_HAS_ANTHROPIC
35 std::cout << "Testing Anthropic functionality...\n";
36 try {
37 auto client = ai::anthropic::create_client();
38 std::cout << "✓ Anthropic client created successfully\n";
39 std::cout << "✓ Available models: "
40 << ai::anthropic::models::kClaudeSonnet46 << ", "
41 << ai::anthropic::models::kClaudeHaiku45 << "\n";
42 } catch (const std::exception& e) {
43 std::cout << "✗ Anthropic client failed: " << e.what() << "\n";
44 }
45#else
46 std::cout << "Anthropic functionality not available\n";
47#endif
48
49 // Demonstrate that OpenAI is NOT available
50#ifdef AI_SDK_HAS_OPENAI
51 std::cout << "\nTesting OpenAI functionality...\n";
52 // This would work if OpenAI was linked
53 auto openai_client = ai::openai::create_client();
54 std::cout << "✓ OpenAI client created\n";
55#else
56 std::cout
57 << "\nOpenAI functionality intentionally not available in this build\n";
58 std::cout << "This example only links ai::anthropic component\n";
59
60 // Uncommenting the next line would cause a compile error:
61 // auto openai_client = ai::openai::create_client(); // ERROR!
62#endif

Callers

nothing calls this directly

Calls 1

create_clientFunction · 0.50

Tested by

no test coverage detected