convergio_knowledge/
types.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct KnowledgeEntry {
8 pub id: String,
9 pub source_type: String,
11 pub source_id: String,
13 pub content: String,
15 pub org_id: Option<String>,
17 pub agent_id: Option<String>,
19 pub project_id: Option<String>,
21 #[serde(default = "default_visibility")]
23 pub visibility: String,
24 pub created_at: String,
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
30pub struct SearchResult {
31 pub entry: KnowledgeEntry,
32 pub score: f64,
34}
35
36#[derive(Debug, Deserialize)]
38pub struct WriteRequest {
39 pub content: String,
40 pub source_type: String,
41 pub source_id: String,
42 #[serde(default)]
43 pub org_id: Option<String>,
44 #[serde(default)]
45 pub agent_id: Option<String>,
46 #[serde(default)]
47 pub project_id: Option<String>,
48 #[serde(default = "default_visibility")]
50 pub visibility: String,
51}
52
53fn default_visibility() -> String {
54 "org".into()
55}
56
57#[derive(Debug, Deserialize)]
59pub struct SearchRequest {
60 pub query: String,
61 #[serde(default = "default_limit")]
62 pub limit: usize,
63 #[serde(default)]
64 pub org_id: Option<String>,
65 #[serde(default)]
66 pub source_type: Option<String>,
67 #[serde(default)]
68 pub project_id: Option<String>,
69 #[serde(default = "default_min_score")]
71 pub min_score: f64,
72 #[serde(default)]
74 pub federated: bool,
75}
76
77fn default_limit() -> usize {
78 5
79}
80
81fn default_min_score() -> f64 {
82 0.3
83}
84
85#[derive(Debug, Serialize)]
87pub struct StoreStats {
88 pub total_entries: i64,
89 pub total_by_source: Vec<(String, i64)>,
90 pub embedding_dimensions: usize,
91}