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

pull/12560/head
Yi 1 year ago
commit aae601f233

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

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

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

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

@ -19,6 +19,7 @@ import { useWorkflowStore } from '../../../store'
import { useRenderI18nObject } from '@/hooks/use-i18n' import { useRenderI18nObject } from '@/hooks/use-i18n'
import type { NodeOutPutVar } from '../../../types' import type { NodeOutPutVar } from '../../../types'
import type { Node } from 'reactflow' import type { Node } from 'reactflow'
import { toType } from '@/app/components/tools/utils/to-form-schema'
export type Strategy = { export type Strategy = {
agent_strategy_provider_name: string agent_strategy_provider_name: string
@ -150,7 +151,7 @@ export const AgentStrategy = memo((props: AgentStrategyProps) => {
onGenerated={handleGenerated} onGenerated={handleGenerated}
title={renderI18nObject(schema.label)} title={renderI18nObject(schema.label)}
headerClassName='bg-transparent px-0 text-text-secondary system-sm-semibold-uppercase' headerClassName='bg-transparent px-0 text-text-secondary system-sm-semibold-uppercase'
containerClassName='bg-transparent' containerBackgroundClassName='bg-transparent'
gradientBorder={false} gradientBorder={false}
isSupportPromptGenerator={!!schema.auto_generate?.type} isSupportPromptGenerator={!!schema.auto_generate?.type}
titleTooltip={schema.tooltip && renderI18nObject(schema.tooltip)} titleTooltip={schema.tooltip && renderI18nObject(schema.tooltip)}
@ -181,7 +182,18 @@ export const AgentStrategy = memo((props: AgentStrategyProps) => {
strategy strategy
? <div> ? <div>
<Form<CustomField> <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} value={formValue}
onChange={onFormValueChange} onChange={onFormValueChange}
validating={false} validating={false}

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

@ -14,6 +14,7 @@ import ResultPanel from '@/app/components/workflow/run/result-panel'
import formatTracing from '@/app/components/workflow/run/utils/format-log' import formatTracing from '@/app/components/workflow/run/utils/format-log'
import { useLogs } from '@/app/components/workflow/run/hooks' 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 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' const i18nPrefix = 'workflow.nodes.agent'
@ -22,6 +23,7 @@ export function strategyParamToCredientialForm(param: StrategyParamItem): Creden
...param as any, ...param as any,
variable: param.name, variable: param.name,
show_on: [], show_on: [],
type: toType(param.type),
} }
} }

Loading…
Cancel
Save