std1.0.0-beta-7 SafeC docs

std :: ml::llm

Struct std::LlmClient

#include <std/ml/llm.h> source

struct LlmClient {
    struct String host;
    unsigned short port;
    struct String model;
    struct String apiKey;
}

Fields

§struct String hostsource
§unsigned short portsource
§struct String modelsource
§struct String apiKeysource

sent as 'Authorization: Bearer <apiKey>' when non-empty

Methods

§struct String chat(&Vec<struct LlmMessage> messages, ?&int ok)source · definition

POSTs 'messages' (Vec<struct LlmMessage>) to '<client.host>:<client.port>/v1/chat/completions' as '{"model":..., "messages":[{"role":...,"content":...}, ...]}' and returns 'choices[0].message.content' from the JSON response. *ok is set to 0 on any transport, HTTP-status, or JSON-shape failure.

§static struct LlmClient new( const &char host, unsigned short port, const &char model, const &char apiKey, )source · definition