Spaces:
Runtime error
Runtime error
Upload 6 files
Browse files- Dockerfile +23 -11
- package.json +7 -0
- public/index.html +6 -11
Dockerfile
CHANGED
|
@@ -1,23 +1,35 @@
|
|
| 1 |
FROM node:22-slim
|
| 2 |
|
| 3 |
-
# Install dependencies
|
| 4 |
-
RUN apt-get update && apt-get install -y
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
ENV MODEL_ID="Multiple-models"
|
| 16 |
|
| 17 |
-
# Copy files
|
| 18 |
COPY public /app/public
|
| 19 |
COPY server.js /app/server.js
|
| 20 |
COPY start.sh /app/start.sh
|
| 21 |
RUN chmod +x /app/start.sh
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
CMD ["/app/start.sh"]
|
|
|
|
| 1 |
FROM node:22-slim
|
| 2 |
|
| 3 |
+
# Install system dependencies
|
| 4 |
+
RUN apt-get update && apt-get install -y \
|
| 5 |
+
curl \
|
| 6 |
+
python3 \
|
| 7 |
+
build-essential \
|
| 8 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
+
# Install OpenClaw globally
|
| 11 |
+
RUN npm install -g openclaw
|
| 12 |
|
| 13 |
+
# Create app directory
|
| 14 |
+
WORKDIR /app
|
| 15 |
|
| 16 |
+
# Copy package.json and install dependencies
|
| 17 |
+
COPY package.json /app/package.json
|
| 18 |
+
RUN npm install
|
|
|
|
| 19 |
|
| 20 |
+
# Copy application files
|
| 21 |
COPY public /app/public
|
| 22 |
COPY server.js /app/server.js
|
| 23 |
COPY start.sh /app/start.sh
|
| 24 |
RUN chmod +x /app/start.sh
|
| 25 |
|
| 26 |
+
# Expose port
|
| 27 |
+
EXPOSE 7860
|
| 28 |
+
|
| 29 |
+
# Environment variables
|
| 30 |
+
ENV BASE_URL=""
|
| 31 |
+
ENV API_KEY=""
|
| 32 |
+
ENV MODEL_ID="Multiple-models"
|
| 33 |
+
ENV PROVIDER_NAME="custom"
|
| 34 |
+
|
| 35 |
CMD ["/app/start.sh"]
|
package.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "openclaw-web",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"dependencies": {
|
| 5 |
+
"ws": "^8.14.0"
|
| 6 |
+
}
|
| 7 |
+
}
|
public/index.html
CHANGED
|
@@ -30,7 +30,7 @@
|
|
| 30 |
gap: 1rem;
|
| 31 |
}
|
| 32 |
.msg {
|
| 33 |
-
max-width:
|
| 34 |
padding: 0.8rem 1rem;
|
| 35 |
border-radius: 12px;
|
| 36 |
white-space: pre-wrap;
|
|
@@ -38,7 +38,6 @@
|
|
| 38 |
}
|
| 39 |
.msg.user { align-self: flex-end; background: #e94560; color: white; }
|
| 40 |
.msg.bot { align-self: flex-start; background: #16213e; border: 1px solid #0f3460; }
|
| 41 |
-
.msg.sys { align-self: center; color: #888; font-size: 0.85rem; font-style: italic; background: none; }
|
| 42 |
.msg.error { background: #4a1a1a; border-color: #e94560; }
|
| 43 |
.input-area {
|
| 44 |
background: #16213e;
|
|
@@ -74,8 +73,8 @@
|
|
| 74 |
</head>
|
| 75 |
<body>
|
| 76 |
<div class="header">
|
| 77 |
-
<h1>๐ฆ OpenClaw
|
| 78 |
-
<div class="status">
|
| 79 |
</div>
|
| 80 |
<div id="chat"></div>
|
| 81 |
<div class="input-area">
|
|
@@ -86,6 +85,7 @@
|
|
| 86 |
const chat = document.getElementById('chat');
|
| 87 |
const input = document.getElementById('input');
|
| 88 |
const sendBtn = document.getElementById('send');
|
|
|
|
| 89 |
|
| 90 |
function add(text, cls) {
|
| 91 |
const div = document.createElement('div');
|
|
@@ -108,16 +108,11 @@
|
|
| 108 |
const res = await fetch('/chat', {
|
| 109 |
method: 'POST',
|
| 110 |
headers: { 'Content-Type': 'application/json' },
|
| 111 |
-
body: JSON.stringify({ message: text })
|
| 112 |
});
|
| 113 |
|
| 114 |
const data = await res.json();
|
| 115 |
-
|
| 116 |
-
if (data.reply) {
|
| 117 |
-
add(data.reply, 'bot');
|
| 118 |
-
} else if (data.error) {
|
| 119 |
-
add('Error: ' + data.error, 'bot error');
|
| 120 |
-
}
|
| 121 |
} catch (err) {
|
| 122 |
add('Connection error: ' + err.message, 'bot error');
|
| 123 |
}
|
|
|
|
| 30 |
gap: 1rem;
|
| 31 |
}
|
| 32 |
.msg {
|
| 33 |
+
max-width: 85%;
|
| 34 |
padding: 0.8rem 1rem;
|
| 35 |
border-radius: 12px;
|
| 36 |
white-space: pre-wrap;
|
|
|
|
| 38 |
}
|
| 39 |
.msg.user { align-self: flex-end; background: #e94560; color: white; }
|
| 40 |
.msg.bot { align-self: flex-start; background: #16213e; border: 1px solid #0f3460; }
|
|
|
|
| 41 |
.msg.error { background: #4a1a1a; border-color: #e94560; }
|
| 42 |
.input-area {
|
| 43 |
background: #16213e;
|
|
|
|
| 73 |
</head>
|
| 74 |
<body>
|
| 75 |
<div class="header">
|
| 76 |
+
<h1>๐ฆ OpenClaw</h1>
|
| 77 |
+
<div class="status" id="status">Connected</div>
|
| 78 |
</div>
|
| 79 |
<div id="chat"></div>
|
| 80 |
<div class="input-area">
|
|
|
|
| 85 |
const chat = document.getElementById('chat');
|
| 86 |
const input = document.getElementById('input');
|
| 87 |
const sendBtn = document.getElementById('send');
|
| 88 |
+
const sessionId = 'web-' + Math.random().toString(36).substr(2, 9);
|
| 89 |
|
| 90 |
function add(text, cls) {
|
| 91 |
const div = document.createElement('div');
|
|
|
|
| 108 |
const res = await fetch('/chat', {
|
| 109 |
method: 'POST',
|
| 110 |
headers: { 'Content-Type': 'application/json' },
|
| 111 |
+
body: JSON.stringify({ message: text, sessionId })
|
| 112 |
});
|
| 113 |
|
| 114 |
const data = await res.json();
|
| 115 |
+
add(data.reply || data.error || JSON.stringify(data), data.error ? 'bot error' : 'bot');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
} catch (err) {
|
| 117 |
add('Connection error: ' + err.message, 'bot error');
|
| 118 |
}
|