Arshit Malik commited on
Commit
0890aa5
·
1 Parent(s): 9f9df01

fix: stable mode:none + custom chat UI replacing broken canvas

Browse files
Files changed (2) hide show
  1. health_server.py +63 -25
  2. start.sh +2 -4
health_server.py CHANGED
@@ -1,35 +1,73 @@
1
- import http.server, json, os
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  class H(http.server.BaseHTTPRequestHandler):
4
  def do_GET(self):
5
- html = b"""<!DOCTYPE html>
6
- <html><head><meta charset=utf-8><title>YT Claw</title>
7
- <style>body{font-family:monospace;background:#111;color:#0f0;padding:40px;text-align:center}
8
- a{color:#0ff;font-size:1.2em}h1{color:#0f0}</style></head><body>
9
- <h1>YT Claw - OpenClaw is LIVE</h1>
10
- <p>Model: DeepSeek R1 Distill Qwen 14B (IQ3_XS)</p>
11
- <p>128K context | CoT reasoning | Text mode</p>
12
- """
13
- try:
14
- config = json.load(open('/root/.openclaw/openclaw.json'))
15
- token = config.get('gateway', {}).get('auth', {}).get('token', '')
16
- if token:
17
- html += '<p><a href="/__openclaw__/canvas/">Open Canvas</a></p>'.encode()
18
- else:
19
- html += b'<p><a href="/__openclaw__/canvas/?token=arshit2025">Open Canvas</a></p>'
20
- except:
21
- html += b'<p><a href="/__openclaw__/canvas/?token=arshit2025">Open Canvas</a></p>'
22
- html += b"</body></html>"
23
- self.send_response(200)
24
- self.send_header('Content-Type', 'text/html; charset=utf-8')
25
- self.end_headers()
26
- self.wfile.write(html)
27
-
28
  def do_POST(self):
29
  self.send_response(200)
30
  self.end_headers()
31
  self.wfile.write(b'OK')
32
-
33
  def log_message(self, *a): pass
34
 
35
  http.server.HTTPServer(('0.0.0.0', 8080), H).serve_forever()
 
1
+ import http.server, json, urllib.parse, io
2
+
3
+ CHAT_PAGE = b"""<!DOCTYPE html>
4
+ <html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1">
5
+ <title>YT Claw Chat</title>
6
+ <style>
7
+ *{box-sizing:border-box}body{font-family:monospace;background:#111;color:#0f0;margin:0;padding:0;height:100vh;display:flex;flex-direction:column}
8
+ #header{background:#0a0a0a;padding:12px 20px;border-bottom:1px solid #333;text-align:center}
9
+ h1{margin:0;font-size:1.1em;color:#0f0}
10
+ #info{font-size:0.7em;color:#666;margin-top:3px}
11
+ #chat{flex:1;overflow-y:auto;padding:15px}
12
+ .msg{margin:8px 0;padding:10px 14px;border-radius:8px;max-width:85%;word-wrap:break-word;white-space:pre-wrap}
13
+ .user{background:#1a3a1a;align-self:flex-end;margin-left:auto}
14
+ .ai{background:#1a1a3a;align-self:flex-start}
15
+ #input-area{display:flex;padding:12px;background:#0a0a0a;border-top:1px solid #333}
16
+ #prompt{flex:1;padding:10px;background:#222;color:#0f0;border:1px solid #444;border-radius:6px;font-family:monospace;font-size:0.95em;resize:none}
17
+ #send{padding:10px 18px;margin-left:8px;background:#0a0;color:#fff;border:none;border-radius:6px;cursor:pointer;font-weight:bold}
18
+ #send:hover{background:#0d0}#send:disabled{background:#333;cursor:not-allowed}
19
+ #status{color:#666;font-size:0.7em;padding:4px 12px;text-align:center}
20
+ </style></head><body>
21
+ <div id=header><h1>YT Claw - DeepSeek R1 14B IQ3_XS</h1><div id=info>128K context | CoT reasoning</div></div>
22
+ <div id=chat></div>
23
+ <div id=status>Ready</div>
24
+ <div id=input-area><textarea id=prompt rows=2 placeholder="Type a message..."></textarea>
25
+ <button id=send onclick=chat()>Send</button></div>
26
+ <script>
27
+ const chatDiv=document.getElementById('chat'),statusDiv=document.getElementById('status'),
28
+ prompt=document.getElementById('prompt'),sendBtn=document.getElementById('send');
29
+ let messages=[];
30
+ function addMsg(text,role){
31
+ const d=document.createElement('div');d.className='msg '+role;d.textContent=text;
32
+ chatDiv.appendChild(d);chatDiv.scrollTop=chatDiv.scrollHeight}
33
+ async function chat(){
34
+ const p=prompt.value.trim();if(!p)return;addMsg(p,'user');messages.push({role:'user',content:p});
35
+ prompt.value='';sendBtn.disabled=prompt.disabled=true;statusDiv.textContent='Thinking...';
36
+ try{
37
+ const r=await fetch('/api/v1/chat/completions',{method:'POST',
38
+ headers:{'Content-Type':'application/json'},
39
+ body:JSON.stringify({model:'ollama/hf.co/bartowski/DeepSeek-R1-Distill-Qwen-14B-GGUF:IQ3_XS',
40
+ messages:messages,max_tokens:4096,temperature:0.7})});
41
+ if(!r.ok)throw new Error(await r.text());
42
+ const j=await r.json();const reply=j.choices[0].message.content;
43
+ addMsg(reply,'ai');messages.push({role:'assistant',content:reply});statusDiv.textContent='Ready';
44
+ }catch(e){addMsg('Error: '+e.message,'ai');statusDiv.textContent='Error'}finally{
45
+ sendBtn.disabled=prompt.disabled=false;prompt.focus()}}
46
+ prompt.addEventListener('keydown',e=>{if(e.key==='Enter'&&!e.shiftKey){e.preventDefault();chat()}})
47
+ prompt.focus()
48
+ </script></body></html>"""
49
 
