feat(model): API support reasoning (#2409)

This commit is contained in:
Fangyin Cheng
2025-03-07 15:31:12 +08:00
committed by GitHub
parent 2697aba4f5
commit 4e993a2be8
76 changed files with 653 additions and 212 deletions

View File

@@ -184,37 +184,54 @@ const ChatContainer = () => {
);
return (
<>
<div className='flex flex-col h-screen w-full overflow-hidden'>
<MuiLoading visible={loading} />
<Header
refreshHistory={getHistory}
modelChange={(newModel: string) => {
setModel(newModel);
}}
/>
<div className='px-4 flex flex-1 flex-wrap overflow-hidden relative'>
<div className='flex-none'>
<Header
refreshHistory={getHistory}
modelChange={(newModel: string) => {
setModel(newModel);
}}
/>
</div>
{/* Use flex-auto to ensure the remaining height is filled */}
<div className='flex-auto flex overflow-hidden'>
{/* Left chart area */}
{!!chartsData?.length && (
<div className='w-full pb-4 xl:w-3/4 h-1/2 xl:pr-4 xl:h-full overflow-y-auto'>
<div
className={classNames('overflow-auto', {
'w-full h-1/2 md:h-full md:w-3/4 pb-4 md:pr-4': scene === 'chat_dashboard',
})}
>
<Chart chartsData={chartsData} />
</div>
)}
{!chartsData?.length && scene === 'chat_dashboard' && <MyEmpty className='w-full xl:w-3/4 h-1/2 xl:h-full' />}
{/** chat panel */}
{!chartsData?.length && scene === 'chat_dashboard' && (
<div
className={classNames('flex items-center justify-center', {
'w-full h-1/2 md:h-full md:w-3/4': scene === 'chat_dashboard',
})}
>
<MyEmpty />
</div>
)}
<div
className={classNames('flex flex-1 flex-col overflow-hidden', {
'px-0 xl:pl-4 h-1/2 w-full xl:w-auto xl:h-full border-t xl:border-t-0 xl:border-l dark:border-gray-800':
className={classNames('flex flex-col overflow-hidden', {
'w-full h-1/2 md:h-full md:w-1/4 border-t md:border-t-0 md:border-l dark:border-gray-800':
scene === 'chat_dashboard',
'h-full lg:px-8': scene !== 'chat_dashboard',
'w-full h-full px-4 lg:px-8': scene !== 'chat_dashboard',
})}
>
<Completion
messages={history}
onSubmit={handleChat}
onFormatContent={formatToVisThinking} // Pass the formatting function to Completion
/>
{/* Wrap the Completion component in a container with a specific height */}
<div className='h-full overflow-hidden'>
<Completion messages={history} onSubmit={handleChat} onFormatContent={formatToVisThinking} />
</div>
</div>
</div>
</>
</div>
);
};

View File

@@ -169,7 +169,7 @@ const Completion = ({ messages, onSubmit, onFormatContent }: Props) => {
return (
<>
{contextHolder}
<div ref={scrollableRef} className='flex flex-1 overflow-y-auto pb-8 w-full flex-col'>
<div ref={scrollableRef} className='flex flex-1 overflow-y-auto h-full w-full flex-col'>
<div className='flex items-center flex-1 flex-col text-sm leading-6 text-slate-900 dark:text-slate-300 sm:text-base sm:leading-7'>
{showMessages.length ? (
showMessages.map((content, index) => {
@@ -230,7 +230,7 @@ const Completion = ({ messages, onSubmit, onFormatContent }: Props) => {
</div>
<div
className={classNames(
'relative after:absolute after:-top-8 after:h-8 after:w-full after:bg-gradient-to-t after:from-theme-light after:to-transparent dark:after:from-theme-dark',
'relative sticky bottom-0 bg-theme-light dark:bg-theme-dark after:absolute after:-top-8 after:h-8 after:w-full after:bg-gradient-to-t after:from-theme-light after:to-transparent dark:after:from-theme-dark',
{
'cursor-not-allowed': scene === 'chat_excel' && !currentDialogue?.select_param,
},