Skip to content

Commit

Permalink
Merge pull request #1 from Yidadaa/main
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
wuhongyi1977 authored Apr 26, 2023
2 parents 563eb96 + 2deb5cb commit f40f62a
Show file tree
Hide file tree
Showing 46 changed files with 1,552 additions and 724 deletions.
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/反馈问题.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ assignees: ''
---

**反馈须知**

⚠️ 注意:不遵循此模板的任何帖子都会被立即关闭。

> 请在下方中括号内输入 x 来表示你已经知晓相关内容。
- [ ] 我确认已经在 [常见问题](https://github.com/Yidadaa/ChatGPT-Next-Web/blob/main/docs/faq-cn.md) 中搜索了此次反馈的问题,没有找到解答;
- [ ] 我确认已经在 [Issues](https://github.com/Yidadaa/ChatGPT-Next-Web/issues) 列表(包括已经 Close 的)中搜索了此次反馈的问题,没有找到解答。
Expand Down
38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ One-Click to deploy well-designed ChatGPT web UI on Vercel.

[Demo](https://chat-gpt-next-web.vercel.app/) / [Issues](https://github.com/Yidadaa/ChatGPT-Next-Web/issues) / [Join Discord](https://discord.gg/zrhvHCr79N) / [Buy Me a Coffee](https://www.buymeacoffee.com/yidadaa)

[演示](https://chat-gpt-next-web.vercel.app/) / [反馈](https://github.com/Yidadaa/ChatGPT-Next-Web/issues) / [QQ 群](https://user-images.githubusercontent.com/16968934/231789746-41f34d05-6ef9-43f3-a1d1-ff109d4c3c14.jpg) / [打赏开发者](https://user-images.githubusercontent.com/16968934/227772541-5bcd52d8-61b7-488c-a203-0330d8006e2b.jpg)
[演示](https://chat-gpt-next-web.vercel.app/) / [反馈](https://github.com/Yidadaa/ChatGPT-Next-Web/issues) / [QQ 群](https://user-images.githubusercontent.com/16968934/234462588-e8eff256-f5ca-46ef-8f5f-d7db6d28735a.jpg) / [打赏开发者](https://user-images.githubusercontent.com/16968934/227772541-5bcd52d8-61b7-488c-a203-0330d8006e2b.jpg)


[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FYidadaa%2FChatGPT-Next-Web&env=OPENAI_API_KEY&env=CODE&project-name=chatgpt-next-web&repository-name=ChatGPT-Next-Web)

Expand All @@ -35,10 +36,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

Expand All @@ -59,7 +62,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)
Expand Down Expand Up @@ -97,14 +102,16 @@ 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:

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:

![Automatic Updates](./docs/images/enable-actions.jpg)

![Enable Automatic Updates](./docs/images/enable-actions-sync.jpg)

### 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.

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.

Expand Down Expand Up @@ -134,17 +141,15 @@ Access passsword, separated by comma.

### `BASE_URL` (optional)

> Default: `api.openai.com`
> Default: `https://api.openai.com`
Override openai api request base url.
> Examples: `http://your-openai-proxy.com`
### `PROTOCOL` (optional)

> Default: `https`
Override openai api request base url.

> Values: `http` | `https`
### `OPENAI_ORG_ID` (optional)

Override openai api request protocol.
Specify OpenAI organization ID.

## Development

Expand Down Expand Up @@ -225,6 +230,13 @@ 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)
[@hotic](https://github.com/hotic)
[@WingCH](https://github.com/WingCH)
[@jtung4](https://github.com/jtung4)


### Contributor

Expand Down
25 changes: 16 additions & 9 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
- 在 Vercel 重新选择并部署,[请查看详细教程](./docs/vercel-cn.md#如何新建项目)

### 打开自动更新

当你 fork 项目之后,由于 Github 的限制,需要手动去你 fork 后的项目的 Actions 页面启用 Workflows,并启用 Upstream Sync Action,启用之后即可开启每小时定时自动更新:

![自动更新](./docs/images/enable-actions.jpg)
Expand Down Expand Up @@ -85,17 +86,17 @@ OpanAI 密钥,你在 openai 账户页面申请的 api key。

### `BASE_URL` (可选)

> Default: `api.openai.com`
> Default: `https://api.openai.com`
OpenAI 接口代理 URL,如果你手动配置了 openai 接口代理,请填写此选项。
> Examples: `http://your-openai-proxy.com`
### `PROTOCOL` (可选)
OpenAI 接口代理 URL,如果你手动配置了 openai 接口代理,请填写此选项。

> Default: `https`
> 如果遇到 ssl 证书问题,请将 `BASE_URL` 的协议设置为 http。
> Values: `http` | `https`
### `OPENAI_ORG_ID` (可选)

OpenAI 代理接口协议,如果遇到 ssl 证书问题,请尝试通过此选项设置为 http
指定 OpenAI 中的组织 ID

## 开发

Expand All @@ -113,14 +114,16 @@ OPENAI_API_KEY=<your api key here>

### 本地开发

1. 安装 nodejs 和 yarn,具体细节请询问 ChatGPT;
2. 执行 `yarn install && yarn dev` 即可。
1. 安装 nodejs 18 和 yarn,具体细节请询问 ChatGPT;
2. 执行 `yarn install && yarn dev` 即可。⚠️注意:此命令仅用于本地开发,不要用于部署!
3. 如果你想本地部署,请使用 `yarn install && yarn start` 命令,你可以配合 pm2 来守护进程,防止被杀死,详情询问 ChatGPT。

## 部署

### 容器部署 (推荐)
> Docker 版本需要在 20 及其以上,否则会提示找不到镜像。
> 注意:docker 版本在大多数时间都会落后最新的版本 1 到 2 天,所以部署后会持续出现“存在更新”的提示,属于正常现象。
> ⚠️注意:docker 版本在大多数时间都会落后最新的版本 1 到 2 天,所以部署后会持续出现“存在更新”的提示,属于正常现象。
```shell
docker pull yidadaa/chatgpt-next-web
Expand All @@ -142,6 +145,8 @@ docker run -d -p 3000:3000 \
yidadaa/chatgpt-next-web
```

如果你需要指定其他环境变量,请自行在上述命令中增加 `-e 环境变量=环境变量值` 来指定。

### 本地部署

在控制台运行下方命令:
Expand All @@ -150,6 +155,8 @@ docker run -d -p 3000:3000 \
bash <(curl -s https://raw.githubusercontent.com/Yidadaa/ChatGPT-Next-Web/main/scripts/setup.sh)
```

⚠️注意:如果你安装过程中遇到了问题,请使用 docker 部署。

## 鸣谢

### 捐赠者
Expand Down
4 changes: 1 addition & 3 deletions app/api/chat-stream/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,4 @@ export async function POST(req: NextRequest) {
}
}

export const config = {
runtime: "edge",
};
export const runtime = "experimental-edge";
14 changes: 13 additions & 1 deletion app/api/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,24 @@ export async function requestOpenai(req: NextRequest) {
const apiKey = req.headers.get("token");
const openaiPath = req.headers.get("path");

let baseUrl = BASE_URL;

if (!baseUrl.startsWith("http")) {
baseUrl = `${PROTOCOL}://${baseUrl}`;
}

console.log("[Proxy] ", openaiPath);
console.log("[Base Url]", baseUrl);

if (process.env.OPENAI_ORG_ID) {
console.log("[Org ID]", process.env.OPENAI_ORG_ID);
}

return fetch(`${PROTOCOL}://${BASE_URL}/${openaiPath}`, {
return fetch(`${baseUrl}/${openaiPath}`, {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`,
...(process.env.OPENAI_ORG_ID && { "OpenAI-Organization": process.env.OPENAI_ORG_ID }),
},
method: req.method,
body: req.body,
Expand Down
4 changes: 3 additions & 1 deletion app/api/openai/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function makeRequest(req: NextRequest) {
},
{
status: 500,
},
}
);
}
}
Expand All @@ -29,3 +29,5 @@ export async function POST(req: NextRequest) {
export async function GET(req: NextRequest) {
return makeRequest(req);
}

export const runtime = "experimental-edge";
40 changes: 29 additions & 11 deletions app/components/chat-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
import { useChatStore } from "../store";

import Locale from "../locales";
import { isMobileScreen } from "../utils";
import { Link, useNavigate } from "react-router-dom";
import { Path } from "../constant";

export function ChatItem(props: {
onClick?: () => void;
Expand All @@ -21,6 +22,7 @@ export function ChatItem(props: {
selected: boolean;
id: number;
index: number;
narrow?: boolean;
}) {
return (
<Draggable draggableId={`${props.id}`} index={props.index}>
Expand All @@ -34,13 +36,20 @@ export function ChatItem(props: {
{...provided.draggableProps}
{...provided.dragHandleProps}
>
<div className={styles["chat-item-title"]}>{props.title}</div>
<div className={styles["chat-item-info"]}>
<div className={styles["chat-item-count"]}>
{Locale.ChatItem.ChatItemCount(props.count)}
</div>
<div className={styles["chat-item-date"]}>{props.time}</div>
</div>
{props.narrow ? (
<div className={styles["chat-item-narrow"]}>{props.count}</div>
) : (
<>
<div className={styles["chat-item-title"]}>{props.title}</div>
<div className={styles["chat-item-info"]}>
<div className={styles["chat-item-count"]}>
{Locale.ChatItem.ChatItemCount(props.count)}
</div>
<div className={styles["chat-item-date"]}>{props.time}</div>
</div>
</>
)}

<div className={styles["chat-item-delete"]} onClick={props.onDelete}>
<DeleteIcon />
</div>
Expand All @@ -50,7 +59,7 @@ export function ChatItem(props: {
);
}

export function ChatList() {
export function ChatList(props: { narrow?: boolean }) {
const [sessions, selectedIndex, selectSession, removeSession, moveSession] =
useChatStore((state) => [
state.sessions,
Expand All @@ -60,6 +69,7 @@ export function ChatList() {
state.moveSession,
]);
const chatStore = useChatStore();
const navigate = useNavigate();

const onDragEnd: OnDragEndResponder = (result) => {
const { destination, source } = result;
Expand Down Expand Up @@ -95,8 +105,16 @@ export function ChatList() {
id={item.id}
index={i}
selected={i === selectedIndex}
onClick={() => selectSession(i)}
onDelete={() => chatStore.deleteSession(i)}
onClick={() => {
navigate(Path.Chat);
selectSession(i);
}}
onDelete={() => {
if (!props.narrow || confirm(Locale.Home.DeleteChat)) {
chatStore.deleteSession(i);
}
}}
narrow={props.narrow}
/>
))}
{provided.placeholder}
Expand Down
Loading

0 comments on commit f40f62a

Please sign in to comment.