Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(model): remove deprecated models #4982

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/api/google/[...path]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ export const GET = handle;
export const POST = handle;

export const runtime = "edge";

// due to Gemini-1.5-pro is not available in Hong Kong, we need to set the preferred region to exclude "Hong Kong (hkg1)".
// the paid service of the Gemini API is required in the following regions until 8 July 2024. The free service is not available. Therefore, the regions is temporarily disabled.
// regions include Dublin (dub1, Ireland), Paris (cdg1, France), Frankfurt (fra1, Germany), London (lhr1, UK), and Stockholm (arn1, Sweden).
// refs: https://ai.google.dev/gemini-api/docs/available-regions
export const preferredRegion = [
"bom1",
"cle1",
Expand Down
6 changes: 0 additions & 6 deletions app/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,21 +197,16 @@ export const KnowledgeCutOffDate: Record<string, string> = {
"gpt-4o-2024-05-13": "2023-10",
"gpt-4o-mini": "2023-10",
"gpt-4o-mini-2024-07-18": "2023-10",
"gpt-4-vision-preview": "2023-04",
// After improvements,
// it's now easier to add "KnowledgeCutOffDate" instead of stupid hardcoding it, as was done previously.
"gemini-pro": "2023-12",
"gemini-pro-vision": "2023-12",
};

const openaiModels = [
"gpt-3.5-turbo",
"gpt-3.5-turbo-1106",
"gpt-3.5-turbo-0125",
"gpt-4",
"gpt-4-0613",
"gpt-4-32k",
"gpt-4-32k-0613",
"gpt-4-turbo",
"gpt-4-turbo-preview",
"gpt-4o",
Expand All @@ -227,7 +222,6 @@ const googleModels = [
"gemini-1.0-pro",
"gemini-1.5-pro-latest",
"gemini-1.5-flash-latest",
"gemini-pro-vision",
];

const anthropicModels = [
Expand Down
15 changes: 2 additions & 13 deletions app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,18 +250,7 @@ export function getMessageImages(message: RequestMessage): string[] {
export function isVisionModel(model: string) {
// Note: This is a better way using the TypeScript feature instead of `&&` or `||` (ts v5.5.0-dev.20240314 I've been using)

const visionKeywords = [
"vision",
"claude-3",
"gemini-1.5-pro",
"gemini-1.5-flash",
"gpt-4o",
"gpt-4o-mini",
];
const isGpt4Turbo =
model.includes("gpt-4-turbo") && !model.includes("preview");
const visionKeywords = ["claude-3", "gemini-1.5", "gpt-4"];

return (
visionKeywords.some((keyword) => model.includes(keyword)) || isGpt4Turbo
);
return visionKeywords.some((keyword) => model.includes(keyword));
}
35 changes: 11 additions & 24 deletions docs/faq-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# 部署相关问题

各种部署方式详细教程参考https://rptzik3toh.feishu.cn/docx/XtrdduHwXoSCGIxeFLlcEPsdn8b
各种部署方式详细教程参考: [link](https://rptzik3toh.feishu.cn/docx/XtrdduHwXoSCGIxeFLlcEPsdn8b)

## 为什么 Docker 部署版本一直提示更新

Expand Down Expand Up @@ -80,7 +80,7 @@ keepalive_timeout 300; # 设定keep-alive超时时间为65秒

## 为什么 docker 部署后出现网络错误?

详见讨论https://github.com/Yidadaa/ChatGPT-Next-Web/issues/1569
详见讨论: [link](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/1569)

# 使用相关问题

Expand Down Expand Up @@ -109,12 +109,12 @@ API KEY 有问题。余额不足。

为了减少首屏白屏时间,默认启用了分块编译,技术原理见下:

- https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading
- https://stackoverflow.com/questions/55993890/how-can-i-disable-chunkcode-splitting-with-webpack4
- https://github.com/vercel/next.js/issues/38507
- https://stackoverflow.com/questions/55993890/how-can-i-disable-chunkcode-splitting-with-webpack4
- [Next.js Lazy Loading](https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading)
- [Stack Overflow: Disable Chunk Code Splitting](https://stackoverflow.com/questions/55993890/how-can-i-disable-chunkcode-splitting-with-webpack4)
- [Vercel Issue 38507](https://github.com/vercel/next.js/issues/38507)
- [Stack Overflow: Disable Chunk Code Splitting](https://stackoverflow.com/questions/55993890/how-can-i-disable-chunkcode-splitting-with-webpack4)

然而 NextJS 的兼容性比较差,在比较老的浏览器上会导致此报错,可以在编译时关闭分块编译。
然而 Next.JS 的兼容性比较差,在比较老的浏览器上会导致此报错,可以在编译时关闭分块编译。

对于 Vercel 平台,在环境变量中增加 `DISABLE_CHUNK=1`,然后重新部署即可;
对于自行编译部署的项目,在构建时使用 `DISABLE_CHUNK=1 yarn build` 构建即可;
Expand Down Expand Up @@ -187,12 +187,6 @@ OpenAI 只接受指定地区的信用卡(中国信用卡无法使用)。一
2. 申请国外信用卡
3. 网上找人代充

## 如何使用 GPT-4 的 API 访问?

- GPT-4 的 API 访问需要单独申请。到以下地址填写你的信息进入申请队列 waitlist(准备好你的 OpenAI 组织 ID):https://openai.com/waitlist/gpt-4-api
之后等待邮件消息。
- 开通 ChatGPT Plus 不代表有 GPT-4 权限,两者毫无关系。

## 如何使用 Azure OpenAI 接口

请参考:[#371](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/371)
Expand All @@ -215,14 +209,7 @@ OpenAI 网站计费说明:https://openai.com/pricing#language-models
OpenAI 根据 token 数收费,1000 个 token 通常可代表 750 个英文单词,或 500 个汉字。输入(Prompt)和输出(Completion)分别统计费用。
|模型|用户输入(Prompt)计费|模型输出(Completion)计费|每次交互最大 token 数|
|----|----|----|----|
|gpt-3.5-turbo|$0.0015 / 1 千 tokens|$0.002 / 1 千 tokens|4096|
|gpt-3.5-turbo-16K|$0.003 / 1 千 tokens|$0.004 / 1 千 tokens|16384|
|gpt-4|$0.03 / 1 千 tokens|$0.06 / 1 千 tokens|8192|
|gpt-4-32K|$0.06 / 1 千 tokens|$0.12 / 1 千 tokens|32768|

## gpt-3.5-turbo 和 gpt3.5-turbo-0301(或者 gpt3.5-turbo-mmdd)模型有什么区别?

官方文档说明:https://platform.openai.com/docs/models/gpt-3-5

- gpt-3.5-turbo 是最新的模型,会不断得到更新。
- gpt-3.5-turbo-0301 是 3 月 1 日定格的模型快照,不会变化,预期 3 个月后被新快照替代。
|gpt-3.5-turbo|$0.0005 / 1 千 tokens|$0.0015 / 1 千 tokens|16384|
|gpt-4|$0.030 / 1 千 tokens|$0.060 / 1 千 tokens|8192|
|gpt-4-turbo|$0.010 / 1 千 tokens|$0.030 / 1 千 tokens|128000|
|gpt-4o|$0.005 / 1 千 tokens|$0.015 / 1 千 tokens|128000|
86 changes: 47 additions & 39 deletions docs/faq-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

# Deployment Related Questions

For detailed tutorials on various deployment methods, please refer to: [link](https://rptzik3toh.feishu.cn/docx/XtrdduHwXoSCGIxeFLlcEPsdn8b)

## Why does the Docker deployment version always prompt for updates

The Docker version is equivalent to the stable version, and the latest Docker is always consistent with the latest release version. Currently, our release frequency is once every one to two days, so the Docker version will always be one to two days behind the latest commit, which is expected.
Expand Down Expand Up @@ -62,62 +64,67 @@ Please check and troubleshoot the following issues:
- Is the route to the server okay?
- Is the domain name resolved correctly?

## You may encounter an "Error: Loading CSS chunk xxx failed..."
## What is a proxy and how do I use it?

Due to OpenAI's IP restrictions, China and some other countries/regions cannot directly connect to the OpenAI API and need to use a proxy. You can use a proxy server (forward proxy), or a pre-configured OpenAI API reverse proxy.

- Example of forward proxy: scientific internet access VPN. In the case of docker deployment, set the environment variable HTTP_PROXY to your proxy address (for example: 10.10.10.10:8002).
- Example of reverse proxy: you can use someone else's built-in proxy address, or set it up through Cloudflare for free. Set the project environment variable BASE_URL to your proxy address.

To reduce the initial white screen time, Next.js enables chunking by default. You can find the technical details here:
## Can I deploy on a domestic server?

- https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading
- https://stackoverflow.com/questions/55993890/how-can-i-disable-chunkcode-splitting-with-webpack4
- https://github.com/vercel/next.js/issues/38507
- https://stackoverflow.com/questions/55993890/how-can-i-disable-chunkcode-splitting-with-webpack4
You can, but you need to solve the following problems:

However, Next.js has limited compatibility with older browsers, which can result in this error.
- You need a proxy to connect to websites like github and openAI;
- If you set up domain name resolution on a domestic server, you need to go through the process of domain name registration;
- Domestic policies restrict proxy access to foreign networks/ChatGPT related applications, which may lead to blocking.

You can disable chunking during building.
## Why do I get network errors after Docker deployment?

For Vercel platform, you can add `DISABLE_CHUNK=1` to the environment variables and redeploy.
For self-deployed projects, you can use `DISABLE_CHUNK=1 yarn build` during the build process.
For Docker users, as the build is already completed during packaging, disabling this feature is currently not supported.
See discussion: [link](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/1569)

Note that when you disable this feature, all resources will be loaded on the user's first visit. This may result in a longer white screen time if the user has a poor network connection, affecting the user experience. Please consider this when making a decision.
# Usage Related Issues

# Usage Related Questions
## Why does it keep prompting "Something went wrong, please try again later"?

## Why does it always prompt "An error occurred, please try again later"
There could be many reasons. Please troubleshoot them in order:

There could be many reasons, please check the following in order:
- Please check if your code version is the latest version. Update to the latest version and try again;
- Please check if your api key is set correctly. The environment variable name must be in all uppercase with an underscore;
- Please check if your api key is valid;
- If you have gone through the above steps and still cannot determine the problem, please submit a new issue in the issue section and attach the runtime log of vercel or the log of docker running.

- First, check if your code version is the latest version, update to the latest version and try again;
- Check if the api key is set correctly, the environment variable name must be uppercase with underscores;
- Check if the api key is available;
- If you still cannot determine the problem after going through the above steps, please submit a new issue in the issue area and attach the runtime log of vercel or the log of docker runtime.
## Why is the ChatGPT reply garbled?

## Why does ChatGPT's reply get garbled
In the settings interface - model settings section, there is an item called `temperature`. If this value is greater than 1, it may cause the reply to be garbled. Setting it back to 1 or less will solve the issue.

In the settings page - model settings, there is an item called `temperature`. If this value is greater than 1, it may cause garbled replies. Adjust it back to within 1.
## When using it, it prompts "Unauthorized state, please enter the access code in the settings page"?

## It prompts "Now it's unauthorized, please enter the access password on the settings page" when using?
The project has set an access password through the environment variable CODE. The first time you use it, you need to go to the settings and enter the access code to use it.

The project has set an access password through the environment variable CODE. When using it for the first time, you need to go to settings and enter the access code to use.
## When using it, it prompts "You exceeded your current quota, ..."

## It prompts "You exceeded your current quota, ..." when using?
There is a problem with the API KEY. Insufficient balance.

The API KEY is problematic. Insufficient balance.
## When using it, it prompts "Error: Loading CSS chunk xxx failed..."

## What is a proxy and how to use it?
In order to reduce the white screen time on the first screen, chunk compilation is enabled by default. The technical principle is as follows:

Due to IP restrictions of OpenAI, China and some other countries/regions cannot directly connect to OpenAI API and need to go through a proxy. You can use a proxy server (forward proxy) or a pre-configured OpenAI API reverse proxy.
- [Next.js Lazy Loading](https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading)
- [Stack Overflow: Disable Chunk Code Splitting](https://stackoverflow.com/questions/55993890/how-can-i-disable-chunkcode-splitting-with-webpack4)
- [Vercel Issue 38507](https://github.com/vercel/next.js/issues/38507)
- [Stack Overflow: Disable Chunk Code Splitting](https://stackoverflow.com/questions/55993890/how-can-i-disable-chunkcode-splitting-with-webpack4)

- Forward proxy example: VPN ladder. In the case of docker deployment, set the environment variable HTTP_PROXY to your proxy address (http://address:port).
- Reverse proxy example: You can use someone else's proxy address or set it up for free through Cloudflare. Set the project environment variable BASE_URL to your proxy address.
However, Next.js's compatibility is relatively poor, which can cause this error on older browsers. You can turn off chunk compilation during compilation.

## Can I deploy it on a server in China?
For the Vercel platform, add `DISABLE_CHUNK=1` to the environment variables and redeploy.
For self-compiled deployment projects, use `DISABLE_CHUNK=1 yarn build` to build during construction.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid repetition.

Reword the sentence to avoid repetition at the beginning of successive sentences.

- For self-compiled deployment projects, use `DISABLE_CHUNK=1 yarn build` to build during construction.
- For Docker users, chunk compilation is completed during Docker packaging, so this feature is not supported for the time being.
+ For self-compiled deployment projects, build using `DISABLE_CHUNK=1 yarn build`.
+ Docker users cannot disable this feature as chunk compilation is completed during Docker packaging.
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
For self-compiled deployment projects, use `DISABLE_CHUNK=1 yarn build` to build during construction.
For self-compiled deployment projects, build using `DISABLE_CHUNK=1 yarn build`.
Docker users cannot disable this feature as chunk compilation is completed during Docker packaging.
Tools
LanguageTool

[style] ~121-~121: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...rn build` to build during construction. For Docker users, chunk compilation is comp...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

For Docker users, chunk compilation is completed during Docker packaging, so this feature is not supported for the time being.

It is possible but there are issues to be addressed:
Note: If you disable this feature, users will load all resources on the first visit to the website. If the user's network condition is poor, it may cause a long white screen, which will affect the user experience. Please consider this carefully.

- Proxy is required to connect to websites such as Github and OpenAI;
- Domain name resolution requires filing for servers in China;
- Chinese policy restricts proxy access to foreign websites/ChatGPT-related applications, which may be blocked.
## When using it, it prompts "NotFoundError: Failed to execute 'removeChild' on 'Node': The node...."
Please disable the browser's own automatic translation function and disable all automatic translation plugins.

# Network Service Related Questions

Expand Down Expand Up @@ -169,11 +176,6 @@ OpenAI only accepts credit cards from designated regions (Chinese credit cards c
2. Apply for a foreign credit card
3. Find someone online to top up

## How to access the GPT-4 API?

(Updated April 6th) Access to the GPT-4 API requires a separate application. Go to the following address and enter your information to join the waitlist (prepare your OpenAI organization ID): https://openai.com/waitlist/gpt-4-api
Wait for email updates afterwards.

## How to use the Azure OpenAI interface

Please refer to: [#371](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/371)
Expand All @@ -189,3 +191,9 @@ Please refer to: [#371](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/371)
- By following these two methods, you can locate the reason for your token's rapid consumption:
- If the OpenAI consumption record is abnormal but the Docker log has no issues, it means your API key has been leaked;
- If the Docker log shows a large number of got access code brute-force attempts, your password has been cracked.
| Model | User input (Prompt) billing | Model output (Completion) billing | Maximum number of tokens per interaction |
|----|----|----|----|
| gpt-3.5-turbo | $0.0005 / 1k tokens | $0.0015 / 1k tokens | 16384 |
| gpt-4 | $0.030 / 1k tokens | $0.060 / 1k tokens | 8192 |
| gpt-4-turbo | $0.010 / 1k tokens | $0.030 / 1k tokens | 128000 |
| gpt-4o | $0.005 / 1k tokens | $0.015 / 1k tokens | 128000 |
Loading
Loading