feat: add GenerateImageButton component to Inputbar for image generation functionality
This commit is contained in:
parent
16ac419b9b
commit
a9b2b32c5a
36
src/renderer/src/pages/home/Inputbar/GenerateImageButton.tsx
Normal file
36
src/renderer/src/pages/home/Inputbar/GenerateImageButton.tsx
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { PictureOutlined } from '@ant-design/icons'
|
||||||
|
import { isGenerateImageModel } from '@renderer/config/models'
|
||||||
|
import { Assistant, Model } from '@renderer/types'
|
||||||
|
import { Tooltip } from 'antd'
|
||||||
|
import { FC } from 'react'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
assistant: Assistant
|
||||||
|
model: Model
|
||||||
|
ToolbarButton: any
|
||||||
|
onEnableGenerateImage: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
const GenerateImageButton: FC<Props> = ({ model, ToolbarButton, assistant, onEnableGenerateImage }) => {
|
||||||
|
const { t } = useTranslation()
|
||||||
|
|
||||||
|
if (!isGenerateImageModel(model)) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tooltip
|
||||||
|
placement="top"
|
||||||
|
title={
|
||||||
|
isGenerateImageModel(model) ? t('chat.input.generate_image') : t('chat.input.generate_image_not_supported')
|
||||||
|
}
|
||||||
|
arrow>
|
||||||
|
<ToolbarButton type="text" disabled={!isGenerateImageModel(model)} onClick={onEnableGenerateImage}>
|
||||||
|
<PictureOutlined style={{ color: assistant.enableGenerateImage ? 'var(--color-link)' : 'var(--color-icon)' }} />
|
||||||
|
</ToolbarButton>
|
||||||
|
</Tooltip>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default GenerateImageButton
|
||||||
@ -7,7 +7,6 @@ import {
|
|||||||
GlobalOutlined,
|
GlobalOutlined,
|
||||||
HolderOutlined,
|
HolderOutlined,
|
||||||
PauseCircleOutlined,
|
PauseCircleOutlined,
|
||||||
PictureOutlined,
|
|
||||||
QuestionCircleOutlined
|
QuestionCircleOutlined
|
||||||
} from '@ant-design/icons'
|
} from '@ant-design/icons'
|
||||||
import TranslateButton from '@renderer/components/TranslateButton'
|
import TranslateButton from '@renderer/components/TranslateButton'
|
||||||
@ -45,6 +44,7 @@ import styled from 'styled-components'
|
|||||||
import NarrowLayout from '../Messages/NarrowLayout'
|
import NarrowLayout from '../Messages/NarrowLayout'
|
||||||
import AttachmentButton from './AttachmentButton'
|
import AttachmentButton from './AttachmentButton'
|
||||||
import AttachmentPreview from './AttachmentPreview'
|
import AttachmentPreview from './AttachmentPreview'
|
||||||
|
import GenerateImageButton from './GenerateImageButton'
|
||||||
import KnowledgeBaseButton from './KnowledgeBaseButton'
|
import KnowledgeBaseButton from './KnowledgeBaseButton'
|
||||||
import MCPToolsButton from './MCPToolsButton'
|
import MCPToolsButton from './MCPToolsButton'
|
||||||
import MentionModelsButton from './MentionModelsButton'
|
import MentionModelsButton from './MentionModelsButton'
|
||||||
@ -745,20 +745,12 @@ const Inputbar: FC<Props> = ({ assistant: _assistant, setActiveTopic, topic }) =
|
|||||||
ToolbarButton={ToolbarButton}
|
ToolbarButton={ToolbarButton}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Tooltip
|
<GenerateImageButton
|
||||||
placement="top"
|
model={model}
|
||||||
title={
|
assistant={assistant}
|
||||||
!isGenerateImageModel(model)
|
onEnableGenerateImage={onEnableGenerateImage}
|
||||||
? t('chat.input.generate_image_not_supported')
|
ToolbarButton={ToolbarButton}
|
||||||
: t('chat.input.generate_image')
|
|
||||||
}
|
|
||||||
arrow>
|
|
||||||
<ToolbarButton type="text" disabled={!isGenerateImageModel(model)} onClick={onEnableGenerateImage}>
|
|
||||||
<PictureOutlined
|
|
||||||
style={{ color: assistant.enableGenerateImage ? 'var(--color-link)' : 'var(--color-icon)' }}
|
|
||||||
/>
|
/>
|
||||||
</ToolbarButton>
|
|
||||||
</Tooltip>
|
|
||||||
<MentionModelsButton
|
<MentionModelsButton
|
||||||
mentionModels={mentionModels}
|
mentionModels={mentionModels}
|
||||||
onMentionModel={(model) => onMentionModel(model, mentionFromKeyboard)}
|
onMentionModel={(model) => onMentionModel(model, mentionFromKeyboard)}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user