Expand description
The public crate. It re-exports the in process API from kime-engine and the request and answer types from kime-core, so a Rust program depends on this one crate and nothing else. See spec/07-engine.md and spec/14-sdks-cli.md.
use kime::{Device, Kime, Request, Response, State};
let kime = Kime::builder()
.model("laya") // alias, local path or hf:// ref
.device(Device::Auto) // Cuda(0), Cpu { threads }, Auto
.preload(true)
.build()?;
let req = Request::new(State::json(&value))
.choice("department", "Which team should handle this", [("billing", "Payment issues"), ("technical", "Bugs")])
.score("urgency", "How urgent", ["not urgent", "soon", "critical"])
.noul("churn", "The customer threatens to leave");
let res: Response = kime.decide(&req)?; // blocking
let many = kime.decide_batch(&[req1, req2])?; // batch
let res = kime.decide_async(&req).await?; // async, any executorModules§
- answer
- Answers, built from a question’s option logits and act logits the way Laya builds them.
- confidence
- The confidence formulas from spec/04-semantics.md.
- hub
- Finding a model by name, in the Hugging Face cache layout so downloads made by Laya or
huggingface_hubare reused and ours are reused by them. - pyjson
- Python’s
json.dumps, byte for byte, for the values a request can hold. - render
- The text the model reads for a question, before tokenizing.
- request
- The
/v1/systemonerequest, parsed from JSON and validated the way spec/03-api.md describes. - round
- Rounding a distribution for the wire, per spec/03-api.md.
Structs§
- Builder
- Settings for
Kime, fromKime::builder. - Decision
- The future
Kime::decide_asyncreturns. - Kime
- A loaded model on a device. Clones share it, and it can be used from any thread.
- Request
- A validated request.
- Response
- The answers to one request.
- State
- What a request asks about: text, or any JSON value, which is rendered the way the model family expects.