app list filter

This commit is contained in:
JzoNg 2024-11-14 15:08:58 +08:00
parent 7446244147
commit 7b4d67d72f
7 changed files with 39 additions and 27 deletions

View File

@ -40,7 +40,7 @@ const AppPicker: FC<Props> = ({
const [searchText, setSearchText] = useState('')
const { data: appList } = useAppFullList()
const filteredAppList = useMemo(() => {
return (appList || []).filter(app => app.name.toLowerCase().includes(searchText.toLowerCase()))
return (appList?.data || []).filter(app => app.name.toLowerCase().includes(searchText.toLowerCase())).filter(app => (app.mode !== 'advanced-chat' && app.mode !== 'workflow') || !!app.workflow)
}, [appList, searchText])
const getAppType = (app: App) => {
switch (app.mode) {
@ -81,7 +81,6 @@ const AppPicker: FC<Props> = ({
<Input
showLeftIcon
showClearIcon
// wrapperClassName='w-[200px]'
value={searchText}
onChange={e => setSearchText(e.target.value)}
onClear={() => setSearchText('')}

View File

@ -26,6 +26,7 @@ const AppTrigger = ({
)}>
{appDetail && (
<AppIcon
className='mr-2'
size='xs'
iconType={appDetail.icon_type}
icon={appDetail.icon}

View File

@ -48,7 +48,7 @@ const AppSelector: FC<Props> = ({
onShowChange(true)
}
const { data: currentApp } = useAppDetail(value?.app_id || '')
const { data: currentApp } = useAppDetail(value?.app_id || 'empty')
const [isShowChooseApp, setIsShowChooseApp] = useState(false)
const handleSelectApp = (app: App) => {
const appValue = {
@ -74,7 +74,7 @@ const AppSelector: FC<Props> = ({
>
<AppTrigger
open={isShow}
appDetail={undefined}
appDetail={currentApp}
/>
</PortalToFollowElemTrigger>
<PortalToFollowElemContent className='z-[1000]'>
@ -87,7 +87,7 @@ const AppSelector: FC<Props> = ({
trigger={
<AppTrigger
open={isShowChooseApp}
appDetail={undefined}
appDetail={currentApp}
/>
}
isShow={isShowChooseApp}

View File

@ -73,7 +73,7 @@ const EndpointModal: FC<Props> = ({
isEditMode={true}
showOnVariableMap={{}}
validating={false}
inputClassName='bg-components-input-bg-normal hover:bg-state-base-hover-alt'
inputClassName='bg-components-input-bg-normal hover:bg-components-input-bg-hover'
fieldMoreInfo={item => item.url
? (<a
href={item.url}

View File

@ -67,7 +67,7 @@ const ToolCredentialForm: FC<Props> = ({
isEditMode={true}
showOnVariableMap={{}}
validating={false}
inputClassName='bg-components-input-bg-normal hover:bg-state-base-hover-alt'
inputClassName='bg-components-input-bg-normal hover:bg-components-input-bg-hover'
fieldMoreInfo={item => item.url
? (<a
href={item.url}

View File

@ -1,5 +1,6 @@
import { get } from './base'
import type { App } from '@/types/app'
import type { AppListResponse } from '@/models/app'
import { useInvalid } from './use-base'
import { useQuery } from '@tanstack/react-query'
@ -8,9 +9,9 @@ const NAME_SPACE = 'apps'
// TODO paging for list
const useAppFullListKey = [NAME_SPACE, 'full-list']
export const useAppFullList = () => {
return useQuery<App[]>({
return useQuery<AppListResponse>({
queryKey: useAppFullListKey,
queryFn: () => get<App[]>('/apps', { params: { page: 1, limit: 100 } }),
queryFn: () => get<AppListResponse>('/apps', { params: { page: 1, limit: 100 } }),
})
}
@ -21,6 +22,10 @@ export const useInvalidateAppFullList = () => {
export const useAppDetail = (appID: string) => {
return useQuery<App>({
queryKey: [NAME_SPACE, 'detail', appID],
queryFn: () => get<App>(`/apps/${appID}`),
queryFn: () => {
if (appID === 'empty')
return Promise.resolve(undefined as unknown as App)
return get<App>(`/apps/${appID}`)
},
})
}

View File

@ -48,7 +48,7 @@ export enum RETRIEVE_METHOD {
keywordSearch = 'keyword_search',
}
export interface VariableInput {
export type VariableInput = {
key: string
name: string
value: string
@ -69,7 +69,7 @@ export type VariableType = typeof VariableTypes[number]
/**
* Prompt variable parameter
*/
export interface PromptVariable {
export type PromptVariable = {
/** Variable key */
key: string
/** Variable name */
@ -82,7 +82,7 @@ export interface PromptVariable {
max_length?: number
}
export interface TextTypeFormItem {
export type TextTypeFormItem = {
default: string
label: string
variable: string
@ -90,7 +90,7 @@ export interface TextTypeFormItem {
max_length: number
}
export interface SelectTypeFormItem {
export type SelectTypeFormItem = {
default: string
label: string
variable: string
@ -98,7 +98,7 @@ export interface SelectTypeFormItem {
options: string[]
}
export interface ParagraphTypeFormItem {
export type ParagraphTypeFormItem = {
default: string
label: string
variable: string
@ -115,7 +115,7 @@ export type UserInputFormItem = {
paragraph: TextTypeFormItem
}
export interface AgentTool {
export type AgentTool = {
provider_id: string
provider_type: CollectionType
provider_name: string
@ -145,7 +145,7 @@ export enum AgentStrategy {
react = 'react',
}
export interface CompletionParams {
export type CompletionParams = {
/** Maximum number of tokens in the answer message returned by Completion */
max_tokens: number
/**
@ -193,7 +193,7 @@ export interface CompletionParams {
/**
* Model configuration. The backend type.
*/
export interface Model {
export type Model = {
/** LLM provider, e.g., OPENAI */
provider: string
/** Model name, e.g, gpt-3.5.turbo */
@ -203,7 +203,7 @@ export interface Model {
completion_params: CompletionParams
}
export interface ModelConfig {
export type ModelConfig = {
opening_statement: string
suggested_questions?: string[]
pre_prompt: string
@ -254,7 +254,7 @@ export type Language = typeof LanguagesSupported[number]
/**
* Web Application Configuration
*/
export interface SiteConfig {
export type SiteConfig = {
/** Application URL Identifier: `http://dify.app/{access_token}` */
access_token: string
/** Public Title */
@ -307,7 +307,7 @@ export type AppIconType = 'image' | 'emoji'
/**
* App
*/
export interface App {
export type App = {
/** App ID */
id: string
/** Name */
@ -351,16 +351,23 @@ export interface App {
/** api site url */
api_base_url: string
tags: Tag[]
workflow?: {
id: string
created_at: number
created_by?: string
updated_at: number
updated_by?: string
}
}
export interface AppSSO {
export type AppSSO = {
enable_sso: boolean
}
/**
* App Template
*/
export interface AppTemplate {
export type AppTemplate = {
/** Name */
name: string
/** Description */
@ -389,7 +396,7 @@ export enum TtsAutoPlay {
export const ALLOW_FILE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'webp', 'gif']
export interface VisionSettings {
export type VisionSettings = {
enabled: boolean
number_limits: number
detail: Resolution
@ -397,7 +404,7 @@ export interface VisionSettings {
image_file_size_limit?: number | string
}
export interface ImageFile {
export type ImageFile = {
type: TransferMethod
_id: string
fileId: string
@ -408,7 +415,7 @@ export interface ImageFile {
deleted?: boolean
}
export interface VisionFile {
export type VisionFile = {
id?: string
type: string
transfer_method: TransferMethod
@ -417,7 +424,7 @@ export interface VisionFile {
belongs_to?: string
}
export interface RetrievalConfig {
export type RetrievalConfig = {
search_method: RETRIEVE_METHOD
reranking_enable: boolean
reranking_model: {