From c5350ca443dabd3189e211ac481655c681ed3a39 Mon Sep 17 00:00:00 2001 From: weaigc <879821485@qq.com> Date: Sun, 26 Nov 2023 00:54:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20gpt4=E6=A8=A1=E5=BC=8F=E5=8F=8A?= =?UTF-8?q?=E9=A2=84=E8=AE=BE=E4=BA=BA=E6=A0=BC=E6=A8=A1=E5=BC=8F=E4=B8=8D?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=AF=86=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/components/chat-image.tsx | 6 +++++- src/lib/bots/bing/index.ts | 5 +++-- src/lib/hooks/use-bing.ts | 2 +- src/pages/api/kblob.ts | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 898e96af..23ad831e 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Bingo,一个让你呼吸顺畅 New Bing。 - [x] 支持画图 - [x] 支持语音输入(支持语音指令,目前仅支持 PC 版 Edge 及 Chrome 浏览器) - [x] 支持语音输出(需要手动开启) - - [x] 支持图片输入 + - [x] 支持识图(gpt4模式及预设人格模式不支持) - [x] 支持自定义域名 - [x] 支持离线访问 - [x] 适配深色模式 diff --git a/src/components/chat-image.tsx b/src/components/chat-image.tsx index e1335df2..1f61f9db 100644 --- a/src/components/chat-image.tsx +++ b/src/components/chat-image.tsx @@ -17,6 +17,8 @@ import CameraIcon from '@/assets/images/camera.svg' import { BingReturnType } from '@/lib/hooks/use-bing' import { cn } from '@/lib/utils' import { ImageUtils } from "@/lib/image" +import { useAtomValue } from "jotai" +import { systemPromptsAtom, gptAtom } from "@/state" interface ChatImageProps extends Pick {} @@ -25,6 +27,8 @@ const preventDefault: MouseEventHandler = (event) => { } export function ChatImage({ children, uploadImage }: React.PropsWithChildren) { + const systemPrompts = useAtomValue(systemPromptsAtom) + const enableGpt = useAtomValue(gptAtom) const videoRef = useRef(null) const canvasRef = useRef(null) const fileRef = useRef(null) @@ -117,7 +121,7 @@ export function ChatImage({ children, uploadImage }: React.PropsWithChildren
panel === 'none' ? setPanel('normal') : setPanel('none')}>{children}
diff --git a/src/lib/bots/bing/index.ts b/src/lib/bots/bing/index.ts index 0144b813..28086cfc 100644 --- a/src/lib/bots/bing/index.ts +++ b/src/lib/bots/bing/index.ts @@ -340,7 +340,7 @@ export class BingWebBot { } } - private async sydneyProxy(params: Params) { + private async sydneyProxy(params: Params, reconnect: boolean = false) { this.lastText = '' const abortController = new AbortController() const response = await fetch(this.endpoint + '/api/sydney', { @@ -362,6 +362,7 @@ export class BingWebBot { }) return e }) + if (reconnect) return const conversation = this.conversationContext! const originalInvocationId = conversation.invocationId conversation.invocationId++ @@ -401,7 +402,7 @@ export class BingWebBot { } else { conversation.invocationId = originalInvocationId params.options.retryCount = (params.options.retryCount ?? 0) + 1 - this.sydneyProxy(params) + this.sydneyProxy(params, true) } } let t = conversation.invocationId ? undefined : setTimeout(timeout, 6000) diff --git a/src/lib/hooks/use-bing.ts b/src/lib/hooks/use-bing.ts index 69cc6543..982489f6 100644 --- a/src/lib/hooks/use-bing.ts +++ b/src/lib/hooks/use-bing.ts @@ -62,7 +62,7 @@ export function useBing(botId: BotId = 'bing') { await chatState.bot.sendMessage({ prompt: input, - imageUrl: !isImageOnly && imageUrl && /api\/blob.jpg\?bcid=([^&]+)/.test(imageUrl) ? `https://www.bing.com/images/blob?bcid=${RegExp.$1}` : imageUrl, + imageUrl: imageUrl && /api\/blob.jpg\?bcid=([^&]+)/.test(imageUrl) ? `https://www.bing.com/images/blob?bcid=${RegExp.$1}` : imageUrl, context: chatState.bot.isInitial ? historyContext.get() : '', options: { ...options, diff --git a/src/pages/api/kblob.ts b/src/pages/api/kblob.ts index f02a0c41..3decca24 100644 --- a/src/pages/api/kblob.ts +++ b/src/pages/api/kblob.ts @@ -34,7 +34,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) headers: { 'x-forwarded-for': headers['x-forwarded-for'], 'user-agent': headers['User-Agent'], - cookie: headers['cookie'], + // cookie: headers['cookie'], Referer: 'https://www.bing.com/search?q=Bing+AI&showconv=1', 'Sec-Fetch-Dest': 'iframe', ...formData.getHeaders()