Skip to content

Commit 9c60107

Browse files
committed
Add multilingual docs structure
1 parent 861c96b commit 9c60107

22 files changed

Lines changed: 1628 additions & 117 deletions

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
| English - [简体中文](README.zh.md) - [繁體中文](README.zh.hant.md) |
1111
|:---:|
12-
| [Documentation](docs/) - [C++ API](docs/cpp-api.md) - [Examples](docs/examples.md) |
12+
| [Documentation](docs/README.md) - [English Docs](docs/en/README.md) - [中文文档](docs/zh/README.md) - [繁體中文文件](docs/zh-hant/README.md) |
1313

1414
`llmapi` provides a typed `Client<Provider>` API for chat, streaming, embeddings, tool calls, and conversation persistence. The default config alias `Config` maps to OpenAI-style providers, so the common case does not need an explicit `openai::OpenAI` wrapper.
1515

@@ -89,7 +89,7 @@ target("demo")
8989
add_packages("llmapi")
9090
```
9191

92-
See [docs/getting-started.md](docs/getting-started.md) and [docs/providers.md](docs/providers.md) for more setup detail.
92+
See [docs/en/getting-started.md](docs/en/getting-started.md) and [docs/en/providers.md](docs/en/providers.md) for more setup detail.
9393

9494
## License
9595

README.zh.hant.md

Lines changed: 57 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,96 @@
11
# llmapi
22

3-
> Modern C++ LLM API client with openai-compatible support
3+
> 使用 C++23 模組建構的現代 LLM 客戶端
44
55
[![C++23](https://img.shields.io/badge/C%2B%2B-23-blue.svg)](https://en.cppreference.com/w/cpp/23)
66
[![Module](https://img.shields.io/badge/module-ok-green.svg)](https://en.cppreference.com/w/cpp/language/modules)
77
[![License](https://img.shields.io/badge/license-Apache_2.0-blue.svg)](LICENSE)
8-
[![OpenAI Compatible](https://img.shields.io/badge/OpenAI_API-Compatible-green.svg)](https://platform.openai.com/docs/api-reference)
8+
[![OpenAI Compatible](https://img.shields.io/badge/OpenAI-Compatible-green.svg)](https://platform.openai.com/docs/api-reference)
99

1010
| [English](README.md) - [简体中文](README.zh.md) - 繁體中文 |
1111
|:---:|
12-
| [完整文件](docs/) - [C++ API](docs/cpp-api.md) - [C API](docs/c-api.md) - [範例](docs/examples.md) |
12+
| [文件導覽](docs/README.md) - [繁體中文文件](docs/zh-hant/README.md) - [English Docs](docs/en/README.md) - [简体中文文档](docs/zh/README.md) |
1313

14-
簡潔、型別安全的 LLM API 客戶端,使用 C++23 模組。流式介面設計,零成本抽象。支援 OpenAI、Poe、DeepSeek 及相容端點
14+
`llmapi` 提供型別化的 `Client<Provider>` API,涵蓋聊天、串流輸出、embeddings、工具呼叫與對話持久化。預設別名 `Config` 對應 OpenAI 風格設定,常見情況下不需要顯式寫出 `openai::OpenAI(...)`
1515

16-
## 特性
16+
## 特性
1717

18-
- **C++23 模組** - `import mcpplibs.llmapi`
19-
- **自動儲存歷史** - 對話歷史自動管理
20-
- **型別安全串流** - 概念約束的回呼函式
21-
- **流式介面** - 可鏈式呼叫的方法
22-
- **提供商無關** - OpenAI、Poe 及相容端點
18+
- C++23 模組:`import mcpplibs.llmapi`
19+
- 強型別訊息、工具與回應結構
20+
- 同步、非同步、串流聊天介面
21+
- OpenAI Provider 支援 embeddings
22+
- 支援儲存 / 載入對話歷史
23+
- 可透過 `baseUrl` 存取 OpenAI 相容端點
2324

2425
## 快速開始
2526

26-
2727
```cpp
28-
import std;
2928
import mcpplibs.llmapi;
29+
import std;
3030

