diff --git a/README.md b/README.md
index 0bb9852d327..892d1fc8495 100644
--- a/README.md
+++ b/README.md
@@ -18,11 +18,11 @@ One-Click to get a well-designed cross-platform ChatGPT web UI, with GPT3, GPT4
[![MacOS][MacOS-image]][download-url]
[![Linux][Linux-image]][download-url]
-[NextChatAI](https://nextchat.dev/chat) / [Web App](https://app.nextchat.dev) / [Desktop App](https://github.com/Yidadaa/ChatGPT-Next-Web/releases) / [Discord](https://discord.gg/YCkeafCafC) / [Enterprise Edition](#enterprise-edition) / [Twitter](https://twitter.com/NextChatDev)
+[NextChatAI](https://nextchat.dev/chat?utm_source=readme) / [Web App](https://app.nextchat.dev) / [Desktop App](https://github.com/Yidadaa/ChatGPT-Next-Web/releases) / [Discord](https://discord.gg/YCkeafCafC) / [Enterprise Edition](#enterprise-edition) / [Twitter](https://twitter.com/NextChatDev)
[NextChatAI](https://nextchat.dev/chat) / [网页版](https://app.nextchat.dev) / [客户端](https://github.com/Yidadaa/ChatGPT-Next-Web/releases) / [企业版](#%E4%BC%81%E4%B8%9A%E7%89%88) / [反馈](https://github.com/Yidadaa/ChatGPT-Next-Web/issues)
-[saas-url]: https://nextchat.dev/chat
+[saas-url]: https://nextchat.dev/chat?utm_source=readme
[saas-image]: https://img.shields.io/badge/NextChat-Saas-green?logo=microsoftedge
[web-url]: https://app.nextchat.dev/
[download-url]: https://github.com/Yidadaa/ChatGPT-Next-Web/releases
@@ -177,7 +177,7 @@ We recommend that you follow the steps below to re-deploy:
### Enable Automatic Updates
-> If you encounter a failure of Upstream Sync execution, please manually sync fork once.
+> If you encounter a failure of Upstream Sync execution, please [manually update code](./README.md#manually-updating-code).
After forking the project, due to the limitations imposed by GitHub, you need to manually enable Workflows and Upstream Sync Action on the Actions page of the forked project. Once enabled, automatic updates will be scheduled every hour:
diff --git a/README_CN.md b/README_CN.md
index 98aeb695e5f..969ae18d85f 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -8,7 +8,7 @@
一键免费部署你的私人 ChatGPT 网页应用,支持 GPT3, GPT4 & Gemini Pro 模型。
-[NextChatAI](https://nextchat.dev/chat) / [企业版](#%E4%BC%81%E4%B8%9A%E7%89%88) / [演示 Demo](https://chat-gpt-next-web.vercel.app/) / [反馈 Issues](https://github.com/Yidadaa/ChatGPT-Next-Web/issues) / [加入 Discord](https://discord.gg/zrhvHCr79N)
+[NextChatAI](https://nextchat.dev/chat?utm_source=readme) / [企业版](#%E4%BC%81%E4%B8%9A%E7%89%88) / [演示 Demo](https://chat-gpt-next-web.vercel.app/) / [反馈 Issues](https://github.com/Yidadaa/ChatGPT-Next-Web/issues) / [加入 Discord](https://discord.gg/zrhvHCr79N)
[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FChatGPTNextWeb%2FChatGPT-Next-Web&env=OPENAI_API_KEY&env=CODE&project-name=nextchat&repository-name=NextChat) [](https://zeabur.com/templates/ZBUEFA) [](https://gitpod.io/#https://github.com/Yidadaa/ChatGPT-Next-Web)
@@ -55,7 +55,7 @@
### 打开自动更新
-> 如果你遇到了 Upstream Sync 执行错误,请手动 Sync Fork 一次!
+> 如果你遇到了 Upstream Sync 执行错误,请[手动 Sync Fork 一次](./README_CN.md#手动更新代码)!
当你 fork 项目之后,由于 Github 的限制,需要手动去你 fork 后的项目的 Actions 页面启用 Workflows,并启用 Upstream Sync Action,启用之后即可开启每小时定时自动更新:
diff --git a/README_JA.md b/README_JA.md
index 0eefadebc05..c0f724de64a 100644
--- a/README_JA.md
+++ b/README_JA.md
@@ -5,7 +5,7 @@
ワンクリックで無料であなた専用の ChatGPT ウェブアプリをデプロイ。GPT3、GPT4 & Gemini Pro モデルをサポート。
-[NextChatAI](https://nextchat.dev/chat) / [企業版](#企業版) / [デモ](https://chat-gpt-next-web.vercel.app/) / [フィードバック](https://github.com/Yidadaa/ChatGPT-Next-Web/issues) / [Discordに参加](https://discord.gg/zrhvHCr79N)
+[NextChatAI](https://nextchat.dev/chat?utm_source=readme) / [企業版](#企業版) / [デモ](https://chat-gpt-next-web.vercel.app/) / [フィードバック](https://github.com/Yidadaa/ChatGPT-Next-Web/issues) / [Discordに参加](https://discord.gg/zrhvHCr79N)
[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FChatGPTNextWeb%2FChatGPT-Next-Web&env=OPENAI_API_KEY&env=CODE&project-name=nextchat&repository-name=NextChat) [](https://zeabur.com/templates/ZBUEFA) [](https://gitpod.io/#https://github.com/Yidadaa/ChatGPT-Next-Web)
@@ -51,7 +51,7 @@
### 自動更新を開く
-> Upstream Sync の実行エラーが発生した場合は、手動で Sync Fork してください!
+> Upstream Sync の実行エラーが発生した場合は、[手動で Sync Fork](./README_JA.md#手動でコードを更新する) してください!
プロジェクトを fork した後、GitHub の制限により、fork 後のプロジェクトの Actions ページで Workflows を手動で有効にし、Upstream Sync Action を有効にする必要があります。有効化後、毎時の定期自動更新が可能になります:
diff --git a/app/api/google.ts b/app/api/google.ts
index 7d3f08be4d9..707892c33d0 100644
--- a/app/api/google.ts
+++ b/app/api/google.ts
@@ -23,7 +23,8 @@ export async function handle(
});
}
- const bearToken = req.headers.get("Authorization") ?? "";
+ const bearToken =
+ req.headers.get("x-goog-api-key") || req.headers.get("Authorization") || "";
const token = bearToken.trim().replaceAll("Bearer ", "").trim();
const apiKey = token ? token : serverConfig.googleApiKey;
@@ -92,7 +93,7 @@ async function request(req: NextRequest, apiKey: string) {
10 * 60 * 1000,
);
const fetchUrl = `${baseUrl}${path}${
- req?.nextUrl?.searchParams?.get("alt") === "sse" ? "&alt=sse" : ""
+ req?.nextUrl?.searchParams?.get("alt") === "sse" ? "?alt=sse" : ""
}`;
console.log("[Fetch Url] ", fetchUrl);
@@ -100,8 +101,8 @@ async function request(req: NextRequest, apiKey: string) {
headers: {
"Content-Type": "application/json",
"Cache-Control": "no-store",
- "x-google-api-key":
- req.headers.get("x-google-api-key") ||
+ "x-goog-api-key":
+ req.headers.get("x-goog-api-key") ||
(req.headers.get("Authorization") ?? "").replace("Bearer ", ""),
},
method: req.method,
diff --git a/app/client/api.ts b/app/client/api.ts
index 19bd5473dd7..73b5fd08ce2 100644
--- a/app/client/api.ts
+++ b/app/client/api.ts
@@ -231,7 +231,7 @@ export function getHeaders(ignoreHeaders: boolean = false) {
function getConfig() {
const modelConfig = chatStore.currentSession().mask.modelConfig;
- const isGoogle = modelConfig.providerName == ServiceProvider.Google;
+ const isGoogle = modelConfig.providerName === ServiceProvider.Google;
const isAzure = modelConfig.providerName === ServiceProvider.Azure;
const isAnthropic = modelConfig.providerName === ServiceProvider.Anthropic;
const isBaidu = modelConfig.providerName == ServiceProvider.Baidu;
diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx
index 8936e0b5bef..6eb2e49c32c 100644
--- a/app/components/markdown.tsx
+++ b/app/components/markdown.tsx
@@ -251,7 +251,7 @@ function tryWrapHtmlCode(text: string) {
},
)
.replace(
- /(<\/body>)([\r\n\s]*?)(<\/html>)([\n\r]*?)([`]*?)([\n\r]*?)/g,
+ /(<\/body>)([\r\n\s]*?)(<\/html>)([\n\r]*)([`]*)([\n\r]*?)/g,
(match, bodyEnd, space, htmlEnd, newLine, quoteEnd) => {
return !quoteEnd ? bodyEnd + space + htmlEnd + "\n```\n" : match;
},
diff --git a/app/store/access.ts b/app/store/access.ts
index d74cb9d0249..9fcd227e7c0 100644
--- a/app/store/access.ts
+++ b/app/store/access.ts
@@ -211,10 +211,13 @@ export const useAccessStore = createPersistStore(
})
.then((res) => res.json())
.then((res) => {
- // Set default model from env request
- let defaultModel = res.defaultModel ?? "";
- if (defaultModel !== "")
- DEFAULT_CONFIG.modelConfig.model = defaultModel;
+ const defaultModel = res.defaultModel ?? "";
+ if (defaultModel !== "") {
+ const [model, providerName] = defaultModel.split("@");
+ DEFAULT_CONFIG.modelConfig.model = model;
+ DEFAULT_CONFIG.modelConfig.providerName = providerName;
+ }
+
return res;
})
.then((res: DangerConfig) => {
diff --git a/app/store/plugin.ts b/app/store/plugin.ts
index 84ae0816e41..40abdc8d9f4 100644
--- a/app/store/plugin.ts
+++ b/app/store/plugin.ts
@@ -4,7 +4,7 @@ import { nanoid } from "nanoid";
import { createPersistStore } from "../utils/store";
import { getClientConfig } from "../config/client";
import yaml from "js-yaml";
-import { adapter } from "../utils";
+import { adapter, getOperationId } from "../utils";
import { useAccessStore } from "./access";
const isApp = getClientConfig()?.isApp;
@@ -116,7 +116,7 @@ export const FunctionToolService = {
return {
type: "function",
function: {
- name: o.operationId,
+ name: getOperationId(o),
description: o.description || o.summary,
parameters: parameters,
},
@@ -124,7 +124,7 @@ export const FunctionToolService = {
}),
funcs: operations.reduce((s, o) => {
// @ts-ignore
- s[o.operationId] = function (args) {
+ s[getOperationId(o)] = function (args) {
const parameters: Record = {};
if (o.parameters instanceof Array) {
o.parameters.forEach((p) => {
@@ -139,8 +139,8 @@ export const FunctionToolService = {
} else if (authLocation == "body") {
args[headerName] = tokenValue;
}
- // @ts-ignore
- return api.client[o.operationId](
+ // @ts-ignore if o.operationId is null, then using o.path and o.method
+ return api.client.paths[o.path][o.method](
parameters,
args,
api.axiosConfigDefaults,
diff --git a/app/utils.ts b/app/utils.ts
index 9a8bebf38c7..6b2f65952c7 100644
--- a/app/utils.ts
+++ b/app/utils.ts
@@ -377,3 +377,15 @@ export function safeLocalStorage(): {
},
};
}
+
+export function getOperationId(operation: {
+ operationId?: string;
+ method: string;
+ path: string;
+}) {
+ // pattern '^[a-zA-Z0-9_-]+$'
+ return (
+ operation?.operationId ||
+ `${operation.method.toUpperCase()}${operation.path.replaceAll("/", "_")}`
+ );
+}