Merge branch 'main' into feat/workflow

This commit is contained in:
StyleZhang
2024-03-19 18:37:09 +08:00
54 changed files with 1730 additions and 249 deletions

View File

@ -210,6 +210,7 @@ const AgentTools: FC = () => {
setting={currentTool?.tool_parameters as any}
collection={currentTool?.collection as Collection}
isBuiltIn={currentTool?.collection?.type === CollectionType.builtIn}
isModel={currentTool?.collection?.type === CollectionType.model}
onSave={handleToolSettingChange}
onHide={() => setIsShowSettingTool(false)}
/>)

View File

@ -58,11 +58,16 @@ const SettingBuiltInTool: FC<Props> = ({
(async () => {
setIsLoading(true)
try {
const list = isBuiltIn
? await fetchBuiltInToolList(collection.name)
: isModel
? await fetchModelToolList(collection.name)
: await fetchCustomToolList(collection.name)
const list = await new Promise<Tool[]>((resolve) => {
(async function () {
if (isModel)
resolve(await fetchModelToolList(collection.name))
else if (isBuiltIn)
resolve(await fetchBuiltInToolList(collection.name))
else
resolve(await fetchCustomToolList(collection.name))
}())
})
setTools(list)
const currTool = list.find(tool => tool.name === toolName)
if (currTool) {

View File

@ -3,7 +3,7 @@ import type { FC } from 'react'
import React, { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import cn from 'classnames'
import { toolCredentialToFormSchemas } from '../../utils/to-form-schema'
import { addDefaultValue, toolCredentialToFormSchemas } from '../../utils/to-form-schema'
import type { Collection } from '../../types'
import Drawer from '@/app/components/base/drawer-plus'
import Button from '@/app/components/base/button'
@ -30,12 +30,15 @@ const ConfigCredential: FC<Props> = ({
const { t } = useTranslation()
const [credentialSchema, setCredentialSchema] = useState<any>(null)
const { team_credentials: credentialValue, name: collectionName } = collection
const [tempCredential, setTempCredential] = React.useState<any>(credentialValue)
useEffect(() => {
fetchBuiltInToolCredentialSchema(collectionName).then((res) => {
setCredentialSchema(toolCredentialToFormSchemas(res))
const toolCredentialSchemas = toolCredentialToFormSchemas(res)
const defaultCredentials = addDefaultValue(credentialValue, toolCredentialSchemas)
setCredentialSchema(toolCredentialSchemas)
setTempCredential(defaultCredentials)
})
}, [])
const [tempCredential, setTempCredential] = React.useState<any>(credentialValue)
return (
<Drawer