Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

chore: perfect type definition (#940)

bowen5e0540077a3f
diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/cardView.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/cardView.tsx
index 4f019b0621a..375524023c4 100644
--- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/cardView.tsx
+++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/cardView.tsx
@@ -17,6 +17,7 @@ import type { App } from '@/types/app'
import type { UpdateAppSiteCodeResponse } from '@/models/app'
import { asyncRunSafe } from '@/utils'
import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
+import type { IAppCardProps } from '@/app/components/app/overview/appCard'
export type ICardViewProps = {
appId: string
@@ -68,7 +69,7 @@ const CardView: FC<ICardViewProps> = ({ appId }) => {
handleError(err)
}
- const onSaveSiteConfig = async (params: any) => {
+ const onSaveSiteConfig: IAppCardProps['onSaveSiteConfig'] = async (params) => {
const [err] = await asyncRunSafe<App>(
updateAppSiteConfig({
url: `/apps/${appId}/site`,
diff --git a/web/app/components/app/chat/answer/index.tsx b/web/app/components/app/chat/answer/index.tsx
index ab0f910abbe..eb7103559d0 100644
--- a/web/app/components/app/chat/answer/index.tsx
+++ b/web/app/components/app/chat/answer/index.tsx
@@ -225,7 +225,7 @@ const Answer: FC<IAnswerProps> = ({ item, feedbackDisabled = false, isHideFeedba
setLoading(true)
const res = await onSubmitAnnotation?.(id, inputValue)
if (res)
- setAnnotation({ ...annotation, content: inputValue } as any)
+ setAnnotation({ ...annotation, content: inputValue } as Annotation)
setLoading(false)
setShowEdit(false)
}}>{t('common.operation.confirm')}</Button>
diff --git a/web/app/components/app/chat/index.tsx b/web/app/components/app/chat/index.tsx
index 88da1905b93..5f67001d98c 100644
--- a/web/app/components/app/chat/index.tsx
+++ b/web/app/components/app/chat/index.tsx
@@ -81,7 +81,7 @@ const Chat: FC<IChatProps> = ({
const isUseInputMethod = useRef(false)
const [query, setQuery] = React.useState('')
- const handleContentChange = (e: any) => {
+ const handleContentChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
const value = e.target.value
setQuery(value)
}
@@ -111,7 +111,7 @@ const Chat: FC<IChatProps> = ({
setQuery('')
}
- const handleKeyUp = (e: any) => {
+ const handleKeyUp = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (e.code === 'Enter') {
e.preventDefault()
// prevent send message when using input method enter
@@ -120,7 +120,7 @@ const Chat: FC<IChatProps> = ({
}
}
- const handleKeyDown = (e: any) => {
+ const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
isUseInputMethod.current = e.nativeEvent.isComposing
if (e.code === 'Enter' && !e.shiftKey) {
setQuery(query.replace(/\n$/, ''))
diff --git a/web/app/components/app/configuration/config-var/input-type-icon.tsx b/web/app/components/app/configuration/config-var/input-type-icon.tsx
index ff59a48bda2..b45ec922c2f 100644
--- a/web/app/components/app/configuration/config-var/input-type-icon.tsx
+++ b/web/app/components/app/configuration/config-var/input-type-icon.tsx
@@ -1,19 +1,19 @@
'use client'
-import React, { FC, ReactNode } from 'react'
-import { ReactElement } from 'react-markdown/lib/react-markdown'
+import React from 'react'
+import type { FC } from 'react'
-export interface IInputTypeIconProps {
- type: string
+type IInputTypeIconProps = {
+ type: 'string' | 'select'
}
-const IconMap = (type: string) => {
- const icons: Record<string, ReactNode> = {
- 'string': (
+const IconMap = (type: IInputTypeIconProps['type']) => {
+ const icons = {
+ string: (
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fillRule="evenodd" clipRule="evenodd" d="M3.52593 0.166672H8.47411C8.94367 0.166665 9.33123 0.166659 9.64692 0.192452C9.97481 0.219242 10.2762 0.276738 10.5593 0.420991C10.9984 0.644695 11.3553 1.00165 11.579 1.44069C11.7233 1.72381 11.7808 2.02522 11.8076 2.35311C11.8334 2.6688 11.8334 3.05634 11.8334 3.5259V8.47411C11.8334 8.94367 11.8334 9.33121 11.8076 9.6469C11.7808 9.97479 11.7233 10.2762 11.579 10.5593C11.3553 10.9984 10.9984 11.3553 10.5593 11.579C10.2762 11.7233 9.97481 11.7808 9.64692 11.8076C9.33123 11.8334 8.94369 11.8333 8.47413 11.8333H3.52592C3.05636 11.8333 2.66882 11.8334 2.35312 11.8076C2.02523 11.7808 1.72382 11.7233 1.44071 11.579C1.00167 11.3553 0.644711 10.9984 0.421006 10.5593C0.276753 10.2762 0.219257 9.97479 0.192468 9.6469C0.166674 9.33121 0.16668 8.94366 0.166687 8.4741V3.52591C0.16668 3.05635 0.166674 2.6688 0.192468 2.35311C0.219257 2.02522 0.276753 1.72381 0.421006 1.44069C0.644711 1.00165 1.00167 0.644695 1.44071 0.420991C1.72382 0.276738 2.02523 0.219242 2.35312 0.192452C2.66882 0.166659 3.05637 0.166665 3.52593 0.166672ZM3.08335 3.08334C3.08335 2.76117 3.34452 2.50001 3.66669 2.50001H8.33335C8.65552 2.50001 8.91669 2.76117 8.91669 3.08334C8.91669 3.4055 8.65552 3.66667 8.33335 3.66667H6.58335V8.91667C6.58335 9.23884 6.32219 9.5 6.00002 9.5C5.67785 9.5 5.41669 9.23884 5.41669 8.91667V3.66667H3.66669C3.34452 3.66667 3.08335 3.4055 3.08335 3.08334Z" fill="#98A2B3" />
</svg>
),
- 'select': (
+ select: (
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fillRule="evenodd" clipRule="evenodd" d="M7.48913 4.08334H3.01083C2.70334 4.08333 2.43804 4.08333 2.21955 4.10118C1.98893 4.12002 1.75955 4.16162 1.53883 4.27408C1.20955 4.44186 0.941831 4.70958 0.774053 5.03886C0.66159 5.25958 0.619989 5.48896 0.601147 5.71958C0.583295 5.93807 0.583304 6.20334 0.583313 6.51084V10.9892C0.583304 11.2967 0.583295 11.5619 0.601147 11.7804C0.619989 12.0111 0.66159 12.2404 0.774053 12.4612C0.941831 12.7904 1.20955 13.0582 1.53883 13.2259C1.75955 13.3384 1.98893 13.38 2.21955 13.3988C2.43803 13.4167 2.70329 13.4167 3.01077 13.4167H7.48912C7.7966 13.4167 8.06193 13.4167 8.28041 13.3988C8.51103 13.38 8.74041 13.3384 8.96113 13.2259C9.29041 13.0582 9.55813 12.7904 9.72591 12.4612C9.83837 12.2404 9.87997 12.0111 9.89882 11.7804C9.91667 11.5619 9.91666 11.2967 9.91665 10.9892V6.51087C9.91666 6.20336 9.91667 5.93808 9.89882 5.71958C9.87997 5.48896 9.83837 5.25958 9.72591 5.03886C9.55813 4.70958 9.29041 4.44186 8.96113 4.27408C8.74041 4.16162 8.51103 4.12002 8.28041 4.10118C8.06192 4.08333 7.79663 4.08333 7.48913 4.08334ZM7.70413 7.70416C7.93193 7.47635 7.93193 7.107 7.70413 6.8792C7.47632 6.65139 7.10697 6.65139 6.87917 6.8792L4.66665 9.09172L3.91246 8.33753C3.68465 8.10973 3.31531 8.10973 3.0875 8.33753C2.8597 8.56534 2.8597 8.93468 3.0875 9.16249L4.25417 10.3292C4.48197 10.557 4.85132 10.557 5.07913 10.3292L7.70413 7.70416Z" fill="#98A2B3" />
<path d="M10.9891 0.583344H6.51083C6.20334 0.583334 5.93804 0.583326 5.71955 0.601177C5.48893 0.620019 5.25955 0.66162 5.03883 0.774084C4.70955 0.941862 4.44183 1.20958 4.27405 1.53886C4.16159 1.75958 4.11999 1.98896 4.10115 2.21958C4.08514 2.41545 4.08349 2.64892 4.08333 2.91669L7.51382 2.91668C7.79886 2.91662 8.10791 2.91654 8.37541 2.9384C8.67818 2.96314 9.07818 3.02436 9.49078 3.23459C10.0396 3.51422 10.4858 3.96041 10.7654 4.50922C10.9756 4.92182 11.0369 5.32182 11.0616 5.62459C11.0835 5.8921 11.0834 6.20115 11.0833 6.48619L11.0833 9.91666C11.3511 9.9165 11.5845 9.91485 11.7804 9.89885C12.011 9.88 12.2404 9.8384 12.4611 9.72594C12.7904 9.55816 13.0581 9.29045 13.2259 8.96116C13.3384 8.74044 13.38 8.51106 13.3988 8.28044C13.4167 8.06196 13.4167 7.7967 13.4166 7.48922V3.01087C13.4167 2.70339 13.4167 2.43807 13.3988 2.21958C13.38 1.98896 13.3384 1.75958 13.2259 1.53886C13.0581 1.20958 12.7904 0.941862 12.4611 0.774084C12.2404 0.66162 12.011 0.620019 11.7804 0.601177C11.5619 0.583326 11.2966 0.583334 10.9891 0.583344Z" fill="#98A2B3" />
@@ -21,11 +21,11 @@ const IconMap = (type: string) => {
),
}
- return icons[type] as any
+ return icons[type]
}
const InputTypeIcon: FC<IInputTypeIconProps> = ({
- type
+ type,
}) => {
const Icon = IconMap(type)
return Icon
diff --git a/web/app/components/app/configuration/dataset-config/card-item/index.tsx b/web/app/components/app/configuration/dataset-config/card-item/index.tsx
index 2ad7ad0d66a..0f5721fd655 100644
--- a/web/app/components/app/configuration/dataset-config/card-item/index.tsx
+++ b/web/app/components/app/configuration/dataset-config/card-item/index.tsx
@@ -6,22 +6,17 @@ import { useTranslation } from 'react-i18next'
import TypeIcon from '../type-icon'
import RemoveIcon from '../../base/icons/remove-icon'
import s from './style.module.css'
+import type { DataSet } from '@/models/datasets'
import { formatNumber } from '@/utils/format'
import Tooltip from '@/app/components/base/tooltip'
export type ICardItemProps = {
className?: string
- config: any
+ config: DataSet
onRemove: (id: string) => void
readonly?: boolean
}
-// const RemoveIcon = ({ className, onClick }: { className: string, onClick: () => void }) => (
-// <svg className={className} onClick={onClick} width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
-// <path d="M10 6H14M6 8H18M16.6667 8L16.1991 15.0129C16.129 16.065 16.0939 16.5911 15.8667 16.99C15.6666 17.3412 15.3648 17.6235 15.0011 17.7998C14.588 18 14.0607 18 13.0062 18H10.9938C9.93927 18 9.41202 18 8.99889 17.7998C8.63517 17.6235 8.33339 17.3412 8.13332 16.99C7.90607 16.5911 7.871 16.065 7.80086 15.0129L7.33333 8M10.6667 11V14.3333M13.3333 11V14.3333" stroke="#667085" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
-// </svg>
-// )
-
const CardItem: FC<ICardItemProps> = ({
className,
config,
diff --git a/web/app/components/app/overview/appCard.tsx b/web/app/components/app/overview/appCard.tsx
index 1700ddacf36..5c4ae75239f 100644
--- a/web/app/components/app/overview/appCard.tsx
+++ b/web/app/components/app/overview/appCard.tsx
@@ -13,6 +13,7 @@ import SettingsModal from './settings'
import EmbeddedModal from './embedded'
import CustomizeModal from './customize'
import style from './style.module.css'
+import type { ConfigParams } from './settings'
import Tooltip from '@/app/components/base/tooltip'
import AppBasic from '@/app/components/app-sidebar/basic'
import { asyncRunSafe, randomString } from '@/utils'
@@ -31,9 +32,9 @@ export type IAppCardProps = {
appInfo: AppDetailResponse
cardType?: 'api' | 'webapp'
customBgColor?: string
- onChangeStatus: (val: boolean) => Promise<any>
- onSaveSiteConfig?: (params: any) => Promise<any>
- onGenerateCode?: () => Promise<any>
+ onChangeStatus: (val: boolean) => Promise<void>
+ onSaveSiteConfig?: (params: ConfigParams) => Promise<void>
+ onGenerateCode?: () => Promise<void>
}
const EmbedIcon: FC<{ className?: string }> = ({ className = '' }) => {
@@ -193,7 +194,7 @@ function AppCard({
</div>
<div className={'pt-2 flex flex-row items-center'}>
{!isApp && <SecretKeyButton className='flex-shrink-0 !h-8 bg-white mr-2' textCls='!text-gray-700 font-medium' iconCls='stroke-[1.2px]' appId={appInfo.id} />}
- {OPERATIONS_MAP[cardType].map((op: any) => {
+ {OPERATIONS_MAP[cardType].map((op) => {
const disabled
= op.opName === t('appOverview.overview.appInfo.settings.entry')
? false
diff --git a/web/app/components/app/overview/settings/index.tsx b/web/app/components/app/overview/settings/index.tsx
index 8b995c8bfa2..c575ed83fc3 100644
--- a/web/app/components/app/overview/settings/index.tsx
+++ b/web/app/components/app/overview/settings/index.tsx
@@ -18,7 +18,7 @@ export type ISettingsModalProps = {
isShow: boolean
defaultValue?: string
onClose: () => void
- onSave?: (params: ConfigParams) => Promise<any>
+ onSave?: (params: ConfigParams) => Promise<void>
}
export type ConfigParams = {
@@ -26,6 +26,10 @@ export type ConfigParams = {
description: string
default_language: string
prompt_public: boolean
+ copyright: string
+ privacy_policy: string
+ icon: string
+ icon_background: string
}
const LANGUAGE_MAP: Record<Language, string> = {
@@ -82,7 +86,7 @@ const SettingsModal: FC<ISettingsModalProps> = ({
}
const onChange = (field: string) => {
- return (e: any) => {
+ return (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
setInputInfo(item => ({ ...item, [field]: e.target.value }))
}
}
diff --git a/web/app/components/app/text-generate/item/index.tsx b/web/app/components/app/text-generate/item/index.tsx
index 8798b9f8381..c85acdd58fa 100644
--- a/web/app/components/app/text-generate/item/index.tsx
+++ b/web/app/components/app/text-generate/item/index.tsx
@@ -10,7 +10,7 @@ import { HashtagIcon } from '@heroicons/react/24/solid'
import { Markdown } from '@/app/components/base/markdown'
import Loading from '@/app/components/base/loading'
import Toast from '@/app/components/base/toast'
-import type { Feedbacktype } from '@/app/components/app/chat'
+import type { Feedbacktype } from '@/app/components/app/chat/type'
import { fetchMoreLikeThis, updateFeedback } from '@/service/share'
const MAX_DEPTH = 3
@@ -136,7 +136,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
}
const mainStyle = (() => {
- const res: any = !isTop
+ const res: React.CSSProperties = !isTop
? {
background: depth % 2 === 0 ? 'linear-gradient(90.07deg, #F9FAFB 0.05%, rgba(249, 250, 251, 0) 99.93%)' : '#fff',
}
diff --git a/web/app/components/base/portal-to-follow-elem/index.tsx b/web/app/components/base/portal-to-follow-elem/index.tsx
index 912114fd98e..28ef0f3732e 100644
--- a/web/app/components/base/portal-to-follow-elem/index.tsx
+++ b/web/app/components/base/portal-to-follow-elem/index.tsx
@@ -1,9 +1,10 @@
'use client'
import { useBoolean } from 'ahooks'
-import React, { FC, useEffect, useState, useRef } from 'react'
+import React, { useEffect, useRef, useState } from 'react'
+import type { FC } from 'react'
import { createRoot } from 'react-dom/client'
-export interface IPortalToFollowElementProps {
+type IPortalToFollowElementProps = {
portalElem: React.ReactNode
children: React.ReactNode
controlShow?: number
@@ -14,44 +15,42 @@ const PortalToFollowElement: FC<IPortalToFollowElementProps> = ({
portalElem,
children,
controlShow,
- controlHide
+ controlHide,
}) => {
const [isShowContent, { setTrue: showContent, setFalse: hideContent, toggle: toggleContent }] = useBoolean(false)
const [wrapElem, setWrapElem] = useState<HTMLDivElement | null>(null)
useEffect(() => {
- if (controlShow) {
+ if (controlShow)
showContent()
- }
}, [controlShow])
useEffect(() => {
- if (controlHide) {
+ if (controlHide)
hideContent()
- }
}, [controlHide])
// todo use click outside hidden
- const triggerElemRef = useRef<HTMLElement>(null)
+ const triggerElemRef = useRef<HTMLDivElement>(null)
const calLoc = () => {
const triggerElem = triggerElemRef.current
if (!triggerElem) {
return {
- display: 'none'
+ display: 'none',
}
}
const {
left: triggerLeft,
top: triggerTop,
- height
- } = triggerElem.getBoundingClientRect();
+ height,
+ } = triggerElem.getBoundingClientRect()
return {
position: 'fixed',
left: triggerLeft,
top: triggerTop + height,
- zIndex: 999
+ zIndex: 999,
}
}
@@ -63,19 +62,20 @@ const PortalToFollowElement: FC<IPortalToFollowElementProps> = ({
root.render(
<div style={style as React.CSSProperties}>
{portalElem}
- </div>
+ </div>,
)
document.body.appendChild(holder)
setWrapElem(holder)
console.log(holder)
- } else {
+ }
+ else {
wrapElem?.remove?.()
setWrapElem(null)
}
}, [isShowContent])
return (
- <div ref={triggerElemRef as any} onClick={toggleContent}>
+ <div ref={triggerElemRef as React.RefObject<HTMLDivElement>} onClick={toggleContent}>
{children}
</div>
)
diff --git a/web/app/components/base/radio/component/radio/index.tsx b/web/app/components/base/radio/component/radio/index.tsx
index 702c3cccca5..5767896b152 100644
--- a/web/app/components/base/radio/component/radio/index.tsx
+++ b/web/app/components/base/radio/component/radio/index.tsx
@@ -26,7 +26,7 @@ export default function Radio({
}: IRadioProps): JSX.Element {
const groupContext = useContext(RadioGroupContext)
const labelId = useId()
- const handleChange = (e: any) => {
+ const handleChange = (e: IRadioProps['value']) => {
if (disabled)
return
diff --git a/web/app/components/datasets/settings/form/index.tsx b/web/app/components/datasets/settings/form/index.tsx
index e2454bba805..f163f0ee822 100644
--- a/web/app/components/datasets/settings/form/index.tsx
+++ b/web/app/components/datasets/settings/form/index.tsx
@@ -1,5 +1,6 @@
'use client'
import { useEffect, useState } from 'react'
+import type { Dispatch } from 'react'
import useSWR from 'swr'
import { useContext } from 'use-context-selector'
import { BookOpenIcon } from '@heroicons/react/24/outline'
@@ -24,7 +25,7 @@ const labelClass = `
const inputClass = `
w-[480px] px-3 bg-gray-100 text-sm text-gray-800 rounded-lg outline-none appearance-none
`
-const useInitialValue = (depend: any, dispatch: any) => {
+const useInitialValue: <T>(depend: T, dispatch: Dispatch<T>) => void = (depend, dispatch) => {
useEffect(() => {
dispatch(depend)
}, [depend])
diff --git a/web/app/components/develop/secret-key/secret-key-modal.tsx b/web/app/components/develop/secret-key/secret-key-modal.tsx
index c93f1ce8162..ef9e73f9edc 100644
--- a/web/app/components/develop/secret-key/secret-key-modal.tsx
+++ b/web/app/components/develop/secret-key/secret-key-modal.tsx
@@ -79,7 +79,7 @@ const SecretKeyModal = ({
return `${token.slice(0, 3)}...${token.slice(-20)}`
}
- const formatDate = (timestamp: any) => {
+ const formatDate = (timestamp: string) => {
if (locale === 'en')
return new Intl.DateTimeFormat('en-US', { year: 'numeric', month: 'long', day: 'numeric' }).format((+timestamp) * 1000)
else
diff --git a/web/app/components/explore/app-list/index.tsx b/web/app/components/explore/app-list/index.tsx
index 4c6d995d0d8..382e462c4d9 100644
--- a/web/app/components/explore/app-list/index.tsx
+++ b/web/app/components/explore/app-list/index.tsx
@@ -13,8 +13,10 @@ import AppCard from '@/app/components/explore/app-card'
import { fetchAppDetail, fetchAppList, installApp } from '@/service/explore'
import { createApp } from '@/service/apps'
import CreateAppModal from '@/app/components/explore/create-app-modal'
+import type { CreateAppModalProps } from '@/app/components/explore/create-app-modal'
import Loading from '@/app/components/base/loading'
import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
+import { type AppMode } from '@/types/app'
const Apps: FC = () => {
const { t } = useTranslation()
@@ -50,7 +52,7 @@ const Apps: FC = () => {
const [currApp, setCurrApp] = React.useState<App | null>(null)
const [isShowCreateModal, setIsShowCreateModal] = React.useState(false)
- const onCreate = async ({ name, icon, icon_background }: any) => {
+ const onCreate: CreateAppModalProps['onConfirm'] = async ({ name, icon, icon_background }) => {
const { app_model_config: model_config } = await fetchAppDetail(currApp?.app.id as string)
try {
@@ -58,7 +60,7 @@ const Apps: FC = () => {
name,
icon,
icon_background,
- mode: currApp?.app.mode as any,
+ mode: currApp?.app.mode as AppMode,
config: model_config,
})
setIsShowCreateModal(false)
diff --git a/web/app/components/explore/create-app-modal/index.tsx b/web/app/components/explore/create-app-modal/index.tsx
index 52de4b8720d..52e9652c718 100644
--- a/web/app/components/explore/create-app-modal/index.tsx
+++ b/web/app/components/explore/create-app-modal/index.tsx
@@ -9,10 +9,14 @@ import Toast from '@/app/components/base/toast'
import AppIcon from '@/app/components/base/app-icon'
import EmojiPicker from '@/app/components/base/emoji-picker'
-type IProps = {
+export type CreateAppModalProps = {
appName: string
show: boolean
- onConfirm: (info: any) => void
+ onConfirm: (info: {
+ name: string
+ icon: string
+ icon_background: string
+ }) => Promise<void>
onHide: () => void
}
@@ -21,7 +25,7 @@ const CreateAppModal = ({
show = false,
onConfirm,
onHide,
-}: IProps) => {
+}: CreateAppModalProps) => {
const { t } = useTranslation()
const [name, setName] = React.useState('')
diff --git a/web/app/components/explore/universal-chat/config-view/detail/index.tsx b/web/app/components/explore/universal-chat/config-view/detail/index.tsx
index fda11c74b5f..debaaef0c38 100644
--- a/web/app/components/explore/universal-chat/config-view/detail/index.tsx
+++ b/web/app/components/explore/universal-chat/config-view/detail/index.tsx
@@ -6,12 +6,13 @@ import { useTranslation } from 'react-i18next'
import s from './style.module.css'
import Config from '@/app/components/explore/universal-chat/config'
import type { ProviderEnum } from '@/app/components/header/account-setting/model-page/declarations'
+import type { DataSet } from '@/models/datasets'
type Props = {
modelId: string
providerName: ProviderEnum
plugins: Record<string, boolean>
- dataSets: any[]
+ dataSets: DataSet[]
}
const ConfigViewPanel: FC<Props> = ({
modelId,
diff --git a/web/app/components/explore/universal-chat/config-view/summary/index.tsx b/web/app/components/explore/universal-chat/config-view/summary/index.tsx
index 6acb6fb84b7..124903c6184 100644
--- a/web/app/components/explore/universal-chat/config-view/summary/index.tsx
+++ b/web/app/components/explore/universal-chat/config-view/summary/index.tsx
@@ -10,12 +10,13 @@ import ConfigDetail from '@/app/components/explore/universal-chat/config-view/de
import type { ProviderEnum } from '@/app/components/header/account-setting/model-page/declarations'
import ModelName from '@/app/components/app/configuration/config-model/model-name'
import { useProviderContext } from '@/context/provider-context'
+import type { DataSet } from '@/models/datasets'
export type ISummaryProps = {
modelId: string
providerName: ProviderEnum
plugins: Record<string, boolean>
- dataSets: any[]
+ dataSets: DataSet[]
}
const getColorInfo = (modelId: string) => {
diff --git a/web/app/components/explore/universal-chat/config/index.tsx b/web/app/components/explore/universal-chat/config/index.tsx
index 7b6f4e59a20..a6d3528ba2f 100644
--- a/web/app/components/explore/universal-chat/config/index.tsx
+++ b/web/app/components/explore/universal-chat/config/index.tsx
@@ -5,6 +5,7 @@ import ModelConfig from './model-config'
import DataConfig from './data-config'
import PluginConfig from './plugins-config'
import type { ProviderEnum } from '@/app/components/header/account-setting/model-page/declarations'
+import type { DataSet } from '@/models/datasets'
export type IConfigProps = {
className?: string
@@ -14,8 +15,8 @@ export type IConfigProps = {
onModelChange?: (modelId: string, providerName: ProviderEnum) => void
plugins: Record<string, boolean>
onPluginChange?: (key: string, value: boolean) => void
- dataSets: any[]
- onDataSetsChange?: (contexts: any[]) => void
+ dataSets: DataSet[]
+ onDataSetsChange?: (contexts: DataSet[]) => void
}
const Config: FC<IConfigProps> = ({
diff --git a/web/app/components/explore/universal-chat/config/plugins-config/index.tsx b/web/app/components/explore/universal-chat/config/plugins-config/index.tsx
index e374d79fefc..25f24989a19 100644
--- a/web/app/components/explore/universal-chat/config/plugins-config/index.tsx
+++ b/web/app/components/explore/universal-chat/config/plugins-config/index.tsx
@@ -19,7 +19,8 @@ const plugins = [
{ key: 'google_search', icon: <Google /> },
{ key: 'web_reader', icon: <WebReader /> },
{ key: 'wikipedia', icon: <Wikipedia /> },
-]
+] as const
+
const Plugins: FC<IPluginsProps> = ({
readonly,
config,
diff --git a/web/app/components/header/account-setting/model-page/model-item/Card.tsx b/web/app/components/header/account-setting/model-page/model-item/Card.tsx
index 65a98d5c529..98485054df0 100644
--- a/web/app/components/header/account-setting/model-page/model-item/Card.tsx
+++ b/web/app/components/header/account-setting/model-page/model-item/Card.tsx
@@ -8,7 +8,7 @@ import Button from '@/app/components/base/button'
type CardProps = {
providerType: ProviderEnum
- models: any[]
+ models: Model[]
onOpenModal: (v: any) => void
onOperate: (v: Record<string, any>) => void
}
@@ -33,7 +33,7 @@ const Card: FC<CardProps> = ({
return (
<div className='px-3 pb-3'>
{
- models.map((model: Model) => (
+ models.map(model => (
<div key={`${model.model_name}-${model.model_type}`} className='flex mb-1 px-3 py-2 bg-white rounded-lg shadow-xs last:mb-0'>
<div className='grow'>
<div className='flex items-center mb-0.5 h-[18px] text-[13px] font-medium text-gray-700'>
diff --git a/web/app/components/header/account-setting/model-page/model-selector/index.tsx b/web/app/components/header/account-setting/model-page/model-selector/index.tsx
index 81592e1b27f..f7c300cdd0c 100644
--- a/web/app/components/header/account-setting/model-page/model-selector/index.tsx
+++ b/web/app/components/header/account-setting/model-page/model-selector/index.tsx
@@ -15,6 +15,7 @@ import ModelIcon from '@/app/components/app/configuration/config-model/model-ico
import ModelName, { supportI18nModelName } from '@/app/components/app/configuration/config-model/model-name'
import ProviderName from '@/app/components/app/configuration/config-model/provider-name'
import { useProviderContext } from '@/context/provider-context'
+
type Props = {
value: {
providerName: ProviderEnum
@@ -28,6 +29,16 @@ type Props = {
triggerIconSmall?: boolean
}
+type ModelOption = {
+ type: 'model'
+ value: string
+ providerName: ProviderEnum
+ modelDisplayName: string
+} | {
+ type: 'provider'
+ value: ProviderEnum
+}
+
const ModelSelector: FC<Props> = ({
value,
modelType,
@@ -69,9 +80,9 @@ const ModelSelector: FC<Props> = ({
const hasRemoved = value && !modelList.find(({ model_name }) => model_name === value.modelName)
- const modelOptions: any[] = (() => {
+ const modelOptions: ModelOption[] = (() => {
const providers = _.uniq(filteredModelList.map(item => item.model_provider.provider_name))
- const res: any[] = []
+ const res: ModelOption[] = []
providers.forEach((providerName) => {
res.push({
type: 'provider',
@@ -162,7 +173,7 @@ const ModelSelector: FC<Props> = ({
</div>
</div>
{
- modelOptions.map((model: any) => {
+ modelOptions.map((model) => {
if (model.type === 'provider') {
return (
<div
diff --git a/web/app/components/header/account-setting/plugin-page/index.tsx b/web/app/components/header/account-setting/plugin-page/index.tsx
index 4b8c11e6abd..191938d435b 100644
--- a/web/app/components/header/account-setting/plugin-page/index.tsx
+++ b/web/app/components/header/account-setting/plugin-page/index.tsx
@@ -10,7 +10,7 @@ const PluginPage = () => {
const { t } = useTranslation()
const { data: plugins, mutate } = useSWR('/workspaces/current/tool-providers', fetchPluginProviders)
- const Plugin_MAP: Record<string, any> = {
+ const Plugin_MAP: Record<string, (plugin: PluginProvider) => JSX.Element> = {
serpapi: (plugin: PluginProvider) => <SerpapiPlugin key='serpapi' plugin={plugin} onUpdate={() => mutate()} />,
}
diff --git a/web/app/components/share/chat/index.tsx b/web/app/components/share/chat/index.tsx
index 53d8ece2500..7ba0ad69e3e 100644
--- a/web/app/components/share/chat/index.tsx
+++ b/web/app/components/share/chat/index.tsx
@@ -30,7 +30,7 @@ import {
} from '@/service/share'
import type { ConversationItem, SiteInfo } from '@/models/share'
import type { PromptConfig, SuggestedQuestionsAfterAnswerConfig } from '@/models/debug'
-import type { Feedbacktype, IChatItem } from '@/app/components/app/chat'
+import type { Feedbacktype, IChatItem } from '@/app/components/app/chat/type'
import Chat from '@/app/components/app/chat'
import { changeLanguage } from '@/i18n/i18next-config'
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
diff --git a/web/app/components/share/text-generation/result/content.tsx b/web/app/components/share/text-generation/result/content.tsx
index 227c583bdd9..21fd5fb6a05 100644
--- a/web/app/components/share/text-generation/result/content.tsx
+++ b/web/app/components/share/text-generation/result/content.tsx
@@ -1,7 +1,7 @@
import type { FC } from 'react'
import React from 'react'
import Header from './header'
-import type { Feedbacktype } from '@/app/components/app/chat'
+import type { Feedbacktype } from '@/app/components/app/chat/type'
import { format } from '@/service/base'
export type IResultProps = {
diff --git a/web/app/components/share/text-generation/result/index.tsx b/web/app/components/share/text-generation/result/index.tsx
index f53b39352b4..443d0dd1a30 100644
--- a/web/app/components/share/text-generation/result/index.tsx
+++ b/web/app/components/share/text-generation/result/index.tsx
@@ -8,7 +8,7 @@ import TextGenerationRes from '@/app/components/app/text-generate/item'
import NoData from '@/app/components/share/text-generation/no-data'
import Toast from '@/app/components/base/toast'
import { sendCompletionMessage, updateFeedback } from '@/service/share'
-import type { Feedbacktype } from '@/app/components/app/chat'
+import type { Feedbacktype } from '@/app/components/app/chat/type'
import Loading from '@/app/components/base/loading'
import type { PromptConfig } from '@/models/debug'
import type { InstalledApp } from '@/models/explore'
diff --git a/web/app/signin/normalForm.tsx b/web/app/signin/normalForm.tsx
index efb3de7839c..515cc283f5f 100644
--- a/web/app/signin/normalForm.tsx
+++ b/web/app/signin/normalForm.tsx
@@ -22,7 +22,11 @@ type IState = {
google: boolean
}
-function reducer(state: IState, action: { type: string; payload: any }) {
+type IAction = {
+ type: 'login' | 'login_failed' | 'github_login' | 'github_login_failed' | 'google_login' | 'google_login_failed'
+}
+
+function reducer(state: IState, action: IAction) {
switch (action.type) {
case 'login':
return {
@@ -120,14 +124,14 @@ const NormalForm = () => {
useEffect(() => {
if (github_error !== undefined)
- dispatch({ type: 'github_login_failed', payload: null })
+ dispatch({ type: 'github_login_failed' })
if (github)
window.location.href = github.redirect_url
}, [github, github_error])
useEffect(() => {
if (google_error !== undefined)
- dispatch({ type: 'google_login_failed', payload: null })
+ dispatch({ type: 'google_login_failed' })
if (google)
window.location.href = google.redirect_url
}, [google, google])