From c9099ca0a5c86ccdcbfd7134daca62f067ca95aa Mon Sep 17 00:00:00 2001 From: lyf <1910527151@qq.com> Date: Wed, 7 Aug 2024 10:55:02 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=97=A0=E9=9A=9C=E7=A2=8D=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=92=8C=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/button.tsx | 10 +++++++++- app/components/chat.tsx | 5 +++++ app/components/sidebar.tsx | 12 ++++++++++-- app/locales/cn.ts | 1 + 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/components/button.tsx b/app/components/button.tsx index c6039acc2..87b4abd30 100644 --- a/app/components/button.tsx +++ b/app/components/button.tsx @@ -18,6 +18,7 @@ export function IconButton(props: { tabIndex?: number; autoFocus?: boolean; style?: CSSProperties; + aria?: string; }) { return ( ); diff --git a/app/components/chat.tsx b/app/components/chat.tsx index e4ba869c3..b18c86708 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -1337,6 +1337,8 @@ function _Chat() { } bordered + title={Locale.Chat.EditMessage.Title} + aria={Locale.Chat.EditMessage.Title} onClick={() => setIsEditingMessage(true)} /> @@ -1356,6 +1358,8 @@ function _Chat() { : } bordered + title={Locale.Chat.Actions.FullScreen} + aria={Locale.Chat.Actions.FullScreen} onClick={() => { config.update( (config) => (config.tightBorder = !config.tightBorder), @@ -1407,6 +1411,7 @@ function _Chat() {
} + aria={Locale.Chat.Actions.Edit} onClick={async () => { const newMessage = await showPrompt( Locale.Chat.Actions.Edit, diff --git a/app/components/sidebar.tsx b/app/components/sidebar.tsx index d8def056e..4ec0f8c84 100644 --- a/app/components/sidebar.tsx +++ b/app/components/sidebar.tsx @@ -297,12 +297,20 @@ export function SideBar(props: { className?: string }) {
- } shadow /> + } + shadow + />
- } shadow /> + } + shadow + />
diff --git a/app/locales/cn.ts b/app/locales/cn.ts index 4f47403ab..4db555422 100644 --- a/app/locales/cn.ts +++ b/app/locales/cn.ts @@ -42,6 +42,7 @@ const cn = { PinToastAction: "查看", Delete: "删除", Edit: "编辑", + FullScreen: "全屏", }, Commands: { new: "新建聊天", From 14ff46b5cd4b2b80b41a0305952410c308353f5a Mon Sep 17 00:00:00 2001 From: lyf <1910527151@qq.com> Date: Wed, 7 Aug 2024 13:01:08 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E6=97=A0=E9=9A=9C=E7=A2=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/input-range.tsx | 3 ++ app/components/mask.tsx | 6 ++++ app/components/model-config.tsx | 11 +++++++ app/components/sd/sd-panel.tsx | 3 ++ app/components/settings.tsx | 52 +++++++++++++++++++++++++++++++++ app/components/ui-lib.tsx | 13 +++++++-- app/locales/cn.ts | 1 + app/locales/en.ts | 2 ++ 8 files changed, 89 insertions(+), 2 deletions(-) diff --git a/app/components/input-range.tsx b/app/components/input-range.tsx index a8ee9532b..08756e2c8 100644 --- a/app/components/input-range.tsx +++ b/app/components/input-range.tsx @@ -9,6 +9,7 @@ interface InputRangeProps { min: string; max: string; step: string; + aria: string; } export function InputRange({ @@ -19,11 +20,13 @@ export function InputRange({ min, max, step, + aria, }: InputRangeProps) { return (
{title || value} setShowPicker(false)} >
setShowPicker(true)} style={{ cursor: "pointer" }} > @@ -139,6 +141,7 @@ export function MaskConfig(props: { @@ -153,6 +156,7 @@ export function MaskConfig(props: { subTitle={Locale.Mask.Config.HideContext.SubTitle} > { @@ -169,6 +173,7 @@ export function MaskConfig(props: { subTitle={Locale.Mask.Config.Share.SubTitle} > } text={Locale.Mask.Config.Share.Action} onClick={copyMaskLink} @@ -182,6 +187,7 @@ export function MaskConfig(props: { subTitle={Locale.Mask.Config.Sync.SubTitle} > { diff --git a/app/components/model-config.tsx b/app/components/model-config.tsx index 346fd3a71..6ce25f664 100644 --- a/app/components/model-config.tsx +++ b/app/components/model-config.tsx @@ -17,6 +17,7 @@ export function ModelConfigList(props: { <> @@ -159,6 +166,7 @@ export function ModelConfigList(props: { subTitle={Locale.Settings.InputTemplate.SubTitle} > @@ -175,6 +183,7 @@ export function ModelConfigList(props: { subTitle={Locale.Settings.HistoryCount.SubTitle} > diff --git a/app/components/sd/sd-panel.tsx b/app/components/sd/sd-panel.tsx index c27fbd54e..a71e560dd 100644 --- a/app/components/sd/sd-panel.tsx +++ b/app/components/sd/sd-panel.tsx @@ -192,6 +192,7 @@ export function ControlParam(props: { required={item.required} > { if (await showConfirm(Locale.Settings.Danger.Reset.Confirm)) { @@ -260,6 +261,7 @@ function DangerItems() { subTitle={Locale.Settings.Danger.Clear.SubTitle} > { if (await showConfirm(Locale.Settings.Danger.Clear.Confirm)) { @@ -513,6 +515,7 @@ function SyncItems() { >
} text={Locale.UI.Config} onClick={() => { @@ -543,6 +546,7 @@ function SyncItems() { >
} text={Locale.UI.Export} onClick={() => { @@ -550,6 +554,7 @@ function SyncItems() { }} /> } text={Locale.UI.Import} onClick={() => { @@ -687,6 +692,7 @@ export function Settings() { subTitle={Locale.Settings.Access.CustomEndpoint.SubTitle} > @@ -706,6 +712,7 @@ export function Settings() { subTitle={Locale.Settings.Access.OpenAI.Endpoint.SubTitle} >
} onClick={() => navigate(Path.Home)} bordered @@ -1267,6 +1304,8 @@ export function Settings() { open={showEmojiPicker} >
{ setShowEmojiPicker(!showEmojiPicker); @@ -1304,6 +1343,7 @@ export function Settings() { { updateConfig( @@ -1339,6 +1380,7 @@ export function Settings() { @@ -1408,6 +1453,7 @@ export function Settings() { subTitle={Locale.Settings.SendPreviewBubble.SubTitle} > @@ -1428,6 +1474,7 @@ export function Settings() { subTitle={Locale.Settings.Mask.Splash.SubTitle} > @@ -1445,6 +1492,7 @@ export function Settings() { subTitle={Locale.Settings.Mask.Builtin.SubTitle} > @@ -1463,6 +1511,7 @@ export function Settings() { subTitle={Locale.Settings.Prompt.Disable.SubTitle} > @@ -1482,6 +1531,7 @@ export function Settings() { )} > } text={Locale.Settings.Prompt.Edit} onClick={() => setShowPromptModal(true)} @@ -1503,6 +1553,7 @@ export function Settings() { subTitle={Locale.Settings.Access.Provider.SubTitle} > ) { - const [visible, setVisible] = useState(false); +// 定义一个接口 AriaProps,包含一个可选的 aria 属性 +interface AriaProps { + aria?: string; +} +// 定义一个接口 PasswordInputProps,继承自 HTMLProps 和 AriaProps +// 用于描述密码输入框组件的属性 +interface PasswordInputProps extends HTMLProps, AriaProps {} + +export function PasswordInput(props: PasswordInputProps) { + const [visible, setVisible] = useState(false); function changeVisibility() { setVisible(!visible); } @@ -275,6 +283,7 @@ export function PasswordInput(props: HTMLProps) { return (
: } onClick={changeVisibility} className={"password-eye"} diff --git a/app/locales/cn.ts b/app/locales/cn.ts index 4db555422..02b3a9d40 100644 --- a/app/locales/cn.ts +++ b/app/locales/cn.ts @@ -133,6 +133,7 @@ const cn = { Settings: { Title: "设置", SubTitle: "所有设置选项", + ShowPassword: "显示密码", Danger: { Reset: { diff --git a/app/locales/en.ts b/app/locales/en.ts index ac7880329..6cca963a9 100644 --- a/app/locales/en.ts +++ b/app/locales/en.ts @@ -44,6 +44,7 @@ const en: LocaleType = { PinToastAction: "View", Delete: "Delete", Edit: "Edit", + FullScreen: "FullScreen", }, Commands: { new: "Start a new chat", @@ -135,6 +136,7 @@ const en: LocaleType = { Settings: { Title: "Settings", SubTitle: "All Settings", + ShowPassword: "ShowPassword", Danger: { Reset: { Title: "Reset All Settings", From 034c82e5149ba03a5d9c690633b7381cf3eea2c2 Mon Sep 17 00:00:00 2001 From: lyf <1910527151@qq.com> Date: Wed, 7 Aug 2024 13:39:23 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E7=9A=84=E6=97=A0=E9=9A=9C=E7=A2=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/sd/sd.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/app/components/sd/sd.tsx b/app/components/sd/sd.tsx index 4f5f86960..0ace62a83 100644 --- a/app/components/sd/sd.tsx +++ b/app/components/sd/sd.tsx @@ -133,6 +133,7 @@ export function Sd() { {showMaxIcon && (
: } bordered onClick={() => { From 0958b9ee12ab9cae387eb595ca0aa30c591c97db Mon Sep 17 00:00:00 2001 From: lyf <1910527151@qq.com> Date: Thu, 8 Aug 2024 13:08:56 +0800 Subject: [PATCH 4/6] tsxiugai --- app/components/ui-lib.tsx | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/app/components/ui-lib.tsx b/app/components/ui-lib.tsx index 88b68d72f..fd78f9c47 100644 --- a/app/components/ui-lib.tsx +++ b/app/components/ui-lib.tsx @@ -265,16 +265,9 @@ export function Input(props: InputProps) { ); } -// 定义一个接口 AriaProps,包含一个可选的 aria 属性 -interface AriaProps { - aria?: string; -} - -// 定义一个接口 PasswordInputProps,继承自 HTMLProps 和 AriaProps -// 用于描述密码输入框组件的属性 -interface PasswordInputProps extends HTMLProps, AriaProps {} - -export function PasswordInput(props: PasswordInputProps) { +export function PasswordInput( + props: HTMLProps & { aria?: string }, +) { const [visible, setVisible] = useState(false); function changeVisibility() { setVisible(!visible); From cc28aef6255d1abed0c5ee675a042e5ffb1f96c0 Mon Sep 17 00:00:00 2001 From: lyf <1910527151@qq.com> Date: Thu, 8 Aug 2024 16:23:40 +0800 Subject: [PATCH 5/6] add gpt-4o-2024-08-06 --- app/constant.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/constant.ts b/app/constant.ts index aa207718c..d21f18f5a 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -243,6 +243,7 @@ export const KnowledgeCutOffDate: Record = { "gpt-4-turbo-preview": "2023-12", "gpt-4o": "2023-10", "gpt-4o-2024-05-13": "2023-10", + "gpt-4o-2024-08-06": "2023-10", "gpt-4o-mini": "2023-10", "gpt-4o-mini-2024-07-18": "2023-10", "gpt-4-vision-preview": "2023-04", @@ -264,6 +265,7 @@ const openaiModels = [ "gpt-4-turbo-preview", "gpt-4o", "gpt-4o-2024-05-13", + "gpt-4o-2024-08-06", "gpt-4o-mini", "gpt-4o-mini-2024-07-18", "gpt-4-vision-preview", From ca865a80dca6c8283e3bf0d4b03c017fe8a2ebfe Mon Sep 17 00:00:00 2001 From: "l.tingting" Date: Sat, 10 Aug 2024 11:09:07 +0800 Subject: [PATCH 6/6] dall-e-3 adds 'quality' and 'style' options --- app/client/api.ts | 2 ++ app/client/platforms/openai.ts | 6 +++- app/components/chat.tsx | 66 +++++++++++++++++++++++++++++++++- app/icons/hd.svg | 4 +++ app/icons/palette.svg | 4 +++ app/store/config.ts | 4 ++- app/typing.ts | 2 ++ 7 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 app/icons/hd.svg create mode 100644 app/icons/palette.svg diff --git a/app/client/api.ts b/app/client/api.ts index 98202c4db..d7fb023a2 100644 --- a/app/client/api.ts +++ b/app/client/api.ts @@ -44,6 +44,8 @@ export interface LLMConfig { presence_penalty?: number; frequency_penalty?: number; size?: DalleRequestPayload["size"]; + quality?: DalleRequestPayload["quality"]; + style?: DalleRequestPayload["style"]; } export interface ChatOptions { diff --git a/app/client/platforms/openai.ts b/app/client/platforms/openai.ts index 98c6f406a..d4e262c16 100644 --- a/app/client/platforms/openai.ts +++ b/app/client/platforms/openai.ts @@ -17,7 +17,7 @@ import { base64Image2Blob, } from "@/app/utils/chat"; import { cloudflareAIGatewayUrl } from "@/app/utils/cloudflare"; -import { DalleSize } from "@/app/typing"; +import { DalleSize, DalleQuality, DalleStyle } from "@/app/typing"; import { ChatOptions, @@ -70,6 +70,8 @@ export interface DalleRequestPayload { response_format: "url" | "b64_json"; n: number; size: DalleSize; + quality: DalleQuality; + style: DalleStyle; } export class ChatGPTApi implements LLMApi { @@ -162,6 +164,8 @@ export class ChatGPTApi implements LLMApi { response_format: "b64_json", // using b64_json, and save image in CacheStorage n: 1, size: options.config?.size ?? "1024x1024", + quality: options.config?.quality ?? "standard", + style: options.config?.style ?? "vivid", }; } else { const visionModel = isVisionModel(options.config.model); diff --git a/app/components/chat.tsx b/app/components/chat.tsx index b18c86708..52befde13 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -38,6 +38,8 @@ import BottomIcon from "../icons/bottom.svg"; import StopIcon from "../icons/pause.svg"; import RobotIcon from "../icons/robot.svg"; import SizeIcon from "../icons/size.svg"; +import QualityIcon from "../icons/hd.svg"; +import StyleIcon from "../icons/palette.svg"; import PluginIcon from "../icons/plugin.svg"; import { @@ -69,7 +71,7 @@ import { uploadImage as uploadImageRemote } from "@/app/utils/chat"; import dynamic from "next/dynamic"; import { ChatControllerPool } from "../client/controller"; -import { DalleSize } from "../typing"; +import { DalleSize, DalleQuality, DalleStyle } from "../typing"; import { Prompt, usePromptStore } from "../store/prompt"; import Locale from "../locales"; @@ -485,9 +487,17 @@ export function ChatActions(props: { const [showUploadImage, setShowUploadImage] = useState(false); const [showSizeSelector, setShowSizeSelector] = useState(false); + const [showQualitySelector, setShowQualitySelector] = useState(false); + const [showStyleSelector, setShowStyleSelector] = useState(false); const dalle3Sizes: DalleSize[] = ["1024x1024", "1792x1024", "1024x1792"]; + const dalle3Qualitys: DalleQuality[] = ["standard", "hd"]; + const dalle3Styles: DalleStyle[] = ["vivid", "natural"]; const currentSize = chatStore.currentSession().mask.modelConfig?.size ?? "1024x1024"; + const currentQuality = + chatStore.currentSession().mask.modelConfig?.quality ?? "standard"; + const currentStyle = + chatStore.currentSession().mask.modelConfig?.style ?? "vivid"; useEffect(() => { const show = isVisionModel(currentModel); @@ -659,6 +669,60 @@ export function ChatActions(props: { /> )} + {isDalle3(currentModel) && ( + setShowQualitySelector(true)} + text={currentQuality} + icon={} + /> + )} + + {showQualitySelector && ( + ({ + title: m, + value: m, + }))} + onClose={() => setShowQualitySelector(false)} + onSelection={(q) => { + if (q.length === 0) return; + const quality = q[0]; + chatStore.updateCurrentSession((session) => { + session.mask.modelConfig.quality = quality; + }); + showToast(quality); + }} + /> + )} + + {isDalle3(currentModel) && ( + setShowStyleSelector(true)} + text={currentStyle} + icon={} + /> + )} + + {showStyleSelector && ( + ({ + title: m, + value: m, + }))} + onClose={() => setShowStyleSelector(false)} + onSelection={(s) => { + if (s.length === 0) return; + const style = s[0]; + chatStore.updateCurrentSession((session) => { + session.mask.modelConfig.style = style; + }); + showToast(style); + }} + /> + )} + setShowPluginSelector(true)} text={Locale.Plugin.Name} diff --git a/app/icons/hd.svg b/app/icons/hd.svg new file mode 100644 index 000000000..baae66af0 --- /dev/null +++ b/app/icons/hd.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/app/icons/palette.svg b/app/icons/palette.svg new file mode 100644 index 000000000..474d0e217 --- /dev/null +++ b/app/icons/palette.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/app/store/config.ts b/app/store/config.ts index b478858a9..e8e3c9863 100644 --- a/app/store/config.ts +++ b/app/store/config.ts @@ -1,5 +1,5 @@ import { LLMModel } from "../client/api"; -import { DalleSize } from "../typing"; +import { DalleSize, DalleQuality, DalleStyle } from "../typing"; import { getClientConfig } from "../config/client"; import { DEFAULT_INPUT_TEMPLATE, @@ -63,6 +63,8 @@ export const DEFAULT_CONFIG = { enableInjectSystemPrompts: true, template: config?.template ?? DEFAULT_INPUT_TEMPLATE, size: "1024x1024" as DalleSize, + quality: "standard" as DalleQuality, + style: "vivid" as DalleStyle, }, }; diff --git a/app/typing.ts b/app/typing.ts index 863203581..0336be75d 100644 --- a/app/typing.ts +++ b/app/typing.ts @@ -9,3 +9,5 @@ export interface RequestMessage { } export type DalleSize = "1024x1024" | "1792x1024" | "1024x1792"; +export type DalleQuality = "standard" | "hd"; +export type DalleStyle = "vivid" | "natural";