3131
int main() {
32-
using namespace mcpplibs;
33-
34-
llmapi::Client client(std::getenv("OPENAI_API_KEY"), llmapi::URL::Poe);
35-
36-
client.model("gpt-5")
37-
.system("You are a helpful assistant.")
38-
.user("In one sentence, introduce modern C++. 並給出中文翻譯")
39-
.request([](std::string_view chunk) {
40-
std::print("{}", chunk);
41-
std::cout.flush();
42-
});
32+
using namespace mcpplibs::llmapi;
33+
34+
auto apiKey = std::getenv("OPENAI_API_KEY");
35+
if (!apiKey) {
36+
std::cerr << "OPENAI_API_KEY not set\n";
37+
return 1;
38+
}
4339

40+
auto client = Client(Config{
41+
.apiKey = apiKey,
42+
.model = "gpt-4o-mini",
43+
});
44+
45+
client.system("You are a concise assistant.");
46+
auto resp = client.chat("用兩句話解釋 C++23 模組的價值。");
47+
48+
std::cout << resp.text() << '\n';
4449
return 0;
4550
}
4651
```
4752

48-
### 模型 / 提供商
53+
## Provider
54+
55+
- `Config``openai::Config` 的匯出別名,預設走 OpenAI 風格
56+
- `openai::OpenAI`:OpenAI 聊天、串流、工具呼叫、embeddings
57+
- `AnthropicConfig` / `anthropic::Anthropic`:Anthropic 聊天與串流
58+
59+
相容端點範例:
4960

5061
```cpp
51-
llmapi::Client client(apiKey, llmapi::URL::OpenAI); // OpenAI
52-
llmapi::Client client(apiKey, llmapi::URL::Poe); // Poe
53-
llmapi::Client client(apiKey, llmapi::URL::DeepSeek); // Deepseek
54-
llmapi::Client client(apiKey, "https://custom.com"); // 自訂
62+
auto client = Client(Config{
63+
.apiKey = std::getenv("DEEPSEEK_API_KEY"),
64+
.baseUrl = std::string(URL::DeepSeek),
65+
.model = "deepseek-chat",
66+
});
5567
```
5668

57-
## 🛠️ 建置
69+
## 建置與執行
5870

5971
```bash
60-
xmake # 建置
61-
xmake run basic # 執行範例(需先設定 OPENAI_API_KEY)
72+
xmake
73+
xmake run hello_mcpp
74+
xmake run basic
75+
xmake run chat
6276
```
6377

64-
## 📦 在建置工具中使用
65-
66-
### xmake
78+
## 套件管理使用
6779

6880
```lua
69-
-- 0 - 新增 mcpplibs 索引倉庫
70-
add_repositories("mcpplibs-index https://github.com/mcpplibs/llmapi.git")
71-
72-
-- 1 - 新增需要的函式庫和版本
81+
add_repositories("mcpplibs-index https://github.com/mcpplibs/mcpplibs-index.git")
7382
add_requires("llmapi 0.0.2")
74-
```
75-
76-
> More: [mcpplibs-index](https://github.com/mcpplibs/mcpplibs-index)
7783

78-
### cmake
79-
80-
```
81-
todo...
84+
target("demo")
85+
set_kind("binary")
86+
set_languages("c++23")
87+
set_policy("build.c++.modules", true)
88+
add_files("src/*.cpp")
89+
add_packages("llmapi")
8290
```
8391

84-
## 📄 授權條款
92+
更多內容見 [docs/zh-hant/getting-started.md](docs/zh-hant/getting-started.md)[docs/zh-hant/providers.md](docs/zh-hant/providers.md)
93+
94+
## 授權
8595

86-
Apache-2.0 - 詳見 [LICENSE](LICENSE)
96+
Apache-2.0詳見 [LICENSE](LICENSE)

README.zh.md

Lines changed: 57 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,96 @@
11
# llmapi
22

3-
> Modern C++ LLM API client with openai-compatible support
3+
> 使用 C++23 模块构建的现代 LLM 客户端
44
55
[![C++23](https://img.shields.io/badge/C%2B%2B-23-blue.svg)](https://en.cppreference.com/w/cpp/23)
66
[![Module](https://img.shields.io/badge/module-ok-green.svg)](https://en.cppreference.com/w/cpp/language/modules)
77
[![License](https://img.shields.io/badge/license-Apache_2.0-blue.svg)](LICENSE)
8-
[![OpenAI Compatible](https://img.shields.io/badge/OpenAI_API-Compatible-green.svg)](https://platform.openai.com/docs/api-reference)
8+
[![OpenAI Compatible](https://img.shields.io/badge/OpenAI-Compatible-green.svg)](https://platform.openai.com/docs/api-reference)
99

1010
| [English](README.md) - 简体中文 - [繁體中文](README.zh.hant.md) |
1111
|:---:|
12-
| [完整文档](docs/) - [C++ API](docs/cpp-api.md) - [C API](docs/c-api.md) - [示例](docs/examples.md) |
12+
| [文档导航](docs/README.md) - [中文文档](docs/zh/README.md) - [English Docs](docs/en/README.md) - [繁體中文文件](docs/zh-hant/README.md) |
1313

14-
简洁、类型安全的 LLM API 客户端,使用 C++23 模块。流式接口设计,零成本抽象。支持 OpenAI、Poe、DeepSeek 及兼容端点
14+
`llmapi` 提供类型化的 `Client<Provider>` API,覆盖聊天、流式输出、嵌入、工具调用与对话持久化。默认别名 `Config` 对应 OpenAI 风格配置,常见场景不需要显式写 `openai::OpenAI(...)`
1515

16-
## 特性
16+
## 特性
1717

18-
- **C++23 模块** - `import mcpplibs.llmapi`
19-
- **自动保存历史** - 对话历史自动管理
20-
- **类型安全流式** - 概念约束的回调函数
21-
- **流式接口** - 可链式调用的方法
22-
- **提供商无关** - OpenAI、Poe 及兼容端点
18+
- C++23 模块:`import mcpplibs.llmapi`
19+
- 强类型消息、工具与响应结构
20+
- 同步、异步、流式聊天接口
21+
- OpenAI Provider 支持 embeddings
22+
- 支持保存 / 加载对话历史
23+
- 可通过 `baseUrl` 访问 OpenAI 兼容端点
2324

2425
## 快速开始
2526

2627
```cpp
27-
import std;
2828
import mcpplibs.llmapi;
29+
import std;
2930

