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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! rcp — the Retrieval Context Protocol, a native Rust SDK.
//!
//! Zero dependencies (Rust standard library only). RCP is an open, versioned
//! JSON-RPC protocol so any RAG engine — any language, any vendor — can expose
//! embed / rerank / retrieve / graph / index / catalog, and any client can
//! consume it uniformly. This SDK speaks the exact same wire format as the C++,
//! Python, and Node.js SDKs, so a Rust client and a C++/Python/Node server (or
//! vice-versa) interoperate byte-for-byte.
//!
//! # Client
//!
//! ```no_run
//! use rcp::Capability;
//! let mut c = rcp::connect_stdio(&["python3", "my_server.py"])?;
//! if c.supports(Capability::Retrieve) {
//! for hit in c.retrieve("eiffel tower", 3)? {
//! println!("{} {}", hit.id, hit.score);
//! }
//! }
//! # Ok::<(), rcp::RcpError>(())
//! ```
//!
//! # Server
//!
//! ```no_run
//! use rcp::{Server, Method, Capability, Json, obj};
//! let mut s = rcp::Server::new();
//! s.set_info("my-engine", "1.0");
//! s.advertise(Capability::Retrieve, obj(&[("maxK", 100.into())]));
//! s.on(Method::RETRIEVE, |params| {
//! let q = params.get_str("query").unwrap_or("");
//! Ok(obj(&[("hits", vec![obj(&[("id", "d1".into()), ("score", 0.9.into()), ("text", q.into())])].into())]))
//! });
//! s.serve_stdio();
//! ```
pub use ;
pub use Filter;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
/// The SDK version.
pub const VERSION: &str = "1.0.0";
/// Spawn an RCP server subprocess and connect. `argv` e.g. `["python3", "srv.py"]`.
/// Connect to an HTTP RCP server, e.g. `"http://127.0.0.1:8000/rcp"`.