teralomaniac commited on
Commit
f915671
1 Parent(s): 2610970
Files changed (8) hide show
  1. .gitattributes +0 -40
  2. .gitkeep +0 -0
  3. clewd.js +35 -40
  4. config.js +0 -63
  5. start.bat +0 -5
  6. start.sh +0 -12
  7. update.bat +0 -37
  8. update.sh +0 -20
.gitattributes DELETED
@@ -1,40 +0,0 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
36
- lib/bin/clewd-superfetch-android-arm filter=lfs diff=lfs merge=lfs -text
37
- lib/bin/clewd-superfetch-linux-amd64 filter=lfs diff=lfs merge=lfs -text
38
- lib/bin/clewd-superfetch-linux-arm64 filter=lfs diff=lfs merge=lfs -text
39
- lib/bin/clewd-superfetch-mac-amd64 filter=lfs diff=lfs merge=lfs -text
40
- lib/bin/clewd-superfetch-win-amd64.exe filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.gitkeep DELETED
File without changes
clewd.js CHANGED
@@ -29,7 +29,7 @@ const convertToType = value => {
29
  return value;
30
  }, CookieCleaner = () => {
31
  Config.CookieArray = Config.CookieArray.filter(item => item !== Config.Cookie);
32
- !process.env.Cookie && !process.env.CookieArray && writeSettings(Config);
33
  currentIndex = (currentIndex - 1 + Config.CookieArray.length) % Config.CookieArray.length;
34
  }, padtxt = content => {
35
  const {countTokens} = require('@anthropic-ai/tokenizer');
@@ -37,18 +37,8 @@ const convertToType = value => {
37
  tokens = countTokens(content);
38
  !apiKey && (content = placeholder.repeat(Math.floor(Math.max(1000, Config.Settings.padtxt - tokens) / countTokens(placeholder.trim()))) + '\n\n\n' + content.trim());
39
  return content;
40
- }, xmlPlot = content => {
41
- // 检查内容中是否包含"<card>"
42
  const card = content.includes('<card>');
43
- //<card>越狱倒置
44
- if (card) {
45
- let segcontentHuman = content.split('\n\nHuman:');
46
- const seglength = segcontentHuman.length;
47
- if (/Assistant: *.$/.test(content) && seglength > 1 && !segcontentHuman[seglength - 2].includes('\n\nAssistant:')) {
48
- segcontentHuman[seglength - 2] = segcontentHuman.splice(seglength - 1, 1, segcontentHuman[seglength - 2])[0];
49
- }
50
- content = segcontentHuman.join('\n\nHuman:');
51
- }
52
  //role合并
53
  const MergeDisable = content.includes('<\!-- Merge Disable -->');
54
  const MergeHumanDisable = content.includes('<\!-- Merge Human Disable -->');
@@ -58,20 +48,16 @@ const convertToType = value => {
58
  content = content.replace(/(\n\n|^\s*)xmlPlot:\s*/gm, '$1');
59
  }
60
  if (!MergeHumanDisable) {
61
- const Human = /^\s*Human:/.test(content);
62
- content = content.replace(/(\n\n|^\s*)xmlPlot:/g, '$1Human:');
63
  content = content.replace(/(?:\n\n|^\s*)Human:(.*?(?:\n\nAssistant:|$))/gs, function(match, p1) {return '\n\nHuman:' + p1.replace(/\n\nHuman:\s*/g, '\n\n')});
64
- !apiKey && !Human && (content = content.replace(/^\s*Human:\s*/, ''));
65
  }
66
  if (!MergeAssistantDisable) {
67
  content = content.replace(/\n\nAssistant:(.*?(?:\n\nHuman:|$))/gs, function(match, p1) {return '\n\nAssistant:' + p1.replace(/\n\nAssistant:\s*/g, '\n\n')});
68
  }
69
  }
70
- content = content.replace(/(\n\n|^\s*)xmlPlot:\s*/gm, '$1');
71
- content = content.replace(/<\!-- Merge.*?Disable -->/gm, '');
72
  //自定义插入
73
- content = content.replace(/(<\/?)PrevAssistant>/gm, '$1@1>');
74
- content = content.replace(/(<\/?)PrevHuman>/gm, '$1@2>');
75
  let splitContent = content.split(/\n\n(?=Assistant:|Human:)/g);
76
  let match;
77
  while ((match = /<@(\d+)>(.*?)<\/@\1>/gs.exec(content)) !== null) {
@@ -103,18 +89,15 @@ const convertToType = value => {
103
  //Plain Prompt
104
  let segcontentHuman = content.split('\n\nHuman:');
105
  let segcontentlastIndex = segcontentHuman.length - 1;
106
- if (segcontentlastIndex >= 2 && segcontentHuman[segcontentlastIndex].includes('<!-- Plain Prompt Enable -->') && !content.includes('\n\nPlainPrompt:')) {
107
- content = segcontentHuman.slice(0, segcontentlastIndex).join('\n\nHuman:') + '\n\nPlainPrompt:' + segcontentHuman.slice(segcontentlastIndex).join('\n\nHuman:');
108
  }
109
  content = content.replace(/<\!-- Plain Prompt Enable -->/gm, '');
110
- content = content.replace(/\n\nHuman: *PlainPrompt:/, '\n\nPlainPrompt:');
111
  //<card>群组
112
  if (!card) {
113
- content = content.replace(/(<reply>\n|\n<\/reply>)/g, '');
114
- return content.replace(/<customname>(.*?)<\/customname>/gm, '$1');
115
  } else {
116
- content = content.replace(/(<reply>\n|\n<\/reply>)\1*/g, '$1');
117
- content = content.replace(/<customname>(.*?)<\/customname>:/gm, '$1:\n');
118
  }
119
  //<card>在第一个"[Start a new"前面加上"<example>",在最后一个"[Start a new"前面加上"</example>\n\n<plot>\n\n"
120
  const cardtag = content.match(/(?=\n\n<\/card>)/) || '</card>';
@@ -125,14 +108,23 @@ const convertToType = value => {
125
  firstChatStart != -1 && firstChatStart === lastChatStart && (content = content.slice(0, firstChatStart) + `\n\n${cardtag}` + content.slice(firstChatStart));
126
  firstChatStart != lastChatStart && (content = content.slice(0, firstChatStart) + `\n\n${cardtag}\n<example>` + content.slice(firstChatStart, lastChatStart) + `\n\n${exampletag}\n\n${plot}` + content.slice(lastChatStart));
127
  //<card>消除空XML tags、两端空白符和多余的\n
128
- content = content.replace(/\s*<\|curtail\|>\s*/g, '\n');
129
- content = content.replace(/\n<\/(card|hidden|META)>\s+?<\1>\n/g, '\n');
130
- content = content.replace(/\n<(\/?card|example|hidden|plot|META)>\s+?<\1>/g, '\n<$1>');
131
- content = content.replace(/(?:<!--.*?-->)?\n<(card|example|hidden|plot|META)>\s+?<\/\1>/g, '');
132
- content = content.replace(/(?<=(: |\n)<(card|hidden|example|plot|META|EOT)>\n)\s*/g, '');
133
- content = content.replace(/\s*(?=\n<\/(card|hidden|example|plot|META|EOT)>(\n|$))/g, '');
134
- content = content.replace(/(?<=\n)\n(?=\n)/g, '');
135
- return content.trim().replace(/^\s*Human:/, '\n\nHuman:');
 
 
 
 
 
 
 
 
 
136
  };
137
  /******************************************************* */
138
 
@@ -395,6 +387,7 @@ const updateParams = res => {
395
  }
396
  /***************************** */
397
  }, writeSettings = async (config, firstRun = false) => {
 
398
  write(ConfigPath, `/*\n* https://rentry.org/teralomaniac_clewd\n* https://github.com/teralomaniac/clewd\n*/\n\n// SET YOUR COOKIE BELOW\n\nmodule.exports = ${JSON.stringify(config, null, 4)}\n\n/*\n BufferSize\n * How many characters will be buffered before the AI types once\n * lower = less chance of \`PreventImperson\` working properly\n\n ---\n\n SystemInterval\n * How many messages until \`SystemExperiments alternates\`\n\n ---\n\n Other settings\n * https://gitgud.io/ahsk/clewd/#defaults\n * and\n * https://gitgud.io/ahsk/clewd/-/blob/master/CHANGELOG.md\n */`.trim().replace(/((?<!\r)\n|\r(?!\n))/g, '\r\n'));
399
  if (firstRun) {
400
  console.warn('config file created!\nedit config.js to set your settings and restart the program');
@@ -678,11 +671,13 @@ const updateParams = res => {
678
  console.log(`${apiKey ? api_model : model} [${type}]${!retryRegen && systems.length > 0 ? ' ' + systems.join(' / ') : ''}`); //console.log(`${model} [${type}]${!retryRegen && systems.length > 0 ? ' ' + systems.join(' / ') : ''}`);
679
  'R' !== type || prompt || (prompt = '...regen...');
680
  /******************************** */
681
- prompt = Config.Settings.xmlPlot ? xmlPlot(prompt) : genericFixes(prompt);
682
- !apiKey && Config.Settings.FullColon && (prompt = prompt.replace(/(?<=\n\n(H(?:uman)?|A(?:ssistant)?)):[ ]?/g, ': '));
 
 
683
  Config.Settings.padtxt && (prompt = padtxt(prompt));
684
  /******************************** */
685
- Logger?.write(`\n\n-------\n[${(new Date).toLocaleString()}]\n####### PROMPT (${type}):\n${prompt}\n--\n####### [Tokens: ${tokens}] REPLY:\n`); //Logger?.write(`\n\n-------\n[${(new Date).toLocaleString()}]\n####### PROMPT (${type}):\n${prompt}\n--\n####### REPLY:\n`);
686
  retryRegen || (fetchAPI = await (async (signal, model, prompt, temperature, type) => {
687
  /******************************** */
688
  if (apiKey) {
@@ -816,7 +811,7 @@ const updateParams = res => {
816
  default:
817
  !['/', '/v1', '/favicon.ico'].includes(req.url) && (console.log('unknown request: ' + req.url)); //console.log('unknown request: ' + req.url);
818
  res.writeHead(200, {'Content-Type': 'text/html'});
819
- res.write(`<!DOCTYPE html>\n<html>\n<head>\n<meta charset="utf-8">\n<script>\nfunction copyToClipboard(text) {\n var textarea = document.createElement("textarea");\n textarea.textContent = text;\n textarea.style.position = "fixed";\n document.body.appendChild(textarea);\n textarea.select();\n try {\n return document.execCommand("copy");\n } catch (ex) {\n console.warn("Copy to clipboard failed.", ex);\n return false;\n } finally {\n document.body.removeChild(textarea);\n }\n}\nfunction copyLink(event) {\n event.preventDefault();\n const url = new URL(window.location.href);\n const link = url.protocol + '//' + url.host + '/v1';\n copyToClipboard(link);\n alert('链接已复制: ' + link);\n}\n</script>\n</head>\n<body>\n${Main}<br/><br/>完全开源、免费且禁止商用<br/><br/>反向代理: <a href="v1" onclick="copyLink(event)">点击复制链接</a><br/>填入OpenAI API反向代理并选择OpenAI分类中的claude-2模型(酒馆需打开Show "External" models)<br/><br/>教程与FAQ: <a href="https://rentry.org/teralomaniac_clewd" target="FAQ">https://rentry.org/teralomaniac_clewd</a>\n</body>\n</html>`);
820
  res.end();
821
  /*res.json(
822
  {
@@ -872,9 +867,9 @@ const updateParams = res => {
872
  Config[key] = key === 'CookieArray' ? (process.env[key]?.split(',')?.map(x => x.replace(/[\[\]"\s]/g, '')) ?? Config[key]) : (convertToType(process.env[key]) ?? Config[key]);
873
  }
874
  }
875
- Config.rProxy = Config.rProxy.endsWith('/') ? Config.rProxy.slice(0, -1) : Config.rProxy || AI.end();
876
  Config.CookieArray = [...new Set(Config.CookieArray)];
877
- !process.env.Cookie && !process.env.CookieArray && writeSettings(Config);
878
  currentIndex = Config.CookieIndex > 0 ? Config.CookieIndex - 1 : Config.Cookiecounter >= 0 ? Math.floor(Math.random() * Config.CookieArray.length) : 0;
879
  /***************************** */
880
  Proxy.listen(Config.Port, Config.Ip, onListen);
 
29
  return value;
30
  }, CookieCleaner = () => {
31
  Config.CookieArray = Config.CookieArray.filter(item => item !== Config.Cookie);
32
+ writeSettings(Config);
33
  currentIndex = (currentIndex - 1 + Config.CookieArray.length) % Config.CookieArray.length;
34
  }, padtxt = content => {
35
  const {countTokens} = require('@anthropic-ai/tokenizer');
 
37
  tokens = countTokens(content);
38
  !apiKey && (content = placeholder.repeat(Math.floor(Math.max(1000, Config.Settings.padtxt - tokens) / countTokens(placeholder.trim()))) + '\n\n\n' + content.trim());
39
  return content;
40
+ }, xmlPlot = (content, nonsys = false) => {
 
41
  const card = content.includes('<card>');
 
 
 
 
 
 
 
 
 
42
  //role合并
43
  const MergeDisable = content.includes('<\!-- Merge Disable -->');
44
  const MergeHumanDisable = content.includes('<\!-- Merge Human Disable -->');
 
48
  content = content.replace(/(\n\n|^\s*)xmlPlot:\s*/gm, '$1');
49
  }
50
  if (!MergeHumanDisable) {
51
+ nonsys ? content = content.replace(/(\n\n|^\s*)xmlPlot:/g, '\n\nHuman:') : content = content.replace(/(?<!\n\n(Human|Assistant):.*?)(\n\n|^\s*)xmlPlot:\s*/gs, '$1');
 
52
  content = content.replace(/(?:\n\n|^\s*)Human:(.*?(?:\n\nAssistant:|$))/gs, function(match, p1) {return '\n\nHuman:' + p1.replace(/\n\nHuman:\s*/g, '\n\n')});
 
53
  }
54
  if (!MergeAssistantDisable) {
55
  content = content.replace(/\n\nAssistant:(.*?(?:\n\nHuman:|$))/gs, function(match, p1) {return '\n\nAssistant:' + p1.replace(/\n\nAssistant:\s*/g, '\n\n')});
56
  }
57
  }
58
+ content = content.replace(/(\n\n|^\s*)xmlPlot:\s*/gm, '$1').replace(/<\!-- Merge.*?Disable -->/gm, '');
 
59
  //自定义插入
60
+ content = content.replace(/(<\/?)PrevAssistant>/gm, '$1@1>').replace(/(<\/?)PrevHuman>/gm, '$1@2>');
 
61
  let splitContent = content.split(/\n\n(?=Assistant:|Human:)/g);
62
  let match;
63
  while ((match = /<@(\d+)>(.*?)<\/@\1>/gs.exec(content)) !== null) {
 
89
  //Plain Prompt
90
  let segcontentHuman = content.split('\n\nHuman:');
91
  let segcontentlastIndex = segcontentHuman.length - 1;
92
+ if (!apiKey && segcontentlastIndex >= 2 && segcontentHuman[segcontentlastIndex].includes('<!-- Plain Prompt Enable -->') && !content.includes('\n\nPlainPrompt:')) {
93
+ content = segcontentHuman.slice(0, segcontentlastIndex).join('\n\nHuman:') + '\n\nPlainPrompt:' + segcontentHuman.slice(segcontentlastIndex).join('\n\nHuman:').replace(/\n\nHuman: *PlainPrompt:/, '\n\nPlainPrompt:');
94
  }
95
  content = content.replace(/<\!-- Plain Prompt Enable -->/gm, '');
 
96
  //<card>群组
97
  if (!card) {
98
+ return content.replace(/(<reply>\n|\n<\/reply>)/g, '').replace(/<customname>(.*?)<\/customname>/gm, '$1');
 
99
  } else {
100
+ content = content.replace(/(<reply>\n|\n<\/reply>)\1*/g, '$1').replace(/<customname>(.*?)<\/customname>:/gm, '$1:\n');
 
101
  }
102
  //<card>在第一个"[Start a new"前面加上"<example>",在最后一个"[Start a new"前面加上"</example>\n\n<plot>\n\n"
103
  const cardtag = content.match(/(?=\n\n<\/card>)/) || '</card>';
 
108
  firstChatStart != -1 && firstChatStart === lastChatStart && (content = content.slice(0, firstChatStart) + `\n\n${cardtag}` + content.slice(firstChatStart));
109
  firstChatStart != lastChatStart && (content = content.slice(0, firstChatStart) + `\n\n${cardtag}\n<example>` + content.slice(firstChatStart, lastChatStart) + `\n\n${exampletag}\n\n${plot}` + content.slice(lastChatStart));
110
  //<card>消除空XML tags、两端空白符和多余的\n
111
+ content = content.replace(/\s*<\|curtail\|>\s*/g, '\n')
112
+ .replace(/\n<\/(card|hidden|META)>\s+?<\1>\n/g, '\n')
113
+ .replace(/\n<(\/?card|example|hidden|plot|META)>\s+?<\1>/g, '\n<$1>')
114
+ .replace(/(?:<!--.*?-->)?\n<(card|example|hidden|plot|META)>\s+?<\/\1>/g, '')
115
+ .replace(/(?<=(: |\n)<(card|hidden|example|plot|META|EOT)>\n)\s*/g, '')
116
+ .replace(/\s*(?=\n<\/(card|hidden|example|plot|META|EOT)>(\n|$))/g, '')
117
+ .replace(/(?<=\n)\n(?=\n)/g, '');
118
+ //确保格式正确
119
+ if (apiKey) {
120
+ content = content.trim().replace(/^Human:/, '\n\nHuman:')
121
+ .replace(/(\n\nAssistant|\n\nHuman):(?!.*?\n\n(Assistant|Human):).*$/s, function(match, p1) {return p1 === '\n\nAssistant' ? match : match + '\n\nAssistant: '})
122
+ .replace(/\s*<\|noAssistant\|>\s*(.*?)(?:\n\nAssistant:)?$/s, '\n\n$1');
123
+ content.includes('<|reverseHA|>') && (content = content.replace(/\s*<\|reverseHA\|>\s*/g, '\n\n').replace(/\n\n(Assistant|Human):/g, function(match, p1) {return p1 === 'Human' ? '\n\nAssistant:' : '\n\nHuman:'}))
124
+ return content;
125
+ } else {
126
+ return content.trim().replace(/^Human:|\n\nAssistant:$/g, '');
127
+ }
128
  };
129
  /******************************************************* */
130
 
 
387
  }
388
  /***************************** */
389
  }, writeSettings = async (config, firstRun = false) => {
390
+ if (process.env.Cookie || process.env.CookieArray) return ChangedSettings = '', UnknownSettings = '';
391
  write(ConfigPath, `/*\n* https://rentry.org/teralomaniac_clewd\n* https://github.com/teralomaniac/clewd\n*/\n\n// SET YOUR COOKIE BELOW\n\nmodule.exports = ${JSON.stringify(config, null, 4)}\n\n/*\n BufferSize\n * How many characters will be buffered before the AI types once\n * lower = less chance of \`PreventImperson\` working properly\n\n ---\n\n SystemInterval\n * How many messages until \`SystemExperiments alternates\`\n\n ---\n\n Other settings\n * https://gitgud.io/ahsk/clewd/#defaults\n * and\n * https://gitgud.io/ahsk/clewd/-/blob/master/CHANGELOG.md\n */`.trim().replace(/((?<!\r)\n|\r(?!\n))/g, '\r\n'));
392
  if (firstRun) {
393
  console.warn('config file created!\nedit config.js to set your settings and restart the program');
 
671
  console.log(`${apiKey ? api_model : model} [${type}]${!retryRegen && systems.length > 0 ? ' ' + systems.join(' / ') : ''}`); //console.log(`${model} [${type}]${!retryRegen && systems.length > 0 ? ' ' + systems.join(' / ') : ''}`);
672
  'R' !== type || prompt || (prompt = '...regen...');
673
  /******************************** */
674
+ prompt = Config.Settings.xmlPlot ? xmlPlot(prompt, api_model && api_model != 'claude-2.1') : apiKey ? `\n\nHuman: ${genericFixes(prompt)}\n\nAssistant: ` : genericFixes(prompt);
675
+ Config.Settings.FullColon && (prompt = apiKey
676
+ ? prompt.replace(/(\n\nAssistant|\n\nHuman):/, function(match, p1) {return p1 === '\n\nHuman' ? match : p1 + ':'}).replace(/(\n\nAssistant|\n\nHuman):(?!.*?\n\n(Assistant|Human):)/s, function(match, p1) {return p1 === '\n\nAssistant' ? match : p1 + ':'})
677
+ : prompt.replace(/(?<=\n\n(H(?:uman)?|A(?:ssistant)?)):[ ]?/g, ': '));
678
  Config.Settings.padtxt && (prompt = padtxt(prompt));
679
  /******************************** */
680
+ Logger?.write(`\n\n-------\n[${(new Date).toLocaleString()}]\n####### ${apiKey ? api_model : model} PROMPT (${type}):\n${prompt}\n--\n####### [Tokens: ${tokens}] REPLY:\n`); //Logger?.write(`\n\n-------\n[${(new Date).toLocaleString()}]\n####### PROMPT (${type}):\n${prompt}\n--\n####### REPLY:\n`);
681
  retryRegen || (fetchAPI = await (async (signal, model, prompt, temperature, type) => {
682
  /******************************** */
683
  if (apiKey) {
 
811
  default:
812
  !['/', '/v1', '/favicon.ico'].includes(req.url) && (console.log('unknown request: ' + req.url)); //console.log('unknown request: ' + req.url);
813
  res.writeHead(200, {'Content-Type': 'text/html'});
814
+ res.write(`<!DOCTYPE html>\n<html>\n<head>\n<meta charset="utf-8">\n<script>\nfunction copyToClipboard(text) {\n var textarea = document.createElement("textarea");\n textarea.textContent = text;\n textarea.style.position = "fixed";\n document.body.appendChild(textarea);\n textarea.select();\n try {\n return document.execCommand("copy");\n } catch (ex) {\n console.warn("Copy to clipboard failed.", ex);\n return false;\n } finally {\n document.body.removeChild(textarea);\n }\n}\nfunction copyLink(event) {\n event.preventDefault();\n const url = new URL(window.location.href);\n const link = url.protocol + '//' + url.host + '/v1';\n copyToClipboard(link);\n alert('链接已复制: ' + link);\n}\n</script>\n</head>\n<body>\n${Main}<br/><br/>完全开源、免费且禁止商用<br/><br/>点击复制反向代理: <a href="v1" onclick="copyLink(event)">Copy Link</a><br/>填入OpenAI API反向代理并选择OpenAI分类中的claude模型(酒馆需打开Show "External" models,仅在api模式有模型选择差异)<br/><br/>教程与FAQ: <a href="https://rentry.org/teralomaniac_clewd" target="FAQ">Rentry</a> | <a href="https://discord.com/invite/B7Wr25Z7BZ" target="FAQ">Discord</a><br/><br/><br/>请举报恶意盗用/商用本教程及Clewd修改版的这个B 站up<a href="https://space.bilibili.com/35307060" target="FAQ">浅睡一天一夜</a>\n</body>\n</html>`);
815
  res.end();
816
  /*res.json(
817
  {
 
867
  Config[key] = key === 'CookieArray' ? (process.env[key]?.split(',')?.map(x => x.replace(/[\[\]"\s]/g, '')) ?? Config[key]) : (convertToType(process.env[key]) ?? Config[key]);
868
  }
869
  }
870
+ Config.rProxy = Config.rProxy ? Config.rProxy.replace(/\/$/, '') : AI.end();
871
  Config.CookieArray = [...new Set(Config.CookieArray)];
872
+ writeSettings(Config);
873
  currentIndex = Config.CookieIndex > 0 ? Config.CookieIndex - 1 : Config.Cookiecounter >= 0 ? Math.floor(Math.random() * Config.CookieArray.length) : 0;
874
  /***************************** */
875
  Proxy.listen(Config.Port, Config.Ip, onListen);
config.js DELETED
@@ -1,63 +0,0 @@
1
- /*
2
- * https://rentry.org/teralomaniac_clewd
3
- * https://github.com/teralomaniac/clewd
4
- */
5
-
6
- // SET YOUR COOKIE BELOW
7
-
8
- module.exports = {
9
- "Cookie": "",
10
- "CookieArray": [],
11
- "Cookiecounter": 1,
12
- "CookieIndex": 0,
13
- "ProxyPassword": "",
14
- "Ip": "0.0.0.0",
15
- "Port": 7860,
16
- "localtunnel": false,
17
- "BufferSize": 1,
18
- "SystemInterval": 3,
19
- "rProxy": "",
20
- "api_rProxy": "",
21
- "padtxt_placeholder": "",
22
- "PromptExperimentFirst": "",
23
- "PromptExperimentNext": "",
24
- "PersonalityFormat": "{{char}}'s personality: {{personality}}",
25
- "ScenarioFormat": "Dialogue scenario: {{scenario}}",
26
- "Settings": {
27
- "RenewAlways": true,
28
- "RetryRegenerate": false,
29
- "PromptExperiments": true,
30
- "SystemExperiments": true,
31
- "PreventImperson": false,
32
- "AllSamples": false,
33
- "NoSamples": false,
34
- "StripAssistant": false,
35
- "StripHuman": false,
36
- "PassParams": false,
37
- "ClearFlags": true,
38
- "PreserveChats": false,
39
- "LogMessages": true,
40
- "FullColon": true,
41
- "padtxt": 15000,
42
- "xmlPlot": true,
43
- "Superfetch": false
44
- }
45
- }
46
-
47
- /*
48
- BufferSize
49
- * How many characters will be buffered before the AI types once
50
- * lower = less chance of `PreventImperson` working properly
51
-
52
- ---
53
-
54
- SystemInterval
55
- * How many messages until `SystemExperiments alternates`
56
-
57
- ---
58
-
59
- Other settings
60
- * https://gitgud.io/ahsk/clewd/#defaults
61
- * and
62
- * https://gitgud.io/ahsk/clewd/-/blob/master/CHANGELOG.md
63
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
start.bat DELETED
@@ -1,5 +0,0 @@
1
- pushd %~dp0
2
- call npm install --no-audit --fund false
3
- node clewd.js
4
- pause
5
- popd
 
 
 
 
 
 
start.sh DELETED
@@ -1,12 +0,0 @@
1
- #!/bin/bash
2
-
3
- if ! command -v npm &> /dev/null
4
- then
5
- echo "Install nodejs"
6
- fi
7
-
8
- npm install --no-audit --fund false
9
- chown -R $(whoami) lib/bin/*
10
- chmod u+x lib/bin/*
11
- chmod -R 777 $(pwd)
12
- node clewd.js
 
 
 
 
 
 
 
 
 
 
 
 
 
update.bat DELETED
@@ -1,37 +0,0 @@
1
- @echo off
2
- pushd %~dp0
3
-
4
- if not exist .git (
5
- GOTO:notgit
6
- )
7
-
8
- where /q git.exe
9
- if %ERRORLEVEL% EQU 0 (
10
- GOTO:pull
11
- )
12
- GOTO:missgit
13
-
14
-
15
- :pull
16
- call git config --local url."https://".insteadOf git://
17
- call git config --local url."https://github.com/".insteadOf [email protected]:
18
- call git config --local url."https://".insteadOf ssh://
19
- call git pull --rebase --autostash
20
- if %ERRORLEVEL% neq 0 (
21
- echo Error updating
22
- )
23
- GOTO:end
24
-
25
- :missgit
26
- echo Install git to update
27
- GOTO:end
28
-
29
- :notgit
30
- echo Only able to update if you clone the repository (git clone https://github.com/teralomaniac/clewd.git)
31
- GOTO:end
32
-
33
-
34
- :end
35
- pause
36
- popd
37
- exit /B
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
update.sh DELETED
@@ -1,20 +0,0 @@
1
- #!/bin/bash
2
-
3
- if ! [ -x "$(command -v git)" ]
4
- then
5
- echo "Install git to update"
6
- exit
7
- fi
8
-
9
- if [ -x "$(command -v git)" ]
10
- then
11
- if [ -d ".git" ]
12
- then
13
- git config --local url."https://".insteadOf git://
14
- git config --local url."https://github.com/".insteadOf [email protected]:
15
- git config --local url."https://".insteadOf ssh://
16
- git pull --rebase --autostash
17
- else
18
- echo "Only able to update if you clone the repository (git clone https://github.com/teralomaniac/clewd.git)"
19
- fi
20
- fi