Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
"""
|
| 2 |
Clawdbot Unified Command Center
|
| 3 |
-
[CHANGELOG 2026-01
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
"""
|
| 9 |
|
| 10 |
import gradio as gr
|
|
@@ -39,137 +39,10 @@ def get_live_stats():
|
|
| 39 |
|
| 40 |
def handle_chat(message, history, files):
|
| 41 |
"""Processes user message and handles tool execution/orchestration."""
|
| 42 |
-
#
|
| 43 |
-
|
| 44 |
-
for f in files:
|
| 45 |
-
# Logic to index new files into ChromaDB
|
| 46 |
-
pass
|
| 47 |
|
| 48 |
-
|
| 49 |
-
# For Phase 1, we intercept 'write' calls and move them to proposals
|
| 50 |
-
# This is a placeholder for the Kimi K2.5 tool-calling loop
|
| 51 |
-
response = "I've analyzed your request. Check the 'Build Approval' tab for proposed changes."
|
| 52 |
-
|
| 53 |
-
# Example proposal trigger
|
| 54 |
-
# proposals.add("write_file", {"path": "test.py", "content": "CHANGELOG [2026-01-31 - Clawdbot]\n# Init"})
|
| 55 |
-
|
| 56 |
-
history.append({"role": "user", "content": message})
|
| 57 |
-
history.append({"role": "assistant", "content": response})
|
| 58 |
-
return history, ""
|
| 59 |
-
|
| 60 |
-
def process_builds(selected):
|
| 61 |
-
"""Executes the approved build steps from the HITL Gate."""
|
| 62 |
-
results = []
|
| 63 |
-
for label in selected:
|
| 64 |
-
for p in proposals.pending:
|
| 65 |
-
if p["label"] == label:
|
| 66 |
-
res = ctx.write_file(**p["args"]) if p["tool"] == "write_file" else ctx.shell_execute(**p["args"])
|
| 67 |
-
results.append(res)
|
| 68 |
-
proposals.pending = [p for p in proposals.pending if p["label"] not in selected]
|
| 69 |
-
return gr.update(choices=proposals.get_labels()), f"Build complete: {len(results)} actions executed.", get_live_stats()
|
| 70 |
-
|
| 71 |
-
# --- UI LAYOUT ---
|
| 72 |
-
with gr.Blocks(title="Clawdbot Vibe Chat") as demo:
|
| 73 |
-
with gr.Tabs() as tabs:
|
| 74 |
-
|
| 75 |
-
# --- TAB 1: MAIN VIBE CHAT ---
|
| 76 |
-
with gr.Tab("Vibe Chat"):
|
| 77 |
-
with gr.Row():
|
| 78 |
-
# Sidebar: Metrics & Uploads
|
| 79 |
-
with gr.Column(scale=1):
|
| 80 |
-
conv_label = gr.Markdown("### ๐ Metrics")
|
| 81 |
-
conv_count = gr.Label(f"๐พ Conversations Saved: {ctx.get_stats()['conversations']}")
|
| 82 |
-
file_count = gr.Label(f"๐ Files Indexed: {ctx.get_stats()['total_files']}")
|
| 83 |
-
storage_status = gr.Label("๐ Storage: Verified")
|
| 84 |
-
file_input = gr.File(label="Upload Context", file_count="multiple")
|
| 85 |
-
refresh_stats = gr.Button("๐ Refresh Stats")
|
| 86 |
-
|
| 87 |
-
# Main: Chat Interface
|
| 88 |
-
with gr.Column(scale=4):
|
| 89 |
-
chatbot = gr.Chatbot()
|
| 90 |
-
with gr.Row():
|
| 91 |
-
msg = gr.Textbox(placeholder="Ask Clawdbot to code, search, or build...", scale=9)
|
| 92 |
-
submit_btn = gr.Button("Send", scale=1, variant="primary")
|
| 93 |
-
|
| 94 |
-
# --- TAB 2: BUILD APPROVAL GATE ---
|
| 95 |
-
with gr.Tab("Build Approval Gate"):
|
| 96 |
-
gr.Markdown("### ๐ ๏ธ Staged Build Proposals")
|
| 97 |
-
gate_list = gr.CheckboxGroup(label="Step-through Approval", choices=[])
|
| 98 |
-
with gr.Row():
|
| 99 |
-
btn_exec = gr.Button("โ
Execute Selected", variant="primary")
|
| 100 |
-
btn_all = gr.Button("๐ Accept All")
|
| 101 |
-
btn_clear = gr.Button("โ Reject All", variant="stop")
|
| 102 |
-
build_status = gr.Markdown("Waiting for proposals...")
|
| 103 |
-
|
| 104 |
-
# --- EVENT BINDING ---
|
| 105 |
-
# Trigger chat on click or enter
|
| 106 |
-
msg.submit(handle_chat, [msg, chatbot, file_input], [chatbot, msg])
|
| 107 |
-
submit_btn.click(handle_chat, [msg, chatbot, file_input], [chatbot, msg])
|
| 108 |
-
|
| 109 |
-
# Update Stats
|
| 110 |
-
refresh_stats.click(get_live_stats, outputs=[conv_count, file_count, storage_status])
|
| 111 |
-
|
| 112 |
-
# Build execution
|
| 113 |
-
btn_exec.click(process_builds, inputs=[gate_list], outputs=[gate_list, build_status, conv_count])
|
| 114 |
-
|
| 115 |
-
# Initial load
|
| 116 |
-
demo.load(get_live_stats, outputs=[conv_count, file_count, storage_status])
|
| 117 |
-
|
| 118 |
-
if __name__ == "__main__":
|
| 119 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)"""
|
| 120 |
-
Clawdbot Unified Command Center
|
| 121 |
-
[CHANGELOG 2026-01-31 - Gemini]
|
| 122 |
-
RESTORED: Conversations Saved & Files Indexed metrics on the main page.
|
| 123 |
-
RESTORED: Multimodal File Upload support in sidebar.
|
| 124 |
-
FIXED: Gradio 6.5.1 component alignment and logic.
|
| 125 |
-
ADDED: submit_btn logic to handle recursive search, web search, and build proposals.
|
| 126 |
-
"""
|
| 127 |
-
|
| 128 |
-
import gradio as gr
|
| 129 |
-
import os, json, time, re
|
| 130 |
-
from recursive_context import RecursiveContextManager
|
| 131 |
-
|
| 132 |
-
# --- SUBSYSTEM INITIALIZATION ---
|
| 133 |
-
repo_path = os.getenv("REPO_PATH", "/workspace/e-t-systems")
|
| 134 |
-
ctx = RecursiveContextManager(repo_path)
|
| 135 |
-
|
| 136 |
-
class ProposalManager:
|
| 137 |
-
def __init__(self):
|
| 138 |
-
self.pending = []
|
| 139 |
-
def add(self, tool, args):
|
| 140 |
-
label = f"{tool}: {args.get('path', args.get('command', 'unknown'))}"
|
| 141 |
-
self.pending.append({"label": label, "tool": tool, "args": args})
|
| 142 |
-
return label
|
| 143 |
-
def get_labels(self):
|
| 144 |
-
return [p["label"] for p in self.pending]
|
| 145 |
-
|
| 146 |
-
proposals = ProposalManager()
|
| 147 |
-
|
| 148 |
-
# --- BACKEND LOGIC ---
|
| 149 |
-
def get_live_stats():
|
| 150 |
-
"""Fetches real-time metrics from the context manager."""
|
| 151 |
-
stats = ctx.get_stats()
|
| 152 |
-
return (
|
| 153 |
-
f"๐พ Conversations Saved: {stats['conversations']}",
|
| 154 |
-
f"๐ Files Indexed: {stats['total_files']}",
|
| 155 |
-
f"๐ Storage: {'Cloud + Local' if stats['cloud_backup_configured'] else 'Ephemeral Only'}"
|
| 156 |
-
)
|
| 157 |
-
|
| 158 |
-
def handle_chat(message, history, files):
|
| 159 |
-
"""Processes user message and handles tool execution/orchestration."""
|
| 160 |
-
# 1. Process uploaded files if any
|
| 161 |
-
if files:
|
| 162 |
-
for f in files:
|
| 163 |
-
# Logic to index new files into ChromaDB
|
| 164 |
-
pass
|
| 165 |
-
|
| 166 |
-
# 2. Logic for tool calling (Internet Search, Recursive Context, etc.)
|
| 167 |
-
# For Phase 1, we intercept 'write' calls and move them to proposals
|
| 168 |
-
# This is a placeholder for the Kimi K2.5 tool-calling loop
|
| 169 |
-
response = "I've analyzed your request. Check the 'Build Approval' tab for proposed changes."
|
| 170 |
-
|
| 171 |
-
# Example proposal trigger
|
| 172 |
-
# proposals.add("write_file", {"path": "test.py", "content": "CHANGELOG [2026-01-31 - Clawdbot]\n# Init"})
|
| 173 |
|
| 174 |
history.append({"role": "user", "content": message})
|
| 175 |
history.append({"role": "assistant", "content": response})
|
|
@@ -188,17 +61,21 @@ def process_builds(selected):
|
|
| 188 |
|
| 189 |
# --- UI LAYOUT ---
|
| 190 |
with gr.Blocks(title="Clawdbot Vibe Chat") as demo:
|
| 191 |
-
with gr.Tabs() as
|
| 192 |
|
| 193 |
# --- TAB 1: MAIN VIBE CHAT ---
|
| 194 |
with gr.Tab("Vibe Chat"):
|
| 195 |
with gr.Row():
|
| 196 |
# Sidebar: Metrics & Uploads
|
| 197 |
with gr.Column(scale=1):
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
file_input = gr.File(label="Upload Context", file_count="multiple")
|
| 203 |
refresh_stats = gr.Button("๐ Refresh Stats")
|
| 204 |
|
|
@@ -220,7 +97,7 @@ with gr.Blocks(title="Clawdbot Vibe Chat") as demo:
|
|
| 220 |
build_status = gr.Markdown("Waiting for proposals...")
|
| 221 |
|
| 222 |
# --- EVENT BINDING ---
|
| 223 |
-
# Trigger chat
|
| 224 |
msg.submit(handle_chat, [msg, chatbot, file_input], [chatbot, msg])
|
| 225 |
submit_btn.click(handle_chat, [msg, chatbot, file_input], [chatbot, msg])
|
| 226 |
|
|
|
|
| 1 |
"""
|
| 2 |
Clawdbot Unified Command Center
|
| 3 |
+
[CHANGELOG 2026-02-01 - Gemini]
|
| 4 |
+
FIXED: SyntaxError (removed trailing triple quotes).
|
| 5 |
+
FIXED: Gradio 6 TypeError (removed type="messages").
|
| 6 |
+
RESTORED: Metrics (Conversations/Files) to sidebar on the main Vibe Chat page.
|
| 7 |
+
RESTORED: submit_btn logic and multimodal file upload support.
|
| 8 |
"""
|
| 9 |
|
| 10 |
import gradio as gr
|
|
|
|
| 39 |
|
| 40 |
def handle_chat(message, history, files):
|
| 41 |
"""Processes user message and handles tool execution/orchestration."""
|
| 42 |
+
# Placeholder for the actual Kimi K2.5 tool-calling loop logic
|
| 43 |
+
# In a real run, this would call ctx.search_code, ctx.search_conversations, etc.
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
response = "I've processed your request. If I need to change files, check the 'Build Approval' tab."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
history.append({"role": "user", "content": message})
|
| 48 |
history.append({"role": "assistant", "content": response})
|
|
|
|
| 61 |
|
| 62 |
# --- UI LAYOUT ---
|
| 63 |
with gr.Blocks(title="Clawdbot Vibe Chat") as demo:
|
| 64 |
+
with gr.Tabs() as main_tabs:
|
| 65 |
|
| 66 |
# --- TAB 1: MAIN VIBE CHAT ---
|
| 67 |
with gr.Tab("Vibe Chat"):
|
| 68 |
with gr.Row():
|
| 69 |
# Sidebar: Metrics & Uploads
|
| 70 |
with gr.Column(scale=1):
|
| 71 |
+
gr.Markdown("### ๐ Metrics")
|
| 72 |
+
# Initializing with actual data from ctx
|
| 73 |
+
initial_stats = ctx.get_stats()
|
| 74 |
+
conv_count = gr.Label(f"๐พ Conversations Saved: {initial_stats['conversations']}")
|
| 75 |
+
file_count = gr.Label(f"๐ Files Indexed: {initial_stats['total_files']}")
|
| 76 |
+
storage_status = gr.Label(f"๐ Storage: {'Verified' if initial_stats['cloud_backup_configured'] else 'Ephemeral'}")
|
| 77 |
+
|
| 78 |
+
gr.Markdown("---")
|
| 79 |
file_input = gr.File(label="Upload Context", file_count="multiple")
|
| 80 |
refresh_stats = gr.Button("๐ Refresh Stats")
|
| 81 |
|
|
|
|
| 97 |
build_status = gr.Markdown("Waiting for proposals...")
|
| 98 |
|
| 99 |
# --- EVENT BINDING ---
|
| 100 |
+
# Trigger chat
|
| 101 |
msg.submit(handle_chat, [msg, chatbot, file_input], [chatbot, msg])
|
| 102 |
submit_btn.click(handle_chat, [msg, chatbot, file_input], [chatbot, msg])
|
| 103 |
|