Skip to content

Commit

Permalink
style: 优化makeResponse200函数实现
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Nov 17, 2023
1 parent 5eebcfe commit 94a46a7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 21 deletions.
2 changes: 1 addition & 1 deletion dist/buildinfo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"sha": "47f793d", "timestamp": 1700201645}
{"sha": "5eebcfe", "timestamp": 1700212771}
15 changes: 4 additions & 11 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ var Environment = class {
// 检查更新的分支
UPDATE_BRANCH = "master";
// 当前版本
BUILD_TIMESTAMP = 1700201645;
BUILD_TIMESTAMP = 1700212771;
// 当前版本 commit id
BUILD_VERSION = "47f793d";
BUILD_VERSION = "5eebcfe";
// 使用流模式
STREAM_MODE = true;
// 安全模式
Expand All @@ -80,7 +80,7 @@ var Environment = class {
// Cloudflare Token
CLOUDFLARE_TOKEN = null;
// Text Generation Model
WORKERS_CHAT_MODEL = "@cf/meta/llama-2-7b-chat-int8";
WORKERS_CHAT_MODEL = "@cf/meta/llama-2-7b-chat-fp16";
// Text-to-Image Model
WORKERS_IMAGE_MODEL = "@cf/stabilityai/stable-diffusion-xl-base-1.0";
};
Expand Down Expand Up @@ -1175,14 +1175,7 @@ async function makeResponse200(resp) {
if (resp.status === 200) {
return resp;
} else {
let body = "";
try {
body = await resp.text();
console.error(body);
} catch (e) {
console.error(e);
}
return new Response(body, {
return new Response(resp.body, {
status: 200,
headers: {
"Original-Status": resp.status,
Expand Down
2 changes: 1 addition & 1 deletion dist/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1700201645
1700212771
9 changes: 1 addition & 8 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,7 @@ export async function makeResponse200(resp) {
return resp;
} else {
// 如果返回4xx,5xx,Telegram会重试这个消息,后续消息就不会到达,所有webhook的错误都返回200
let body = '';
try {
body = await resp.text();
console.error(body);
} catch (e) {
console.error(e);
}
return new Response(body, {
return new Response(resp.body, {
status: 200,
headers: {
'Original-Status': resp.status,
Expand Down

0 comments on commit 94a46a7

Please sign in to comment.