Skip to content

Navigation Menu

Sign in
Sign up

Commit a48d0cd

Browse files
fix(templates): import-std-safe I/O; CI template smoke; 0.2.8 (#18)
Templates use std::cerr/std::cout instead of <cstdio> macros (stderr broke under pure import std). tools/template_smoke.sh compile-gates every template in CI. Version 0.2.8 (0.2.7 not indexed: broken default template).
1 parent 8e7e09d commit a48d0cd

13 files changed

Lines changed: 88 additions & 16 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ jobs:
3737

3838
- name: Build with mcpp
3939
run: mcpp build
40+
41+
- name: Template smoke (compile each template against this checkout)
42+
run: bash tools/template_smoke.sh

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ mcpp add llmapi
3939

4040
```toml
4141
[dependencies.mcpplibs]
42-
llmapi = "0.2.7"
42+
llmapi = "0.2.8"
4343
```
4444

4545
```cpp

‎README.zh.hant.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ mcpp add llmapi
3939

4040
```toml
4141
[dependencies.mcpplibs]
42-
llmapi = "0.2.7"
42+
llmapi = "0.2.8"
4343
```
4444

4545
```cpp

‎README.zh.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ mcpp add llmapi
3939

4040
```toml
4141
[dependencies.mcpplibs]
42-
llmapi = "0.2.7"
42+
llmapi = "0.2.8"
4343
```
4444

4545
```cpp

‎docs/en/getting-started.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Or declare it in `mcpp.toml`:
3333

3434
```toml
3535
[dependencies.mcpplibs]
36-
llmapi = "0.2.7"
36+
llmapi = "0.2.8"
3737
```
3838

3939
### Building from Source

‎docs/zh-hant/getting-started.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ mcpp add llmapi
3030

3131
```toml
3232
[dependencies.mcpplibs]
33-
llmapi = "0.2.7"
33+
llmapi = "0.2.8"
3434
```
3535

3636
## 從原始碼建置

‎docs/zh/getting-started.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ mcpp add llmapi
3030

3131
```toml
3232
[dependencies.mcpplibs]
33-
llmapi = "0.2.7"
33+
llmapi = "0.2.8"
3434
```
3535

3636
## 从源码构建

‎mcpp.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
namespace = "mcpplibs"
33
name = "llmapi"
4-
version = "0.2.7"
4+
version = "0.2.8"
55
description = "Modern C++ LLM API client with openai-compatible support"
66
license = "Apache-2.0"
77
repo = "https://github.com/mcpplibs/llmapi"

‎templates/anthropic/src/main.cpp.in‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ int main() {
77

88
auto apiKey = std::getenv("ANTHROPIC_API_KEY");
99
if (!apiKey) {
10-
std::println(stderr, "ANTHROPIC_API_KEY not set");
10+
std::println(std::cerr, "ANTHROPIC_API_KEY not set");
1111
return 1;
1212
}
1313

‎templates/chat/src/main.cpp.in‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ int main() {
88

99
auto apiKey = std::getenv("OPENAI_API_KEY");
1010
if (!apiKey) {
11-
std::println(stderr, "OPENAI_API_KEY not set");
11+
std::println(std::cerr, "OPENAI_API_KEY not set");
1212
return 1;
1313
}
1414

@@ -21,21 +21,23 @@ int main() {
2121
std::println("{{project.name}} — chat CLI (type 'quit' to exit)");
2222

2323
while (true) {
24-
std::print("\nYou: ");
24+
std::print(std::cout, "\nYou: ");
25+
std::cout.flush();
2526
std::string input;
2627
if (!std::getline(std::cin, input)) break;
2728
if (input == "quit" || input == "q") break;
2829
if (input.empty()) continue;
2930

3031
try {
31-
std::print("AI: ");
32+
std::print(std::cout, "AI: ");
33+
std::cout.flush();
3234
client.chat_stream(input, [](std::string_view chunk) {
33-
std::print("{}", chunk);
34-
std::fflush(stdout);
35+
std::print(std::cout, "{}", chunk);
36+
std::cout.flush();
3537
});
3638
std::println("");
3739
} catch (const std::exception& e) {
38-
std::println(stderr, "\nError: {}", e.what());
40+
std::println(std::cerr, "\nError: {}", e.what());
3941
}
4042
}
4143

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /