9dfa06ffee
Docker image / Build (linux/amd64) (push) Has been cancelled
Docker image / Build (linux/arm64) (push) Has been cancelled
Docker image / Merge release multi-arch manifest (push) Has been cancelled
Docker image / Merge debug multi-arch manifest (push) Has been cancelled
Docker image / Build public push gateway (linux/amd64) (push) Has been cancelled
Docker image / Build public push gateway (linux/arm64) (push) Has been cancelled
Docker image / Publish public push gateway image (push) Has been cancelled
Sprig image / Build (linux/amd64) (push) Has been cancelled
Sprig image / Build (linux/arm64) (push) Has been cancelled
Sprig image / Merge multi-arch manifest (push) Has been cancelled
Harbor Buzz Orchestra / Python tests and lint (push) Has been cancelled
CI / Detect Changed Paths (push) Has been cancelled
CI / Rust Lint (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Desktop Core (push) Has been cancelled
CI / Desktop Smoke E2E (1) (push) Has been cancelled
CI / Desktop Smoke E2E (2) (push) Has been cancelled
CI / Desktop Smoke E2E (3) (push) Has been cancelled
CI / Desktop Smoke E2E (4) (push) Has been cancelled
CI / Desktop (push) Has been cancelled
CI / Desktop E2E Relay (push) Has been cancelled
CI / Desktop E2E Integration (1/2) (push) Has been cancelled
CI / Desktop E2E Integration (2/2) (push) Has been cancelled
CI / Desktop E2E Integration (push) Has been cancelled
CI / Backend Integration (relay e2e) (push) Has been cancelled
CI / Relay E2E (push) Has been cancelled
CI / Web (push) Has been cancelled
CI / Mobile (push) Has been cancelled
CI / Security (push) Has been cancelled
CI / Dead Token Reference Guard (push) Has been cancelled
CI / Server Cross-Compile (aarch64-unknown-linux-musl) (push) Has been cancelled
CI / Server Cross-Compile (x86_64-unknown-linux-musl) (push) Has been cancelled
CI / Windows Rust (x86_64-pc-windows-msvc) (push) Has been cancelled
CI / Desktop Build (macOS) (push) Has been cancelled
helm chart / lint + unittest + render matrix (push) Has been cancelled
helm chart / install on kind (gated) (push) Has been cancelled
helm chart / publish chart to GHCR (push) Has been cancelled
Mesh Lifecycle / Relay-Driven Mesh Lifecycle Smoke (push) Has been cancelled
Sprig / Build (aarch64-unknown-linux-musl) (push) Has been cancelled
Sprig / Build (x86_64-unknown-linux-musl) (push) Has been cancelled
Sprig / Publish rolling release (push) Has been cancelled
Sprig / Publish tagged release (push) Has been cancelled
Signed-off-by: cls_宁波本机 <908705107@qq.com>
97 lines
3.8 KiB
Rust
97 lines
3.8 KiB
Rust
//! Local mesh-serve inference smoke test.
|
|
//!
|
|
//! Serves a GGUF model through the same `mesh_llm_sdk::serve` path Buzz
|
|
//! desktop uses in "Share compute" mode, then drives one chat completion
|
|
//! against the node's local OpenAI-compatible endpoint. No mesh publish, no
|
|
//! auto-join, no Nostr discovery — pure single-node serve-and-self-consume,
|
|
//! which is exactly the loopback variant we can prove on one box.
|
|
//!
|
|
//! Usage:
|
|
//! cargo run -p buzz-relay --example mesh_serve_smoke -- <path-to.gguf>
|
|
use std::time::Duration;
|
|
|
|
use mesh_llm_sdk::{serve, MeshDiscoveryMode};
|
|
|
|
#[tokio::main]
|
|
async fn main() -> anyhow::Result<()> {
|
|
let model = std::env::args()
|
|
.nth(1)
|
|
.ok_or_else(|| anyhow::anyhow!("usage: mesh_serve_smoke <path-to.gguf>"))?;
|
|
eprintln!("[smoke] serving model: {model}");
|
|
|
|
let config = serve::EmbeddedServeConfig::builder()
|
|
.model(&model)
|
|
.api_port(19337)
|
|
.console_port(13131)
|
|
.publish(false)
|
|
.auto_join(false)
|
|
.discovery_mode(MeshDiscoveryMode::Mdns)
|
|
// NOTE: console_ui(true) is required here, not cosmetic. In mesh rev
|
|
// bd16da4, serve::start always polls `:console_port/api/status` to
|
|
// confirm readiness, but the console HTTP server only binds when
|
|
// !headless (i.e. console_ui == true). With console_ui(false) the
|
|
// poll never succeeds and startup times out after 30s. Desktop's
|
|
// Share-compute path sets console_ui(false) — likely hits the same
|
|
// wall. Flagged to the team.
|
|
.console_ui(true)
|
|
.build();
|
|
|
|
let node = serve::start(config).await?;
|
|
let base = node.api_base_url().to_string();
|
|
eprintln!("[smoke] node up, api_base_url = {base}");
|
|
|
|
// Poll until the model reports loaded/ready (give it generous time — first
|
|
// load of a 17GB GGUF into Metal can take a while).
|
|
let http = reqwest::Client::new();
|
|
let models_url = format!("{base}/models");
|
|
let mut model_id = String::new();
|
|
for i in 0..120 {
|
|
tokio::time::sleep(Duration::from_secs(5)).await;
|
|
match http.get(&models_url).send().await {
|
|
Ok(r) => {
|
|
let body = r.text().await.unwrap_or_default();
|
|
// The serve node assigns its own id (e.g. local-gguf/sha256-…),
|
|
// not the file path we passed — pull it from /models.
|
|
if let Ok(json) = serde_json::from_str::<serde_json::Value>(&body) {
|
|
if let Some(id) = json["data"].get(0).and_then(|m| m["id"].as_str()) {
|
|
model_id = id.to_string();
|
|
eprintln!(
|
|
"[smoke] /models after {}s, served id = {model_id}",
|
|
(i + 1) * 5
|
|
);
|
|
break;
|
|
}
|
|
}
|
|
eprintln!("[smoke] waiting ({}s) /models -> {body}", (i + 1) * 5);
|
|
}
|
|
Err(e) => eprintln!("[smoke] waiting ({}s) /models err: {e}", (i + 1) * 5),
|
|
}
|
|
}
|
|
if model_id.is_empty() {
|
|
anyhow::bail!("model never became ready within timeout");
|
|
}
|
|
|
|
// One real completion — use the server's own model id.
|
|
let chat_url = format!("{base}/chat/completions");
|
|
let req = serde_json::json!({
|
|
"model": model_id,
|
|
"messages": [
|
|
{"role": "user", "content": "Reply with exactly one word: PONG"}
|
|
],
|
|
"max_tokens": 512,
|
|
"temperature": 0.0
|
|
});
|
|
eprintln!("[smoke] POST {chat_url}");
|
|
let resp = http.post(&chat_url).json(&req).send().await?;
|
|
let status = resp.status();
|
|
let body = resp.text().await?;
|
|
println!("[smoke] completion status={status}");
|
|
println!("[smoke] completion body={body}");
|
|
|
|
node.stop().await?;
|
|
if !status.is_success() {
|
|
anyhow::bail!("completion request failed: {status}");
|
|
}
|
|
Ok(())
|
|
}
|