fix feature bar in basic chabot

This commit is contained in:
JzoNg 2024-09-18 13:36:11 +08:00
parent affb2e38a1
commit 9f66e6e357
3 changed files with 26 additions and 12 deletions

View File

@ -17,7 +17,7 @@ import ChatInput from '@/app/components/base/chat/chat/chat-input'
import type { VisionFile } from '@/app/components/base/chat/types' import type { VisionFile } from '@/app/components/base/chat/types'
import { useDebugConfigurationContext } from '@/context/debug-configuration' import { useDebugConfigurationContext } from '@/context/debug-configuration'
import { useFeatures } from '@/app/components/base/features/hooks' import { useFeatures } from '@/app/components/base/features/hooks'
// import { useStore as useAppStore } from '@/app/components/app/store' import { useStore as useAppStore } from '@/app/components/app/store'
import { Resolution, TransferMethod } from '@/types/app' import { Resolution, TransferMethod } from '@/types/app'
const DebugWithMultipleModel = () => { const DebugWithMultipleModel = () => {
@ -106,7 +106,7 @@ const DebugWithMultipleModel = () => {
} }
}, [twoLine, threeLine, fourLine]) }, [twoLine, threeLine, fourLine])
// const setShowAppConfigureFeaturesModal = useAppStore(s => s.setShowAppConfigureFeaturesModal) const setShowAppConfigureFeaturesModal = useAppStore(s => s.setShowAppConfigureFeaturesModal)
return ( return (
<div className='flex flex-col h-full'> <div className='flex flex-col h-full'>
@ -140,6 +140,9 @@ const DebugWithMultipleModel = () => {
{isChatMode && ( {isChatMode && (
<div className='shrink-0 pb-0 px-6'> <div className='shrink-0 pb-0 px-6'>
<ChatInput <ChatInput
showFeatureBar
showFileUpload={false}
onFeatureBarClick={setShowAppConfigureFeaturesModal}
onSend={handleSend} onSend={handleSend}
speechToTextConfig={speech2text as any} speechToTextConfig={speech2text as any}
visionConfig={visionConfig} visionConfig={visionConfig}

View File

@ -32,9 +32,14 @@ import {
useDraggableUploader, useDraggableUploader,
useImageFiles, useImageFiles,
} from '@/app/components/base/image-uploader/hooks' } from '@/app/components/base/image-uploader/hooks'
import FeatureBar from '@/app/components/base/features/new-feature-panel/feature-bar'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
type ChatInputProps = { type ChatInputProps = {
showFeatureBar?: boolean
showFileUpload?: boolean
featureBarDisabled?: boolean
onFeatureBarClick?: (state: boolean) => void
visionConfig?: VisionConfig visionConfig?: VisionConfig
speechToTextConfig?: EnableType speechToTextConfig?: EnableType
onSend?: OnSend onSend?: OnSend
@ -42,6 +47,10 @@ type ChatInputProps = {
noSpacing?: boolean noSpacing?: boolean
} }
const ChatInput: FC<ChatInputProps> = ({ const ChatInput: FC<ChatInputProps> = ({
showFeatureBar,
showFileUpload,
featureBarDisabled,
onFeatureBarClick,
visionConfig, visionConfig,
speechToTextConfig, speechToTextConfig,
onSend, onSend,
@ -149,12 +158,9 @@ const ChatInput: FC<ChatInputProps> = ({
return ( return (
<> <>
<div className={cn('relative', !noSpacing && 'px-8')}> <div className={cn('relative', !noSpacing && 'px-8', showFeatureBar && 'z-10')}>
<div <div
className={` className={cn('p-[5.5px] max-h-[150px] bg-white border-[1.5px] border-gray-200 rounded-xl overflow-y-auto', isDragActive && 'border-primary-600', !showFeatureBar && 'mb-2')}
p-[5.5px] max-h-[150px] bg-white border-[1.5px] border-gray-200 rounded-xl overflow-y-auto
${isDragActive && 'border-primary-600'} mb-2
`}
> >
{ {
visionConfig?.enabled && ( visionConfig?.enabled && (
@ -180,7 +186,7 @@ const ChatInput: FC<ChatInputProps> = ({
) )
} }
<Textarea <Textarea
ref={textAreaRef} ref={textAreaRef as any}
className={` className={`
block w-full px-2 pr-[118px] py-[7px] leading-5 max-h-none text-sm text-gray-700 outline-none appearance-none resize-none block w-full px-2 pr-[118px] py-[7px] leading-5 max-h-none text-sm text-gray-700 outline-none appearance-none resize-none
${visionConfig?.enabled && 'pl-12'} ${visionConfig?.enabled && 'pl-12'}
@ -251,6 +257,7 @@ const ChatInput: FC<ChatInputProps> = ({
{appData?.site?.custom_disclaimer && <div className='text-xs text-gray-500 mt-1 text-center'> {appData?.site?.custom_disclaimer && <div className='text-xs text-gray-500 mt-1 text-center'>
{appData.site.custom_disclaimer} {appData.site.custom_disclaimer}
</div>} </div>}
{showFeatureBar && <FeatureBar showFileUpload={showFileUpload} disabled={featureBarDisabled} onFeatureBarClick={onFeatureBarClick} />}
</> </>
) )
} }

View File

@ -26,7 +26,7 @@ import ChatInput from './chat-input'
import ChatInputArea from './chat-input-area' import ChatInputArea from './chat-input-area'
import TryToAsk from './try-to-ask' import TryToAsk from './try-to-ask'
import { ChatContextProvider } from './context' import { ChatContextProvider } from './context'
import classNames from '@/utils/classnames' import cn from '@/utils/classnames'
import type { Emoji } from '@/app/components/tools/types' import type { Emoji } from '@/app/components/tools/types'
import Button from '@/app/components/base/button' import Button from '@/app/components/base/button'
import { StopCircle } from '@/app/components/base/icons/src/vender/solid/mediaAndDevices' import { StopCircle } from '@/app/components/base/icons/src/vender/solid/mediaAndDevices'
@ -210,12 +210,12 @@ const Chat: FC<ChatProps> = ({
<div className='relative h-full'> <div className='relative h-full'>
<div <div
ref={chatContainerRef} ref={chatContainerRef}
className={classNames('relative h-full overflow-y-auto overflow-x-hidden', chatContainerClassName)} className={cn('relative h-full overflow-y-auto overflow-x-hidden', chatContainerClassName)}
> >
{chatNode} {chatNode}
<div <div
ref={chatContainerInnerRef} ref={chatContainerInnerRef}
className={classNames('w-full', !noSpacing && 'px-8', chatContainerInnerClassName)} className={cn('w-full', !noSpacing && 'px-8', chatContainerInnerClassName)}
> >
{ {
chatList.map((item, index) => { chatList.map((item, index) => {
@ -258,7 +258,7 @@ const Chat: FC<ChatProps> = ({
> >
<div <div
ref={chatFooterInnerRef} ref={chatFooterInnerRef}
className={`${chatFooterInnerClassName}`} className={cn('relative', chatFooterInnerClassName)}
> >
{ {
!noStopResponding && isResponding && ( !noStopResponding && isResponding && (
@ -294,6 +294,10 @@ const Chat: FC<ChatProps> = ({
} }
{!noChatInput && !showFileUpload && ( {!noChatInput && !showFileUpload && (
<ChatInput <ChatInput
showFeatureBar={showFeatureBar}
showFileUpload={showFileUpload}
featureBarDisabled={isResponding}
onFeatureBarClick={onFeatureBarClick}
onSend={onSend} onSend={onSend}
speechToTextConfig={config?.speech_to_text} speechToTextConfig={config?.speech_to_text}
visionConfig={visionConfig} visionConfig={visionConfig}