custom mode switch
This commit is contained in:
@@ -91,6 +91,7 @@ app.post("/v1/messages", apiKeyAuth, (req, res) => {
|
|||||||
});
|
});
|
||||||
var proxyModel = process.env.AI_MODEL || "claude_3_opus";
|
var proxyModel = process.env.AI_MODEL || "claude_3_opus";
|
||||||
// 检查该session是否已经创建对应模型的对应user chat mode
|
// 检查该session是否已经创建对应模型的对应user chat mode
|
||||||
|
if(process.env.USE_CUSTOM_MODE == "true") {
|
||||||
if (session.user_chat_mode_id && session.user_chat_mode_id[proxyModel]) {
|
if (session.user_chat_mode_id && session.user_chat_mode_id[proxyModel]) {
|
||||||
console.log("Using existing user chat mode");
|
console.log("Using existing user chat mode");
|
||||||
} else {
|
} else {
|
||||||
@@ -113,11 +114,16 @@ app.post("/v1/messages", apiKeyAuth, (req, res) => {
|
|||||||
fs.writeFileSync("./config.js", "module.exports = " + JSON.stringify(config, null, 4));
|
fs.writeFileSync("./config.js", "module.exports = " + JSON.stringify(config, null, 4));
|
||||||
}
|
}
|
||||||
var userChatModeId = session?.user_chat_mode_id?.[proxyModel] ? session.user_chat_mode_id[proxyModel] : "custom";
|
var userChatModeId = session?.user_chat_mode_id?.[proxyModel] ? session.user_chat_mode_id[proxyModel] : "custom";
|
||||||
|
}else{
|
||||||
|
console.log("Custom mode is disabled, using default mode.");
|
||||||
|
var userChatModeId = "custom";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 试算用户消息长度
|
// 试算用户消息长度
|
||||||
if(encodeURIComponent(JSON.stringify(userMessage)).length + encodeURIComponent(userQuery).length > 32000) {
|
if(encodeURIComponent(JSON.stringify(userMessage)).length + encodeURIComponent(userQuery).length > 32000) {
|
||||||
//太长了,需要上传
|
//太长了,需要上传
|
||||||
|
console.log("User message too long, uploading to server.")
|
||||||
// user message to plaintext
|
// user message to plaintext
|
||||||
let previousMessages = jsonBody.messages
|
let previousMessages = jsonBody.messages
|
||||||
.map((msg) => {
|
.map((msg) => {
|
||||||
|
|||||||
@@ -3,5 +3,6 @@ set PASSWORD=
|
|||||||
set https_proxy=
|
set https_proxy=
|
||||||
set PORT=8080
|
set PORT=8080
|
||||||
set AI_MODEL=claude_3_opus
|
set AI_MODEL=claude_3_opus
|
||||||
|
set USE_CUSTOM_MODE=false
|
||||||
node index
|
node index
|
||||||
pause
|
pause
|
||||||
@@ -39,6 +39,8 @@ module.exports = {
|
|||||||
|
|
||||||
(可选)如果需要,可以修改使用的模型。但是仍然建议使用opus,因为其他未经测试。
|
(可选)如果需要,可以修改使用的模型。但是仍然建议使用opus,因为其他未经测试。
|
||||||
|
|
||||||
|
(可选)如果需要,可以启用自定义会话模式(`USE_CUSTOM_MODE`设置为`true`)。可以缩短原系统消息长度、禁用联网、减缓等待时间,可能有助于破限。但有可能导致更容易出现 unusual query volume。
|
||||||
|
|
||||||
8. 启动 start.bat
|
8. 启动 start.bat
|
||||||
|
|
||||||
9. 酒馆中选择 Claude,反向代理地址填 http://127.0.0.1:8080/v1 **反代密码必须填, 同时打开流式传输**,随便什么都可以(除非你在第7步设置了PASSWORD)。
|
9. 酒馆中选择 Claude,反向代理地址填 http://127.0.0.1:8080/v1 **反代密码必须填, 同时打开流式传输**,随便什么都可以(除非你在第7步设置了PASSWORD)。
|
||||||
@@ -120,6 +122,8 @@ module.exports = {
|
|||||||
|
|
||||||
(Optional) You may change the model to use, but only claude_3_opus is tested.
|
(Optional) You may change the model to use, but only claude_3_opus is tested.
|
||||||
|
|
||||||
|
(Optional) You may turn on the custom chat mode by setting `USE_CUSTOM_MODE` env to `true`
|
||||||
|
|
||||||
8. Start start.bat
|
8. Start start.bat
|
||||||
|
|
||||||
9. Select Claude in the Tavern and put http://127.0.0.1:8080/v1 as the address of the reverse proxy. **Use any random string for password, also turn on Streaming** (unless you set PASSWORD in step 7).
|
9. Select Claude in the Tavern and put http://127.0.0.1:8080/v1 as the address of the reverse proxy. **Use any random string for password, also turn on Streaming** (unless you set PASSWORD in step 7).
|
||||||
|
|||||||
Reference in New Issue
Block a user