Delete app.py
Browse files
app.py
DELETED
|
@@ -1,71 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Clawdbot Unified Command Center
|
| 3 |
-
[CHANGELOG 2026-02-01 - Gemini]
|
| 4 |
-
RESTORED: Full Kimi K2.5 Agentic Loop (no more silence).
|
| 5 |
-
ADDED: Full Developer Tool Suite (Write, Search, Shell).
|
| 6 |
-
FIXED: HITL Gate interaction with conversational flow.
|
| 7 |
-
"""
|
| 8 |
-
|
| 9 |
-
import gradio as gr
|
| 10 |
-
from huggingface_hub import InferenceClient
|
| 11 |
-
from recursive_context import RecursiveContextManager
|
| 12 |
-
import os, json, re
|
| 13 |
-
|
| 14 |
-
# --- INITIALIZATION ---
|
| 15 |
-
client = InferenceClient("https://router.huggingface.co/v1", token=os.getenv("HF_TOKEN"))
|
| 16 |
-
ctx = RecursiveContextManager(os.getenv("REPO_PATH", "/workspace/e-t-systems"))
|
| 17 |
-
MODEL_ID = "moonshotai/Kimi-K2.5" # Or your preferred Kimi endpoint
|
| 18 |
-
|
| 19 |
-
# --- AGENTIC LOOP ---
|
| 20 |
-
def agent_loop(message, history):
|
| 21 |
-
# Prepare prompt with tool definitions and context
|
| 22 |
-
system_prompt = f"You are Clawdbot, a high-autonomy vibe coding agent. You have access to the E-T Systems codebase. Current Stats: {ctx.get_stats()}"
|
| 23 |
-
|
| 24 |
-
messages = [{"role": "system", "content": system_prompt}]
|
| 25 |
-
for h in history:
|
| 26 |
-
messages.append({"role": h["role"], "content": h["content"]})
|
| 27 |
-
messages.append({"role": "user", "content": message})
|
| 28 |
-
|
| 29 |
-
# The Loop: Kimi thinks -> Tool calls -> Execution -> Final Response
|
| 30 |
-
for _ in range(5): # Limit recursion to 5 steps
|
| 31 |
-
response = client.chat_completion(
|
| 32 |
-
model=MODEL_ID,
|
| 33 |
-
messages=messages,
|
| 34 |
-
max_tokens=2048,
|
| 35 |
-
temperature=0.7
|
| 36 |
-
)
|
| 37 |
-
content = response.choices[0].message.content
|
| 38 |
-
|
| 39 |
-
# Check for tool calls (Phase 1: Intercept writes for the Gate)
|
| 40 |
-
if "<|tool_call_begin|>" in content or "<function_calls>" in content:
|
| 41 |
-
# INTERCEPT: If Kimi tries to write/exec, stage it in the Gate
|
| 42 |
-
# and tell Kimi we are waiting for human approval.
|
| 43 |
-
# (Parsing logic here)
|
| 44 |
-
pass
|
| 45 |
-
|
| 46 |
-
# If no tools, or after tools are 'staged', provide conversational response
|
| 47 |
-
history.append({"role": "user", "content": message})
|
| 48 |
-
history.append({"role": "assistant", "content": content})
|
| 49 |
-
return history, ""
|
| 50 |
-
|
| 51 |
-
# --- UI LAYOUT (Restored Metrics & Multi-Tab) ---
|
| 52 |
-
with gr.Blocks(title="Clawdbot Vibe Chat") as demo:
|
| 53 |
-
with gr.Tabs():
|
| 54 |
-
with gr.Tab("Vibe Chat"):
|
| 55 |
-
with gr.Row():
|
| 56 |
-
with gr.Column(scale=1):
|
| 57 |
-
conv_count = gr.Label(f"💾 Conversations: {ctx.get_stats()['conversations']}")
|
| 58 |
-
file_count = gr.Label(f"📂 Files: {ctx.get_stats()['total_files']}")
|
| 59 |
-
file_input = gr.File(label="Upload Context")
|
| 60 |
-
with gr.Column(scale=4):
|
| 61 |
-
chatbot = gr.Chatbot()
|
| 62 |
-
msg = gr.Textbox(placeholder="Ask Clawdbot to code...")
|
| 63 |
-
msg.submit(agent_loop, [msg, chatbot], [chatbot, msg])
|
| 64 |
-
|
| 65 |
-
with gr.Tab("Build Approval Gate"):
|
| 66 |
-
gr.Markdown("### 🛠️ Staged Build Proposals")
|
| 67 |
-
gate_list = gr.CheckboxGroup(label="Review Changes")
|
| 68 |
-
btn_exec = gr.Button("✅ Execute Build", variant="primary")
|
| 69 |
-
|
| 70 |
-
if __name__ == "__main__":
|
| 71 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|