building out the components, updating the UI in overview and adding a little sqlite viewer
This commit is contained in:
@@ -179,6 +179,30 @@ impl RagStore {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Preview chunks for a source: (id, first 200 chars of text). Used by the
|
||||
/// Lore panel so a DM can see what actually got embedded without a full dump.
|
||||
pub fn list_chunks(&self, source: &str) -> anyhow::Result<Vec<(i64, String)>> {
|
||||
let db = self.db.lock().map_err(|e| anyhow::anyhow!("db lock: {e}"))?;
|
||||
let mut stmt = db.prepare("SELECT id, substr(text, 1, 200) FROM chunks WHERE source = ? ORDER BY id")?;
|
||||
let rows = stmt.query_map(params![source], |r| {
|
||||
Ok((r.get::<_, i64>(0)?, r.get::<_, String>(1)?))
|
||||
})?;
|
||||
let mut out = Vec::new();
|
||||
for r in rows {
|
||||
out.push(r?);
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// Read-only SQL pass-through for the advanced SQLite viewer.
|
||||
pub fn raw_query(
|
||||
&self,
|
||||
sql: &str,
|
||||
) -> anyhow::Result<(Vec<String>, Vec<Vec<serde_json::Value>>)> {
|
||||
let db = self.db.lock().map_err(|e| anyhow::anyhow!("db lock: {e}"))?;
|
||||
crate::sql_viewer::run_readonly_query(&db, sql)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user