dify
This commit is contained in:
30
dify/web/models/access-control.ts
Normal file
30
dify/web/models/access-control.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
export enum SubjectType {
|
||||
GROUP = 'group',
|
||||
ACCOUNT = 'account',
|
||||
}
|
||||
|
||||
export enum AccessMode {
|
||||
PUBLIC = 'public',
|
||||
SPECIFIC_GROUPS_MEMBERS = 'private',
|
||||
ORGANIZATION = 'private_all',
|
||||
EXTERNAL_MEMBERS = 'sso_verified',
|
||||
}
|
||||
|
||||
export type AccessControlGroup = {
|
||||
id: 'string'
|
||||
name: 'string'
|
||||
groupSize: 5
|
||||
}
|
||||
|
||||
export type AccessControlAccount = {
|
||||
id: 'string'
|
||||
name: 'string'
|
||||
email: 'string'
|
||||
avatar: 'string'
|
||||
avatarUrl: 'string'
|
||||
}
|
||||
|
||||
export type SubjectGroup = { subjectId: string; subjectType: SubjectType; groupData: AccessControlGroup }
|
||||
export type SubjectAccount = { subjectId: string; subjectType: SubjectType; accountData: AccessControlAccount }
|
||||
|
||||
export type Subject = SubjectGroup | SubjectAccount
|
||||
134
dify/web/models/app.ts
Normal file
134
dify/web/models/app.ts
Normal file
@@ -0,0 +1,134 @@
|
||||
import type {
|
||||
AliyunConfig,
|
||||
ArizeConfig,
|
||||
DatabricksConfig,
|
||||
LangFuseConfig,
|
||||
LangSmithConfig,
|
||||
MLflowConfig,
|
||||
OpikConfig,
|
||||
PhoenixConfig,
|
||||
TencentConfig,
|
||||
TracingProvider,
|
||||
WeaveConfig,
|
||||
} from '@/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/type'
|
||||
import type { App, AppModeEnum, AppTemplate, SiteConfig } from '@/types/app'
|
||||
import type { Dependency } from '@/app/components/plugins/types'
|
||||
|
||||
export enum DSLImportMode {
|
||||
YAML_CONTENT = 'yaml-content',
|
||||
YAML_URL = 'yaml-url',
|
||||
}
|
||||
|
||||
export enum DSLImportStatus {
|
||||
COMPLETED = 'completed',
|
||||
COMPLETED_WITH_WARNINGS = 'completed-with-warnings',
|
||||
PENDING = 'pending',
|
||||
FAILED = 'failed',
|
||||
}
|
||||
|
||||
export type AppListResponse = {
|
||||
data: App[]
|
||||
has_more: boolean
|
||||
limit: number
|
||||
page: number
|
||||
total: number
|
||||
}
|
||||
|
||||
export type AppDetailResponse = App
|
||||
|
||||
export type DSLImportResponse = {
|
||||
id: string
|
||||
status: DSLImportStatus
|
||||
app_mode: AppModeEnum
|
||||
app_id?: string
|
||||
current_dsl_version?: string
|
||||
imported_dsl_version?: string
|
||||
error: string
|
||||
leaked_dependencies: Dependency[]
|
||||
}
|
||||
|
||||
export type AppTemplatesResponse = {
|
||||
data: AppTemplate[]
|
||||
}
|
||||
|
||||
export type CreateAppResponse = App
|
||||
|
||||
export type UpdateAppSiteCodeResponse = { app_id: string } & SiteConfig
|
||||
|
||||
export type AppDailyMessagesResponse = {
|
||||
data: Array<{ date: string; message_count: number }>
|
||||
}
|
||||
|
||||
export type AppDailyConversationsResponse = {
|
||||
data: Array<{ date: string; conversation_count: number }>
|
||||
}
|
||||
|
||||
export type WorkflowDailyConversationsResponse = {
|
||||
data: Array<{ date: string; runs: number }>
|
||||
}
|
||||
|
||||
export type AppStatisticsResponse = {
|
||||
data: Array<{ date: string }>
|
||||
}
|
||||
|
||||
export type AppDailyEndUsersResponse = {
|
||||
data: Array<{ date: string; terminal_count: number }>
|
||||
}
|
||||
|
||||
export type AppTokenCostsResponse = {
|
||||
data: Array<{ date: string; token_count: number; total_price: number; currency: number }>
|
||||
}
|
||||
|
||||
export type UpdateAppModelConfigResponse = { result: string }
|
||||
|
||||
export type ApiKeyItemResponse = {
|
||||
id: string
|
||||
token: string
|
||||
last_used_at: string
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export type ApiKeysListResponse = {
|
||||
data: ApiKeyItemResponse[]
|
||||
}
|
||||
|
||||
export type CreateApiKeyResponse = {
|
||||
id: string
|
||||
token: string
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export type ValidateOpenAIKeyResponse = {
|
||||
result: string
|
||||
error?: string
|
||||
}
|
||||
|
||||
export type UpdateOpenAIKeyResponse = ValidateOpenAIKeyResponse
|
||||
|
||||
export type GenerationIntroductionResponse = {
|
||||
introduction: string
|
||||
}
|
||||
|
||||
export type AppVoicesListResponse = [{
|
||||
name: string
|
||||
value: string
|
||||
}]
|
||||
|
||||
export type TracingStatus = {
|
||||
enabled: boolean
|
||||
tracing_provider: TracingProvider | null
|
||||
}
|
||||
|
||||
export type TracingConfig = {
|
||||
tracing_provider: TracingProvider
|
||||
tracing_config: ArizeConfig | PhoenixConfig | LangSmithConfig | LangFuseConfig | DatabricksConfig | MLflowConfig | OpikConfig | WeaveConfig | AliyunConfig | TencentConfig
|
||||
}
|
||||
|
||||
export type WebhookTriggerResponse = {
|
||||
id: string
|
||||
webhook_id: string
|
||||
webhook_url: string
|
||||
webhook_debug_url: string
|
||||
node_id: string
|
||||
created_at: string
|
||||
}
|
||||
317
dify/web/models/common.ts
Normal file
317
dify/web/models/common.ts
Normal file
@@ -0,0 +1,317 @@
|
||||
import type { I18nText } from '@/i18n-config/language'
|
||||
import type { Model } from '@/types/app'
|
||||
|
||||
export type CommonResponse = {
|
||||
result: 'success' | 'fail'
|
||||
}
|
||||
|
||||
export type FileDownloadResponse = {
|
||||
id: string
|
||||
name: string
|
||||
size: number
|
||||
extension: string
|
||||
url: string
|
||||
download_url: string
|
||||
mime_type: string
|
||||
created_by: string
|
||||
created_at: number
|
||||
}
|
||||
|
||||
export type OauthResponse = {
|
||||
redirect_url: string
|
||||
}
|
||||
|
||||
export type SetupStatusResponse = {
|
||||
step: 'finished' | 'not_started'
|
||||
setup_at?: Date
|
||||
}
|
||||
|
||||
export type InitValidateStatusResponse = {
|
||||
status: 'finished' | 'not_started'
|
||||
}
|
||||
|
||||
export type UserProfileResponse = {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
avatar: string
|
||||
avatar_url: string | null
|
||||
is_password_set: boolean
|
||||
interface_language?: string
|
||||
interface_theme?: string
|
||||
timezone?: string
|
||||
last_login_at?: string
|
||||
last_active_at?: string
|
||||
last_login_ip?: string
|
||||
created_at?: string
|
||||
}
|
||||
|
||||
export type UserProfileOriginResponse = {
|
||||
json: () => Promise<UserProfileResponse>
|
||||
bodyUsed: boolean
|
||||
headers: any
|
||||
}
|
||||
|
||||
export type LangGeniusVersionResponse = {
|
||||
current_version: string
|
||||
latest_version: string
|
||||
version: string
|
||||
release_date: string
|
||||
release_notes: string
|
||||
can_auto_update: boolean
|
||||
current_env: string
|
||||
}
|
||||
|
||||
export type TenantInfoResponse = {
|
||||
name: string
|
||||
created_at: string
|
||||
providers: Array<{
|
||||
provider: string
|
||||
provider_name: string
|
||||
token_is_set: boolean
|
||||
is_valid: boolean
|
||||
token_is_valid: boolean
|
||||
}>
|
||||
in_trail: boolean
|
||||
trial_end_reason: null | 'trial_exceeded' | 'using_custom'
|
||||
}
|
||||
|
||||
export type Member = Pick<UserProfileResponse, 'id' | 'name' | 'email' | 'last_login_at' | 'last_active_at' | 'created_at' | 'avatar_url'> & {
|
||||
avatar: string
|
||||
status: 'pending' | 'active' | 'banned' | 'closed'
|
||||
role: 'owner' | 'admin' | 'editor' | 'normal' | 'dataset_operator'
|
||||
}
|
||||
|
||||
export enum ProviderName {
|
||||
OPENAI = 'openai',
|
||||
AZURE_OPENAI = 'azure_openai',
|
||||
ANTHROPIC = 'anthropic',
|
||||
Replicate = 'replicate',
|
||||
HuggingfaceHub = 'huggingface_hub',
|
||||
MiniMax = 'minimax',
|
||||
Spark = 'spark',
|
||||
Tongyi = 'tongyi',
|
||||
ChatGLM = 'chatglm',
|
||||
}
|
||||
export type ProviderAzureToken = {
|
||||
openai_api_base?: string
|
||||
openai_api_key?: string
|
||||
}
|
||||
export type ProviderAnthropicToken = {
|
||||
anthropic_api_key?: string
|
||||
}
|
||||
export type ProviderTokenType = {
|
||||
[ProviderName.OPENAI]: string
|
||||
[ProviderName.AZURE_OPENAI]: ProviderAzureToken
|
||||
[ProviderName.ANTHROPIC]: ProviderAnthropicToken
|
||||
}
|
||||
export type Provider = {
|
||||
[Name in ProviderName]: {
|
||||
provider_name: Name
|
||||
} & {
|
||||
provider_type: 'custom' | 'system'
|
||||
is_valid: boolean
|
||||
is_enabled: boolean
|
||||
last_used: string
|
||||
token?: string | ProviderAzureToken | ProviderAnthropicToken
|
||||
}
|
||||
}[ProviderName]
|
||||
|
||||
export type ProviderHosted = Provider & {
|
||||
quota_type: string
|
||||
quota_limit: number
|
||||
quota_used: number
|
||||
}
|
||||
|
||||
export type AccountIntegrate = {
|
||||
provider: 'google' | 'github'
|
||||
created_at: number
|
||||
is_bound: boolean
|
||||
link: string
|
||||
}
|
||||
|
||||
export type IWorkspace = {
|
||||
id: string
|
||||
name: string
|
||||
plan: string
|
||||
status: string
|
||||
created_at: number
|
||||
current: boolean
|
||||
}
|
||||
|
||||
export type ICurrentWorkspace = Omit<IWorkspace, 'current'> & {
|
||||
role: 'owner' | 'admin' | 'editor' | 'dataset_operator' | 'normal'
|
||||
providers: Provider[]
|
||||
trial_end_reason?: string
|
||||
custom_config?: {
|
||||
remove_webapp_brand?: boolean
|
||||
replace_webapp_logo?: string
|
||||
}
|
||||
}
|
||||
|
||||
export type DataSourceNotionPage = {
|
||||
page_icon: null | {
|
||||
type: string | null
|
||||
url: string | null
|
||||
emoji: string | null
|
||||
}
|
||||
page_id: string
|
||||
page_name: string
|
||||
parent_id: string
|
||||
type: string
|
||||
is_bound: boolean
|
||||
}
|
||||
|
||||
export type NotionPage = DataSourceNotionPage & {
|
||||
workspace_id: string
|
||||
}
|
||||
|
||||
export type DataSourceNotionPageMap = Record<string, DataSourceNotionPage & { workspace_id: string }>
|
||||
|
||||
export type DataSourceNotionWorkspace = {
|
||||
workspace_name: string
|
||||
workspace_id: string
|
||||
workspace_icon: string | null
|
||||
total?: number
|
||||
pages: DataSourceNotionPage[]
|
||||
}
|
||||
|
||||
export type DataSourceNotionWorkspaceMap = Record<string, DataSourceNotionWorkspace>
|
||||
|
||||
export type DataSourceNotion = {
|
||||
id: string
|
||||
provider: string
|
||||
is_bound: boolean
|
||||
source_info: DataSourceNotionWorkspace
|
||||
}
|
||||
|
||||
export enum DataSourceCategory {
|
||||
website = 'website',
|
||||
}
|
||||
export enum DataSourceProvider {
|
||||
fireCrawl = 'firecrawl',
|
||||
jinaReader = 'jinareader',
|
||||
waterCrawl = 'watercrawl',
|
||||
}
|
||||
|
||||
export type FirecrawlConfig = {
|
||||
api_key: string
|
||||
base_url: string
|
||||
}
|
||||
|
||||
export type WatercrawlConfig = {
|
||||
api_key: string
|
||||
base_url: string
|
||||
}
|
||||
|
||||
export type DataSourceItem = {
|
||||
id: string
|
||||
category: DataSourceCategory
|
||||
provider: DataSourceProvider
|
||||
disabled: boolean
|
||||
created_at: number
|
||||
updated_at: number
|
||||
}
|
||||
|
||||
export type DataSources = {
|
||||
sources: DataSourceItem[]
|
||||
}
|
||||
|
||||
export type GithubRepo = {
|
||||
stargazers_count: number
|
||||
}
|
||||
|
||||
export type PluginProvider = {
|
||||
tool_name: string
|
||||
is_enabled: boolean
|
||||
credentials: {
|
||||
api_key: string
|
||||
} | null
|
||||
}
|
||||
|
||||
export type FileUploadConfigResponse = {
|
||||
batch_count_limit: number
|
||||
image_file_size_limit?: number | string // default is 10MB
|
||||
file_size_limit: number // default is 15MB
|
||||
audio_file_size_limit?: number // default is 50MB
|
||||
video_file_size_limit?: number // default is 100MB
|
||||
workflow_file_upload_limit?: number // default is 10
|
||||
file_upload_limit: number // default is 5
|
||||
}
|
||||
|
||||
export type InvitationResult = {
|
||||
status: 'success'
|
||||
email: string
|
||||
url: string
|
||||
} | {
|
||||
status: 'failed'
|
||||
email: string
|
||||
message: string
|
||||
}
|
||||
|
||||
export type InvitationResponse = CommonResponse & {
|
||||
invitation_results: InvitationResult[]
|
||||
}
|
||||
|
||||
export type ApiBasedExtension = {
|
||||
id?: string
|
||||
name?: string
|
||||
api_endpoint?: string
|
||||
api_key?: string
|
||||
}
|
||||
|
||||
export type CodeBasedExtensionForm = {
|
||||
type: string
|
||||
label: I18nText
|
||||
variable: string
|
||||
required: boolean
|
||||
options: { label: I18nText; value: string }[]
|
||||
default: string
|
||||
placeholder: string
|
||||
max_length?: number
|
||||
}
|
||||
|
||||
export type CodeBasedExtensionItem = {
|
||||
name: string
|
||||
label: any
|
||||
form_schema: CodeBasedExtensionForm[]
|
||||
}
|
||||
export type CodeBasedExtension = {
|
||||
module: string
|
||||
data: CodeBasedExtensionItem[]
|
||||
}
|
||||
|
||||
export type ExternalDataTool = {
|
||||
type?: string
|
||||
label?: string
|
||||
icon?: string
|
||||
icon_background?: string
|
||||
variable?: string
|
||||
enabled?: boolean
|
||||
config?: {
|
||||
api_based_extension_id?: string
|
||||
} & Partial<Record<string, any>>
|
||||
}
|
||||
|
||||
export type ModerateResponse = {
|
||||
flagged: boolean
|
||||
text: string
|
||||
}
|
||||
|
||||
export type ModerationService = (
|
||||
url: string,
|
||||
body: {
|
||||
app_id: string
|
||||
text: string
|
||||
},
|
||||
) => Promise<ModerateResponse>
|
||||
|
||||
export type StructuredOutputRulesRequestBody = {
|
||||
instruction: string
|
||||
model_config: Model
|
||||
}
|
||||
|
||||
export type StructuredOutputRulesResponse = {
|
||||
output: string
|
||||
error?: string
|
||||
}
|
||||
816
dify/web/models/datasets.ts
Normal file
816
dify/web/models/datasets.ts
Normal file
@@ -0,0 +1,816 @@
|
||||
import type { DataSourceNotionPage, DataSourceProvider } from './common'
|
||||
import type { AppIconType, AppModeEnum, RetrievalConfig, TransferMethod } from '@/types/app'
|
||||
import type { Tag } from '@/app/components/base/tag-management/constant'
|
||||
import type { IndexingType } from '@/app/components/datasets/create/step-two'
|
||||
import type { MetadataFilteringVariableType } from '@/app/components/workflow/nodes/knowledge-retrieval/types'
|
||||
import type { MetadataItemWithValue } from '@/app/components/datasets/metadata/types'
|
||||
import { ExternalKnowledgeBase, General, ParentChild, Qa } from '@/app/components/base/icons/src/public/knowledge/dataset-card'
|
||||
import { GeneralChunk, ParentChildChunk, QuestionAndAnswer } from '@/app/components/base/icons/src/vender/knowledge'
|
||||
import type { DatasourceType } from './pipeline'
|
||||
|
||||
export enum DataSourceType {
|
||||
FILE = 'upload_file',
|
||||
NOTION = 'notion_import',
|
||||
WEB = 'website_crawl',
|
||||
}
|
||||
|
||||
export enum DatasetPermission {
|
||||
onlyMe = 'only_me',
|
||||
allTeamMembers = 'all_team_members',
|
||||
partialMembers = 'partial_members',
|
||||
}
|
||||
|
||||
export enum ChunkingMode {
|
||||
text = 'text_model', // General text
|
||||
qa = 'qa_model', // General QA
|
||||
parentChild = 'hierarchical_model', // Parent-Child
|
||||
// graph = 'graph', // todo: Graph RAG
|
||||
}
|
||||
|
||||
export type MetadataInDoc = {
|
||||
value: string
|
||||
id: string
|
||||
type: MetadataFilteringVariableType
|
||||
name: string
|
||||
}
|
||||
|
||||
export type IconInfo = {
|
||||
icon: string
|
||||
icon_background?: string
|
||||
icon_type: AppIconType
|
||||
icon_url?: string
|
||||
}
|
||||
|
||||
export type DataSet = {
|
||||
id: string
|
||||
name: string
|
||||
indexing_status: DocumentIndexingStatus
|
||||
icon_info: IconInfo
|
||||
description: string
|
||||
permission: DatasetPermission
|
||||
data_source_type: DataSourceType
|
||||
indexing_technique: IndexingType
|
||||
author_name?: string
|
||||
created_by: string
|
||||
updated_by: string
|
||||
updated_at: number
|
||||
app_count: number
|
||||
doc_form: ChunkingMode
|
||||
document_count: number
|
||||
total_document_count: number
|
||||
total_available_documents?: number
|
||||
word_count: number
|
||||
provider: string
|
||||
embedding_model: string
|
||||
embedding_model_provider: string
|
||||
embedding_available: boolean
|
||||
retrieval_model_dict: RetrievalConfig
|
||||
retrieval_model: RetrievalConfig
|
||||
tags: Tag[]
|
||||
partial_member_list?: string[]
|
||||
external_knowledge_info: {
|
||||
external_knowledge_id: string
|
||||
external_knowledge_api_id: string
|
||||
external_knowledge_api_name: string
|
||||
external_knowledge_api_endpoint: string
|
||||
}
|
||||
external_retrieval_model: {
|
||||
top_k: number
|
||||
score_threshold: number
|
||||
score_threshold_enabled: boolean
|
||||
}
|
||||
built_in_field_enabled: boolean
|
||||
doc_metadata?: MetadataInDoc[]
|
||||
keyword_number?: number
|
||||
pipeline_id?: string
|
||||
is_published?: boolean // Indicates if the pipeline is published
|
||||
runtime_mode: 'rag_pipeline' | 'general'
|
||||
enable_api: boolean
|
||||
}
|
||||
|
||||
export type ExternalAPIItem = {
|
||||
id: string
|
||||
tenant_id: string
|
||||
name: string
|
||||
description: string
|
||||
settings: {
|
||||
endpoint: string
|
||||
api_key: string
|
||||
}
|
||||
dataset_bindings: { id: string; name: string }[]
|
||||
created_by: string
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export type ExternalKnowledgeItem = {
|
||||
id: string
|
||||
name: string
|
||||
description: string | null
|
||||
provider: 'external'
|
||||
permission: DatasetPermission
|
||||
data_source_type: null
|
||||
indexing_technique: null
|
||||
app_count: number
|
||||
document_count: number
|
||||
word_count: number
|
||||
created_by: string
|
||||
created_at: string
|
||||
updated_by: string
|
||||
updated_at: string
|
||||
tags: Tag[]
|
||||
}
|
||||
|
||||
export type ExternalAPIDeleteResponse = {
|
||||
result: 'success' | 'error'
|
||||
}
|
||||
|
||||
export type ExternalAPIUsage = {
|
||||
is_using: boolean
|
||||
count: number
|
||||
}
|
||||
|
||||
export type CustomFile = File & {
|
||||
id?: string
|
||||
extension?: string
|
||||
mime_type?: string
|
||||
created_by?: string
|
||||
created_at?: number
|
||||
}
|
||||
|
||||
export type DocumentItem = {
|
||||
id: string
|
||||
name: string
|
||||
extension: string
|
||||
}
|
||||
|
||||
export type CrawlOptions = {
|
||||
crawl_sub_pages: boolean
|
||||
only_main_content: boolean
|
||||
includes: string
|
||||
excludes: string
|
||||
limit: number | string
|
||||
max_depth: number | string
|
||||
use_sitemap: boolean
|
||||
}
|
||||
|
||||
export type CrawlResultItem = {
|
||||
title: string
|
||||
content: string
|
||||
description: string
|
||||
source_url: string
|
||||
}
|
||||
|
||||
export type CrawlResult = {
|
||||
data: CrawlResultItem[]
|
||||
time_consuming: number | string
|
||||
}
|
||||
|
||||
export enum CrawlStep {
|
||||
init = 'init',
|
||||
running = 'running',
|
||||
finished = 'finished',
|
||||
}
|
||||
|
||||
export type FileItem = {
|
||||
fileID: string
|
||||
file: CustomFile
|
||||
progress: number
|
||||
}
|
||||
|
||||
export type FetchDatasetsParams = {
|
||||
url: string
|
||||
params: {
|
||||
page: number
|
||||
ids?: string[]
|
||||
tag_ids?: string[]
|
||||
limit?: number
|
||||
include_all?: boolean
|
||||
keyword?: string
|
||||
}
|
||||
}
|
||||
|
||||
export type DatasetListRequest = {
|
||||
initialPage: number
|
||||
tag_ids?: string[]
|
||||
limit: number
|
||||
include_all?: boolean
|
||||
keyword?: string
|
||||
}
|
||||
|
||||
export type DataSetListResponse = {
|
||||
data: DataSet[]
|
||||
has_more: boolean
|
||||
limit: number
|
||||
page: number
|
||||
total: number
|
||||
}
|
||||
|
||||
export type ExternalAPIListResponse = {
|
||||
data: ExternalAPIItem[]
|
||||
has_more: boolean
|
||||
limit: number
|
||||
page: number
|
||||
total: number
|
||||
}
|
||||
|
||||
export type QA = {
|
||||
question: string
|
||||
answer: string
|
||||
}
|
||||
|
||||
export type IndexingEstimateResponse = {
|
||||
tokens: number
|
||||
total_price: number
|
||||
currency: string
|
||||
total_segments: number
|
||||
preview: Array<{ content: string; child_chunks: string[] }>
|
||||
qa_preview?: QA[]
|
||||
}
|
||||
|
||||
export type FileIndexingEstimateResponse = {
|
||||
total_nodes: number
|
||||
} & IndexingEstimateResponse
|
||||
|
||||
export type IndexingStatusResponse = {
|
||||
id: string
|
||||
indexing_status: DocumentIndexingStatus
|
||||
processing_started_at: number
|
||||
parsing_completed_at: number
|
||||
cleaning_completed_at: number
|
||||
splitting_completed_at: number
|
||||
completed_at: any
|
||||
paused_at: any
|
||||
error: any
|
||||
stopped_at: any
|
||||
completed_segments: number
|
||||
total_segments: number
|
||||
}
|
||||
export type IndexingStatusBatchResponse = {
|
||||
data: IndexingStatusResponse[]
|
||||
}
|
||||
|
||||
export enum ProcessMode {
|
||||
general = 'custom',
|
||||
parentChild = 'hierarchical',
|
||||
}
|
||||
|
||||
export type ParentMode = 'full-doc' | 'paragraph'
|
||||
|
||||
export type ProcessRuleResponse = {
|
||||
mode: ProcessMode
|
||||
rules: Rules
|
||||
limits: Limits
|
||||
}
|
||||
|
||||
export type Rules = {
|
||||
pre_processing_rules: PreProcessingRule[]
|
||||
segmentation: Segmentation
|
||||
parent_mode: ParentMode
|
||||
subchunk_segmentation: Segmentation
|
||||
}
|
||||
|
||||
export type Limits = {
|
||||
indexing_max_segmentation_tokens_length: number
|
||||
}
|
||||
|
||||
export type PreProcessingRule = {
|
||||
id: string
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
export type Segmentation = {
|
||||
separator: string
|
||||
max_tokens: number
|
||||
chunk_overlap?: number
|
||||
}
|
||||
|
||||
export const DocumentIndexingStatusList = [
|
||||
'waiting',
|
||||
'parsing',
|
||||
'cleaning',
|
||||
'splitting',
|
||||
'indexing',
|
||||
'paused',
|
||||
'error',
|
||||
'completed',
|
||||
] as const
|
||||
|
||||
export type DocumentIndexingStatus = typeof DocumentIndexingStatusList[number]
|
||||
|
||||
export const DisplayStatusList = [
|
||||
'queuing',
|
||||
'indexing',
|
||||
'paused',
|
||||
'error',
|
||||
'available',
|
||||
'enabled',
|
||||
'disabled',
|
||||
'archived',
|
||||
] as const
|
||||
|
||||
export type DocumentDisplayStatus = typeof DisplayStatusList[number]
|
||||
|
||||
export type LegacyDataSourceInfo = {
|
||||
upload_file: {
|
||||
id: string
|
||||
name: string
|
||||
size: number
|
||||
mime_type: string
|
||||
created_at: number
|
||||
created_by: string
|
||||
extension: string
|
||||
}
|
||||
notion_page_icon?: string
|
||||
notion_workspace_id?: string
|
||||
notion_page_id?: string
|
||||
provider?: DataSourceProvider
|
||||
job_id: string
|
||||
url: string
|
||||
credential_id?: string
|
||||
}
|
||||
|
||||
export type LocalFileInfo = {
|
||||
extension: string
|
||||
mime_type: string
|
||||
name: string
|
||||
related_id: string
|
||||
size: number
|
||||
transfer_method: TransferMethod
|
||||
url: string
|
||||
}
|
||||
|
||||
export type WebsiteCrawlInfo = {
|
||||
content: string
|
||||
credential_id: string
|
||||
description: string
|
||||
source_url: string
|
||||
title: string
|
||||
provider?: string
|
||||
job_id?: string
|
||||
}
|
||||
|
||||
export type OnlineDocumentInfo = {
|
||||
credential_id: string
|
||||
workspace_id: string
|
||||
page: {
|
||||
last_edited_time: string
|
||||
page_icon: DataSourceNotionPage['page_icon']
|
||||
page_id: string
|
||||
page_name: string
|
||||
parent_id: string
|
||||
type: string
|
||||
},
|
||||
}
|
||||
|
||||
export type OnlineDriveInfo = {
|
||||
bucket: string
|
||||
credential_id: string
|
||||
id: string
|
||||
name: string
|
||||
type: 'file' | 'folder'
|
||||
}
|
||||
|
||||
export type DataSourceInfo = LegacyDataSourceInfo | LocalFileInfo | OnlineDocumentInfo | WebsiteCrawlInfo
|
||||
|
||||
export type InitialDocumentDetail = {
|
||||
id: string
|
||||
batch: string
|
||||
position: number
|
||||
dataset_id: string
|
||||
data_source_type: DataSourceType | DatasourceType
|
||||
data_source_info: DataSourceInfo
|
||||
dataset_process_rule_id: string
|
||||
name: string
|
||||
created_from: 'rag-pipeline' | 'api' | 'web'
|
||||
created_by: string
|
||||
created_at: number
|
||||
indexing_status: DocumentIndexingStatus
|
||||
display_status: DocumentDisplayStatus
|
||||
completed_segments?: number
|
||||
total_segments?: number
|
||||
doc_form: ChunkingMode
|
||||
doc_language: string
|
||||
}
|
||||
|
||||
export type SimpleDocumentDetail = InitialDocumentDetail & {
|
||||
enabled: boolean
|
||||
word_count: number
|
||||
error?: string | null
|
||||
archived: boolean
|
||||
updated_at: number
|
||||
hit_count: number
|
||||
dataset_process_rule_id?: string
|
||||
data_source_detail_dict?: {
|
||||
upload_file: {
|
||||
name: string
|
||||
extension: string
|
||||
}
|
||||
}
|
||||
doc_metadata?: MetadataItemWithValue[]
|
||||
}
|
||||
|
||||
export type DocumentListResponse = {
|
||||
data: SimpleDocumentDetail[]
|
||||
has_more: boolean
|
||||
total: number
|
||||
page: number
|
||||
limit: number
|
||||
}
|
||||
|
||||
export type DocumentReq = {
|
||||
original_document_id?: string
|
||||
indexing_technique?: IndexingType
|
||||
doc_form: ChunkingMode
|
||||
doc_language: string
|
||||
process_rule: ProcessRule
|
||||
}
|
||||
|
||||
export type CreateDocumentReq = DocumentReq & {
|
||||
data_source: DataSource
|
||||
retrieval_model: RetrievalConfig
|
||||
embedding_model: string
|
||||
embedding_model_provider: string
|
||||
}
|
||||
|
||||
export type IndexingEstimateParams = DocumentReq & Partial<DataSource> & {
|
||||
dataset_id: string
|
||||
}
|
||||
|
||||
export type DataSource = {
|
||||
type: DataSourceType
|
||||
info_list: {
|
||||
data_source_type: DataSourceType
|
||||
notion_info_list?: NotionInfo[]
|
||||
file_info_list?: {
|
||||
file_ids: string[]
|
||||
}
|
||||
website_info_list?: {
|
||||
provider: string
|
||||
job_id: string
|
||||
urls: string[]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type NotionInfo = {
|
||||
workspace_id: string
|
||||
pages: DataSourceNotionPage[]
|
||||
credential_id: string
|
||||
}
|
||||
export type NotionPage = {
|
||||
page_id: string
|
||||
type: string
|
||||
}
|
||||
|
||||
export type ProcessRule = {
|
||||
mode: ProcessMode
|
||||
rules: Rules
|
||||
}
|
||||
|
||||
export type createDocumentResponse = {
|
||||
dataset?: DataSet
|
||||
batch: string
|
||||
documents: InitialDocumentDetail[]
|
||||
}
|
||||
|
||||
export type FullDocumentDetail = SimpleDocumentDetail & {
|
||||
batch: string
|
||||
created_api_request_id: string
|
||||
processing_started_at: number
|
||||
parsing_completed_at: number
|
||||
cleaning_completed_at: number
|
||||
splitting_completed_at: number
|
||||
tokens: number
|
||||
indexing_latency: number
|
||||
completed_at: number
|
||||
paused_by: string
|
||||
paused_at: number
|
||||
stopped_at: number
|
||||
indexing_status: string
|
||||
disabled_at: number
|
||||
disabled_by: string
|
||||
archived_reason: 'rule_modified' | 're_upload'
|
||||
archived_by: string
|
||||
archived_at: number
|
||||
doc_type?: DocType | null | 'others'
|
||||
doc_metadata?: DocMetadata | null
|
||||
segment_count: number
|
||||
dataset_process_rule: ProcessRule
|
||||
document_process_rule: ProcessRule
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export type DocMetadata = {
|
||||
title: string
|
||||
language: string
|
||||
author: string
|
||||
publisher: string
|
||||
publicationDate: string
|
||||
ISBN: string
|
||||
category: string
|
||||
[key: string]: string
|
||||
}
|
||||
|
||||
export const CUSTOMIZABLE_DOC_TYPES = [
|
||||
'book',
|
||||
'web_page',
|
||||
'paper',
|
||||
'social_media_post',
|
||||
'personal_document',
|
||||
'business_document',
|
||||
'im_chat_log',
|
||||
] as const
|
||||
|
||||
export const FIXED_DOC_TYPES = ['synced_from_github', 'synced_from_notion', 'wikipedia_entry'] as const
|
||||
|
||||
export type CustomizableDocType = typeof CUSTOMIZABLE_DOC_TYPES[number]
|
||||
export type FixedDocType = typeof FIXED_DOC_TYPES[number]
|
||||
export type DocType = CustomizableDocType | FixedDocType
|
||||
|
||||
export type DocumentDetailResponse = FullDocumentDetail
|
||||
|
||||
export const SEGMENT_STATUS_LIST = ['waiting', 'completed', 'error', 'indexing']
|
||||
export type SegmentStatus = typeof SEGMENT_STATUS_LIST[number]
|
||||
|
||||
export type SegmentsQuery = {
|
||||
page?: string
|
||||
limit: number
|
||||
// status?: SegmentStatus
|
||||
hit_count_gte?: number
|
||||
keyword?: string
|
||||
enabled?: boolean | 'all'
|
||||
}
|
||||
|
||||
export type SegmentDetailModel = {
|
||||
id: string
|
||||
position: number
|
||||
document_id: string
|
||||
content: string
|
||||
sign_content: string
|
||||
word_count: number
|
||||
tokens: number
|
||||
keywords: string[]
|
||||
index_node_id: string
|
||||
index_node_hash: string
|
||||
hit_count: number
|
||||
enabled: boolean
|
||||
disabled_at: number
|
||||
disabled_by: string
|
||||
status: SegmentStatus
|
||||
created_by: string
|
||||
created_at: number
|
||||
indexing_at: number
|
||||
completed_at: number
|
||||
error: string | null
|
||||
stopped_at: number
|
||||
answer?: string
|
||||
child_chunks?: ChildChunkDetail[]
|
||||
updated_at: number
|
||||
}
|
||||
|
||||
export type SegmentsResponse = {
|
||||
data: SegmentDetailModel[]
|
||||
has_more: boolean
|
||||
limit: number
|
||||
total: number
|
||||
total_pages: number
|
||||
page: number
|
||||
}
|
||||
|
||||
export type HitTestingRecord = {
|
||||
id: string
|
||||
content: string
|
||||
source: 'app' | 'hit_testing' | 'plugin'
|
||||
source_app_id: string
|
||||
created_by_role: 'account' | 'end_user'
|
||||
created_by: string
|
||||
created_at: number
|
||||
}
|
||||
|
||||
export type HitTestingChildChunk = {
|
||||
id: string
|
||||
content: string
|
||||
position: number
|
||||
score: number
|
||||
}
|
||||
export type HitTesting = {
|
||||
segment: Segment
|
||||
content: Segment
|
||||
score: number
|
||||
tsne_position: TsnePosition
|
||||
child_chunks?: HitTestingChildChunk[] | null
|
||||
}
|
||||
|
||||
export type ExternalKnowledgeBaseHitTesting = {
|
||||
content: string
|
||||
title: string
|
||||
score: number
|
||||
metadata: {
|
||||
'x-amz-bedrock-kb-source-uri': string
|
||||
'x-amz-bedrock-kb-data-source-id': string
|
||||
}
|
||||
}
|
||||
|
||||
export type Segment = {
|
||||
id: string
|
||||
document: Document
|
||||
content: string
|
||||
sign_content: string
|
||||
position: number
|
||||
word_count: number
|
||||
tokens: number
|
||||
keywords: string[]
|
||||
hit_count: number
|
||||
index_node_hash: string
|
||||
answer: string
|
||||
}
|
||||
|
||||
export type Document = {
|
||||
id: string
|
||||
data_source_type: string
|
||||
name: string
|
||||
doc_type: DocType
|
||||
}
|
||||
|
||||
export type HitTestingRecordsResponse = {
|
||||
data: HitTestingRecord[]
|
||||
has_more: boolean
|
||||
limit: number
|
||||
total: number
|
||||
page: number
|
||||
}
|
||||
|
||||
export type TsnePosition = {
|
||||
x: number
|
||||
y: number
|
||||
}
|
||||
|
||||
export type HitTestingResponse = {
|
||||
query: {
|
||||
content: string
|
||||
tsne_position: TsnePosition
|
||||
}
|
||||
records: Array<HitTesting>
|
||||
}
|
||||
|
||||
export type ExternalKnowledgeBaseHitTestingResponse = {
|
||||
query: {
|
||||
content: string
|
||||
}
|
||||
records: Array<ExternalKnowledgeBaseHitTesting>
|
||||
}
|
||||
|
||||
export type RelatedApp = {
|
||||
id: string
|
||||
name: string
|
||||
mode: AppModeEnum
|
||||
icon_type: AppIconType | null
|
||||
icon: string
|
||||
icon_background: string
|
||||
icon_url: string
|
||||
}
|
||||
|
||||
export type RelatedAppResponse = {
|
||||
data: Array<RelatedApp>
|
||||
total: number
|
||||
}
|
||||
|
||||
export type SegmentUpdater = {
|
||||
content: string
|
||||
answer?: string
|
||||
keywords?: string[]
|
||||
regenerate_child_chunks?: boolean
|
||||
}
|
||||
|
||||
export type ErrorDocsResponse = {
|
||||
data: IndexingStatusResponse[]
|
||||
total: number
|
||||
}
|
||||
|
||||
export type SelectedDatasetsMode = {
|
||||
allHighQuality: boolean
|
||||
allHighQualityVectorSearch: boolean
|
||||
allHighQualityFullTextSearch: boolean
|
||||
allEconomic: boolean
|
||||
mixtureHighQualityAndEconomic: boolean
|
||||
allInternal: boolean
|
||||
allExternal: boolean
|
||||
mixtureInternalAndExternal: boolean
|
||||
inconsistentEmbeddingModel: boolean
|
||||
}
|
||||
|
||||
export enum WeightedScoreEnum {
|
||||
SemanticFirst = 'semantic_first',
|
||||
KeywordFirst = 'keyword_first',
|
||||
Customized = 'customized',
|
||||
}
|
||||
|
||||
export enum RerankingModeEnum {
|
||||
RerankingModel = 'reranking_model',
|
||||
WeightedScore = 'weighted_score',
|
||||
}
|
||||
|
||||
export const DEFAULT_WEIGHTED_SCORE = {
|
||||
allHighQualityVectorSearch: {
|
||||
semantic: 1.0,
|
||||
keyword: 0,
|
||||
},
|
||||
allHighQualityFullTextSearch: {
|
||||
semantic: 0,
|
||||
keyword: 1.0,
|
||||
},
|
||||
other: {
|
||||
semantic: 0.7,
|
||||
keyword: 0.3,
|
||||
},
|
||||
}
|
||||
|
||||
export type ChildChunkType = 'automatic' | 'customized'
|
||||
|
||||
export type ChildChunkDetail = {
|
||||
id: string
|
||||
position: number
|
||||
segment_id: string
|
||||
content: string
|
||||
word_count: number
|
||||
created_at: number
|
||||
updated_at: number
|
||||
type: ChildChunkType
|
||||
}
|
||||
|
||||
export type ChildSegmentsResponse = {
|
||||
data: ChildChunkDetail[]
|
||||
total: number
|
||||
total_pages: number
|
||||
page: number
|
||||
limit: number
|
||||
}
|
||||
|
||||
export type UpdateDocumentParams = {
|
||||
datasetId: string
|
||||
documentId: string
|
||||
}
|
||||
|
||||
// Used in api url
|
||||
export enum DocumentActionType {
|
||||
enable = 'enable',
|
||||
disable = 'disable',
|
||||
archive = 'archive',
|
||||
unArchive = 'un_archive',
|
||||
delete = 'delete',
|
||||
}
|
||||
|
||||
export type UpdateDocumentBatchParams = {
|
||||
datasetId: string
|
||||
documentId?: string
|
||||
documentIds?: string[] | string
|
||||
}
|
||||
|
||||
export type BatchImportResponse = {
|
||||
job_id: string
|
||||
job_status: string
|
||||
}
|
||||
|
||||
export const DOC_FORM_ICON_WITH_BG: Record<ChunkingMode | 'external', React.ComponentType<{ className: string }>> = {
|
||||
[ChunkingMode.text]: General,
|
||||
[ChunkingMode.qa]: Qa,
|
||||
[ChunkingMode.parentChild]: ParentChild,
|
||||
// [ChunkingMode.graph]: Graph, // todo: Graph RAG
|
||||
external: ExternalKnowledgeBase,
|
||||
}
|
||||
|
||||
export const DOC_FORM_ICON: Record<ChunkingMode.text | ChunkingMode.qa | ChunkingMode.parentChild, React.ComponentType<{ className: string }>> = {
|
||||
[ChunkingMode.text]: GeneralChunk,
|
||||
[ChunkingMode.qa]: QuestionAndAnswer,
|
||||
[ChunkingMode.parentChild]: ParentChildChunk,
|
||||
}
|
||||
|
||||
export const DOC_FORM_TEXT: Record<ChunkingMode, string> = {
|
||||
[ChunkingMode.text]: 'general',
|
||||
[ChunkingMode.qa]: 'qa',
|
||||
[ChunkingMode.parentChild]: 'parentChild',
|
||||
// [ChunkingMode.graph]: 'graph', // todo: Graph RAG
|
||||
}
|
||||
|
||||
export type CreateDatasetReq = {
|
||||
yaml_content?: string
|
||||
}
|
||||
|
||||
export type CreateDatasetResponse = {
|
||||
id: string
|
||||
name: string
|
||||
description: string
|
||||
permission: DatasetPermission
|
||||
indexing_technique: IndexingType
|
||||
created_by: string
|
||||
created_at: number
|
||||
updated_by: string
|
||||
updated_at: number
|
||||
pipeline_id: string
|
||||
dataset_id: string
|
||||
}
|
||||
|
||||
export type IndexingStatusBatchRequest = {
|
||||
datasetId: string
|
||||
batchId: string
|
||||
}
|
||||
269
dify/web/models/debug.ts
Normal file
269
dify/web/models/debug.ts
Normal file
@@ -0,0 +1,269 @@
|
||||
import type { AgentStrategy, ModelModeType, RETRIEVE_TYPE, ToolItem, TtsAutoPlay } from '@/types/app'
|
||||
import type {
|
||||
RerankingModeEnum,
|
||||
WeightedScoreEnum,
|
||||
} from '@/models/datasets'
|
||||
import type { FileUpload } from '@/app/components/base/features/types'
|
||||
import type {
|
||||
MetadataFilteringConditions,
|
||||
MetadataFilteringModeEnum,
|
||||
} from '@/app/components/workflow/nodes/knowledge-retrieval/types'
|
||||
import type { ModelConfig as NodeModelConfig } from '@/app/components/workflow/types'
|
||||
import type { ExternalDataTool } from '@/models/common'
|
||||
export type Inputs = Record<string, string | number | object | boolean>
|
||||
|
||||
export enum PromptMode {
|
||||
simple = 'simple',
|
||||
advanced = 'advanced',
|
||||
}
|
||||
|
||||
export type PromptItem = {
|
||||
role?: PromptRole
|
||||
text: string
|
||||
}
|
||||
|
||||
export type ChatPromptConfig = {
|
||||
prompt: PromptItem[]
|
||||
}
|
||||
|
||||
export type ConversationHistoriesRole = {
|
||||
user_prefix: string
|
||||
assistant_prefix: string
|
||||
}
|
||||
export type CompletionPromptConfig = {
|
||||
prompt: PromptItem
|
||||
conversation_histories_role: ConversationHistoriesRole
|
||||
}
|
||||
|
||||
export type BlockStatus = {
|
||||
context: boolean
|
||||
history: boolean
|
||||
query: boolean
|
||||
}
|
||||
|
||||
export enum PromptRole {
|
||||
system = 'system',
|
||||
user = 'user',
|
||||
assistant = 'assistant',
|
||||
}
|
||||
|
||||
export type PromptVariable = {
|
||||
key: string
|
||||
name: string
|
||||
type: string // "string" | "number" | "select",
|
||||
default?: string | number
|
||||
required?: boolean
|
||||
options?: string[]
|
||||
max_length?: number
|
||||
is_context_var?: boolean
|
||||
enabled?: boolean
|
||||
config?: Record<string, any>
|
||||
icon?: string
|
||||
icon_background?: string
|
||||
hide?: boolean // used in frontend to hide variable
|
||||
json_schema?: string
|
||||
}
|
||||
|
||||
export type CompletionParams = {
|
||||
max_tokens: number
|
||||
temperature: number
|
||||
top_p: number
|
||||
presence_penalty: number
|
||||
frequency_penalty: number
|
||||
stop?: string[]
|
||||
}
|
||||
|
||||
export type ModelId = 'gpt-3.5-turbo' | 'text-davinci-003'
|
||||
|
||||
export type PromptConfig = {
|
||||
prompt_template: string
|
||||
prompt_variables: PromptVariable[]
|
||||
}
|
||||
|
||||
export type MoreLikeThisConfig = {
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
export type SuggestedQuestionsAfterAnswerConfig = MoreLikeThisConfig
|
||||
|
||||
export type SpeechToTextConfig = MoreLikeThisConfig
|
||||
|
||||
export type TextToSpeechConfig = {
|
||||
enabled: boolean
|
||||
voice?: string
|
||||
language?: string
|
||||
autoPlay?: TtsAutoPlay
|
||||
}
|
||||
|
||||
export type CitationConfig = MoreLikeThisConfig
|
||||
|
||||
export type AnnotationReplyConfig = {
|
||||
id: string
|
||||
enabled: boolean
|
||||
score_threshold: number
|
||||
embedding_model: {
|
||||
embedding_provider_name: string
|
||||
embedding_model_name: string
|
||||
}
|
||||
}
|
||||
|
||||
export type ModerationContentConfig = {
|
||||
enabled: boolean
|
||||
preset_response?: string
|
||||
}
|
||||
export type ModerationConfig = MoreLikeThisConfig & {
|
||||
type?: string
|
||||
config?: {
|
||||
keywords?: string
|
||||
api_based_extension_id?: string
|
||||
inputs_config?: ModerationContentConfig
|
||||
outputs_config?: ModerationContentConfig
|
||||
} & Partial<Record<string, any>>
|
||||
}
|
||||
|
||||
export type RetrieverResourceConfig = MoreLikeThisConfig
|
||||
export type AgentConfig = {
|
||||
enabled: boolean
|
||||
strategy: AgentStrategy
|
||||
max_iteration: number
|
||||
tools: ToolItem[]
|
||||
}
|
||||
// frontend use. Not the same as backend
|
||||
export type ModelConfig = {
|
||||
provider: string // LLM Provider: for example "OPENAI"
|
||||
model_id: string
|
||||
mode: ModelModeType
|
||||
configs: PromptConfig
|
||||
chat_prompt_config?: ChatPromptConfig | null
|
||||
completion_prompt_config?: CompletionPromptConfig | null
|
||||
opening_statement: string | null
|
||||
more_like_this: MoreLikeThisConfig | null
|
||||
suggested_questions: string[] | null
|
||||
suggested_questions_after_answer: SuggestedQuestionsAfterAnswerConfig | null
|
||||
speech_to_text: SpeechToTextConfig | null
|
||||
text_to_speech: TextToSpeechConfig | null
|
||||
file_upload: FileUpload | null
|
||||
retriever_resource: RetrieverResourceConfig | null
|
||||
sensitive_word_avoidance: ModerationConfig | null
|
||||
annotation_reply: AnnotationReplyConfig | null
|
||||
external_data_tools?: ExternalDataTool[] | null
|
||||
system_parameters: {
|
||||
audio_file_size_limit: number
|
||||
file_size_limit: number
|
||||
image_file_size_limit: number
|
||||
video_file_size_limit: number
|
||||
workflow_file_upload_limit: number
|
||||
}
|
||||
dataSets: any[]
|
||||
agentConfig: AgentConfig
|
||||
}
|
||||
export type DatasetConfigItem = {
|
||||
enable: boolean
|
||||
value: number
|
||||
}
|
||||
|
||||
export type DatasetConfigs = {
|
||||
retrieval_model: RETRIEVE_TYPE
|
||||
reranking_model: {
|
||||
reranking_provider_name: string
|
||||
reranking_model_name: string
|
||||
}
|
||||
top_k: number
|
||||
score_threshold_enabled: boolean
|
||||
score_threshold: number | null | undefined
|
||||
datasets: {
|
||||
datasets: {
|
||||
enabled: boolean
|
||||
id: string
|
||||
}[]
|
||||
}
|
||||
reranking_mode?: RerankingModeEnum
|
||||
weights?: {
|
||||
weight_type: WeightedScoreEnum
|
||||
vector_setting: {
|
||||
vector_weight: number
|
||||
embedding_provider_name: string
|
||||
embedding_model_name: string
|
||||
}
|
||||
keyword_setting: {
|
||||
keyword_weight: number
|
||||
}
|
||||
}
|
||||
reranking_enable?: boolean
|
||||
metadata_filtering_mode?: MetadataFilteringModeEnum
|
||||
metadata_filtering_conditions?: MetadataFilteringConditions
|
||||
metadata_model_config?: NodeModelConfig
|
||||
}
|
||||
|
||||
export type DebugRequestBody = {
|
||||
inputs: Inputs
|
||||
query: string
|
||||
completion_params: CompletionParams
|
||||
model_config: ModelConfig
|
||||
}
|
||||
|
||||
export type DebugResponse = {
|
||||
id: string
|
||||
answer: string
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export type DebugResponseStream = {
|
||||
id: string
|
||||
data: string
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export type FeedBackRequestBody = {
|
||||
message_id: string
|
||||
rating: 'like' | 'dislike'
|
||||
content?: string
|
||||
from_source: 'api' | 'log'
|
||||
}
|
||||
|
||||
export type FeedBackResponse = {
|
||||
message_id: string
|
||||
rating: 'like' | 'dislike'
|
||||
}
|
||||
|
||||
// Log session list
|
||||
export type LogSessionListQuery = {
|
||||
keyword?: string
|
||||
start?: string // format datetime(YYYY-mm-dd HH:ii)
|
||||
end?: string // format datetime(YYYY-mm-dd HH:ii)
|
||||
page: number
|
||||
limit: number // default 20. 1-100
|
||||
}
|
||||
|
||||
export type LogSessionListResponse = {
|
||||
data: {
|
||||
id: string
|
||||
conversation_id: string
|
||||
query: string // user's query question
|
||||
message: string // prompt send to LLM
|
||||
answer: string
|
||||
created_at: string
|
||||
}[]
|
||||
total: number
|
||||
page: number
|
||||
}
|
||||
|
||||
// log session detail and debug
|
||||
export type LogSessionDetailResponse = {
|
||||
id: string
|
||||
conversation_id: string
|
||||
model_provider: string
|
||||
query: string
|
||||
inputs: Record<string, string | number | object>[]
|
||||
message: string
|
||||
message_tokens: number // number of tokens in message
|
||||
answer: string
|
||||
answer_tokens: number // number of tokens in answer
|
||||
provider_response_latency: number // used time in ms
|
||||
from_source: 'api' | 'log'
|
||||
}
|
||||
|
||||
export type SavedMessage = {
|
||||
id: string
|
||||
answer: string
|
||||
}
|
||||
37
dify/web/models/explore.ts
Normal file
37
dify/web/models/explore.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import type { AppIconType, AppModeEnum } from '@/types/app'
|
||||
export type AppBasicInfo = {
|
||||
id: string
|
||||
mode: AppModeEnum
|
||||
icon_type: AppIconType | null
|
||||
icon: string
|
||||
icon_background: string
|
||||
icon_url: string
|
||||
name: string
|
||||
description: string
|
||||
use_icon_as_answer_icon: boolean
|
||||
}
|
||||
|
||||
export type AppCategory = 'Writing' | 'Translate' | 'HR' | 'Programming' | 'Assistant' | 'Agent' | 'Recommended' | 'Workflow'
|
||||
|
||||
export type App = {
|
||||
app: AppBasicInfo
|
||||
app_id: string
|
||||
description: string
|
||||
copyright: string
|
||||
privacy_policy: string | null
|
||||
custom_disclaimer: string | null
|
||||
category: AppCategory
|
||||
position: number
|
||||
is_listed: boolean
|
||||
install_count: number
|
||||
installed: boolean
|
||||
editable: boolean
|
||||
is_agent: boolean
|
||||
}
|
||||
|
||||
export type InstalledApp = {
|
||||
app: AppBasicInfo
|
||||
id: string
|
||||
uninstallable: boolean
|
||||
is_pinned: boolean
|
||||
}
|
||||
387
dify/web/models/log.ts
Normal file
387
dify/web/models/log.ts
Normal file
@@ -0,0 +1,387 @@
|
||||
import type { Viewport } from 'reactflow'
|
||||
import type { VisionFile } from '@/types/app'
|
||||
import type {
|
||||
Edge,
|
||||
Node,
|
||||
} from '@/app/components/workflow/types'
|
||||
import type { Metadata } from '@/app/components/base/chat/chat/type'
|
||||
|
||||
// Log type contains key:string conversation_id:string created_at:string question:string answer:string
|
||||
export type Conversation = {
|
||||
id: string
|
||||
key: string
|
||||
conversationId: string
|
||||
question: string
|
||||
answer: string
|
||||
userRate: number
|
||||
adminRate: number
|
||||
}
|
||||
|
||||
export type ConversationListResponse = {
|
||||
logs: Conversation[]
|
||||
}
|
||||
|
||||
export const fetchLogs = (url: string) =>
|
||||
fetch(url).then<ConversationListResponse>(r => r.json())
|
||||
|
||||
export const CompletionParams = ['temperature', 'top_p', 'presence_penalty', 'max_token', 'stop', 'frequency_penalty'] as const
|
||||
|
||||
export type CompletionParamType = typeof CompletionParams[number]
|
||||
|
||||
export type CompletionParamsType = {
|
||||
max_tokens: number
|
||||
temperature: number
|
||||
top_p: number
|
||||
stop: string[]
|
||||
presence_penalty: number
|
||||
frequency_penalty: number
|
||||
}
|
||||
|
||||
export type LogModelConfig = {
|
||||
name: string
|
||||
provider: string
|
||||
completion_params: CompletionParamsType
|
||||
}
|
||||
|
||||
export type ModelConfigDetail = {
|
||||
introduction: string
|
||||
prompt_template: string
|
||||
prompt_variables: Array<{
|
||||
key: string
|
||||
name: string
|
||||
description: string
|
||||
type: string | number
|
||||
default: string
|
||||
options: string[]
|
||||
}>
|
||||
completion_params: CompletionParamsType
|
||||
}
|
||||
|
||||
export type LogAnnotation = {
|
||||
id: string
|
||||
content: string
|
||||
account: {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
}
|
||||
created_at: number
|
||||
}
|
||||
|
||||
export type Annotation = {
|
||||
id: string
|
||||
authorName: string
|
||||
logAnnotation?: LogAnnotation
|
||||
created_at?: number
|
||||
}
|
||||
|
||||
export type MessageContent = {
|
||||
id: string
|
||||
conversation_id: string
|
||||
query: string
|
||||
inputs: Record<string, any>
|
||||
message: { role: string; text: string; files?: VisionFile[] }[]
|
||||
message_tokens: number
|
||||
answer_tokens: number
|
||||
answer: string
|
||||
provider_response_latency: number
|
||||
created_at: number
|
||||
annotation: LogAnnotation
|
||||
annotation_hit_history: {
|
||||
annotation_id: string
|
||||
annotation_create_account: {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
}
|
||||
created_at: number
|
||||
}
|
||||
feedbacks: Array<{
|
||||
rating: 'like' | 'dislike' | null
|
||||
content: string | null
|
||||
from_source?: 'admin' | 'user'
|
||||
from_end_user_id?: string
|
||||
}>
|
||||
message_files: VisionFile[]
|
||||
metadata: Metadata
|
||||
agent_thoughts: any[] // TODO
|
||||
workflow_run_id: string
|
||||
parent_message_id: string | null
|
||||
}
|
||||
|
||||
export type CompletionConversationGeneralDetail = {
|
||||
id: string
|
||||
status: 'normal' | 'finished'
|
||||
from_source: 'api' | 'console'
|
||||
from_end_user_id: string
|
||||
from_end_user_session_id: string
|
||||
from_account_id: string
|
||||
read_at: Date
|
||||
created_at: number
|
||||
updated_at: number
|
||||
annotation: Annotation
|
||||
user_feedback_stats: {
|
||||
like: number
|
||||
dislike: number
|
||||
}
|
||||
admin_feedback_stats: {
|
||||
like: number
|
||||
dislike: number
|
||||
}
|
||||
model_config: {
|
||||
provider: string
|
||||
model_id: string
|
||||
configs: Pick<ModelConfigDetail, 'prompt_template'>
|
||||
}
|
||||
message: Pick<MessageContent, 'inputs' | 'query' | 'answer' | 'message'>
|
||||
}
|
||||
|
||||
export type CompletionConversationFullDetailResponse = {
|
||||
id: string
|
||||
status: 'normal' | 'finished'
|
||||
from_source: 'api' | 'console'
|
||||
from_end_user_id: string
|
||||
from_account_id: string
|
||||
// read_at: Date
|
||||
created_at: number
|
||||
model_config: {
|
||||
provider: string
|
||||
model_id: string
|
||||
configs: ModelConfigDetail
|
||||
}
|
||||
message: MessageContent
|
||||
}
|
||||
|
||||
export type CompletionConversationsResponse = {
|
||||
data: Array<CompletionConversationGeneralDetail>
|
||||
has_more: boolean
|
||||
limit: number
|
||||
total: number
|
||||
page: number
|
||||
}
|
||||
|
||||
export type CompletionConversationsRequest = {
|
||||
keyword: string
|
||||
start: string
|
||||
end: string
|
||||
annotation_status: string
|
||||
page: number
|
||||
limit: number // The default value is 20 and the range is 1-100
|
||||
}
|
||||
|
||||
export type ChatConversationGeneralDetail = Omit<CompletionConversationGeneralDetail, 'message' | 'annotation'> & {
|
||||
summary: string
|
||||
message_count: number
|
||||
annotated: boolean
|
||||
}
|
||||
|
||||
export type ChatConversationsResponse = {
|
||||
data: Array<ChatConversationGeneralDetail>
|
||||
has_more: boolean
|
||||
limit: number
|
||||
total: number
|
||||
page: number
|
||||
}
|
||||
|
||||
export type ChatConversationsRequest = CompletionConversationsRequest & { message_count: number }
|
||||
|
||||
export type ChatConversationFullDetailResponse = Omit<CompletionConversationGeneralDetail, 'message' | 'model_config'> & {
|
||||
message_count: number
|
||||
model_config: {
|
||||
provider: string
|
||||
model_id: string
|
||||
configs: ModelConfigDetail
|
||||
model: LogModelConfig
|
||||
}
|
||||
}
|
||||
|
||||
export type ChatMessagesRequest = {
|
||||
conversation_id: string
|
||||
first_id?: string
|
||||
limit: number
|
||||
}
|
||||
export type ChatMessage = MessageContent
|
||||
|
||||
export type ChatMessagesResponse = {
|
||||
data: Array<ChatMessage>
|
||||
has_more: boolean
|
||||
limit: number
|
||||
}
|
||||
|
||||
export const MessageRatings = ['like', 'dislike', null] as const
|
||||
export type MessageRating = typeof MessageRatings[number]
|
||||
|
||||
export type LogMessageFeedbacksRequest = {
|
||||
message_id: string
|
||||
rating: MessageRating
|
||||
content?: string
|
||||
}
|
||||
|
||||
export type LogMessageFeedbacksResponse = {
|
||||
result: 'success' | 'error'
|
||||
}
|
||||
|
||||
export type LogMessageAnnotationsRequest = Omit<LogMessageFeedbacksRequest, 'rating'>
|
||||
|
||||
export type LogMessageAnnotationsResponse = LogMessageFeedbacksResponse
|
||||
|
||||
export type AnnotationsCountResponse = {
|
||||
count: number
|
||||
}
|
||||
|
||||
export enum WorkflowRunTriggeredFrom {
|
||||
DEBUGGING = 'debugging',
|
||||
APP_RUN = 'app-run',
|
||||
RAG_PIPELINE_RUN = 'rag-pipeline-run',
|
||||
RAG_PIPELINE_DEBUGGING = 'rag-pipeline-debugging',
|
||||
WEBHOOK = 'webhook',
|
||||
SCHEDULE = 'schedule',
|
||||
PLUGIN = 'plugin',
|
||||
}
|
||||
|
||||
export type TriggerMetadata = {
|
||||
type?: string
|
||||
endpoint_id?: string
|
||||
plugin_unique_identifier?: string
|
||||
provider_id?: string
|
||||
event_name?: string
|
||||
icon_filename?: string
|
||||
icon_dark_filename?: string
|
||||
icon?: string | null
|
||||
icon_dark?: string | null
|
||||
}
|
||||
|
||||
export type WorkflowLogDetails = {
|
||||
trigger_metadata?: TriggerMetadata
|
||||
}
|
||||
|
||||
export type WorkflowRunDetail = {
|
||||
id: string
|
||||
version: string
|
||||
status: 'running' | 'succeeded' | 'failed' | 'stopped'
|
||||
error?: string
|
||||
triggered_from?: WorkflowRunTriggeredFrom
|
||||
elapsed_time: number
|
||||
total_tokens: number
|
||||
total_price: number
|
||||
currency: string
|
||||
total_steps: number
|
||||
finished_at: number
|
||||
}
|
||||
export type AccountInfo = {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
}
|
||||
export type EndUserInfo = {
|
||||
id: string
|
||||
type: 'browser' | 'service_api'
|
||||
is_anonymous: boolean
|
||||
session_id: string
|
||||
}
|
||||
export type WorkflowAppLogDetail = {
|
||||
id: string
|
||||
workflow_run: WorkflowRunDetail
|
||||
details?: WorkflowLogDetails
|
||||
created_from: 'service-api' | 'web-app' | 'explore'
|
||||
created_by_role: 'account' | 'end_user'
|
||||
created_by_account?: AccountInfo
|
||||
created_by_end_user?: EndUserInfo
|
||||
created_at: number
|
||||
read_at?: number
|
||||
}
|
||||
export type WorkflowLogsResponse = {
|
||||
data: Array<WorkflowAppLogDetail>
|
||||
has_more: boolean
|
||||
limit: number
|
||||
total: number
|
||||
page: number
|
||||
}
|
||||
export type WorkflowLogsRequest = {
|
||||
keyword: string
|
||||
status: string
|
||||
page: number
|
||||
limit: number // The default value is 20 and the range is 1-100
|
||||
}
|
||||
|
||||
export type WorkflowRunDetailResponse = {
|
||||
id: string
|
||||
version: string
|
||||
graph: {
|
||||
nodes: Node[]
|
||||
edges: Edge[]
|
||||
viewport?: Viewport
|
||||
}
|
||||
inputs: string
|
||||
inputs_truncated: boolean
|
||||
status: 'running' | 'succeeded' | 'failed' | 'stopped'
|
||||
outputs?: string
|
||||
outputs_truncated: boolean
|
||||
outputs_full_content?: {
|
||||
download_url: string
|
||||
}
|
||||
error?: string
|
||||
elapsed_time?: number
|
||||
total_tokens?: number
|
||||
total_steps: number
|
||||
created_by_role: 'account' | 'end_user'
|
||||
created_by_account?: AccountInfo
|
||||
created_by_end_user?: EndUserInfo
|
||||
created_at: number
|
||||
finished_at: number
|
||||
exceptions_count?: number
|
||||
}
|
||||
|
||||
export type AgentLogMeta = {
|
||||
status: string
|
||||
executor: string
|
||||
start_time: string
|
||||
elapsed_time: number
|
||||
total_tokens: number
|
||||
agent_mode: string
|
||||
iterations: number
|
||||
error?: string
|
||||
}
|
||||
|
||||
export type ToolCall = {
|
||||
status: string
|
||||
error?: string | null
|
||||
time_cost?: number
|
||||
tool_icon: any
|
||||
tool_input?: any
|
||||
tool_output?: any
|
||||
tool_name?: string
|
||||
tool_label?: any
|
||||
tool_parameters?: any
|
||||
}
|
||||
|
||||
export type AgentIteration = {
|
||||
created_at: string
|
||||
files: string[]
|
||||
thought: string
|
||||
tokens: number
|
||||
tool_calls: ToolCall[]
|
||||
tool_raw: {
|
||||
inputs: string
|
||||
outputs: string
|
||||
}
|
||||
}
|
||||
|
||||
export type AgentLogFile = {
|
||||
id: string
|
||||
type: string
|
||||
url: string
|
||||
name: string
|
||||
belongs_to: string
|
||||
}
|
||||
|
||||
export type AgentLogDetailRequest = {
|
||||
conversation_id: string
|
||||
message_id: string
|
||||
}
|
||||
|
||||
export type AgentLogDetailResponse = {
|
||||
meta: AgentLogMeta
|
||||
iterations: AgentIteration[]
|
||||
files: AgentLogFile[]
|
||||
}
|
||||
302
dify/web/models/pipeline.ts
Normal file
302
dify/web/models/pipeline.ts
Normal file
@@ -0,0 +1,302 @@
|
||||
import type { Edge, EnvironmentVariable, Node, SupportUploadFileTypes } from '@/app/components/workflow/types'
|
||||
import type { DSLImportMode, DSLImportStatus } from './app'
|
||||
import type { ChunkingMode, DatasetPermission, DocumentIndexingStatus, FileIndexingEstimateResponse, IconInfo } from './datasets'
|
||||
import type { Dependency } from '@/app/components/plugins/types'
|
||||
import type { AppIconSelection } from '@/app/components/base/app-icon-picker'
|
||||
import type { Viewport } from 'reactflow'
|
||||
import type { TransferMethod } from '@/types/app'
|
||||
import { BaseFieldType } from '@/app/components/base/form/form-scenarios/base/types'
|
||||
import type { NodeRunResult } from '@/types/workflow'
|
||||
|
||||
export enum DatasourceType {
|
||||
localFile = 'local_file',
|
||||
onlineDocument = 'online_document',
|
||||
websiteCrawl = 'website_crawl',
|
||||
onlineDrive = 'online_drive',
|
||||
}
|
||||
|
||||
export type PipelineTemplateListParams = {
|
||||
type: 'built-in' | 'customized'
|
||||
language?: string
|
||||
}
|
||||
|
||||
export type PipelineTemplate = {
|
||||
id: string
|
||||
name: string
|
||||
icon: IconInfo
|
||||
description: string
|
||||
position: number
|
||||
chunk_structure: ChunkingMode
|
||||
}
|
||||
|
||||
export type PipelineTemplateListResponse = {
|
||||
pipeline_templates: PipelineTemplate[]
|
||||
}
|
||||
|
||||
export type PipelineTemplateByIdRequest = {
|
||||
template_id: string
|
||||
type: 'built-in' | 'customized'
|
||||
}
|
||||
|
||||
export type PipelineTemplateByIdResponse = {
|
||||
id: string
|
||||
name: string
|
||||
icon_info: IconInfo
|
||||
description: string
|
||||
chunk_structure: ChunkingMode
|
||||
export_data: string // DSL content
|
||||
graph: {
|
||||
nodes: Node[]
|
||||
edges: Edge[]
|
||||
viewport: Viewport
|
||||
}
|
||||
created_by: string
|
||||
}
|
||||
|
||||
export type CreateFormData = {
|
||||
name: string
|
||||
appIcon: AppIconSelection
|
||||
description: string
|
||||
permission: DatasetPermission
|
||||
selectedMemberIDs: string[]
|
||||
}
|
||||
|
||||
export type UpdateTemplateInfoRequest = {
|
||||
template_id: string
|
||||
name: string
|
||||
icon_info: IconInfo
|
||||
description: string
|
||||
}
|
||||
|
||||
export type UpdateTemplateInfoResponse = {
|
||||
pipeline_id: string
|
||||
name: string
|
||||
icon: IconInfo
|
||||
description: string
|
||||
position: number
|
||||
}
|
||||
|
||||
export type DeleteTemplateResponse = {
|
||||
code: number
|
||||
}
|
||||
|
||||
export type ExportTemplateDSLResponse = {
|
||||
data: string
|
||||
}
|
||||
|
||||
export type ImportPipelineDSLRequest = {
|
||||
mode: DSLImportMode
|
||||
yaml_content?: string
|
||||
yaml_url?: string
|
||||
pipeline_id?: string
|
||||
}
|
||||
|
||||
export type ImportPipelineDSLResponse = {
|
||||
id: string
|
||||
status: DSLImportStatus
|
||||
pipeline_id: string
|
||||
dataset_id: string
|
||||
current_dsl_version: string
|
||||
imported_dsl_version: string
|
||||
}
|
||||
|
||||
export type ImportPipelineDSLConfirmResponse = {
|
||||
status: DSLImportStatus
|
||||
pipeline_id: string
|
||||
dataset_id: string
|
||||
current_dsl_version: string
|
||||
imported_dsl_version: string
|
||||
error: string
|
||||
}
|
||||
|
||||
export type PipelineCheckDependenciesResponse = {
|
||||
leaked_dependencies: Dependency[]
|
||||
}
|
||||
|
||||
export enum PipelineInputVarType {
|
||||
textInput = 'text-input',
|
||||
paragraph = 'paragraph',
|
||||
select = 'select',
|
||||
number = 'number',
|
||||
singleFile = 'file',
|
||||
multiFiles = 'file-list',
|
||||
checkbox = 'checkbox',
|
||||
}
|
||||
|
||||
export const VAR_TYPE_MAP: Record<PipelineInputVarType, BaseFieldType> = {
|
||||
[PipelineInputVarType.textInput]: BaseFieldType.textInput,
|
||||
[PipelineInputVarType.paragraph]: BaseFieldType.paragraph,
|
||||
[PipelineInputVarType.select]: BaseFieldType.select,
|
||||
[PipelineInputVarType.singleFile]: BaseFieldType.file,
|
||||
[PipelineInputVarType.multiFiles]: BaseFieldType.fileList,
|
||||
[PipelineInputVarType.number]: BaseFieldType.numberInput,
|
||||
[PipelineInputVarType.checkbox]: BaseFieldType.checkbox,
|
||||
}
|
||||
|
||||
export type RAGPipelineVariable = {
|
||||
belong_to_node_id: string // indicates belong to which node or 'shared'
|
||||
type: PipelineInputVarType
|
||||
label: string
|
||||
variable: string
|
||||
max_length?: number
|
||||
default_value?: string
|
||||
placeholder?: string
|
||||
unit?: string
|
||||
required: boolean
|
||||
tooltips?: string
|
||||
options?: string[]
|
||||
allowed_file_upload_methods?: TransferMethod[]
|
||||
allowed_file_types?: SupportUploadFileTypes[]
|
||||
allowed_file_extensions?: string[]
|
||||
}
|
||||
|
||||
export type InputVar = Omit<RAGPipelineVariable, 'belong_to_node_id'>
|
||||
export type RAGPipelineVariables = RAGPipelineVariable[]
|
||||
|
||||
export type PipelineProcessingParamsRequest = {
|
||||
pipeline_id: string
|
||||
node_id: string
|
||||
}
|
||||
|
||||
export type PipelineProcessingParamsResponse = {
|
||||
variables: RAGPipelineVariables
|
||||
}
|
||||
|
||||
export type PipelinePreProcessingParamsRequest = {
|
||||
pipeline_id: string
|
||||
node_id: string
|
||||
}
|
||||
|
||||
export type PipelinePreProcessingParamsResponse = {
|
||||
variables: RAGPipelineVariables
|
||||
}
|
||||
|
||||
export type PublishedPipelineInfoResponse = {
|
||||
id: string
|
||||
graph: {
|
||||
nodes: Node[]
|
||||
edges: Edge[]
|
||||
viewport: Viewport
|
||||
}
|
||||
created_at: number
|
||||
created_by: {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
}
|
||||
hash: string
|
||||
updated_at: number
|
||||
updated_by: {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
},
|
||||
environment_variables?: EnvironmentVariable[]
|
||||
rag_pipeline_variables?: RAGPipelineVariables
|
||||
version: string
|
||||
marked_name: string
|
||||
marked_comment: string
|
||||
}
|
||||
|
||||
export type PublishedPipelineRunRequest = {
|
||||
pipeline_id: string
|
||||
inputs: Record<string, any>
|
||||
start_node_id: string
|
||||
datasource_type: DatasourceType
|
||||
datasource_info_list: Array<Record<string, any>>
|
||||
original_document_id?: string
|
||||
is_preview: boolean
|
||||
}
|
||||
|
||||
export type PublishedPipelineRunPreviewResponse = {
|
||||
task_iod: string
|
||||
workflow_run_id: string
|
||||
data: {
|
||||
id: string
|
||||
status: string
|
||||
created_at: number
|
||||
elapsed_time: number
|
||||
error: string
|
||||
finished_at: number
|
||||
outputs: FileIndexingEstimateResponse
|
||||
total_steps: number
|
||||
total_tokens: number
|
||||
workflow_id: string
|
||||
}
|
||||
}
|
||||
|
||||
export type PublishedPipelineRunResponse = {
|
||||
batch: string
|
||||
dataset: {
|
||||
chunk_structure: ChunkingMode
|
||||
description: string
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
documents: InitialDocumentDetail[]
|
||||
}
|
||||
|
||||
export type InitialDocumentDetail = {
|
||||
data_source_info: Record<string, any>
|
||||
data_source_type: DatasourceType
|
||||
enable: boolean
|
||||
error: string
|
||||
id: string
|
||||
indexing_status: DocumentIndexingStatus
|
||||
name: string
|
||||
position: number
|
||||
}
|
||||
|
||||
export type PipelineExecutionLogRequest = {
|
||||
dataset_id: string
|
||||
document_id: string
|
||||
}
|
||||
|
||||
export type PipelineExecutionLogResponse = {
|
||||
datasource_info: Record<string, any>
|
||||
datasource_type: DatasourceType
|
||||
input_data: Record<string, any>
|
||||
datasource_node_id: string
|
||||
}
|
||||
|
||||
export type OnlineDocumentPreviewRequest = {
|
||||
workspaceID: string
|
||||
pageID: string
|
||||
pageType: string
|
||||
pipelineId: string
|
||||
datasourceNodeId: string
|
||||
credentialId: string
|
||||
}
|
||||
|
||||
export type OnlineDocumentPreviewResponse = {
|
||||
content: string
|
||||
}
|
||||
|
||||
export type ConversionResponse = {
|
||||
pipeline_id: string
|
||||
dataset_id: string
|
||||
status: 'success' | 'failed'
|
||||
}
|
||||
|
||||
export enum OnlineDriveFileType {
|
||||
file = 'file',
|
||||
folder = 'folder',
|
||||
bucket = 'bucket',
|
||||
}
|
||||
|
||||
export type OnlineDriveFile = {
|
||||
id: string
|
||||
name: string
|
||||
size?: number
|
||||
type: OnlineDriveFileType
|
||||
}
|
||||
|
||||
export type DatasourceNodeSingleRunRequest = {
|
||||
pipeline_id: string
|
||||
start_node_id: string
|
||||
start_node_title: string
|
||||
datasource_type: DatasourceType
|
||||
datasource_info: Record<string, any>
|
||||
}
|
||||
|
||||
export type DatasourceNodeSingleRunResponse = NodeRunResult
|
||||
48
dify/web/models/share.ts
Normal file
48
dify/web/models/share.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import type { Locale } from '@/i18n-config'
|
||||
import type { AppIconType } from '@/types/app'
|
||||
|
||||
export type ResponseHolder = {}
|
||||
|
||||
export type ConversationItem = {
|
||||
id: string
|
||||
name: string
|
||||
inputs: Record<string, any> | null
|
||||
introduction: string
|
||||
}
|
||||
|
||||
export type SiteInfo = {
|
||||
title: string
|
||||
chat_color_theme?: string
|
||||
chat_color_theme_inverted?: boolean
|
||||
icon_type?: AppIconType | null
|
||||
icon?: string
|
||||
icon_background?: string | null
|
||||
icon_url?: string | null
|
||||
description?: string
|
||||
default_language?: Locale
|
||||
prompt_public?: boolean
|
||||
copyright?: string
|
||||
privacy_policy?: string
|
||||
custom_disclaimer?: string
|
||||
show_workflow_steps?: boolean
|
||||
use_icon_as_answer_icon?: boolean
|
||||
}
|
||||
|
||||
export type AppMeta = {
|
||||
tool_icons: Record<string, string>
|
||||
}
|
||||
|
||||
export type AppData = {
|
||||
app_id: string
|
||||
can_replace_logo?: boolean
|
||||
custom_config: Record<string, any> | null
|
||||
enable_site?: boolean
|
||||
end_user_id?: string
|
||||
site: SiteInfo
|
||||
}
|
||||
|
||||
export type AppConversationData = {
|
||||
data: ConversationItem[]
|
||||
has_more: boolean
|
||||
limit: number
|
||||
}
|
||||
17
dify/web/models/user.ts
Normal file
17
dify/web/models/user.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
export type User = {
|
||||
id: string
|
||||
firstName: string
|
||||
lastName: string
|
||||
name: string
|
||||
phone: string
|
||||
username: string
|
||||
email: string
|
||||
avatar: string
|
||||
}
|
||||
|
||||
export type UserResponse = {
|
||||
users: User[]
|
||||
}
|
||||
|
||||
export const fetchUsers = (url: string) =>
|
||||
fetch(url).then<UserResponse>(r => r.json())
|
||||
Reference in New Issue
Block a user