Merge branch 'feat/plugins' of https://github.com/langgenius/dify into feat/plugins

pull/12372/head
AkaraChen 1 year ago
commit fe5702784e

@ -39,6 +39,7 @@ export type AgentModelTriggerProps = {
providerName?: string providerName?: string
modelId?: string modelId?: string
hasDeprecated?: boolean hasDeprecated?: boolean
scope?: string
} }
const AgentModelTrigger: FC<AgentModelTriggerProps> = ({ const AgentModelTrigger: FC<AgentModelTriggerProps> = ({
@ -48,6 +49,7 @@ const AgentModelTrigger: FC<AgentModelTriggerProps> = ({
providerName, providerName,
modelId, modelId,
hasDeprecated, hasDeprecated,
scope,
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
const { modelProviders } = useProviderContext() const { modelProviders } = useProviderContext()
@ -136,9 +138,19 @@ const AgentModelTrigger: FC<AgentModelTriggerProps> = ({
try { try {
const { all_installed } = await installPackageFromMarketPlace(pluginInfo.latest_package_identifier) const { all_installed } = await installPackageFromMarketPlace(pluginInfo.latest_package_identifier)
if (all_installed) { if (all_installed) {
setInstalled(true) [
ModelTypeEnum.textGeneration,
ModelTypeEnum.textEmbedding,
ModelTypeEnum.rerank,
ModelTypeEnum.moderation,
ModelTypeEnum.speech2text,
ModelTypeEnum.tts,
].forEach((type: ModelTypeEnum) => {
if (scope?.includes(type))
updateModelList(type)
})
updateModelProviders() updateModelProviders()
updateModelList(ModelTypeEnum.textGeneration) setInstalled(true)
} }
} }
catch (error) { catch (error) {
@ -190,7 +202,7 @@ const AgentModelTrigger: FC<AgentModelTriggerProps> = ({
t={t} t={t}
/> />
)} )}
{modelProvider && !disabled && ( {modelProvider && !disabled && !needsConfiguration && (
<div className="flex pr-1 items-center"> <div className="flex pr-1 items-center">
<RiEqualizer2Line className="w-4 h-4 text-text-tertiary group-hover:text-text-secondary" /> <RiEqualizer2Line className="w-4 h-4 text-text-tertiary group-hover:text-text-secondary" />
</div> </div>

@ -40,7 +40,7 @@ const SearchBox = ({
locale={locale} locale={locale}
/> />
<div className='mx-1 w-[1px] h-3.5 bg-divider-regular'></div> <div className='mx-1 w-[1px] h-3.5 bg-divider-regular'></div>
<div className='grow flex items-center p-1 pl-2'> <div className='relative grow flex items-center p-1 pl-2'>
<div className='flex items-center mr-2 w-full'> <div className='flex items-center mr-2 w-full'>
<input <input
className={cn( className={cn(
@ -54,9 +54,11 @@ const SearchBox = ({
/> />
{ {
search && ( search && (
<ActionButton onClick={() => onSearchChange('')}> <div className='absolute right-2 top-1/2 -translate-y-1/2'>
<RiCloseLine className='w-4 h-4' /> <ActionButton onClick={() => onSearchChange('')}>
</ActionButton> <RiCloseLine className='w-4 h-4' />
</ActionButton>
</div>
) )
} }
</div> </div>

@ -190,6 +190,7 @@ const ModelParameterModal: FC<ModelParameterModalProps> = ({
currentModel={currentModel} currentModel={currentModel}
providerName={value?.provider} providerName={value?.provider}
modelId={value?.model} modelId={value?.model}
scope={scope}
/> />
: <Trigger : <Trigger
disabled={disabled} disabled={disabled}

@ -74,11 +74,13 @@ const List = ({
) )
} }
const maxWidthClassName = 'max-w-[300px]'
return ( return (
<> <>
{hasRes && ( {hasRes && (
<div <div
className={cn('sticky z-10 flex justify-between h-8 px-4 py-1 text-text-primary system-sm-medium cursor-pointer', stickyClassName)} className={cn('sticky z-10 flex justify-between h-8 px-4 py-1 text-text-primary system-sm-medium cursor-pointer', stickyClassName, maxWidthClassName)}
onClick={handleHeadClick} onClick={handleHeadClick}
> >
<span>{t('plugin.fromMarketplace')}</span> <span>{t('plugin.fromMarketplace')}</span>
@ -93,7 +95,7 @@ const List = ({
</Link> </Link>
</div> </div>
)} )}
<div className='p-1' ref={nextToStickyELemRef}> <div className={cn('p-1', maxWidthClassName)} ref={nextToStickyELemRef}>
{list.map((item, index) => ( {list.map((item, index) => (
<Item <Item
key={index} key={index}

@ -68,6 +68,7 @@ const Tabs: FC<TabsProps> = ({
{ {
activeTab === TabsEnum.Tools && ( activeTab === TabsEnum.Tools && (
<AllTools <AllTools
className='w-[315px]'
searchText={searchText} searchText={searchText}
onSelect={onSelect} onSelect={onSelect}
tags={tags} tags={tags}

Loading…
Cancel
Save