diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d492352..66f5053 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,14 +26,14 @@ jobs: - name: Refresh package index run: xlings update - - name: Install workspace tools (.xlings.json → mcpp 0.0.13) + - name: Install workspace tools (.xlings.json → mcpp 0.0.53) run: xlings install -y - name: Cache mcpp sandbox uses: actions/cache@v4 with: - path: ~/.xlings/data/xpkgs/xim-x-mcpp/0.0.13/registry - key: mcpp-sandbox-${{ runner.os }}-mcpp0.0.13 + path: ~/.xlings/data/xpkgs/xim-x-mcpp/0.0.53/registry + key: mcpp-sandbox-${{ runner.os }}-mcpp0.0.53 - name: Build with mcpp run: mcpp build diff --git a/.xlings.json b/.xlings.json index 62fdda3..925b1b8 100644 --- a/.xlings.json +++ b/.xlings.json @@ -1,5 +1,5 @@ { "workspace": { - "mcpp": { "linux": "0.0.13" } + "mcpp": { "linux": "0.0.53" } } } diff --git a/README.md b/README.md index 5be4e2a..ca41fb2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # llmapi -> Modern C++23 LLM client built with modules +> Modern C++23 LLM client built with modules — `import` and chat, OpenAI-compatible, template-ready +[![Release](https://img.shields.io/github/v/release/mcpplibs/llmapi)](https://github.com/mcpplibs/llmapi/releases) [![C++23](https://img.shields.io/badge/C%2B%2B-23-blue.svg)](https://en.cppreference.com/w/cpp/23) [![Module](https://img.shields.io/badge/module-ok-green.svg)](https://en.cppreference.com/w/cpp/language/modules) [![License](https://img.shields.io/badge/license-Apache_2.0-blue.svg)](LICENSE) @@ -9,20 +10,37 @@ | English - [简体中文](README.zh.md) - [繁體中文](README.zh.hant.md) | |:---:| -| [Documentation](docs/README.md) - [English Docs](docs/en/README.md) - [中文文档](docs/zh/README.md) - [繁體中文文件](docs/zh-hant/README.md) | +| [mcpp build tool](https://github.com/mcpp-community/mcpp) · [package index](https://github.com/mcpp-community/mcpp-index) · [Documentation](docs/README.md) · [Issues](https://github.com/mcpplibs/llmapi/issues) | `llmapi` provides a typed `Client` 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. -## Features +## Quick Start (mcpp) -- `import mcpplibs.llmapi` with C++23 modules -- Strongly typed messages, tools, and response structs -- Sync, async, and streaming chat APIs -- Embeddings via the OpenAI provider -- Conversation save/load helpers -- OpenAI-compatible endpoint support through `openai::Config::baseUrl` +```bash +mcpp new myagent --template llmapi && cd myagent +export OPENAI_API_KEY="sk-..." +mcpp run +``` + +Templates ship with the library and version-track it automatically: + +```bash +mcpp new --list-templates llmapi # list available templates +mcpp new mybot --template llmapi:chat # interactive streaming chat CLI +mcpp new mybot --template llmapi:anthropic # Anthropic provider +mcpp new mybot --template llmapi:deepseek # OpenAI-compatible endpoint (DeepSeek) +``` -## Quick Start +Or add it to an existing mcpp project: + +```bash +mcpp add llmapi +``` + +```toml +[dependencies.mcpplibs] +llmapi = "0.2.7" +``` ```cpp import mcpplibs.llmapi; @@ -33,7 +51,7 @@ int main() { auto apiKey = std::getenv("OPENAI_API_KEY"); if (!apiKey) { - std::cerr << "OPENAI_API_KEY not set\n"; + std::println(stderr, "OPENAI_API_KEY not set"); return 1; } @@ -45,11 +63,30 @@ int main() { client.system("You are a concise assistant."); auto resp = client.chat("Explain why C++23 modules are useful in two sentences."); - std::cout << resp.text() << '\n'; + std::println("{}", resp.text()); return 0; } ``` +## Features + +- `import mcpplibs.llmapi` with C++23 modules +- Strongly typed messages, tools, and response structs +- Sync, async, and streaming chat APIs +- Embeddings via the OpenAI provider +- Conversation save/load helpers +- OpenAI-compatible endpoint support through `openai::Config::baseUrl` +- Project templates: `mcpp new --template llmapi[: