Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
feat: optimize the feature of ov tui - vector records (#664)
MaojiaSheng08cc4f6943b2
diff --git a/crates/ov_cli/src/client.rs b/crates/ov_cli/src/client.rsindex a03232ba0..d9d9724b8 100644--- a/crates/ov_cli/src/client.rs+++ b/crates/ov_cli/src/client.rs@@ -742,6 +742,7 @@ impl HttpClient {&self,limit: Option<u32>,cursor: Option<String>,+ uri_prefix: Option<String>,) -> Result<(Vec<serde_json::Value>, Option<String>)> {let mut params = Vec::new();if let Some(l) = limit {@@ -750,6 +751,9 @@ impl HttpClient {if let Some(c) = cursor {params.push(("cursor".to_string(), c));}+ if let Some(u) = uri_prefix {+ params.push(("uri".to_string(), u));+ }let result: serde_json::Value = self.get("/api/v1/debug/vector/scroll", ¶ms).await?;let records = result["records"]@@ -765,11 +769,15 @@ impl HttpClient {pub async fn debug_vector_count(&self,filter: Option<&serde_json::Value>,+ uri_prefix: Option<String>,) -> Result<u64> {let mut params = Vec::new();if let Some(f) = filter {params.push(("filter".to_string(), serde_json::to_string(f)?));}+ if let Some(u) = uri_prefix {+ params.push(("uri".to_string(), u));+ }let result: serde_json::Value = self.get("/api/v1/debug/vector/count", ¶ms).await?;let count = result["count"]diff --git a/crates/ov_cli/src/tui/app.rs b/crates/ov_cli/src/tui/app.rsindex e2c5bb461..8e7517d46 100644--- a/crates/ov_cli/src/tui/app.rs+++ b/crates/ov_cli/src/tui/app.rs@@ -55,6 +55,7 @@ pub struct App {pub status_message: String,pub vector_state: VectorRecordsState,pub showing_vector_records: bool,+ pub current_uri: String,}impl App {@@ -71,6 +72,7 @@ impl App {status_message: String::new(),vector_state: VectorRecordsState::new(),showing_vector_records: false,+ current_uri: "/".to_string(),}}@@ -93,6 +95,7 @@ impl App {}};+ self.current_uri = uri.clone();self.content_title = uri.clone();self.content_scroll = 0;@@ -114,6 +117,11 @@ impl App {}self.content_line_count = self.content.lines().count() as u16;++ // If in vector mode, reload records with new current_uri+ if self.showing_vector_records {+ self.load_vector_records(Some(self.current_uri.clone())).await;+ }}async fn load_directory_content(&mut self, uri: &str) {@@ -197,9 +205,13 @@ impl App {};}- pub async fn load_vector_records(&mut self) {+ pub async fn load_vector_records(&mut self, uri_prefix: Option<String>) {self.status_message = "Loading vector records...".to_string();- match self.client.debug_vector_scroll(Some(100), None).await {+ match self+ .client+ .debug_vector_scroll(Some(100), None, uri_prefix.clone())+ .await+ {Ok((records, next_cursor)) => {self.vector_state.records = records;self.vector_state.has_more = next_cursor.is_some();@@ -223,7 +235,11 @@ impl App {self.status_message = "Loading next page...".to_string();match self.client- .debug_vector_scroll(Some(100), self.vector_state.next_page_cursor.clone())+ .debug_vector_scroll(+ Some(100),+ self.vector_state.next_page_cursor.clone(),+ Some(self.current_uri.clone()),+ ).await{Ok((mut new_records, next_cursor)) => {@@ -241,13 +257,17 @@ impl App {pub async fn toggle_vector_records_mode(&mut self) {self.showing_vector_records = !self.showing_vector_records;if self.showing_vector_records && self.vector_state.records.is_empty() {- self.load_vector_records().await;+ self.load_vector_records(Some(self.current_uri.clone())).await;}}pub async fn load_vector_count(&mut self) {self.status_message = "Loading vector count...".to_string();- match self.client.debug_vector_count(None).await {+ match self+ .client+ .debug_vector_count(None, Some(self.current_uri.clone()))+ .await+ {Ok(count) => {self.vector_state.total_count = Some(count);self.status_message = format!("Total vector records: {}", count);diff --git a/crates/ov_cli/src/tui/ui.rs b/crates/ov_cli/src/tui/ui.rsindex 59c292e69..d3d0630f9 100644--- a/crates/ov_cli/src/tui/ui.rs+++ b/crates/ov_cli/src/tui/ui.rs@@ -147,14 +147,16 @@ fn render_vector_records(frame: &mut Frame, app: &App, area: ratatui::layout::Relet title = if let Some(total) = app.vector_state.total_count {format!(- " Vector Records ({}/{}, total: {}) ",+ " Vector Records for {} ({}/{}, total: {}) ",+ app.current_uri,app.vector_state.cursor + 1,app.vector_state.records.len(),total)} else {format!(- " Vector Records ({}/{}) ",+ " Vector Records for {} ({}/{}) ",+ app.current_uri,app.vector_state.cursor + 1,app.vector_state.records.len())@@ -184,6 +186,15 @@ fn render_vector_records(frame: &mut Frame, app: &App, area: ratatui::layout::Re.skip(app.vector_state.scroll_offset).take(viewport_height).map(|record| {+ let context_type = record+ .get("context_type")+ .and_then(|v| v.as_str())+ .unwrap_or("(no type)");+ let level_str = record+ .get("level")+ .and_then(|v| v.as_i64())+ .map(|l| l.to_string())+ .unwrap_or("(no level)".to_string());let id = record.get("id").and_then(|v| v.as_str())@@ -193,6 +204,20 @@ fn render_vector_records(frame: &mut Frame, app: &App, area: ratatui::layout::Re.and_then(|v| v.as_str()).unwrap_or("(no uri)");let line = Line::from(vec![+ Span::styled(+ context_type,+ Style::default()+ .fg(Color::Green)+ .add_modifier(Modifier::BOLD),+ ),+ Span::raw(" "),+ Span::styled(+ level_str,+ Style::default()+ .fg(Color::Magenta)+ .add_modifier(Modifier::BOLD),+ ),+ Span::raw(" "),Span::styled(id,Style::default()diff --git a/openviking/server/routers/debug.py b/openviking/server/routers/debug.pyindex 5cc5f6a74..d31c22794 100644--- a/openviking/server/routers/debug.py+++ b/openviking/server/routers/debug.py@@ -35,6 +35,7 @@ async def debug_health(async def debug_vector_scroll(limit: int = Query(100, ge=1, le=1000),cursor: Optional[str] = None,+ uri: Optional[str] = None,_ctx: RequestContext = Depends(get_request_context),):"""Get paginated vector records with tenant isolation."""@@ -46,7 +47,12 @@ async def debug_vector_scroll()proxy = VikingDBManagerProxy(service.vikingdb_manager, _ctx)- records, next_cursor = await proxy.scroll(limit=limit, cursor=cursor)++ filter_expr = None+ if uri:+ filter_expr = {"op": "must", "field": "uri", "conds": [uri]}++ records, next_cursor = await proxy.scroll(filter=filter_expr, limit=limit, cursor=cursor)return Response(status="ok", result={"records": records, "next_cursor": next_cursor})@@ -54,6 +60,7 @@ async def debug_vector_scroll(@router.get("/vector/count")async def debug_vector_count(filter: Optional[str] = None,+ uri: Optional[str] = None,_ctx: RequestContext = Depends(get_request_context),):"""Get count of vector records with tenant isolation."""@@ -78,5 +85,18 @@ async def debug_vector_count(error=ErrorInfo(code="INVALID_FILTER", message="Invalid filter JSON"),)+ if uri:+ uri_filter = {"op": "must", "field": "uri", "conds": [uri]}+ if filter_expr:+ # For combining filters, we should use And from expr, but for simplicity, let's use RawDSL for now+ from openviking.storage.expr import And, RawDSL++ if isinstance(filter_expr, dict):+ filter_expr = RawDSL(filter_expr)+ uri_filter = RawDSL(uri_filter)+ filter_expr = And([filter_expr, uri_filter])+ else:+ filter_expr = uri_filter+count = await proxy.count(filter=filter_expr)return Response(status="ok", result={"count": count})