- 新增数联网设置页面 - 优化数联网搜索结果展示 - 添加数据集、科创场景和科技企业等不同类型的搜索结果 - 重构搜索结果卡片组件,支持加载状态和不同展示模式 - 更新数联网搜索相关的国际化文案
64 lines
2.0 KiB
TypeScript
64 lines
2.0 KiB
TypeScript
import React from "react"
|
|
import { useMessageOption } from "~/hooks/useMessageOption"
|
|
import { PlaygroundEmpty } from "./PlaygroundEmpty"
|
|
import { PlaygroundMessage } from "~/components/Common/Playground/Message"
|
|
import { MessageSourcePopup } from "@/components/Common/Playground/MessageSourcePopup"
|
|
|
|
export const PlaygroundChat = () => {
|
|
const {
|
|
messages,
|
|
streaming,
|
|
regenerateLastMessage,
|
|
isSearchingInternet,
|
|
editMessage,
|
|
ttsEnabled
|
|
} = useMessageOption()
|
|
const [isSourceOpen, setIsSourceOpen] = React.useState(false)
|
|
const [source, setSource] = React.useState<any>(null)
|
|
|
|
return (
|
|
<>
|
|
<div className="relative flex w-full flex-col items-center pb-4">
|
|
{messages.length === 0 && (
|
|
<div className="mt-3 w-full">
|
|
<PlaygroundEmpty />
|
|
</div>
|
|
)}
|
|
{messages.map((message, index) => (
|
|
<PlaygroundMessage
|
|
key={index}
|
|
isBot={message.isBot}
|
|
message={message.message}
|
|
name={message.name}
|
|
images={message.images || []}
|
|
currentMessageIndex={index}
|
|
totalMessages={messages.length}
|
|
onRengerate={regenerateLastMessage}
|
|
isProcessing={streaming}
|
|
isSearchingInternet={isSearchingInternet}
|
|
webSources={message.webSources}
|
|
iodSources={message.iodSources}
|
|
onEditFormSubmit={(value, isSend) => {
|
|
editMessage(index, value, !message.isBot, isSend)
|
|
}}
|
|
onSourceClick={(data) => {
|
|
setSource(data)
|
|
setIsSourceOpen(true)
|
|
}}
|
|
isTTSEnabled={ttsEnabled}
|
|
generationInfo={message?.generationInfo}
|
|
isStreaming={streaming}
|
|
reasoningTimeTaken={message?.reasoning_time_taken}
|
|
/>
|
|
))}
|
|
</div>
|
|
{messages.length !== 0 && <div className="w-full pb-[157px]"></div>}
|
|
<MessageSourcePopup
|
|
open={isSourceOpen}
|
|
setOpen={setIsSourceOpen}
|
|
source={source}
|
|
/>
|
|
</>
|
|
)
|
|
}
|