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

This commit is contained in:
Yi 2025-01-08 17:55:19 +08:00
commit aae601f233
7 changed files with 27 additions and 13 deletions

View File

@ -21,7 +21,7 @@ export const tagKeys = [
export const categoryKeys = [
'model',
'tool',
'agent',
'agent-strategy',
'extension',
'bundle',
]

View File

@ -42,10 +42,10 @@ export const useCategories = (translateFromOut?: TFunction) => {
const t = translateFromOut || translation
const categories = categoryKeys.map((category) => {
if (category === 'agent') {
if (category === 'agent-strategy') {
return {
name: 'agent_strategy',
label: t(`plugin.category.${category}s`),
name: 'agent-strategy',
label: t('plugin.category.agents'),
}
}
return {
@ -70,10 +70,10 @@ export const useSingleCategories = (translateFromOut?: TFunction) => {
const t = translateFromOut || translation
const categories = categoryKeys.map((category) => {
if (category === 'agent') {
if (category === 'agent-strategy') {
return {
name: 'agent_strategy',
label: t(`plugin.categorySingle.${category}`),
name: 'agent-strategy',
label: t('plugin.categorySingle.agent'),
}
}
return {

View File

@ -6,7 +6,7 @@ export enum PluginType {
tool = 'tool',
model = 'model',
extension = 'extension',
agent = 'agent_strategy',
agent = 'agent-strategy',
}
export enum PluginSource {

View File

@ -1,5 +1,5 @@
import type { ToolCredential, ToolParameter } from '../types'
const toType = (type: string) => {
export const toType = (type: string) => {
switch (type) {
case 'string':
return 'text-input'

View File

@ -19,6 +19,7 @@ import { useWorkflowStore } from '../../../store'
import { useRenderI18nObject } from '@/hooks/use-i18n'
import type { NodeOutPutVar } from '../../../types'
import type { Node } from 'reactflow'
import { toType } from '@/app/components/tools/utils/to-form-schema'
export type Strategy = {
agent_strategy_provider_name: string
@ -150,7 +151,7 @@ export const AgentStrategy = memo((props: AgentStrategyProps) => {
onGenerated={handleGenerated}
title={renderI18nObject(schema.label)}
headerClassName='bg-transparent px-0 text-text-secondary system-sm-semibold-uppercase'
containerClassName='bg-transparent'
containerBackgroundClassName='bg-transparent'
gradientBorder={false}
isSupportPromptGenerator={!!schema.auto_generate?.type}
titleTooltip={schema.tooltip && renderI18nObject(schema.tooltip)}
@ -181,7 +182,18 @@ export const AgentStrategy = memo((props: AgentStrategyProps) => {
strategy
? <div>
<Form<CustomField>
formSchemas={formSchema}
formSchemas={[...formSchema, {
name: 'max_iteration',
type: toType('number'),
required: true,
label: {
en_US: 'Max Iteration',
zh_Hans: '最大迭代次数',
pt_BR: 'Max Iteration',
},
show_on: [],
variable: 'max-ite',
}]}
value={formValue}
onChange={onFormValueChange}
validating={false}

View File

@ -68,7 +68,7 @@ type Props = {
onEditionTypeChange?: (editionType: EditionType) => void
varList?: Variable[]
handleAddVariable?: (payload: any) => void
containerClassName?: string
containerBackgroundClassName?: string
gradientBorder?: boolean
titleTooltip?: ReactNode
inputClassName?: string
@ -103,7 +103,7 @@ const Editor: FC<Props> = ({
handleAddVariable,
onGenerated,
modelConfig,
containerClassName,
containerBackgroundClassName: containerClassName,
gradientBorder = true,
titleTooltip,
inputClassName,

View File

@ -14,6 +14,7 @@ import ResultPanel from '@/app/components/workflow/run/result-panel'
import formatTracing from '@/app/components/workflow/run/utils/format-log'
import { useLogs } from '@/app/components/workflow/run/hooks'
import type { Props as FormProps } from '@/app/components/workflow/nodes/_base/components/before-run-form/form'
import { toType } from '@/app/components/tools/utils/to-form-schema'
const i18nPrefix = 'workflow.nodes.agent'
@ -22,6 +23,7 @@ export function strategyParamToCredientialForm(param: StrategyParamItem): Creden
...param as any,
variable: param.name,
show_on: [],
type: toType(param.type),
}
}