djmuted
commited on
Commit
•
61b6ff3
1
Parent(s):
d77295c
Init
Browse files- Dockerfile +22 -0
- app.js +108 -0
- index.html +17 -0
- nginx.conf +25 -0
Dockerfile
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM node:18-bullseye-slim
|
2 |
+
COPY app.js /app/app.js
|
3 |
+
RUN apt-get update && apt-get install -y nginx
|
4 |
+
COPY nginx.conf /etc/nginx/sites-available/default
|
5 |
+
COPY index.html /var/www/html/index.html
|
6 |
+
WORKDIR /app
|
7 |
+
RUN --mount=type=secret,id=ORG_ID,mode=0444,required=true \
|
8 |
+
sed -i "s/xoxc-xxxx/$(cat /run/secrets/ORG_ID)/g" app.js
|
9 |
+
RUN --mount=type=secret,id=COOKIE,mode=0444,required=true \
|
10 |
+
sed -i "s/xoxd-xxxx/$(cat /run/secrets/COOKIE)/g" app.js
|
11 |
+
RUN npm install uuid
|
12 |
+
EXPOSE 7860
|
13 |
+
ENV NODE_ENV=production
|
14 |
+
RUN chown -R node:node /app && chmod -R 755 /app && \
|
15 |
+
chown -R node:node /var/log/nginx && \
|
16 |
+
chown -R node:node /var/lib/nginx && \
|
17 |
+
chown -R node:node /var/www/html && \
|
18 |
+
chown -R node:node /etc/nginx/conf.d
|
19 |
+
RUN touch /var/run/nginx.pid && \
|
20 |
+
chown -R node:node /var/run/nginx.pid
|
21 |
+
|
22 |
+
CMD [ "sh", "-c", "nginx && node app.js" ]
|
app.js
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const http = require('http');
|
2 |
+
const https = require('https');
|
3 |
+
const uuidv4 = require('uuid').v4;
|
4 |
+
const config = {
|
5 |
+
ORG_ID: "xoxc-xxxx",
|
6 |
+
COOKIE: "xoxd-xxxx",
|
7 |
+
};
|
8 |
+
let orgid = config.ORG_ID;
|
9 |
+
let cookieHeader = config.COOKIE;
|
10 |
+
|
11 |
+
https.get('https://claude.ai/api/organizations', { headers: { 'Cookie': cookieHeader } }, (res) => {
|
12 |
+
let data = '';
|
13 |
+
res.on('data', (chunk) => {
|
14 |
+
data += chunk;
|
15 |
+
});
|
16 |
+
res.on('end', () => {
|
17 |
+
const jsonData = JSON.parse(data);
|
18 |
+
orgid = jsonData[0].uuid;
|
19 |
+
});
|
20 |
+
|
21 |
+
}).on("error", (err) => {
|
22 |
+
console.log("Error: " + err.message);
|
23 |
+
});
|
24 |
+
|
25 |
+
const server = http.createServer((req, res) => {
|
26 |
+
if (req.url === '/v1/complete') {
|
27 |
+
let body = '';
|
28 |
+
var promptHeader;
|
29 |
+
req.on('data', chunk => {
|
30 |
+
body += chunk.toString();
|
31 |
+
});
|
32 |
+
req.on('end', () => {
|
33 |
+
body = JSON.parse(body);
|
34 |
+
promptHeader = body.prompt;
|
35 |
+
const uuid = uuidv4().toString();
|
36 |
+
const options = {
|
37 |
+
hostname: 'claude.ai',
|
38 |
+
port: 443,
|
39 |
+
path: `/api/organizations/${orgid}/chat_conversations`,
|
40 |
+
method: 'POST',
|
41 |
+
headers: {
|
42 |
+
'Content-Type': 'application/json',
|
43 |
+
'Cookie': cookieHeader
|
44 |
+
}
|
45 |
+
};
|
46 |
+
|
47 |
+
const postData = JSON.stringify({
|
48 |
+
"uuid": uuid,
|
49 |
+
"name": ""
|
50 |
+
});
|
51 |
+
|
52 |
+
const req2 = https.request(options, (res2) => {
|
53 |
+
res2.on('data', (d) => {
|
54 |
+
process.stdout.write(d);
|
55 |
+
});
|
56 |
+
});
|
57 |
+
|
58 |
+
req2.on('error', (error) => {
|
59 |
+
console.error(error);
|
60 |
+
});
|
61 |
+
|
62 |
+
req2.write(postData);
|
63 |
+
req2.end();
|
64 |
+
const options2 = {
|
65 |
+
hostname: 'claude.ai',
|
66 |
+
port: 443,
|
67 |
+
path: `/api/append_message`,
|
68 |
+
method: 'POST',
|
69 |
+
headers: {
|
70 |
+
'Content-Type': 'application/json',
|
71 |
+
'Cookie': cookieHeader
|
72 |
+
}
|
73 |
+
};
|
74 |
+
|
75 |
+
const postData2 = JSON.stringify({
|
76 |
+
"completion": {
|
77 |
+
"prompt": promptHeader,
|
78 |
+
"timezone": "",
|
79 |
+
"model": "claude-1"
|
80 |
+
},
|
81 |
+
"organization_uuid": orgid,
|
82 |
+
"conversation_uuid": uuid,
|
83 |
+
"text": promptHeader,
|
84 |
+
"attachments": []
|
85 |
+
});
|
86 |
+
const req3 = https.request(options2, (res3) => {
|
87 |
+
let output = '';
|
88 |
+
res3.on('data', (d) => {
|
89 |
+
output = d
|
90 |
+
});
|
91 |
+
res3.on('end', () => {
|
92 |
+
res.end(output);
|
93 |
+
});
|
94 |
+
});
|
95 |
+
req3.on('error', (error) => {
|
96 |
+
console.error(error);
|
97 |
+
});
|
98 |
+
|
99 |
+
req3.write(postData2);
|
100 |
+
req3.end();
|
101 |
+
});
|
102 |
+
|
103 |
+
}
|
104 |
+
|
105 |
+
});
|
106 |
+
server.listen(5004, '0.0.0.0', () => {
|
107 |
+
console.log(`http://127.0.0.1:5004/v1`);
|
108 |
+
});
|
index.html
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
|
4 |
+
<head>
|
5 |
+
<meta charset="UTF-8">
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
8 |
+
<title>sus 2</title>
|
9 |
+
<link rel="stylesheet" href="style.css">
|
10 |
+
</head>
|
11 |
+
|
12 |
+
<body>
|
13 |
+
<h1>sus 2</h1>
|
14 |
+
<img src="https://i.redd.it/v9b9aj4z2n491.jpg" alt="sus">
|
15 |
+
</body>
|
16 |
+
|
17 |
+
</html>
|
nginx.conf
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
server {
|
2 |
+
listen 7860 default_server;
|
3 |
+
|
4 |
+
root /var/www/html;
|
5 |
+
|
6 |
+
index index.html;
|
7 |
+
|
8 |
+
server_name _;
|
9 |
+
|
10 |
+
location / {
|
11 |
+
try_files $uri $uri/ =404;
|
12 |
+
}
|
13 |
+
|
14 |
+
chunked_transfer_encoding off;
|
15 |
+
proxy_buffering off;
|
16 |
+
proxy_cache off;
|
17 |
+
|
18 |
+
location /v1 {
|
19 |
+
if ($http_authorization = "Bearer API_TOKEN") {
|
20 |
+
proxy_pass http://localhost:5004;
|
21 |
+
}
|
22 |
+
proxy_set_header Connection '';
|
23 |
+
proxy_http_version 1.1;
|
24 |
+
}
|
25 |
+
}
|