Three dialects spell the same two numbers differently: Ollama counts in `prompt_eval_count` and `eval_count`, the OpenAI shape in `usage.prompt_tokens` and `usage.completion_tokens`, Anthropic in `usage.input_tokens` and `usage.output_tokens`. All three now reach the caller as `tokens_prompt` and `tokens_completion`, which the hub lifts into the audit log by itself. An answer that carries no count leaves both fields empty rather than reporting a zero: a zero is a measurement, and this is the absence of one. Half a count is reported as far as it goes. The cost of a model call was the one part of the audit question "which model produced this, and what did it cost" that nothing answered (model pool M3). Signed-off-by: flemming-it <sf@flemming.it>
49 lines
1.1 KiB
TOML
49 lines
1.1 KiB
TOML
# Standalone Cargo.toml — targets wasm32-wasip2.
|
|
#
|
|
# Build with:
|
|
# cargo build --release --target wasm32-wasip2
|
|
|
|
[package]
|
|
name = "llm_chat"
|
|
version = "0.3.0"
|
|
edition = "2024"
|
|
license = "Apache-2.0"
|
|
publish = false
|
|
description = "F∆I module providing llm.chat"
|
|
|
|
[lib]
|
|
# cdylib for the wasm artifact, rlib so integration tests can
|
|
# link against the module's `invoke` function on the host.
|
|
crate-type = ["cdylib", "rlib"]
|
|
|
|
[dependencies]
|
|
chain-module-sdk = { git = "https://git.flemming.ai/fai/chain-module-sdk-rust.git", tag = "v0.3.0" }
|
|
serde = { version = "1", features = ["derive"] }
|
|
serde_json = "1"
|
|
thiserror = "2"
|
|
|
|
# WASI-0.2 HTTP client. Only compiled into the wasm32-wasip2 build.
|
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
|
waki = "0.5"
|
|
|
|
[dev-dependencies]
|
|
serde_json = "1"
|
|
|
|
[profile.release]
|
|
opt-level = "s"
|
|
lto = true
|
|
codegen-units = 1
|
|
strip = "symbols"
|
|
|
|
[lints.rust]
|
|
unsafe_op_in_unsafe_fn = "warn"
|
|
|
|
[lints.clippy]
|
|
unwrap_used = "deny"
|
|
expect_used = "deny"
|
|
panic = "deny"
|
|
print_stdout = "deny"
|
|
print_stderr = "deny"
|
|
|
|
[workspace]
|
|
# Empty so this package is NOT picked up by a parent.
|