mirror of
https://github.com/langgenius/dify.git
synced 2026-05-10 05:56:31 +08:00
fix: support tool call badge & disable tools in llm when model not support tool call
This commit is contained in:
parent
5157a33aff
commit
439d931e9f
@ -1,6 +1,8 @@
|
||||
import type { FC, PropsWithChildren } from 'react'
|
||||
import type { ModelItem } from '../declarations'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import { ModelFeatureEnum } from '../declarations'
|
||||
|
||||
import { useLanguage } from '../hooks'
|
||||
import ModelBadge from '../model-badge'
|
||||
import FeatureIcon from '../model-selector/feature-icon'
|
||||
@ -69,7 +71,12 @@ const ModelName: FC<ModelNameProps> = ({
|
||||
)
|
||||
}
|
||||
{
|
||||
showFeatures && modelItem.features?.map(feature => (
|
||||
showFeatures && modelItem.features?.reduce((acc, feature) => {
|
||||
if (acc.some(f => [ModelFeatureEnum.toolCall, ModelFeatureEnum.multiToolCall, ModelFeatureEnum.streamToolCall].includes(f)) && [ModelFeatureEnum.toolCall, ModelFeatureEnum.multiToolCall, ModelFeatureEnum.streamToolCall].includes(feature)) {
|
||||
return acc
|
||||
}
|
||||
return [...acc, feature]
|
||||
}, [] as ModelFeatureEnum[]).map(feature => (
|
||||
<FeatureIcon
|
||||
key={feature}
|
||||
feature={feature}
|
||||
|
||||
@ -39,7 +39,7 @@ const FeatureIcon: FC<FeatureIconProps> = ({
|
||||
// )
|
||||
// }
|
||||
|
||||
if (feature === ModelFeatureEnum.toolCall) {
|
||||
if (feature === ModelFeatureEnum.toolCall || feature === ModelFeatureEnum.multiToolCall || feature === ModelFeatureEnum.streamToolCall) {
|
||||
if (showFeaturesLabel) {
|
||||
return (
|
||||
<ModelBadge className={cn('gap-x-0.5', className)}>
|
||||
|
||||
@ -97,7 +97,7 @@ const PopupItem: FC<PopupItemProps> = ({
|
||||
)} */}
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{
|
||||
modelItem.features?.includes(ModelFeatureEnum.toolCall) && (
|
||||
modelItem.features?.some(feature => [ModelFeatureEnum.toolCall, ModelFeatureEnum.multiToolCall, ModelFeatureEnum.streamToolCall].includes(feature)) && (
|
||||
<FeatureIcon
|
||||
feature={ModelFeatureEnum.toolCall}
|
||||
showFeaturesLabel
|
||||
@ -126,7 +126,7 @@ const PopupItem: FC<PopupItemProps> = ({
|
||||
<div className="pt-2">
|
||||
<div className="mb-1 text-text-tertiary system-2xs-medium-uppercase">{t('model.capabilities', { ns: 'common' })}</div>
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{modelItem.features?.filter(feature => feature !== ModelFeatureEnum.toolCall).map(feature => (
|
||||
{modelItem.features?.filter(feature => ![ModelFeatureEnum.toolCall, ModelFeatureEnum.multiToolCall, ModelFeatureEnum.streamToolCall].includes(feature)).map(feature => (
|
||||
<FeatureIcon
|
||||
key={feature}
|
||||
feature={feature}
|
||||
|
||||
@ -8,8 +8,9 @@ type MaxIterationsProps = {
|
||||
value?: number
|
||||
onChange?: (value: number) => void
|
||||
className?: string
|
||||
disabled?: boolean
|
||||
}
|
||||
const MaxIterations = ({ value = 10, onChange, className }: MaxIterationsProps) => {
|
||||
const MaxIterations = ({ value = 10, onChange, className, disabled }: MaxIterationsProps) => {
|
||||
return (
|
||||
<div className={cn('mt-3 flex h-10 items-center justify-between', className)}>
|
||||
<div className="flex items-center">
|
||||
@ -20,11 +21,12 @@ const MaxIterations = ({ value = 10, onChange, className }: MaxIterationsProps)
|
||||
/>
|
||||
</div>
|
||||
<InputNumber
|
||||
className="w-14 shrink-0"
|
||||
className={cn('w-14 shrink-0', disabled && 'opacity-50')}
|
||||
value={value}
|
||||
onChange={onChange ?? (() => {})}
|
||||
min={1}
|
||||
step={1}
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
@ -290,7 +290,7 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
|
||||
tools={inputs.tools}
|
||||
maxIterations={inputs.max_iterations}
|
||||
hideMaxIterations
|
||||
disabled={isToolsBlocked}
|
||||
disabled={isToolsBlocked || !isModelSupportToolCall}
|
||||
disabledTip={toolsDisabledTip}
|
||||
/>
|
||||
)}
|
||||
@ -335,6 +335,7 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
|
||||
className="flex h-10 items-center"
|
||||
value={inputs.max_iterations}
|
||||
onChange={handleMaxIterationsChange}
|
||||
disabled={!isModelSupportToolCall}
|
||||
/>
|
||||
</div>
|
||||
</FieldCollapse>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user