package inference // The wire types for the MEGAMIND inference plane. They are deliberately plain JSON structs shared in // spirit with cmd/megamind-gateway, so the typed client and the stateless service agree on one contract. // Vectors are float32 to match pgvector(384); the API never sends client identifiers to the plane. // EmbedRequest asks for embeddings of one or more input strings under a named model. type EmbedRequest struct { Model string `json:"model"` Inputs []string `json:"inputs"` } // EmbedResponse returns one vector per input plus the dimension, so the caller can hard fail on a // mismatch with the pgvector column width. type EmbedResponse struct { Model string `json:"model"` Dimension int `json:"dimension"` Embeddings [][]float32 `json:"embeddings"` } // RerankRequest scores documents against a query with a cross encoder (or a cosine fallback). type RerankRequest struct { Model string `json:"model"` Query string `json:"query"` Documents []string `json:"documents"` TopN int `json:"top_n"` } // RerankResult is one scored document, identified only by its index in the request (never by a client id). type RerankResult struct { Index int `json:"index"` Score float64 `json:"score"` } // RerankResponse returns the reranked results, highest score first. type RerankResponse struct { Model string `json:"model"` Results []RerankResult `json:"results"` } // GenerateRequest is a single stateless generation. System carries instructions; Prompt the question and // retrieved evidence. The plane keeps nothing between calls. type GenerateRequest struct { Model string `json:"model"` System string `json:"system"` Prompt string `json:"prompt"` MaxTokens int `json:"max_tokens"` Temperature float64 `json:"temperature"` } // GenerateResponse is the model's text plus light accounting. type GenerateResponse struct { Model string `json:"model"` Text string `json:"text"` Tokens int `json:"tokens"` } // FaithfulnessRequest asks whether Answer is supported by Evidence. It is the self correction gate's input. type FaithfulnessRequest struct { Answer string `json:"answer"` Evidence []string `json:"evidence"` } // FaithfulnessResponse reports support as a 0 to 1 score plus a boolean decision and a short reason. type FaithfulnessResponse struct { Supported bool `json:"supported"` Score float64 `json:"score"` Reason string `json:"reason"` }