jammi_wire/request.rs
1//! Request vocabulary the consumer surface shares with the wire.
2//!
3//! These owned, serialisable request shapes are what a session verb takes
4//! (`Modality` / `QueryInput` / `SearchRequest`) and the addressable id a
5//! fine-tune job returns (`FineTuneJobId`). They hold no engine state, so they
6//! live on the wire substrate: the embedded session and the data-plane client
7//! both build verbs from them, and the gRPC converters map them on/off the wire.
8
9/// Which embedding tower an embeddings / encode-query call targets. Unifies the
10/// three per-modality engine verbs (`text`/`image`/`audio`) into one parameter
11/// so the consumer surface carries one embedding verb, not three.
12#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
13pub enum Modality {
14 /// Dense vectors of input text.
15 Text,
16 /// Dense vectors of input images.
17 Image,
18 /// Dense vectors of input audio clips.
19 Audio,
20}
21
22/// A single query to encode into a vector. Text is encoded by the text tower;
23/// raw bytes are encoded by the image or audio tower, with the [`Modality`] the
24/// caller passes selecting which.
25pub enum QueryInput {
26 /// A text string to encode with the text tower.
27 Text(String),
28 /// Encoded bytes (an image file or an audio clip) for the vision/audio
29 /// tower.
30 Bytes(Vec<u8>),
31}
32
33/// The query side of a flattened search: either a caller-supplied vector or a
34/// row key resolved to its stored vector inside the engine.
35pub enum SearchQuery {
36 /// Search against a caller-supplied query vector.
37 Vector(Vec<f32>),
38 /// Query-by-example: rank by the vector stored for this row key.
39 RowKey(String),
40}
41
42/// A flattened vector-search request. Every knob a one-shot search exposes
43/// (`embedding_table`, `filter`, `select`) is a field here, so a transport can
44/// serialise the whole request rather than replay a chain of builder calls.
45pub struct SearchRequest {
46 /// Source whose embedding table is searched.
47 pub source_id: String,
48 /// The query vector or the row key to resolve into one.
49 pub query: SearchQuery,
50 /// Number of nearest neighbours to retrieve.
51 pub k: usize,
52 /// Which embedding table of the source to search. `None` selects the
53 /// source's most-recent ready table; `Some(name)` searches that table.
54 pub embedding_table: Option<String>,
55 /// Optional SQL predicate applied to the hydrated results.
56 pub filter: Option<String>,
57 /// Columns to project. Empty keeps every hydrated column.
58 pub select: Vec<String>,
59}
60
61/// Identifier of a fine-tune job. Returned in place of an in-process job handle
62/// so the job is addressable across a transport boundary; poll it with a
63/// fine-tune-status verb.
64#[derive(Debug, Clone, PartialEq, Eq)]
65pub struct FineTuneJobId(pub String);