Commit ·
a3af4f1
1
Parent(s): 9d5041f
refactor UI and visualizer components for improved clarity
Browse files- Adjusted import order in ui.py for consistency.
- Removed unused chat_history attribute from ContextVisualizerUI.
- Deleted the format_token_breakdown method from ContextVisualizer to streamline functionality.
- Cleaned up unnecessary type imports in visualizer.py.
- src/app/ui.py +1 -9
- src/app/visualizer.py +0 -9
src/app/ui.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
"""Gradio UI for Context Engineering Visualizer"""
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
-
from typing import
|
| 5 |
|
| 6 |
from .agent import ContextEngineeringAgent
|
| 7 |
from config.settings import Settings
|
|
@@ -13,7 +13,6 @@ class ContextVisualizerUI:
|
|
| 13 |
|
| 14 |
def __init__(self):
|
| 15 |
self.agent = None
|
| 16 |
-
self.chat_history = []
|
| 17 |
logger_ui.info("ContextVisualizerUI initialized")
|
| 18 |
|
| 19 |
def initialize_agent(self) -> str:
|
|
@@ -109,13 +108,6 @@ class ContextVisualizerUI:
|
|
| 109 |
|
| 110 |
return "\n".join(output)
|
| 111 |
|
| 112 |
-
def format_token_breakdown(self, visualizer) -> List[Tuple[str, int]]:
|
| 113 |
-
"""Format token breakdown for chart"""
|
| 114 |
-
if not visualizer.token_counts:
|
| 115 |
-
return []
|
| 116 |
-
|
| 117 |
-
return [(layer, tokens) for layer, tokens in visualizer.token_counts.items()]
|
| 118 |
-
|
| 119 |
def process_query(
|
| 120 |
self,
|
| 121 |
query: str,
|
|
|
|
| 1 |
"""Gradio UI for Context Engineering Visualizer"""
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
+
from typing import List, Tuple
|
| 5 |
|
| 6 |
from .agent import ContextEngineeringAgent
|
| 7 |
from config.settings import Settings
|
|
|
|
| 13 |
|
| 14 |
def __init__(self):
|
| 15 |
self.agent = None
|
|
|
|
| 16 |
logger_ui.info("ContextVisualizerUI initialized")
|
| 17 |
|
| 18 |
def initialize_agent(self) -> str:
|
|
|
|
| 108 |
|
| 109 |
return "\n".join(output)
|
| 110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
def process_query(
|
| 112 |
self,
|
| 113 |
query: str,
|
src/app/visualizer.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
"""Context window visualization component"""
|
| 2 |
|
| 3 |
-
from typing import Dict, Any
|
| 4 |
from datetime import datetime
|
| 5 |
|
| 6 |
|
|
@@ -24,11 +23,3 @@ class ContextVisualizer:
|
|
| 24 |
"timestamp": datetime.now().isoformat()
|
| 25 |
})
|
| 26 |
self.token_counts[layer_name] = token_estimate
|
| 27 |
-
|
| 28 |
-
def get_summary(self) -> Dict[str, Any]:
|
| 29 |
-
"""Get structured summary of context"""
|
| 30 |
-
return {
|
| 31 |
-
"layers": [l["layer"] for l in self.context_layers],
|
| 32 |
-
"total_tokens": sum(self.token_counts.values()),
|
| 33 |
-
"breakdown": self.token_counts
|
| 34 |
-
}
|
|
|
|
| 1 |
"""Context window visualization component"""
|
| 2 |
|
|
|
|
| 3 |
from datetime import datetime
|
| 4 |
|
| 5 |
|
|
|
|
| 23 |
"timestamp": datetime.now().isoformat()
|
| 24 |
})
|
| 25 |
self.token_counts[layer_name] = token_estimate
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|