Skip to content

Commit

Permalink
feat: gpt4模式及预设人格模式不支持识图
Browse files Browse the repository at this point in the history
  • Loading branch information
weaigc committed Nov 25, 2023
1 parent 7dd049d commit c5350ca
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Bingo,一个让你呼吸顺畅 New Bing。
- [x] 支持画图
- [x] 支持语音输入(支持语音指令,目前仅支持 PC 版 Edge 及 Chrome 浏览器)
- [x] 支持语音输出(需要手动开启)
- [x] 支持图片输入
- [x] 支持识图(gpt4模式及预设人格模式不支持)
- [x] 支持自定义域名
- [x] 支持离线访问
- [x] 适配深色模式
Expand Down
6 changes: 5 additions & 1 deletion src/components/chat-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<BingReturnType, 'uploadImage'> {}

Expand All @@ -25,6 +27,8 @@ const preventDefault: MouseEventHandler<HTMLDivElement> = (event) => {
}

export function ChatImage({ children, uploadImage }: React.PropsWithChildren<ChatImageProps>) {
const systemPrompts = useAtomValue(systemPromptsAtom)
const enableGpt = useAtomValue(gptAtom)
const videoRef = useRef<HTMLVideoElement>(null)
const canvasRef = useRef<HTMLCanvasElement>(null)
const fileRef = useRef<HTMLInputElement>(null)
Expand Down Expand Up @@ -117,7 +121,7 @@ export function ChatImage({ children, uploadImage }: React.PropsWithChildren<Cha
}
}, [panel])

return (
return !enableGpt && !systemPrompts && (
<div className="visual-search-container">
<div onClick={() => panel === 'none' ? setPanel('normal') : setPanel('none')}>{children}</div>
<div className={cn('visual-search', panel)} onClick={preventDefault}>
Expand Down
5 changes: 3 additions & 2 deletions src/lib/bots/bing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand All @@ -362,6 +362,7 @@ export class BingWebBot {
})
return e
})
if (reconnect) return
const conversation = this.conversationContext!
const originalInvocationId = conversation.invocationId
conversation.invocationId++
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/hooks/use-bing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/kblob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit c5350ca

Please sign in to comment.