Explorar o código

chore: perfect type definition (#940)

bowen hai 1 ano
pai
achega
5e0540077a
Modificáronse 25 ficheiros con 97 adicións e 70 borrados
  1. 2 1
      web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/cardView.tsx
  2. 1 1
      web/app/components/app/chat/answer/index.tsx
  3. 3 3
      web/app/components/app/chat/index.tsx
  4. 10 10
      web/app/components/app/configuration/config-var/input-type-icon.tsx
  5. 2 7
      web/app/components/app/configuration/dataset-config/card-item/index.tsx
  6. 5 4
      web/app/components/app/overview/appCard.tsx
  7. 6 2
      web/app/components/app/overview/settings/index.tsx
  8. 2 2
      web/app/components/app/text-generate/item/index.tsx
  9. 15 15
      web/app/components/base/portal-to-follow-elem/index.tsx
  10. 1 1
      web/app/components/base/radio/component/radio/index.tsx
  11. 2 1
      web/app/components/datasets/settings/form/index.tsx
  12. 1 1
      web/app/components/develop/secret-key/secret-key-modal.tsx
  13. 4 2
      web/app/components/explore/app-list/index.tsx
  14. 7 3
      web/app/components/explore/create-app-modal/index.tsx
  15. 2 1
      web/app/components/explore/universal-chat/config-view/detail/index.tsx
  16. 2 1
      web/app/components/explore/universal-chat/config-view/summary/index.tsx
  17. 3 2
      web/app/components/explore/universal-chat/config/index.tsx
  18. 2 1
      web/app/components/explore/universal-chat/config/plugins-config/index.tsx
  19. 2 2
      web/app/components/header/account-setting/model-page/model-item/Card.tsx
  20. 14 3
      web/app/components/header/account-setting/model-page/model-selector/index.tsx
  21. 1 1
      web/app/components/header/account-setting/plugin-page/index.tsx
  22. 1 1
      web/app/components/share/chat/index.tsx
  23. 1 1
      web/app/components/share/text-generation/result/content.tsx
  24. 1 1
      web/app/components/share/text-generation/result/index.tsx
  25. 7 3
      web/app/signin/normalForm.tsx

+ 2 - 1
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 type { UpdateAppSiteCodeResponse } from '@/models/app'
 import { asyncRunSafe } from '@/utils'
 import { asyncRunSafe } from '@/utils'
 import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
 import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
+import type { IAppCardProps } from '@/app/components/app/overview/appCard'
 
 
 export type ICardViewProps = {
 export type ICardViewProps = {
   appId: string
   appId: string
@@ -68,7 +69,7 @@ const CardView: FC<ICardViewProps> = ({ appId }) => {
     handleError(err)
     handleError(err)
   }
   }
 
 
-  const onSaveSiteConfig = async (params: any) => {
+  const onSaveSiteConfig: IAppCardProps['onSaveSiteConfig'] = async (params) => {
     const [err] = await asyncRunSafe<App>(
     const [err] = await asyncRunSafe<App>(
       updateAppSiteConfig({
       updateAppSiteConfig({
         url: `/apps/${appId}/site`,
         url: `/apps/${appId}/site`,

+ 1 - 1
web/app/components/app/chat/answer/index.tsx

@@ -225,7 +225,7 @@ const Answer: FC<IAnswerProps> = ({ item, feedbackDisabled = false, isHideFeedba
                           setLoading(true)
                           setLoading(true)
                           const res = await onSubmitAnnotation?.(id, inputValue)
                           const res = await onSubmitAnnotation?.(id, inputValue)
                           if (res)
                           if (res)
-                            setAnnotation({ ...annotation, content: inputValue } as any)
+                            setAnnotation({ ...annotation, content: inputValue } as Annotation)
                           setLoading(false)
                           setLoading(false)
                           setShowEdit(false)
                           setShowEdit(false)
                         }}>{t('common.operation.confirm')}</Button>
                         }}>{t('common.operation.confirm')}</Button>

+ 3 - 3
web/app/components/app/chat/index.tsx

@@ -81,7 +81,7 @@ const Chat: FC<IChatProps> = ({
   const isUseInputMethod = useRef(false)
   const isUseInputMethod = useRef(false)
 
 
   const [query, setQuery] = React.useState('')
   const [query, setQuery] = React.useState('')
-  const handleContentChange = (e: any) => {
+  const handleContentChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
     const value = e.target.value
     const value = e.target.value
     setQuery(value)
     setQuery(value)
   }
   }
@@ -111,7 +111,7 @@ const Chat: FC<IChatProps> = ({
       setQuery('')
       setQuery('')
   }
   }
 
 
-  const handleKeyUp = (e: any) => {
+  const handleKeyUp = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
     if (e.code === 'Enter') {
     if (e.code === 'Enter') {
       e.preventDefault()
       e.preventDefault()
       // prevent send message when using input method enter
       // 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
     isUseInputMethod.current = e.nativeEvent.isComposing
     if (e.code === 'Enter' && !e.shiftKey) {
     if (e.code === 'Enter' && !e.shiftKey) {
       setQuery(query.replace(/\n$/, ''))
       setQuery(query.replace(/\n$/, ''))

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 10 - 10
web/app/components/app/configuration/config-var/input-type-icon.tsx


+ 2 - 7
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 TypeIcon from '../type-icon'
 import RemoveIcon from '../../base/icons/remove-icon'
 import RemoveIcon from '../../base/icons/remove-icon'
 import s from './style.module.css'
 import s from './style.module.css'
+import type { DataSet } from '@/models/datasets'
 import { formatNumber } from '@/utils/format'
 import { formatNumber } from '@/utils/format'
 import Tooltip from '@/app/components/base/tooltip'
 import Tooltip from '@/app/components/base/tooltip'
 
 
 export type ICardItemProps = {
 export type ICardItemProps = {
   className?: string
   className?: string
-  config: any
+  config: DataSet
   onRemove: (id: string) => void
   onRemove: (id: string) => void
   readonly?: boolean
   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> = ({
 const CardItem: FC<ICardItemProps> = ({
   className,
   className,
   config,
   config,

+ 5 - 4
web/app/components/app/overview/appCard.tsx

@@ -13,6 +13,7 @@ import SettingsModal from './settings'
 import EmbeddedModal from './embedded'
 import EmbeddedModal from './embedded'
 import CustomizeModal from './customize'
 import CustomizeModal from './customize'
 import style from './style.module.css'
 import style from './style.module.css'
+import type { ConfigParams } from './settings'
 import Tooltip from '@/app/components/base/tooltip'
 import Tooltip from '@/app/components/base/tooltip'
 import AppBasic from '@/app/components/app-sidebar/basic'
 import AppBasic from '@/app/components/app-sidebar/basic'
 import { asyncRunSafe, randomString } from '@/utils'
 import { asyncRunSafe, randomString } from '@/utils'
@@ -31,9 +32,9 @@ export type IAppCardProps = {
   appInfo: AppDetailResponse
   appInfo: AppDetailResponse
   cardType?: 'api' | 'webapp'
   cardType?: 'api' | 'webapp'
   customBgColor?: string
   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 = '' }) => {
 const EmbedIcon: FC<{ className?: string }> = ({ className = '' }) => {
@@ -193,7 +194,7 @@ function AppCard({
         </div>
         </div>
         <div className={'pt-2 flex flex-row items-center'}>
         <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} />}
           {!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
             const disabled
               = op.opName === t('appOverview.overview.appInfo.settings.entry')
               = op.opName === t('appOverview.overview.appInfo.settings.entry')
                 ? false
                 ? false

+ 6 - 2
web/app/components/app/overview/settings/index.tsx

@@ -18,7 +18,7 @@ export type ISettingsModalProps = {
   isShow: boolean
   isShow: boolean
   defaultValue?: string
   defaultValue?: string
   onClose: () => void
   onClose: () => void
-  onSave?: (params: ConfigParams) => Promise<any>
+  onSave?: (params: ConfigParams) => Promise<void>
 }
 }
 
 
 export type ConfigParams = {
 export type ConfigParams = {
@@ -26,6 +26,10 @@ export type ConfigParams = {
   description: string
   description: string
   default_language: string
   default_language: string
   prompt_public: boolean
   prompt_public: boolean
+  copyright: string
+  privacy_policy: string
+  icon: string
+  icon_background: string
 }
 }
 
 
 const LANGUAGE_MAP: Record<Language, string> = {
 const LANGUAGE_MAP: Record<Language, string> = {
@@ -82,7 +86,7 @@ const SettingsModal: FC<ISettingsModalProps> = ({
   }
   }
 
 
   const onChange = (field: string) => {
   const onChange = (field: string) => {
-    return (e: any) => {
+    return (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
       setInputInfo(item => ({ ...item, [field]: e.target.value }))
       setInputInfo(item => ({ ...item, [field]: e.target.value }))
     }
     }
   }
   }

+ 2 - 2
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 { Markdown } from '@/app/components/base/markdown'
 import Loading from '@/app/components/base/loading'
 import Loading from '@/app/components/base/loading'
 import Toast from '@/app/components/base/toast'
 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'
 import { fetchMoreLikeThis, updateFeedback } from '@/service/share'
 
 
 const MAX_DEPTH = 3
 const MAX_DEPTH = 3
@@ -136,7 +136,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
   }
   }
 
 
   const mainStyle = (() => {
   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',
         background: depth % 2 === 0 ? 'linear-gradient(90.07deg, #F9FAFB 0.05%, rgba(249, 250, 251, 0) 99.93%)' : '#fff',
       }
       }

+ 15 - 15
web/app/components/base/portal-to-follow-elem/index.tsx

@@ -1,9 +1,10 @@
 'use client'
 'use client'
 import { useBoolean } from 'ahooks'
 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'
 import { createRoot } from 'react-dom/client'
 
 
-export interface IPortalToFollowElementProps {
+type IPortalToFollowElementProps = {
   portalElem: React.ReactNode
   portalElem: React.ReactNode
   children: React.ReactNode
   children: React.ReactNode
   controlShow?: number
   controlShow?: number
@@ -14,44 +15,42 @@ const PortalToFollowElement: FC<IPortalToFollowElementProps> = ({
   portalElem,
   portalElem,
   children,
   children,
   controlShow,
   controlShow,
-  controlHide
+  controlHide,
 }) => {
 }) => {
   const [isShowContent, { setTrue: showContent, setFalse: hideContent, toggle: toggleContent }] = useBoolean(false)
   const [isShowContent, { setTrue: showContent, setFalse: hideContent, toggle: toggleContent }] = useBoolean(false)
   const [wrapElem, setWrapElem] = useState<HTMLDivElement | null>(null)
   const [wrapElem, setWrapElem] = useState<HTMLDivElement | null>(null)
 
 
   useEffect(() => {
   useEffect(() => {
-    if (controlShow) {
+    if (controlShow)
       showContent()
       showContent()
-    }
   }, [controlShow])
   }, [controlShow])
 
 
   useEffect(() => {
   useEffect(() => {
-    if (controlHide) {
+    if (controlHide)
       hideContent()
       hideContent()
-    }
   }, [controlHide])
   }, [controlHide])
 
 
   // todo use click outside hidden
   // todo use click outside hidden
-  const triggerElemRef = useRef<HTMLElement>(null)
+  const triggerElemRef = useRef<HTMLDivElement>(null)
 
 
   const calLoc = () => {
   const calLoc = () => {
     const triggerElem = triggerElemRef.current
     const triggerElem = triggerElemRef.current
     if (!triggerElem) {
     if (!triggerElem) {
       return {
       return {
-        display: 'none'
+        display: 'none',
       }
       }
     }
     }
     const {
     const {
       left: triggerLeft,
       left: triggerLeft,
       top: triggerTop,
       top: triggerTop,
-      height
-    } = triggerElem.getBoundingClientRect();
+      height,
+    } = triggerElem.getBoundingClientRect()
 
 
     return {
     return {
       position: 'fixed',
       position: 'fixed',
       left: triggerLeft,
       left: triggerLeft,
       top: triggerTop + height,
       top: triggerTop + height,
-      zIndex: 999
+      zIndex: 999,
     }
     }
   }
   }
 
 
@@ -63,19 +62,20 @@ const PortalToFollowElement: FC<IPortalToFollowElementProps> = ({
       root.render(
       root.render(
         <div style={style as React.CSSProperties}>
         <div style={style as React.CSSProperties}>
           {portalElem}
           {portalElem}
-        </div>
+        </div>,
       )
       )
       document.body.appendChild(holder)
       document.body.appendChild(holder)
       setWrapElem(holder)
       setWrapElem(holder)
       console.log(holder)
       console.log(holder)
-    } else {
+    }
+    else {
       wrapElem?.remove?.()
       wrapElem?.remove?.()
       setWrapElem(null)
       setWrapElem(null)
     }
     }
   }, [isShowContent])
   }, [isShowContent])
 
 
   return (
   return (
-    <div ref={triggerElemRef as any} onClick={toggleContent}>
+    <div ref={triggerElemRef as React.RefObject<HTMLDivElement>} onClick={toggleContent}>
       {children}
       {children}
     </div>
     </div>
   )
   )

+ 1 - 1
web/app/components/base/radio/component/radio/index.tsx

@@ -26,7 +26,7 @@ export default function Radio({
 }: IRadioProps): JSX.Element {
 }: IRadioProps): JSX.Element {
   const groupContext = useContext(RadioGroupContext)
   const groupContext = useContext(RadioGroupContext)
   const labelId = useId()
   const labelId = useId()
-  const handleChange = (e: any) => {
+  const handleChange = (e: IRadioProps['value']) => {
     if (disabled)
     if (disabled)
       return
       return
 
 

+ 2 - 1
web/app/components/datasets/settings/form/index.tsx

@@ -1,5 +1,6 @@
 'use client'
 'use client'
 import { useEffect, useState } from 'react'
 import { useEffect, useState } from 'react'
+import type { Dispatch } from 'react'
 import useSWR from 'swr'
 import useSWR from 'swr'
 import { useContext } from 'use-context-selector'
 import { useContext } from 'use-context-selector'
 import { BookOpenIcon } from '@heroicons/react/24/outline'
 import { BookOpenIcon } from '@heroicons/react/24/outline'
@@ -24,7 +25,7 @@ const labelClass = `
 const inputClass = `
 const inputClass = `
   w-[480px] px-3 bg-gray-100 text-sm text-gray-800 rounded-lg outline-none appearance-none
   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(() => {
   useEffect(() => {
     dispatch(depend)
     dispatch(depend)
   }, [depend])
   }, [depend])

+ 1 - 1
web/app/components/develop/secret-key/secret-key-modal.tsx

@@ -79,7 +79,7 @@ const SecretKeyModal = ({
     return `${token.slice(0, 3)}...${token.slice(-20)}`
     return `${token.slice(0, 3)}...${token.slice(-20)}`
   }
   }
 
 
-  const formatDate = (timestamp: any) => {
+  const formatDate = (timestamp: string) => {
     if (locale === 'en')
     if (locale === 'en')
       return new Intl.DateTimeFormat('en-US', { year: 'numeric', month: 'long', day: 'numeric' }).format((+timestamp) * 1000)
       return new Intl.DateTimeFormat('en-US', { year: 'numeric', month: 'long', day: 'numeric' }).format((+timestamp) * 1000)
     else
     else

+ 4 - 2
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 { fetchAppDetail, fetchAppList, installApp } from '@/service/explore'
 import { createApp } from '@/service/apps'
 import { createApp } from '@/service/apps'
 import CreateAppModal from '@/app/components/explore/create-app-modal'
 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 Loading from '@/app/components/base/loading'
 import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
 import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
+import { type AppMode } from '@/types/app'
 
 
 const Apps: FC = () => {
 const Apps: FC = () => {
   const { t } = useTranslation()
   const { t } = useTranslation()
@@ -50,7 +52,7 @@ const Apps: FC = () => {
 
 
   const [currApp, setCurrApp] = React.useState<App | null>(null)
   const [currApp, setCurrApp] = React.useState<App | null>(null)
   const [isShowCreateModal, setIsShowCreateModal] = React.useState(false)
   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)
     const { app_model_config: model_config } = await fetchAppDetail(currApp?.app.id as string)
 
 
     try {
     try {
@@ -58,7 +60,7 @@ const Apps: FC = () => {
         name,
         name,
         icon,
         icon,
         icon_background,
         icon_background,
-        mode: currApp?.app.mode as any,
+        mode: currApp?.app.mode as AppMode,
         config: model_config,
         config: model_config,
       })
       })
       setIsShowCreateModal(false)
       setIsShowCreateModal(false)

+ 7 - 3
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 AppIcon from '@/app/components/base/app-icon'
 import EmojiPicker from '@/app/components/base/emoji-picker'
 import EmojiPicker from '@/app/components/base/emoji-picker'
 
 
-type IProps = {
+export type CreateAppModalProps = {
   appName: string
   appName: string
   show: boolean
   show: boolean
-  onConfirm: (info: any) => void
+  onConfirm: (info: {
+    name: string
+    icon: string
+    icon_background: string
+  }) => Promise<void>
   onHide: () => void
   onHide: () => void
 }
 }
 
 
@@ -21,7 +25,7 @@ const CreateAppModal = ({
   show = false,
   show = false,
   onConfirm,
   onConfirm,
   onHide,
   onHide,
-}: IProps) => {
+}: CreateAppModalProps) => {
   const { t } = useTranslation()
   const { t } = useTranslation()
 
 
   const [name, setName] = React.useState('')
   const [name, setName] = React.useState('')

+ 2 - 1
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 s from './style.module.css'
 import Config from '@/app/components/explore/universal-chat/config'
 import Config from '@/app/components/explore/universal-chat/config'
 import type { ProviderEnum } from '@/app/components/header/account-setting/model-page/declarations'
 import type { ProviderEnum } from '@/app/components/header/account-setting/model-page/declarations'
+import type { DataSet } from '@/models/datasets'
 
 
 type Props = {
 type Props = {
   modelId: string
   modelId: string
   providerName: ProviderEnum
   providerName: ProviderEnum
   plugins: Record<string, boolean>
   plugins: Record<string, boolean>
-  dataSets: any[]
+  dataSets: DataSet[]
 }
 }
 const ConfigViewPanel: FC<Props> = ({
 const ConfigViewPanel: FC<Props> = ({
   modelId,
   modelId,

+ 2 - 1
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 type { ProviderEnum } from '@/app/components/header/account-setting/model-page/declarations'
 import ModelName from '@/app/components/app/configuration/config-model/model-name'
 import ModelName from '@/app/components/app/configuration/config-model/model-name'
 import { useProviderContext } from '@/context/provider-context'
 import { useProviderContext } from '@/context/provider-context'
+import type { DataSet } from '@/models/datasets'
 
 
 export type ISummaryProps = {
 export type ISummaryProps = {
   modelId: string
   modelId: string
   providerName: ProviderEnum
   providerName: ProviderEnum
   plugins: Record<string, boolean>
   plugins: Record<string, boolean>
-  dataSets: any[]
+  dataSets: DataSet[]
 }
 }
 
 
 const getColorInfo = (modelId: string) => {
 const getColorInfo = (modelId: string) => {

+ 3 - 2
web/app/components/explore/universal-chat/config/index.tsx

@@ -5,6 +5,7 @@ import ModelConfig from './model-config'
 import DataConfig from './data-config'
 import DataConfig from './data-config'
 import PluginConfig from './plugins-config'
 import PluginConfig from './plugins-config'
 import type { ProviderEnum } from '@/app/components/header/account-setting/model-page/declarations'
 import type { ProviderEnum } from '@/app/components/header/account-setting/model-page/declarations'
+import type { DataSet } from '@/models/datasets'
 
 
 export type IConfigProps = {
 export type IConfigProps = {
   className?: string
   className?: string
@@ -14,8 +15,8 @@ export type IConfigProps = {
   onModelChange?: (modelId: string, providerName: ProviderEnum) => void
   onModelChange?: (modelId: string, providerName: ProviderEnum) => void
   plugins: Record<string, boolean>
   plugins: Record<string, boolean>
   onPluginChange?: (key: string, value: boolean) => void
   onPluginChange?: (key: string, value: boolean) => void
-  dataSets: any[]
-  onDataSetsChange?: (contexts: any[]) => void
+  dataSets: DataSet[]
+  onDataSetsChange?: (contexts: DataSet[]) => void
 }
 }
 
 
 const Config: FC<IConfigProps> = ({
 const Config: FC<IConfigProps> = ({

+ 2 - 1
web/app/components/explore/universal-chat/config/plugins-config/index.tsx

@@ -19,7 +19,8 @@ const plugins = [
   { key: 'google_search', icon: <Google /> },
   { key: 'google_search', icon: <Google /> },
   { key: 'web_reader', icon: <WebReader /> },
   { key: 'web_reader', icon: <WebReader /> },
   { key: 'wikipedia', icon: <Wikipedia /> },
   { key: 'wikipedia', icon: <Wikipedia /> },
-]
+] as const
+
 const Plugins: FC<IPluginsProps> = ({
 const Plugins: FC<IPluginsProps> = ({
   readonly,
   readonly,
   config,
   config,

+ 2 - 2
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 = {
 type CardProps = {
   providerType: ProviderEnum
   providerType: ProviderEnum
-  models: any[]
+  models: Model[]
   onOpenModal: (v: any) => void
   onOpenModal: (v: any) => void
   onOperate: (v: Record<string, any>) => void
   onOperate: (v: Record<string, any>) => void
 }
 }
@@ -33,7 +33,7 @@ const Card: FC<CardProps> = ({
   return (
   return (
     <div className='px-3 pb-3'>
     <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 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='grow'>
               <div className='flex items-center mb-0.5 h-[18px] text-[13px] font-medium text-gray-700'>
               <div className='flex items-center mb-0.5 h-[18px] text-[13px] font-medium text-gray-700'>

+ 14 - 3
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 ModelName, { supportI18nModelName } from '@/app/components/app/configuration/config-model/model-name'
 import ProviderName from '@/app/components/app/configuration/config-model/provider-name'
 import ProviderName from '@/app/components/app/configuration/config-model/provider-name'
 import { useProviderContext } from '@/context/provider-context'
 import { useProviderContext } from '@/context/provider-context'
+
 type Props = {
 type Props = {
   value: {
   value: {
     providerName: ProviderEnum
     providerName: ProviderEnum
@@ -28,6 +29,16 @@ type Props = {
   triggerIconSmall?: boolean
   triggerIconSmall?: boolean
 }
 }
 
 
+type ModelOption = {
+  type: 'model'
+  value: string
+  providerName: ProviderEnum
+  modelDisplayName: string
+} | {
+  type: 'provider'
+  value: ProviderEnum
+}
+
 const ModelSelector: FC<Props> = ({
 const ModelSelector: FC<Props> = ({
   value,
   value,
   modelType,
   modelType,
@@ -69,9 +80,9 @@ const ModelSelector: FC<Props> = ({
 
 
   const hasRemoved = value && !modelList.find(({ model_name }) => model_name === value.modelName)
   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 providers = _.uniq(filteredModelList.map(item => item.model_provider.provider_name))
-    const res: any[] = []
+    const res: ModelOption[] = []
     providers.forEach((providerName) => {
     providers.forEach((providerName) => {
       res.push({
       res.push({
         type: 'provider',
         type: 'provider',
@@ -162,7 +173,7 @@ const ModelSelector: FC<Props> = ({
                 </div>
                 </div>
               </div>
               </div>
               {
               {
-                modelOptions.map((model: any) => {
+                modelOptions.map((model) => {
                   if (model.type === 'provider') {
                   if (model.type === 'provider') {
                     return (
                     return (
                       <div
                       <div

+ 1 - 1
web/app/components/header/account-setting/plugin-page/index.tsx

@@ -10,7 +10,7 @@ const PluginPage = () => {
   const { t } = useTranslation()
   const { t } = useTranslation()
   const { data: plugins, mutate } = useSWR('/workspaces/current/tool-providers', fetchPluginProviders)
   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()} />,
     serpapi: (plugin: PluginProvider) => <SerpapiPlugin key='serpapi' plugin={plugin} onUpdate={() => mutate()} />,
   }
   }
 
 

+ 1 - 1
web/app/components/share/chat/index.tsx

@@ -30,7 +30,7 @@ import {
 } from '@/service/share'
 } from '@/service/share'
 import type { ConversationItem, SiteInfo } from '@/models/share'
 import type { ConversationItem, SiteInfo } from '@/models/share'
 import type { PromptConfig, SuggestedQuestionsAfterAnswerConfig } from '@/models/debug'
 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 Chat from '@/app/components/app/chat'
 import { changeLanguage } from '@/i18n/i18next-config'
 import { changeLanguage } from '@/i18n/i18next-config'
 import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
 import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'

+ 1 - 1
web/app/components/share/text-generation/result/content.tsx

@@ -1,7 +1,7 @@
 import type { FC } from 'react'
 import type { FC } from 'react'
 import React from 'react'
 import React from 'react'
 import Header from './header'
 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'
 import { format } from '@/service/base'
 
 
 export type IResultProps = {
 export type IResultProps = {

+ 1 - 1
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 NoData from '@/app/components/share/text-generation/no-data'
 import Toast from '@/app/components/base/toast'
 import Toast from '@/app/components/base/toast'
 import { sendCompletionMessage, updateFeedback } from '@/service/share'
 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 Loading from '@/app/components/base/loading'
 import type { PromptConfig } from '@/models/debug'
 import type { PromptConfig } from '@/models/debug'
 import type { InstalledApp } from '@/models/explore'
 import type { InstalledApp } from '@/models/explore'

+ 7 - 3
web/app/signin/normalForm.tsx

@@ -22,7 +22,11 @@ type IState = {
   google: boolean
   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) {
   switch (action.type) {
     case 'login':
     case 'login':
       return {
       return {
@@ -120,14 +124,14 @@ const NormalForm = () => {
 
 
   useEffect(() => {
   useEffect(() => {
     if (github_error !== undefined)
     if (github_error !== undefined)
-      dispatch({ type: 'github_login_failed', payload: null })
+      dispatch({ type: 'github_login_failed' })
     if (github)
     if (github)
       window.location.href = github.redirect_url
       window.location.href = github.redirect_url
   }, [github, github_error])
   }, [github, github_error])
 
 
   useEffect(() => {
   useEffect(() => {
     if (google_error !== undefined)
     if (google_error !== undefined)
-      dispatch({ type: 'google_login_failed', payload: null })
+      dispatch({ type: 'google_login_failed' })
     if (google)
     if (google)
       window.location.href = google.redirect_url
       window.location.href = google.redirect_url
   }, [google, google])
   }, [google, google])