diff --git a/app/api/tencent/[...path]/route.ts b/app/api/tencent/route.ts similarity index 91% rename from app/api/tencent/[...path]/route.ts rename to app/api/tencent/route.ts index 216f941b6..d506d1016 100644 --- a/app/api/tencent/[...path]/route.ts +++ b/app/api/tencent/route.ts @@ -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( diff --git a/app/client/platforms/tencent.ts b/app/client/platforms/tencent.ts index 119006770..621fede10 100644 --- a/app/client/platforms/tencent.ts +++ b/app/client/platforms/tencent.ts @@ -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); diff --git a/app/constant.ts b/app/constant.ts index ae57b340d..5251b5b4f 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -195,7 +195,6 @@ export const Alibaba = { export const Tencent = { ExampleEndpoint: TENCENT_BASE_URL, - ChatPath: "v1/chat/completions", }; export const Moonshot = { diff --git a/app/utils/tencent.ts b/app/utils/tencent.ts index d304c6284..019d330b6 100644 --- a/app/utils/tencent.ts +++ b/app/utils/tencent.ts @@ -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); }