Skip to content

Commit 1325eb1

Browse files
author
xcatliu
committed
feat: gpt-5 暂时不可用,因为必须上传身份证。所以退回到 gpt-4o
1 parent 9c1c287 commit 1325eb1

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

app/context/ChatContext.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const ChatProvider: FC<{ children: ReactNode }> = ({ children }) => {
6464
let settings = getCache<SettingsState>('settings');
6565
// 如果检测到缓存中有上次还未存储到 cache 的 message,则加入到 history 中
6666
if (messages && messages.length > 0) {
67-
history = [{ model: settings?.model ?? Model['gpt-5'], messages }, ...(history ?? [])];
67+
history = [{ model: settings?.model ?? Model['gpt-4o'], messages }, ...(history ?? [])];
6868
setHistory(history);
6969
setCache('history', history);
7070
setMessages([]);
@@ -229,7 +229,7 @@ export const ChatProvider: FC<{ children: ReactNode }> = ({ children }) => {
229229
return;
230230
}
231231

232-
const newModel = history?.[index].model ?? Model['gpt-5'];
232+
const newModel = history?.[index].model ?? Model['gpt-4o'];
233233

234234
if (historyIndex === 'empty') {
235235
setHistoryIndex(index);
@@ -284,7 +284,7 @@ export const ChatProvider: FC<{ children: ReactNode }> = ({ children }) => {
284284
const newIndex = history && history.length > 0 ? 0 : 'empty';
285285
setHistoryIndex(newIndex);
286286
if (typeof newIndex === 'number') {
287-
const newModel = history?.[newIndex].model ?? Model['gpt-5'];
287+
const newModel = history?.[newIndex].model ?? Model['gpt-4o'];
288288
setSettings({
289289
model: newModel,
290290
});
@@ -303,7 +303,7 @@ export const ChatProvider: FC<{ children: ReactNode }> = ({ children }) => {
303303
const newIndex = newHistory && newHistory.length > 0 ? Math.min(deleteIndex, newHistory.length - 1) : 'empty';
304304
setHistoryIndex(newIndex);
305305
if (typeof newIndex === 'number') {
306-
const newModel = newHistory[newIndex].model ?? Model['gpt-5'];
306+
const newModel = newHistory[newIndex].model ?? Model['gpt-4o'];
307307
setSettings({
308308
model: newModel,
309309
});

app/context/SettingsContext.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ export interface SettingsState extends Omit<ChatRequest, 'messages'> {
1717
}
1818

1919
const INITIAL_SETTINGS: SettingsState = {
20-
newChatModel: Model['gpt-5'],
21-
model: Model['gpt-5'],
20+
newChatModel: Model['gpt-4o'],
21+
model: Model['gpt-4o'],
2222
maxHistoryLength: 6,
23-
availableModels: [Model['gpt-5']],
23+
availableModels: [Model['gpt-4o']],
2424
};
2525

2626
enum SettingsActionType {

app/utils/constants.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,29 @@ export enum Role {
3838
* ChatGPT 模型
3939
*/
4040
export enum Model {
41+
'gpt-4o' = 'gpt-4o',
42+
'gpt-4o-mini' = 'gpt-4o-mini',
4143
'gpt-5' = 'gpt-5',
4244
'gpt-5-mini' = 'gpt-5-mini',
4345
'gpt-5-nano' = 'gpt-5-nano',
4446
}
4547

46-
export const AllModels = [Model['gpt-5'], Model['gpt-5-mini'], Model['gpt-5-nano']];
48+
export const AllModels = [
49+
Model['gpt-4o'],
50+
Model['gpt-4o-mini'],
51+
Model['gpt-5'],
52+
Model['gpt-5-mini'],
53+
Model['gpt-5-nano'],
54+
];
4755

4856
/** 支持发送图片的模型 */
49-
export const VisionModels = [Model['gpt-5'], Model['gpt-5-mini'], Model['gpt-5-nano']];
57+
export const VisionModels = [
58+
Model['gpt-4o'],
59+
Model['gpt-4o-mini'],
60+
Model['gpt-5'],
61+
Model['gpt-5-mini'],
62+
Model['gpt-5-nano'],
63+
];
5064

5165
export enum MessageContentType {
5266
text = 'text',
@@ -153,6 +167,10 @@ export interface ChatRequest {
153167
* 结束语,最多设置四个,如果 ChatGPT 的回复中包含某个结束语,则停止生成
154168
*/
155169
stop?: string | string[];
170+
/**
171+
* tokens 限制
172+
*/
173+
max_tokens?: number;
156174
/**
157175
* 存在惩罚,取值范围 -2.0 到 2.0
158176
*
@@ -286,7 +304,7 @@ export const exampleModelsResponse: ModelsResponse = {
286304
data: [
287305
{
288306
created: 1677610602,
289-
id: Model['gpt-5'],
307+
id: Model['gpt-4o'],
290308
object: 'model',
291309
owned_by: 'openai',
292310
parent: null,
@@ -306,7 +324,7 @@ export const exampleModelsResponse: ModelsResponse = {
306324
organization: '*',
307325
},
308326
},
309-
root: Model['gpt-5'],
327+
root: Model['gpt-4o'],
310328
},
311329
],
312330
object: 'list',

0 commit comments

Comments
 (0)