50
  class H(http.server.BaseHTTPRequestHandler):
51
  def do_GET(self):
52
+ if self.path == '/':
53
+ self.send_response(200)
54
+ self.send_header('Content-Type', 'text/html; charset=utf-8')
55
+ self.end_headers()
56
+ self.wfile.write(CHAT_PAGE)
57
+ elif self.path == '/health':
58
+ self.send_response(200)
59
+ self.send_header('Content-Type', 'application/json')
60
+ self.end_headers()
61
+ self.wfile.write(b'{"status":"ok"}')
62
+ else:
63
+ self.send_response(200)
64
+ self.send_header('Content-Type', 'text/html; charset=utf-8')
65
+ self.end_headers()
66
+ self.wfile.write(CHAT_PAGE)
 
 
 
 
 
 
 
 
67
  def do_POST(self):
68
  self.send_response(200)
69
  self.end_headers()
70
  self.wfile.write(b'OK')
 
71
  def log_message(self, *a): pass
72
 
73
  http.server.HTTPServer(('0.0.0.0', 8080), H).serve_forever()
start.sh CHANGED
@@ -30,8 +30,7 @@ cat > ~/.openclaw/openclaw.json << JSONEOF
30
  "bind": "loopback",
31
  "mode": "local",
32
  "channelHealthCheckMinutes": 0,
33
- "controlUi": {"dangerouslyDisableDeviceAuth": true, "allowInsecureAuth": true},
34
- "auth": {"mode": "token", "token": "arshit2025"}
35
  },
36
  "models": {
37
  "providers": {
@@ -102,7 +101,6 @@ echo "[boot] Starting Ollama..."
102
  export OLLAMA_FLASH_ATTENTION=1
103
  export OLLAMA_KV_CACHE_TYPE=q4_0
104
  export OLLAMA_NUM_CTX=131072
105
- export OPENCLAW_GATEWAY_TOKEN=arshit2025
106
  OLLAMA_HOST=127.0.0.1 OLLAMA_NUM_PARALLEL=1 OLLAMA_MAX_LOADED_MODELS=1 ollama serve &
107
 
108
  for i in $(seq 1 30); do
@@ -119,7 +117,7 @@ wait $PULL_PID
119
  echo "[boot] Model ready"
120
 
121
  echo "[boot] Starting OpenClaw gateway on :8081..."
122
- openclaw gateway --allow-unconfigured --token arshit2025 2>&1 &
123
  OPENCLAW_PID=$!
124
 
125
  echo "[boot] Waiting for OpenClaw..."
 
30
  "bind": "loopback",
31
  "mode": "local",
32
  "channelHealthCheckMinutes": 0,
33
+ "auth": {"mode": "none"}
 
34
  },
35
  "models": {
36
  "providers": {
 
101
  export OLLAMA_FLASH_ATTENTION=1
102
  export OLLAMA_KV_CACHE_TYPE=q4_0
103
  export OLLAMA_NUM_CTX=131072
 
104
  OLLAMA_HOST=127.0.0.1 OLLAMA_NUM_PARALLEL=1 OLLAMA_MAX_LOADED_MODELS=1 ollama serve &
105
 
106
  for i in $(seq 1 30); do
 
117
  echo "[boot] Model ready"
118
 
119
  echo "[boot] Starting OpenClaw gateway on :8081..."
120
+ openclaw gateway --allow-unconfigured 2>&1 &
121
  OPENCLAW_PID=$!
122
 
123
  echo "[boot] Waiting for OpenClaw..."