diff --git a/README.md b/README.md index 35be192e6..8737919d1 100644 --- a/README.md +++ b/README.md @@ -39,10 +39,12 @@ One-Click to deploy well-designed ChatGPT web UI on Vercel. ## Roadmap - [x] System Prompt: pin a user defined prompt as system prompt [#138](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/138) -- [ ] User Prompt: user can edit and save custom prompts to prompt list +- [x] User Prompt: user can edit and save custom prompts to prompt list +- [ ] Prompt Template: create a new chat with pre-defined in-context prompts +- [ ] Share as image, share to ShareGPT - [ ] Desktop App with tauri - [ ] Self-host Model: support llama, alpaca, ChatGLM, BELLE etc. -- [ ] Plugins: support network search, caculator, any other apis etc. [#165](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/165) +- [ ] Plugins: support network search, calculator, any other apis etc. [#165](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/165) ### Not in Plan @@ -63,7 +65,9 @@ One-Click to deploy well-designed ChatGPT web UI on Vercel. ## 开发计划 - [x] 为每个对话设置系统 Prompt [#138](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/138) -- [ ] 允许用户自行编辑内置 Prompt 列表 +- [x] 允许用户自行编辑内置 Prompt 列表 +- [ ] 提示词模板:使用预制上下文快速定制新对话 +- [ ] 分享为图片,分享到 ShareGPT - [ ] 使用 tauri 打包桌面应用 - [ ] 支持自部署的大语言模型 - [ ] 插件机制,支持联网搜索、计算器、调用其他平台 api [#165](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/165) @@ -101,6 +105,7 @@ We recommend that you follow the steps below to re-deploy: - Choose and deploy in Vercel again, [please see the detailed tutorial](./docs/vercel-cn.md). ### Enable Automatic Updates + 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:  @@ -108,6 +113,7 @@ After forking the project, due to the limitations imposed by Github, you need to  ### Manually Updating Code + If you want to update instantly, you can check out the [Github documentation](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork) to learn how to synchronize a forked project with upstream code. You can star or watch this project or follow author to get release notifictions in time. @@ -138,18 +144,12 @@ Access passsword, separated by comma. ### `BASE_URL` (optional) -> Default: `api.openai.com` +> Default: `https://api.openai.com` + +> Examples: `http://your-openai-proxy.com` Override openai api request base url. -### `PROTOCOL` (optional) - -> Default: `https` - -> Values: `http` | `https` - -Override openai api request protocol. - ## Development > [简体中文 > 如何进行二次开发](./README_CN.md#开发) @@ -229,6 +229,9 @@ bash <(curl -s https://raw.githubusercontent.com/Yidadaa/ChatGPT-Next-Web/main/s [@chazzhou](https://github.com/chazzhou) [@hauy](https://github.com/hauy) [@Corwin006](https://github.com/Corwin006) +[@yankunsong](https://github.com/yankunsong) +[@ypwhs](https://github.com/ypwhs) +[@fxxxchao](https://github.com/fxxxchao) ### Contributor diff --git a/README_CN.md b/README_CN.md index 7d1a835c4..d2d64aa00 100644 --- a/README_CN.md +++ b/README_CN.md @@ -43,6 +43,7 @@ - 在 Vercel 重新选择并部署,[请查看详细教程](./docs/vercel-cn.md#如何新建项目)。 ### 打开自动更新 + 当你 fork 项目之后,由于 Github 的限制,需要手动去你 fork 后的项目的 Actions 页面启用 Workflows,并启用 Upstream Sync Action,启用之后即可开启每小时定时自动更新:  @@ -85,17 +86,13 @@ OpanAI 密钥,你在 openai 账户页面申请的 api key。 ### `BASE_URL` (可选) -> Default: `api.openai.com` +> Default: `https://api.openai.com` + +> Examples: `http://your-openai-proxy.com` OpenAI 接口代理 URL,如果你手动配置了 openai 接口代理,请填写此选项。 -### `PROTOCOL` (可选) - -> Default: `https` - -> Values: `http` | `https` - -OpenAI 代理接口协议,如果遇到 ssl 证书问题,请尝试通过此选项设置为 http。 +> 如果遇到 ssl 证书问题,请将 `BASE_URL` 的协议设置为 http。 ## 开发 diff --git a/app/api/common.ts b/app/api/common.ts index 842eeacaf..53ab18ed6 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -9,9 +9,16 @@ export async function requestOpenai(req: NextRequest) { const apiKey = req.headers.get("token"); const openaiPath = req.headers.get("path"); - console.log("[Proxy] ", openaiPath); + let baseUrl = BASE_URL; - return fetch(`${PROTOCOL}://${BASE_URL}/${openaiPath}`, { + if (!baseUrl.startsWith("http")) { + baseUrl = `${PROTOCOL}://${baseUrl}`; + } + + console.log("[Proxy] ", openaiPath); + console.log("[Base Url]", baseUrl); + + return fetch(`${baseUrl}/${openaiPath}`, { headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, diff --git a/app/api/openai/route.ts b/app/api/openai/route.ts index 261c20a85..0ac94bdd5 100644 --- a/app/api/openai/route.ts +++ b/app/api/openai/route.ts @@ -17,7 +17,7 @@ async function makeRequest(req: NextRequest) { }, { status: 500, - }, + } ); } } @@ -29,3 +29,7 @@ export async function POST(req: NextRequest) { export async function GET(req: NextRequest) { return makeRequest(req); } + +export const config = { + runtime: "edge", +}; diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 343caf12b..e1235f771 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -3,6 +3,7 @@ import { memo, useState, useRef, useEffect, useLayoutEffect } from "react"; import SendWhiteIcon from "../icons/send-white.svg"; import BrainIcon from "../icons/brain.svg"; +import RenameIcon from "../icons/rename.svg"; import ExportIcon from "../icons/share.svg"; import ReturnIcon from "../icons/return.svg"; import CopyIcon from "../icons/copy.svg"; @@ -18,6 +19,7 @@ import LightIcon from "../icons/light.svg"; import DarkIcon from "../icons/dark.svg"; import AutoIcon from "../icons/auto.svg"; import BottomIcon from "../icons/bottom.svg"; +import StopIcon from "../icons/pause.svg"; import { Message, @@ -37,7 +39,6 @@ import { isMobileScreen, selectOrCopy, autoGrowTextArea, - getCSSVar, } from "../utils"; import dynamic from "next/dynamic"; @@ -354,8 +355,8 @@ export function ChatActions(props: { }) { const chatStore = useChatStore(); + // switch themes const theme = chatStore.config.theme; - function nextTheme() { const themes = [Theme.Auto, Theme.Light, Theme.Dark]; const themeIndex = themes.indexOf(theme); @@ -364,8 +365,20 @@ export function ChatActions(props: { chatStore.updateConfig((config) => (config.theme = nextTheme)); } + // stop all responses + const couldStop = ControllerPool.hasPending(); + const stopAll = () => ControllerPool.stopAll(); + return (