brainos_httpadapter/
types.rs1use std::collections::HashMap;
4
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, thiserror::Error)]
10pub enum HttpAdapterError {
11 #[error("Server error: {0}")]
12 Server(String),
13}
14
15#[derive(Debug, Deserialize)]
19pub struct SignalRequest {
20 pub source: Option<String>,
21 pub channel: Option<String>,
22 pub sender: Option<String>,
23 pub content: String,
24 pub metadata: Option<HashMap<String, String>>,
25 pub namespace: Option<String>,
27 pub agent: Option<String>,
29 pub session_id: Option<String>,
31}
32
33#[derive(Debug, Deserialize)]
35pub struct SearchRequest {
36 pub query: String,
37 pub top_k: Option<usize>,
38 pub namespace: Option<String>,
40}
41
42#[derive(Debug, Serialize)]
44pub struct NamespaceJson {
45 pub namespace: String,
46 pub fact_count: i64,
47 pub episode_count: i64,
48}
49
50#[derive(Debug, Serialize)]
52pub struct ExportJson {
53 pub version: String,
54 pub exported_at: String,
55 pub facts: Vec<signal::ExportedFact>,
56 pub episodes: Vec<signal::ExportedEpisode>,
57}
58
59#[derive(Debug, Deserialize)]
61pub struct ImportRequest {
62 pub facts: Vec<signal::ExportedFact>,
63 pub episodes: Vec<signal::ExportedEpisode>,
64 #[serde(default)]
66 pub dry_run: bool,
67}
68
69#[derive(Debug, Serialize)]
71pub struct ImportResponse {
72 pub facts_imported: usize,
73 pub episodes_imported: usize,
74 pub facts_already_existed: usize,
75 pub episodes_already_existed: usize,
76 pub embedded: usize,
77 pub embed_failed: usize,
78}
79
80#[derive(Debug, Serialize)]
82pub struct FactJson {
83 pub id: String,
84 pub namespace: String,
85 pub category: String,
86 pub subject: String,
87 pub predicate: String,
88 pub object: String,
89 pub confidence: f64,
90 pub distance: Option<f32>,
91}
92
93#[derive(Debug, Serialize)]
95pub struct HealthResponse {
96 pub status: &'static str,
97 pub version: &'static str,
98}