Skip to content

Repository files navigation

Network ML

CI Release v2.0.0 License: MIT Wiki

A small, easy-to-use C++ library for REST API requests and LLM chat, built on libcurl. The chat client works with a local model via Ollama or cloud providers (Groq, OpenRouter, DeepSeek, OpenAI, Anthropic) behind one API.

Looking for ML::File? The filesystem utilities live in File ML now. The class is unchanged; depend on file-ml and #include "fileml.h".

It aims to make two things one-liners from C++:

// HTTP request with a rich response
ML::Requests req;
ML::Response r = req.get("https://api.example.com/data");
if (r.ok()) std::cout << r.status << "\n" << r.body;

// Talk to an LLM (local Ollama here; swap the Provider for a cloud model)
ML::Chat chat(ML::Provider::Ollama, "llama3.2:1b");
std::cout << chat.ask("Explain RAII in one sentence.");

Documentation

Full documentation, including build instructions and usage examples, lives in the project wiki:

Features

  • ML::Requests: full HTTP verbs (get/post/put/patch/del/head) returning a rich Response, with inline request bodies, multiple request headers, and per-request timeouts. Also file download (streamed to disk with optional progress), multipart upload, and opt-in auto-retries with backoff. (Legacy string-returning getReq/postReq/etc. are kept for compatibility.)
  • ML::Auth / ML::Url: helpers for auth headers (bearer/basic/apiKey) and percent-encoded query URLs (Url::build).
  • ML::Response: status, body, response headers (a map), and ok() (true for any 2xx).
  • ML::Chat: conversational client for Ollama (local), Groq, OpenRouter, DeepSeek, OpenAI, or Anthropic:
    • one API across every provider
    • persistent system prompt and conversation memory
    • adjustable temperature and max tokens
    • token streaming via a callback
    • reasoning-token support for reasoning models (the model's "thinking" streams to a separate callback, available via lastReasoning())
    • save/load conversation history to a JSON file (saveHistory/loadHistory)
  • All HTTP runs in-process via libcurl (HTTPS through Schannel on Windows), with no curl subprocess and no temp files.

License

MIT. See LICENSE.

About

The main repository for the Network ML Library.

Topics

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages