1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// SPDX-License-Identifier: Apache-2.0
//! Drop-in backend handlers for iicp-client.
//!
//! Each helper returns a closure suitable for use as the task handler in
//! `IicpNode::serve()` or as the `TcpTaskHandler` for `IicpTcpServer`.
//!
//! - [`openai_compat`] — drives Ollama, LM Studio, or any OpenAI-compatible
//! HTTP server.
//! - [`vllm`] — vLLM OpenAI server (default port 8000).
//! - [`llamacpp`] — llama.cpp `llama-server` (default port 8080).
//! - [`anthropic`] — native Anthropic Messages API (`POST /v1/messages`) for
//! first-class Claude. Translates the IICP chat task ↔ Messages API so a
//! Claude-backed node looks identical to an Ollama/vLLM node to clients.
//!
//! Use [`invoke_backend`] to dispatch by engine name (e.g. from a CLI
//! `--backend-type` flag). Valid names are listed in [`BACKEND_TYPES`].
use Value;
use OpenAiCompatOptions;
/// Selectable backend engine names (mirrors the Python/TS `BACKEND_TYPES`).
pub const BACKEND_TYPES: & = &;
/// Dispatch a stand-alone (HTTP-style) invocation to the named engine.
///
/// Returns `Err` with the offending name when `backend_type` is unknown so the
/// caller can surface a clear CLI error. Each engine shares the OpenAI dialect;
/// the only difference is the label in error messages and the per-engine default
/// port the caller may have applied to `opts.base_url`.
pub async