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

禁用gpt-4不禁用gpt-4o-mini #5206

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion app/api/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function getModels(remoteModelRes: OpenAIListModelResponse) {

if (config.disableGPT4) {
remoteModelRes.data = remoteModelRes.data.filter(
(m) => !m.id.startsWith("gpt-4"),
(m) => !m.id.startsWith("gpt-4") || m.id.startsWith("gpt-40-mini"),
);
}

Expand Down
10 changes: 9 additions & 1 deletion app/components/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function IconButton(props: {
tabIndex?: number;
autoFocus?: boolean;
style?: CSSProperties;
aria?: string;
}) {
return (
<button
Expand All @@ -34,9 +35,11 @@ export function IconButton(props: {
tabIndex={props.tabIndex}
autoFocus={props.autoFocus}
style={props.style}
aria-label={props.aria}
>
{props.icon && (
<div
aria-label={props.text || props.title}
className={
styles["icon-button-icon"] +
` ${props.type === "primary" && "no-dark"}`
Expand All @@ -47,7 +50,12 @@ export function IconButton(props: {
)}

{props.text && (
<div className={styles["icon-button-text"]}>{props.text}</div>
<div
aria-label={props.text || props.title}
className={styles["icon-button-text"]}
>
{props.text}
</div>
)}
</button>
);
Expand Down
7 changes: 6 additions & 1 deletion app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ export function ChatAction(props: {
} as React.CSSProperties
}
>
<div ref={iconRef} className={styles["icon"]}>
<div ref={iconRef} className={styles["icon"]} aria-label={props.text}>
{props.icon}
</div>
<div className={styles["text"]} ref={textRef}>
Expand Down Expand Up @@ -1337,6 +1337,8 @@ function _Chat() {
<IconButton
icon={<RenameIcon />}
bordered
title={Locale.Chat.EditMessage.Title}
aria={Locale.Chat.EditMessage.Title}
Comment on lines +1340 to +1341
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove redundant aria attribute.

The aria attribute on the IconButton is redundant. Use aria-label instead.

-  <IconButton
-    icon={<RenameIcon />}
-    bordered
-    title={Locale.Chat.EditMessage.Title}
-    aria={Locale.Chat.EditMessage.Title}
-    onClick={() => setIsEditingMessage(true)}
-  />
+  <IconButton
+    icon={<RenameIcon />}
+    bordered
+    title={Locale.Chat.EditMessage.Title}
+    aria-label={Locale.Chat.EditMessage.Title}
+    onClick={() => setIsEditingMessage(true)}
+  />
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
title={Locale.Chat.EditMessage.Title}
aria={Locale.Chat.EditMessage.Title}
<IconButton
icon={<RenameIcon />}
bordered
title={Locale.Chat.EditMessage.Title}
aria-label={Locale.Chat.EditMessage.Title}
onClick={() => setIsEditingMessage(true)}
/>

onClick={() => setIsEditingMessage(true)}
/>
</div>
Expand All @@ -1356,6 +1358,8 @@ function _Chat() {
<IconButton
icon={config.tightBorder ? <MinIcon /> : <MaxIcon />}
bordered
title={Locale.Chat.Actions.FullScreen}
aria={Locale.Chat.Actions.FullScreen}
Comment on lines +1361 to +1362
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove redundant aria attribute.

The aria attribute on the IconButton is redundant. Use aria-label instead.

-  <IconButton
-    icon={config.tightBorder ? <MinIcon /> : <MaxIcon />}
-    bordered
-    title={Locale.Chat.Actions.FullScreen}
-    aria={Locale.Chat.Actions.FullScreen}
-    onClick={() => {
-      config.update(
-        (config) => (config.tightBorder = !config.tightBorder),
-      );
-    }}
-  />
+  <IconButton
+    icon={config.tightBorder ? <MinIcon /> : <MaxIcon />}
+    bordered
+    title={Locale.Chat.Actions.FullScreen}
+    aria-label={Locale.Chat.Actions.FullScreen}
+    onClick={() => {
+      config.update(
+        (config) => (config.tightBorder = !config.tightBorder),
+      );
+    }}
+  />
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
title={Locale.Chat.Actions.FullScreen}
aria={Locale.Chat.Actions.FullScreen}
title={Locale.Chat.Actions.FullScreen}
aria-label={Locale.Chat.Actions.FullScreen}

onClick={() => {
config.update(
(config) => (config.tightBorder = !config.tightBorder),
Expand Down Expand Up @@ -1407,6 +1411,7 @@ function _Chat() {
<div className={styles["chat-message-edit"]}>
<IconButton
icon={<EditIcon />}
aria={Locale.Chat.Actions.Edit}
onClick={async () => {
const newMessage = await showPrompt(
Locale.Chat.Actions.Edit,
Expand Down
19 changes: 15 additions & 4 deletions app/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,10 @@ export function SideBar(props: { className?: string }) {
<SideBarTail
primaryAction={
<>
<div className={styles["sidebar-action"] + " " + styles.mobile}>
<div
aria-label={Locale.Settings.Title}
className={styles["sidebar-action"] + " " + styles.mobile}
>
Comment on lines +288 to +291
Copy link
Contributor

Choose a reason for hiding this comment

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

Add aria-label for delete action button.

The aria-label attribute is missing for the IconButton within the delete action div.

+  <IconButton
+    icon={<DeleteIcon />}
+    aria-label={Locale.Home.DeleteChat}
+    onClick={async () => {
+      if (await showConfirm(Locale.Home.DeleteChat)) {
+        chatStore.deleteSession(chatStore.currentSessionIndex);
+      }
+    }}
  />

Committable suggestion was skipped due to low confidence.

<IconButton
icon={<DeleteIcon />}
onClick={async () => {
Expand All @@ -296,13 +299,21 @@ export function SideBar(props: { className?: string }) {
/>
</div>
<div className={styles["sidebar-action"]}>
<Link to={Path.Settings}>
<IconButton icon={<SettingsIcon />} shadow />
<Link to={Path.Settings} aria-label={Locale.Settings.Title}>
<IconButton
aria={Locale.Settings.Title}
icon={<SettingsIcon />}
shadow
/>
Comment on lines +302 to +307
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove redundant aria attribute.

The aria attribute on the IconButton is redundant. Use aria-label instead.

-  <IconButton
-    aria={Locale.Settings.Title}
-    icon={<SettingsIcon />}
-    shadow
-  />
+  <IconButton
+    aria-label={Locale.Settings.Title}
+    icon={<SettingsIcon />}
+    shadow
+  />
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
<Link to={Path.Settings} aria-label={Locale.Settings.Title}>
<IconButton
aria={Locale.Settings.Title}
icon={<SettingsIcon />}
shadow
/>
<Link to={Path.Settings} aria-label={Locale.Settings.Title}>
<IconButton
aria-label={Locale.Settings.Title}
icon={<SettingsIcon />}
shadow
/>

</Link>
</div>
<div className={styles["sidebar-action"]}>
<a href={REPO_URL} target="_blank" rel="noopener noreferrer">
<IconButton icon={<GithubIcon />} shadow />
<IconButton
aria={Locale.Export.MessageFromChatGPT}
icon={<GithubIcon />}
shadow
/>
Comment on lines +312 to +316
Copy link
Contributor

Choose a reason for hiding this comment

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

Add aria-label for GitHub link button.

The aria attribute on the IconButton is redundant. Use aria-label instead.

-  <IconButton
-    aria={Locale.Export.MessageFromChatGPT}
-    icon={<GithubIcon />}
-    shadow
-  />
+  <IconButton
+    aria-label={Locale.Export.MessageFromChatGPT}
+    icon={<GithubIcon />}
+    shadow
+  />
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
<IconButton
aria={Locale.Export.MessageFromChatGPT}
icon={<GithubIcon />}
shadow
/>
<IconButton
aria-label={Locale.Export.MessageFromChatGPT}
icon={<GithubIcon />}
shadow
/>

</a>
</div>
</>
Expand Down
10 changes: 8 additions & 2 deletions app/config/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,16 @@ export const getServerSideConfig = () => {

if (disableGPT4) {
if (customModels) customModels += ",";
customModels += DEFAULT_MODELS.filter((m) => m.name.startsWith("gpt-4"))
customModels += DEFAULT_MODELS.filter(
(m) => m.name.startsWith("gpt-4") && !m.name.startsWith("gpt-4o-mini"),
)
.map((m) => "-" + m.name)
.join(",");
if (defaultModel.startsWith("gpt-4")) defaultModel = "";
if (
defaultModel.startsWith("gpt-4") &&
!defaultModel.startsWith("gpt-4o-mini")
)
defaultModel = "";
}

const isStability = !!process.env.STABILITY_API_KEY;
Expand Down
1 change: 1 addition & 0 deletions app/locales/cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const cn = {
PinToastAction: "查看",
Delete: "删除",
Edit: "编辑",
FullScreen: "全屏",
},
Commands: {
new: "新建聊天",
Expand Down
Loading