mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-19 20:20:16 +09:00
update
This commit is contained in:
parent
e1d6131f13
commit
c359b92ddc
@ -67,12 +67,6 @@ export const preferredRegion = [
|
||||
async function request(req: NextRequest) {
|
||||
const controller = new AbortController();
|
||||
|
||||
// tencent just use base url or just remove the path
|
||||
let path = `${req.nextUrl.pathname}`.replaceAll(
|
||||
ApiPath.Tencent + "/" + Tencent.ChatPath,
|
||||
"",
|
||||
);
|
||||
|
||||
let baseUrl = serverConfig.tencentUrl || TENCENT_BASE_URL;
|
||||
|
||||
if (!baseUrl.startsWith("http")) {
|
||||
@ -83,7 +77,6 @@ async function request(req: NextRequest) {
|
||||
baseUrl = baseUrl.slice(0, -1);
|
||||
}
|
||||
|
||||
console.log("[Proxy] ", path);
|
||||
console.log("[Base Url]", baseUrl);
|
||||
|
||||
const timeoutId = setTimeout(
|
||||
@ -93,7 +86,7 @@ async function request(req: NextRequest) {
|
||||
10 * 60 * 1000,
|
||||
);
|
||||
|
||||
const fetchUrl = `${baseUrl}${path}`;
|
||||
const fetchUrl = baseUrl;
|
||||
|
||||
const body = await req.text();
|
||||
const headers = await getHeader(
|
@ -91,8 +91,7 @@ export class HunyuanApi implements LLMApi {
|
||||
}
|
||||
|
||||
console.log("[Proxy Endpoint] ", baseUrl);
|
||||
|
||||
return [baseUrl, path].join("/");
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
extractMessage(res: any) {
|
||||
@ -115,11 +114,11 @@ export class HunyuanApi implements LLMApi {
|
||||
};
|
||||
|
||||
const requestPayload: RequestPayload = capitalizeKeys({
|
||||
messages,
|
||||
stream: options.config.stream,
|
||||
model: modelConfig.model,
|
||||
messages,
|
||||
temperature: modelConfig.temperature,
|
||||
top_p: modelConfig.top_p,
|
||||
stream: options.config.stream,
|
||||
});
|
||||
|
||||
console.log("[Request] Tencent payload: ", requestPayload);
|
||||
|
@ -195,7 +195,6 @@ export const Alibaba = {
|
||||
|
||||
export const Tencent = {
|
||||
ExampleEndpoint: TENCENT_BASE_URL,
|
||||
ChatPath: "v1/chat/completions",
|
||||
};
|
||||
|
||||
export const Moonshot = {
|
||||
|
@ -1,17 +1,14 @@
|
||||
"use server";
|
||||
import * as crypto from "node:crypto";
|
||||
import { createHash, createHmac } from "node:crypto";
|
||||
// 使用 SHA-256 和 secret 进行 HMAC 加密
|
||||
function sha256(message: any, secret = "", encoding?: string) {
|
||||
return crypto
|
||||
.createHmac("sha256", secret)
|
||||
return createHmac("sha256", secret)
|
||||
.update(message)
|
||||
.digest(encoding as any);
|
||||
}
|
||||
|
||||
// 使用 SHA-256 进行哈希
|
||||
function getHash(message: any, encoding = "hex") {
|
||||
return crypto
|
||||
.createHash("sha256")
|
||||
return createHash("sha256")
|
||||
.update(message)
|
||||
.digest(encoding as any);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user