3031
int main() {
31-
using namespace mcpplibs;
32-
33-
llmapi::Client client(std::getenv("OPENAI_API_KEY"), llmapi::URL::Poe);
34-
35-
client.model("gpt-5")
36-
.system("You are a helpful assistant.")
37-
.user("In one sentence, introduce modern C++. 并给出中文翻译")
38-
.request([](std::string_view chunk) {
39-
std::print("{}", chunk);
40-
std::cout.flush();
41-
});
32+
using namespace mcpplibs::llmapi;
33+
34+
auto apiKey = std::getenv("OPENAI_API_KEY");
35+
if (!apiKey) {
36+
std::cerr << "OPENAI_API_KEY not set\n";
37+
return 1;
38+
}
39+
40+
auto client = Client(Config{
41+
.apiKey = apiKey,
42+
.model = "gpt-4o-mini",
43+
});
4244

45+
client.system("You are a concise assistant.");
46+
auto resp = client.chat("用两句话解释 C++23 模块的价值。");
47+
48+
std::cout << resp.text() << '\n';
4349
return 0;
4450
}
4551
```
4652

47-
### 模型 / 提供商
53+
## Provider
54+
55+
- `Config``openai::Config` 的导出别名,默认走 OpenAI 风格
56+
- `openai::OpenAI`:OpenAI 聊天、流式、工具调用、embeddings
57+
- `AnthropicConfig` / `anthropic::Anthropic`:Anthropic 聊天与流式
58+
59+
兼容端点示例:
4860

4961
```cpp
50-
llmapi::Client client(apiKey, llmapi::URL::OpenAI); // OpenAI
51-
llmapi::Client client(apiKey, llmapi::URL::Poe); // Poe
52-
llmapi::Client client(apiKey, llmapi::URL::DeepSeek); // Deepseek
53-
llmapi::Client client(apiKey, "https://custom.com"); // 自定义
62+
auto client = Client(Config{
63+
.apiKey = std::getenv("DEEPSEEK_API_KEY"),
64+
.baseUrl = std::string(URL::DeepSeek),
65+
.model = "deepseek-chat",
66+
});
5467
```
5568

56-
## 构建
69+
## 构建与运行
5770

5871
```bash
59-
xmake # 构建
60-
xmake run basic # 运行示例(需要先配置 OPENAI_API_KEY)
72+
xmake
73+
xmake run hello_mcpp
74+
xmake run basic
75+
xmake run chat
6176
```
6277

63-
## 在构建工具中使用
64-
65-
### xmake
78+
## 包管理使用
6679

6780
```lua
68-
-- 0 - 添加 mcpplibs 索引仓库
69-
add_repositories("mcpplibs-index https://github.com/mcpplibs/llmapi.git")
70-
71-
-- 1 - 添加需要的库和版本
81+
add_repositories("mcpplibs-index https://github.com/mcpplibs/mcpplibs-index.git")
7282
add_requires("llmapi 0.0.2")
73-
```
74-
75-
> More: [mcpplibs-index](https://github.com/mcpplibs/mcpplibs-index)
7683

77-
### cmake
78-
79-
```
80-
todo...
84+
target("demo")
85+
set_kind("binary")
86+
set_languages("c++23")
87+
set_policy("build.c++.modules", true)
88+
add_files("src/*.cpp")
89+
add_packages("llmapi")
8190
```
8291

83-
## 📄 许可证
92+
更多内容见 [docs/zh/getting-started.md](docs/zh/getting-started.md)[docs/zh/providers.md](docs/zh/providers.md)
93+
94+
## 许可证
8495

85-
Apache-2.0 - 详见 [LICENSE](LICENSE)
96+
Apache-2.0详见 [LICENSE](LICENSE)

docs/README.md

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
1-
# llmapi Documentation
1+
# Documentation
22

3-
Current documentation for the `llmapi` C++23 module library.
3+
Select a language:
44

5-
## Contents
6-
7-
- [Getting Started](getting-started.md) - install, build, and first request
8-
- [C++ API Guide](cpp-api.md) - types, providers, and `Client<P>`
9-
- [Examples](examples.md) - chat, streaming, embeddings, and tool flows
10-
- [Providers](providers.md) - OpenAI, Anthropic, and compatible endpoints
11-
- [Advanced Usage](advanced.md) - persistence, async calls, and custom configuration
12-
13-
## What The Library Provides
14-
15-
- C++23 modules via `import mcpplibs.llmapi`
16-
- Typed chat messages and multimodal content structs
17-
- Provider concepts for sync, async, streaming, and embeddings
18-
- Built-in OpenAI and Anthropic providers
19-
- OpenAI-compatible endpoint support through configurable base URLs
20-
- Conversation save/load helpers for local session persistence
21-
22-
## License
23-
24-
Apache-2.0 - see [LICENSE](../LICENSE)
5+
- [English](en/README.md)
6+
- [简体中文](zh/README.md)
7+
- [繁體中文](zh-hant/README.md)

docs/en/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# llmapi Documentation
2+
3+
Current documentation for the `llmapi` C++23 module library.
4+
5+
Language:
6+
7+
- English
8+
- [简体中文](../zh/README.md)
9+
- [繁體中文](../zh-hant/README.md)
10+
11+
## Contents
12+
13+
- [Getting Started](getting-started.md) - install, build, and first request
14+
- [C++ API Guide](cpp-api.md) - types, providers, and `Client<P>`
15+
- [Examples](examples.md) - chat, streaming, embeddings, and tool flows
16+
- [Providers](providers.md) - OpenAI, Anthropic, and compatible endpoints
17+
- [Advanced Usage](advanced.md) - persistence, async calls, and custom configuration
18+
19+
## What The Library Provides
20+
21+
- C++23 modules via `import mcpplibs.llmapi`
22+
- Typed chat messages and multimodal content structs
23+
- Provider concepts for sync, async, streaming, and embeddings
24+
- Built-in OpenAI and Anthropic providers
25+
- OpenAI-compatible endpoint support through configurable base URLs
26+
- Conversation save/load helpers for local session persistence
27+
28+
## License
29+
30+
Apache-2.0 - see [LICENSE](../../LICENSE)

0 commit comments

Comments
 (0)