dify
This commit is contained in:
472
dify/web/types/app.ts
Normal file
472
dify/web/types/app.ts
Normal file
@@ -0,0 +1,472 @@
|
||||
import type { AnnotationReplyConfig, ChatPromptConfig, CompletionPromptConfig, DatasetConfigs, PromptMode } from '@/models/debug'
|
||||
import type { CollectionType } from '@/app/components/tools/types'
|
||||
import type { LanguagesSupported } from '@/i18n-config/language'
|
||||
import type { Tag } from '@/app/components/base/tag-management/constant'
|
||||
import type {
|
||||
RerankingModeEnum,
|
||||
WeightedScoreEnum,
|
||||
} from '@/models/datasets'
|
||||
import type { UploadFileSetting } from '@/app/components/workflow/types'
|
||||
import type { AccessMode } from '@/models/access-control'
|
||||
import type { ExternalDataTool } from '@/models/common'
|
||||
|
||||
export enum Theme {
|
||||
light = 'light',
|
||||
dark = 'dark',
|
||||
system = 'system',
|
||||
}
|
||||
|
||||
export enum ProviderType {
|
||||
openai = 'openai',
|
||||
anthropic = 'anthropic',
|
||||
azure_openai = 'azure_openai',
|
||||
replicate = 'replicate',
|
||||
huggingface_hub = 'huggingface_hub',
|
||||
minimax = 'minimax',
|
||||
tongyi = 'tongyi',
|
||||
spark = 'spark',
|
||||
}
|
||||
|
||||
export enum AppType {
|
||||
chat = 'chat',
|
||||
completion = 'completion',
|
||||
}
|
||||
|
||||
export enum ModelModeType {
|
||||
chat = 'chat',
|
||||
completion = 'completion',
|
||||
unset = '',
|
||||
}
|
||||
|
||||
export enum RETRIEVE_TYPE {
|
||||
oneWay = 'single',
|
||||
multiWay = 'multiple',
|
||||
}
|
||||
|
||||
export enum RETRIEVE_METHOD {
|
||||
semantic = 'semantic_search',
|
||||
fullText = 'full_text_search',
|
||||
hybrid = 'hybrid_search',
|
||||
invertedIndex = 'invertedIndex',
|
||||
keywordSearch = 'keyword_search',
|
||||
}
|
||||
|
||||
export type VariableInput = {
|
||||
key: string
|
||||
name: string
|
||||
value: string
|
||||
}
|
||||
|
||||
/**
|
||||
* App modes
|
||||
*/
|
||||
export enum AppModeEnum {
|
||||
COMPLETION = 'completion',
|
||||
WORKFLOW = 'workflow',
|
||||
CHAT = 'chat',
|
||||
ADVANCED_CHAT = 'advanced-chat',
|
||||
AGENT_CHAT = 'agent-chat',
|
||||
}
|
||||
export const AppModes = [AppModeEnum.COMPLETION, AppModeEnum.WORKFLOW, AppModeEnum.CHAT, AppModeEnum.ADVANCED_CHAT, AppModeEnum.AGENT_CHAT] as const
|
||||
|
||||
/**
|
||||
* Variable type
|
||||
*/
|
||||
export const VariableTypes = ['string', 'number', 'select'] as const
|
||||
export type VariableType = typeof VariableTypes[number]
|
||||
|
||||
/**
|
||||
* Prompt variable parameter
|
||||
*/
|
||||
export type PromptVariable = {
|
||||
/** Variable key */
|
||||
key: string
|
||||
/** Variable name */
|
||||
name: string
|
||||
/** Type */
|
||||
type: VariableType
|
||||
required: boolean
|
||||
/** Enumeration of single-selection drop-down values */
|
||||
options?: string[]
|
||||
max_length?: number
|
||||
}
|
||||
|
||||
export type TextTypeFormItem = {
|
||||
default: string
|
||||
label: string
|
||||
variable: string
|
||||
required: boolean
|
||||
max_length: number
|
||||
hide: boolean
|
||||
}
|
||||
|
||||
export type SelectTypeFormItem = {
|
||||
default: string
|
||||
label: string
|
||||
variable: string
|
||||
required: boolean
|
||||
options: string[]
|
||||
hide: boolean
|
||||
}
|
||||
/**
|
||||
* User Input Form Item
|
||||
*/
|
||||
export type UserInputFormItem = {
|
||||
'text-input': TextTypeFormItem
|
||||
} | {
|
||||
select: SelectTypeFormItem
|
||||
} | {
|
||||
paragraph: TextTypeFormItem
|
||||
}
|
||||
|
||||
export type AgentTool = {
|
||||
provider_id: string
|
||||
provider_type: CollectionType
|
||||
provider_name: string
|
||||
tool_name: string
|
||||
tool_label: string
|
||||
tool_parameters: Record<string, any>
|
||||
enabled: boolean
|
||||
isDeleted?: boolean
|
||||
notAuthor?: boolean
|
||||
credential_id?: string
|
||||
}
|
||||
|
||||
export type ToolItem = {
|
||||
dataset: {
|
||||
enabled: boolean
|
||||
id: string
|
||||
}
|
||||
} | {
|
||||
'sensitive-word-avoidance': {
|
||||
enabled: boolean
|
||||
words: string[]
|
||||
canned_response: string
|
||||
}
|
||||
} | AgentTool
|
||||
|
||||
export enum AgentStrategy {
|
||||
functionCall = 'function_call',
|
||||
react = 'react',
|
||||
}
|
||||
|
||||
export type CompletionParams = {
|
||||
/** Maximum number of tokens in the answer message returned by Completion */
|
||||
max_tokens: number
|
||||
/**
|
||||
* A number between 0 and 2.
|
||||
* The larger the number, the more random the result;
|
||||
* otherwise, the more deterministic.
|
||||
* When in use, choose either `temperature` or `top_p`.
|
||||
* Default is 1.
|
||||
*/
|
||||
temperature: number
|
||||
/**
|
||||
* Represents the proportion of probability mass samples to take,
|
||||
* e.g., 0.1 means taking the top 10% probability mass samples.
|
||||
* The determinism between the samples is basically consistent.
|
||||
* Among these results, the `top_p` probability mass results are taken.
|
||||
* When in use, choose either `temperature` or `top_p`.
|
||||
* Default is 1.
|
||||
*/
|
||||
top_p: number
|
||||
/** When enabled, the Completion Text will concatenate the Prompt content together and return it. */
|
||||
echo: boolean
|
||||
/**
|
||||
* Specify up to 4 to automatically stop generating before the text specified in `stop`.
|
||||
* Suitable for use in chat mode.
|
||||
* For example, specify "Q" and "A",
|
||||
* and provide some Q&A examples as context,
|
||||
* and the model will give out in Q&A format and stop generating before Q&A.
|
||||
*/
|
||||
stop: string[]
|
||||
/**
|
||||
* A number between -2.0 and 2.0.
|
||||
* The larger the value, the less the model will repeat topics and the more it will provide new topics.
|
||||
*/
|
||||
presence_penalty: number
|
||||
/**
|
||||
* A number between -2.0 and 2.0.
|
||||
* A lower setting will make the model appear less cultured,
|
||||
* always repeating expressions.
|
||||
* The difference between `frequency_penalty` and `presence_penalty`
|
||||
* is that `frequency_penalty` penalizes a word based on its frequency in the training data,
|
||||
* while `presence_penalty` penalizes a word based on its occurrence in the input text.
|
||||
*/
|
||||
frequency_penalty: number
|
||||
}
|
||||
/**
|
||||
* Model configuration. The backend type.
|
||||
*/
|
||||
export type Model = {
|
||||
/** LLM provider, e.g., OPENAI */
|
||||
provider: string
|
||||
/** Model name, e.g, gpt-3.5.turbo */
|
||||
name: string
|
||||
mode: ModelModeType
|
||||
/** Default Completion call parameters */
|
||||
completion_params: CompletionParams
|
||||
}
|
||||
|
||||
export type ModelConfig = {
|
||||
opening_statement: string
|
||||
suggested_questions?: string[]
|
||||
pre_prompt: string
|
||||
prompt_type: PromptMode
|
||||
chat_prompt_config?: ChatPromptConfig | null
|
||||
completion_prompt_config?: CompletionPromptConfig | null
|
||||
user_input_form: UserInputFormItem[]
|
||||
dataset_query_variable?: string
|
||||
more_like_this: {
|
||||
enabled: boolean
|
||||
}
|
||||
suggested_questions_after_answer: {
|
||||
enabled: boolean
|
||||
}
|
||||
speech_to_text: {
|
||||
enabled: boolean
|
||||
}
|
||||
text_to_speech: {
|
||||
enabled: boolean
|
||||
voice?: string
|
||||
language?: string
|
||||
autoPlay?: TtsAutoPlay
|
||||
}
|
||||
retriever_resource: {
|
||||
enabled: boolean
|
||||
}
|
||||
sensitive_word_avoidance: {
|
||||
enabled: boolean
|
||||
}
|
||||
annotation_reply?: AnnotationReplyConfig
|
||||
agent_mode: {
|
||||
enabled: boolean
|
||||
strategy?: AgentStrategy
|
||||
tools: ToolItem[]
|
||||
}
|
||||
external_data_tools?: ExternalDataTool[]
|
||||
model: Model
|
||||
dataset_configs: DatasetConfigs
|
||||
file_upload?: {
|
||||
image: VisionSettings
|
||||
} & UploadFileSetting
|
||||
files?: VisionFile[]
|
||||
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
|
||||
}
|
||||
created_at?: number
|
||||
updated_at?: number
|
||||
}
|
||||
|
||||
export type Language = typeof LanguagesSupported[number]
|
||||
|
||||
/**
|
||||
* Web Application Configuration
|
||||
*/
|
||||
export type SiteConfig = {
|
||||
/** Application URL Identifier: `http://dify.app/{access_token}` */
|
||||
access_token: string
|
||||
/** Public Title */
|
||||
title: string
|
||||
/** Application Description will be shown in the Client */
|
||||
description: string
|
||||
/** Define the color in hex for different elements of the chatbot, such as:
|
||||
* The header, the button , etc.
|
||||
*/
|
||||
chat_color_theme: string
|
||||
/** Invert the color of the theme set in chat_color_theme */
|
||||
chat_color_theme_inverted: boolean
|
||||
/** Author */
|
||||
author: string
|
||||
/** User Support Email Address */
|
||||
support_email: string
|
||||
/**
|
||||
* Default Language, e.g. zh-Hans, en-US
|
||||
* Use standard RFC 4646, see https://www.ruanyifeng.com/blog/2008/02/codes_for_language_names.html
|
||||
*/
|
||||
default_language: Language
|
||||
/** Custom Domain */
|
||||
customize_domain: string
|
||||
/** Theme */
|
||||
theme: string
|
||||
/** Custom Token strategy Whether Terminal Users can choose their OpenAI Key */
|
||||
customize_token_strategy: 'must' | 'allow' | 'not_allow'
|
||||
/** Is Prompt Public */
|
||||
prompt_public: boolean
|
||||
/** Web API and APP Base Domain Name */
|
||||
app_base_url: string
|
||||
/** Copyright */
|
||||
copyright: string
|
||||
/** Privacy Policy */
|
||||
privacy_policy: string
|
||||
/** Custom Disclaimer */
|
||||
custom_disclaimer: string
|
||||
|
||||
icon_type: AppIconType | null
|
||||
icon: string
|
||||
icon_background: string | null
|
||||
icon_url: string | null
|
||||
|
||||
show_workflow_steps: boolean
|
||||
use_icon_as_answer_icon: boolean
|
||||
}
|
||||
|
||||
export type AppIconType = 'image' | 'emoji'
|
||||
|
||||
/**
|
||||
* App
|
||||
*/
|
||||
export type App = {
|
||||
/** App ID */
|
||||
id: string
|
||||
/** Name */
|
||||
name: string
|
||||
/** Description */
|
||||
description: string
|
||||
/** Author Name */
|
||||
author_name: string;
|
||||
|
||||
/**
|
||||
* Icon Type
|
||||
* @default 'emoji'
|
||||
*/
|
||||
icon_type: AppIconType | null
|
||||
/** Icon, stores file ID if icon_type is 'image' */
|
||||
icon: string
|
||||
/** Icon Background, only available when icon_type is null or 'emoji' */
|
||||
icon_background: string | null
|
||||
/** Icon URL, only available when icon_type is 'image' */
|
||||
icon_url: string | null
|
||||
/** Whether to use app icon as answer icon */
|
||||
use_icon_as_answer_icon: boolean
|
||||
|
||||
/** Mode */
|
||||
mode: AppModeEnum
|
||||
/** Enable web app */
|
||||
enable_site: boolean
|
||||
/** Enable web API */
|
||||
enable_api: boolean
|
||||
/** API requests per minute, default is 60 */
|
||||
api_rpm: number
|
||||
/** API requests per hour, default is 3600 */
|
||||
api_rph: number
|
||||
/** Whether it's a demo app */
|
||||
is_demo: boolean
|
||||
/** Model configuration */
|
||||
model_config: ModelConfig
|
||||
app_model_config: ModelConfig
|
||||
/** Timestamp of creation */
|
||||
created_at: number
|
||||
/** Timestamp of update */
|
||||
updated_at: number
|
||||
/** Web Application Configuration */
|
||||
site: SiteConfig
|
||||
/** api site url */
|
||||
api_base_url: string
|
||||
tags: Tag[]
|
||||
workflow?: {
|
||||
id: string
|
||||
created_at: number
|
||||
created_by?: string
|
||||
updated_at: number
|
||||
updated_by?: string
|
||||
}
|
||||
deleted_tools?: Array<{ id: string; tool_name: string }>
|
||||
/** access control */
|
||||
access_mode: AccessMode
|
||||
max_active_requests?: number | null
|
||||
/** whether workflow trigger has un-published draft */
|
||||
has_draft_trigger?: boolean
|
||||
}
|
||||
|
||||
export type AppSSO = {
|
||||
enable_sso: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* App Template
|
||||
*/
|
||||
export type AppTemplate = {
|
||||
/** Name */
|
||||
name: string
|
||||
/** Description */
|
||||
description: string
|
||||
/** Mode */
|
||||
mode: AppModeEnum
|
||||
/** Model */
|
||||
model_config: ModelConfig
|
||||
}
|
||||
|
||||
export enum Resolution {
|
||||
low = 'low',
|
||||
high = 'high',
|
||||
}
|
||||
|
||||
export enum TransferMethod {
|
||||
all = 'all',
|
||||
local_file = 'local_file',
|
||||
remote_url = 'remote_url',
|
||||
}
|
||||
|
||||
export enum TtsAutoPlay {
|
||||
enabled = 'enabled',
|
||||
disabled = 'disabled',
|
||||
}
|
||||
|
||||
export const ALLOW_FILE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'webp', 'gif']
|
||||
|
||||
export type VisionSettings = {
|
||||
enabled: boolean
|
||||
number_limits: number
|
||||
detail: Resolution
|
||||
transfer_methods: TransferMethod[]
|
||||
image_file_size_limit?: number | string
|
||||
}
|
||||
|
||||
export type ImageFile = {
|
||||
type: TransferMethod
|
||||
_id: string
|
||||
fileId: string
|
||||
file?: File
|
||||
progress: number
|
||||
url: string
|
||||
base64Url?: string
|
||||
deleted?: boolean
|
||||
}
|
||||
|
||||
export type VisionFile = {
|
||||
id?: string
|
||||
type: string
|
||||
transfer_method: TransferMethod
|
||||
url: string
|
||||
upload_file_id: string
|
||||
belongs_to?: string
|
||||
}
|
||||
|
||||
export type RetrievalConfig = {
|
||||
search_method: RETRIEVE_METHOD
|
||||
reranking_enable: boolean
|
||||
reranking_model: {
|
||||
reranking_provider_name: string
|
||||
reranking_model_name: string
|
||||
}
|
||||
top_k: number
|
||||
score_threshold_enabled: boolean
|
||||
score_threshold: number
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
24
dify/web/types/assets.d.ts
vendored
Normal file
24
dify/web/types/assets.d.ts
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
declare module '*.svg' {
|
||||
const value: any
|
||||
export default value
|
||||
}
|
||||
|
||||
declare module '*.png' {
|
||||
const value: any
|
||||
export default value
|
||||
}
|
||||
|
||||
declare module '*.jpg' {
|
||||
const value: any
|
||||
export default value
|
||||
}
|
||||
|
||||
declare module '*.jpeg' {
|
||||
const value: any
|
||||
export default value
|
||||
}
|
||||
|
||||
declare module '*.gif' {
|
||||
const value: any
|
||||
export default value
|
||||
}
|
||||
4
dify/web/types/common.ts
Normal file
4
dify/web/types/common.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export enum FlowType {
|
||||
appFlow = 'appFlow',
|
||||
ragPipeline = 'ragPipeline',
|
||||
}
|
||||
133
dify/web/types/feature.ts
Normal file
133
dify/web/types/feature.ts
Normal file
@@ -0,0 +1,133 @@
|
||||
export enum SSOProtocol {
|
||||
SAML = 'saml',
|
||||
OIDC = 'oidc',
|
||||
OAuth2 = 'oauth2',
|
||||
}
|
||||
|
||||
export enum LicenseStatus {
|
||||
NONE = 'none',
|
||||
INACTIVE = 'inactive',
|
||||
ACTIVE = 'active',
|
||||
EXPIRING = 'expiring',
|
||||
EXPIRED = 'expired',
|
||||
LOST = 'lost',
|
||||
}
|
||||
|
||||
export enum InstallationScope {
|
||||
ALL = 'all',
|
||||
NONE = 'none',
|
||||
OFFICIAL_ONLY = 'official_only',
|
||||
OFFICIAL_AND_PARTNER = 'official_and_specific_partners',
|
||||
}
|
||||
|
||||
type License = {
|
||||
status: LicenseStatus
|
||||
expired_at: string | null
|
||||
}
|
||||
|
||||
export type SystemFeatures = {
|
||||
plugin_installation_permission: {
|
||||
plugin_installation_scope: InstallationScope,
|
||||
restrict_to_marketplace_only: boolean
|
||||
},
|
||||
sso_enforced_for_signin: boolean
|
||||
sso_enforced_for_signin_protocol: SSOProtocol | ''
|
||||
sso_enforced_for_web: boolean
|
||||
sso_enforced_for_web_protocol: SSOProtocol | ''
|
||||
enable_marketplace: boolean
|
||||
enable_change_email: boolean
|
||||
enable_email_code_login: boolean
|
||||
enable_email_password_login: boolean
|
||||
enable_social_oauth_login: boolean
|
||||
is_allow_create_workspace: boolean
|
||||
is_allow_register: boolean
|
||||
is_email_setup: boolean
|
||||
license: License
|
||||
branding: {
|
||||
enabled: boolean
|
||||
login_page_logo: string
|
||||
workspace_logo: string
|
||||
favicon: string
|
||||
application_title: string
|
||||
}
|
||||
webapp_auth: {
|
||||
enabled: boolean
|
||||
allow_sso: boolean
|
||||
sso_config: {
|
||||
protocol: SSOProtocol | ''
|
||||
}
|
||||
allow_email_code_login: boolean
|
||||
allow_email_password_login: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const defaultSystemFeatures: SystemFeatures = {
|
||||
plugin_installation_permission: {
|
||||
plugin_installation_scope: InstallationScope.ALL,
|
||||
restrict_to_marketplace_only: false,
|
||||
},
|
||||
sso_enforced_for_signin: false,
|
||||
sso_enforced_for_signin_protocol: '',
|
||||
sso_enforced_for_web: false,
|
||||
sso_enforced_for_web_protocol: '',
|
||||
enable_marketplace: false,
|
||||
enable_change_email: false,
|
||||
enable_email_code_login: false,
|
||||
enable_email_password_login: false,
|
||||
enable_social_oauth_login: false,
|
||||
is_allow_create_workspace: false,
|
||||
is_allow_register: false,
|
||||
is_email_setup: false,
|
||||
license: {
|
||||
status: LicenseStatus.NONE,
|
||||
expired_at: '',
|
||||
},
|
||||
branding: {
|
||||
enabled: false,
|
||||
login_page_logo: '',
|
||||
workspace_logo: '',
|
||||
favicon: '',
|
||||
application_title: 'test title',
|
||||
},
|
||||
webapp_auth: {
|
||||
enabled: false,
|
||||
allow_sso: false,
|
||||
sso_config: {
|
||||
protocol: '',
|
||||
},
|
||||
allow_email_code_login: false,
|
||||
allow_email_password_login: false,
|
||||
},
|
||||
}
|
||||
|
||||
export enum DatasetAttr {
|
||||
DATA_API_PREFIX = 'data-api-prefix',
|
||||
DATA_PUBLIC_API_PREFIX = 'data-public-api-prefix',
|
||||
DATA_MARKETPLACE_API_PREFIX = 'data-marketplace-api-prefix',
|
||||
DATA_MARKETPLACE_URL_PREFIX = 'data-marketplace-url-prefix',
|
||||
DATA_PUBLIC_EDITION = 'data-public-edition',
|
||||
DATA_PUBLIC_COOKIE_DOMAIN = 'data-public-cookie-domain',
|
||||
DATA_PUBLIC_SUPPORT_MAIL_LOGIN = 'data-public-support-mail-login',
|
||||
DATA_PUBLIC_SENTRY_DSN = 'data-public-sentry-dsn',
|
||||
DATA_PUBLIC_MAINTENANCE_NOTICE = 'data-public-maintenance-notice',
|
||||
DATA_PUBLIC_SITE_ABOUT = 'data-public-site-about',
|
||||
DATA_PUBLIC_TEXT_GENERATION_TIMEOUT_MS = 'data-public-text-generation-timeout-ms',
|
||||
DATA_PUBLIC_MAX_TOOLS_NUM = 'data-public-max-tools-num',
|
||||
DATA_PUBLIC_MAX_PARALLEL_LIMIT = 'data-public-max-parallel-limit',
|
||||
DATA_PUBLIC_TOP_K_MAX_VALUE = 'data-public-top-k-max-value',
|
||||
DATA_PUBLIC_INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH = 'data-public-indexing-max-segmentation-tokens-length',
|
||||
DATA_PUBLIC_LOOP_NODE_MAX_COUNT = 'data-public-loop-node-max-count',
|
||||
DATA_PUBLIC_MAX_ITERATIONS_NUM = 'data-public-max-iterations-num',
|
||||
DATA_PUBLIC_MAX_TREE_DEPTH = 'data-public-max-tree-depth',
|
||||
DATA_PUBLIC_ALLOW_UNSAFE_DATA_SCHEME = 'data-public-allow-unsafe-data-scheme',
|
||||
DATA_PUBLIC_ENABLE_WEBSITE_JINAREADER = 'data-public-enable-website-jinareader',
|
||||
DATA_PUBLIC_ENABLE_WEBSITE_FIRECRAWL = 'data-public-enable-website-firecrawl',
|
||||
DATA_PUBLIC_ENABLE_WEBSITE_WATERCRAWL = 'data-public-enable-website-watercrawl',
|
||||
DATA_PUBLIC_ENABLE_SINGLE_DOLLAR_LATEX = 'data-public-enable-single-dollar-latex',
|
||||
NEXT_PUBLIC_ZENDESK_WIDGET_KEY = 'next-public-zendesk-widget-key',
|
||||
NEXT_PUBLIC_ZENDESK_FIELD_ID_ENVIRONMENT = 'next-public-zendesk-field-id-environment',
|
||||
NEXT_PUBLIC_ZENDESK_FIELD_ID_VERSION = 'next-public-zendesk-field-id-version',
|
||||
NEXT_PUBLIC_ZENDESK_FIELD_ID_EMAIL = 'next-public-zendesk-field-id-email',
|
||||
NEXT_PUBLIC_ZENDESK_FIELD_ID_WORKSPACE_ID = 'next-public-zendesk-field-id-workspace-id',
|
||||
NEXT_PUBLIC_ZENDESK_FIELD_ID_PLAN = 'next-public-zendesk-field-id-plan',
|
||||
}
|
||||
102
dify/web/types/i18n.d.ts
vendored
Normal file
102
dify/web/types/i18n.d.ts
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
// TypeScript type definitions for Dify's i18next configuration
|
||||
// This file is auto-generated. Do not edit manually.
|
||||
// To regenerate, run: pnpm run gen:i18n-types
|
||||
import 'react-i18next'
|
||||
|
||||
// Extract types from translation files using typeof import pattern
|
||||
|
||||
type AppAnnotationMessages = typeof import('../i18n/en-US/app-annotation').default
|
||||
type AppApiMessages = typeof import('../i18n/en-US/app-api').default
|
||||
type AppDebugMessages = typeof import('../i18n/en-US/app-debug').default
|
||||
type AppLogMessages = typeof import('../i18n/en-US/app-log').default
|
||||
type AppOverviewMessages = typeof import('../i18n/en-US/app-overview').default
|
||||
type AppMessages = typeof import('../i18n/en-US/app').default
|
||||
type BillingMessages = typeof import('../i18n/en-US/billing').default
|
||||
type CommonMessages = typeof import('../i18n/en-US/common').default
|
||||
type CustomMessages = typeof import('../i18n/en-US/custom').default
|
||||
type DatasetCreationMessages = typeof import('../i18n/en-US/dataset-creation').default
|
||||
type DatasetDocumentsMessages = typeof import('../i18n/en-US/dataset-documents').default
|
||||
type DatasetHitTestingMessages = typeof import('../i18n/en-US/dataset-hit-testing').default
|
||||
type DatasetPipelineMessages = typeof import('../i18n/en-US/dataset-pipeline').default
|
||||
type DatasetSettingsMessages = typeof import('../i18n/en-US/dataset-settings').default
|
||||
type DatasetMessages = typeof import('../i18n/en-US/dataset').default
|
||||
type EducationMessages = typeof import('../i18n/en-US/education').default
|
||||
type ExploreMessages = typeof import('../i18n/en-US/explore').default
|
||||
type LayoutMessages = typeof import('../i18n/en-US/layout').default
|
||||
type LoginMessages = typeof import('../i18n/en-US/login').default
|
||||
type OauthMessages = typeof import('../i18n/en-US/oauth').default
|
||||
type PipelineMessages = typeof import('../i18n/en-US/pipeline').default
|
||||
type PluginTagsMessages = typeof import('../i18n/en-US/plugin-tags').default
|
||||
type PluginTriggerMessages = typeof import('../i18n/en-US/plugin-trigger').default
|
||||
type PluginMessages = typeof import('../i18n/en-US/plugin').default
|
||||
type RegisterMessages = typeof import('../i18n/en-US/register').default
|
||||
type RunLogMessages = typeof import('../i18n/en-US/run-log').default
|
||||
type ShareMessages = typeof import('../i18n/en-US/share').default
|
||||
type TimeMessages = typeof import('../i18n/en-US/time').default
|
||||
type ToolsMessages = typeof import('../i18n/en-US/tools').default
|
||||
type WorkflowMessages = typeof import('../i18n/en-US/workflow').default
|
||||
|
||||
// Complete type structure that matches i18next-config.ts camelCase conversion
|
||||
export type Messages = {
|
||||
appAnnotation: AppAnnotationMessages;
|
||||
appApi: AppApiMessages;
|
||||
appDebug: AppDebugMessages;
|
||||
appLog: AppLogMessages;
|
||||
appOverview: AppOverviewMessages;
|
||||
app: AppMessages;
|
||||
billing: BillingMessages;
|
||||
common: CommonMessages;
|
||||
custom: CustomMessages;
|
||||
datasetCreation: DatasetCreationMessages;
|
||||
datasetDocuments: DatasetDocumentsMessages;
|
||||
datasetHitTesting: DatasetHitTestingMessages;
|
||||
datasetPipeline: DatasetPipelineMessages;
|
||||
datasetSettings: DatasetSettingsMessages;
|
||||
dataset: DatasetMessages;
|
||||
education: EducationMessages;
|
||||
explore: ExploreMessages;
|
||||
layout: LayoutMessages;
|
||||
login: LoginMessages;
|
||||
oauth: OauthMessages;
|
||||
pipeline: PipelineMessages;
|
||||
pluginTags: PluginTagsMessages;
|
||||
pluginTrigger: PluginTriggerMessages;
|
||||
plugin: PluginMessages;
|
||||
register: RegisterMessages;
|
||||
runLog: RunLogMessages;
|
||||
share: ShareMessages;
|
||||
time: TimeMessages;
|
||||
tools: ToolsMessages;
|
||||
workflow: WorkflowMessages;
|
||||
}
|
||||
|
||||
// Utility type to flatten nested object keys into dot notation
|
||||
type FlattenKeys<T> = T extends object
|
||||
? {
|
||||
[K in keyof T]: T[K] extends object
|
||||
? `${K & string}.${FlattenKeys<T[K]> & string}`
|
||||
: `${K & string}`
|
||||
}[keyof T]
|
||||
: never
|
||||
|
||||
export type ValidTranslationKeys = FlattenKeys<Messages>
|
||||
|
||||
// Extend react-i18next with Dify's type structure
|
||||
declare module 'react-i18next' {
|
||||
type CustomTypeOptions = {
|
||||
defaultNS: 'translation';
|
||||
resources: {
|
||||
translation: Messages;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Extend i18next for complete type safety
|
||||
declare module 'i18next' {
|
||||
type CustomTypeOptions = {
|
||||
defaultNS: 'translation';
|
||||
resources: {
|
||||
translation: Messages;
|
||||
};
|
||||
}
|
||||
}
|
||||
13
dify/web/types/jsx.d.ts
vendored
Normal file
13
dify/web/types/jsx.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// TypeScript type definitions for custom JSX elements
|
||||
// Custom JSX elements for emoji-mart web components
|
||||
|
||||
import 'react'
|
||||
|
||||
declare module 'react' {
|
||||
namespace JSX {
|
||||
// eslint-disable-next-line ts/consistent-type-definitions
|
||||
interface IntrinsicElements {
|
||||
'em-emoji': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>
|
||||
}
|
||||
}
|
||||
}
|
||||
36
dify/web/types/lamejs.d.ts
vendored
Normal file
36
dify/web/types/lamejs.d.ts
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
declare module 'lamejs' {
|
||||
export class Mp3Encoder {
|
||||
constructor(channels: number, sampleRate: number, bitRate: number)
|
||||
encodeBuffer(left: Int16Array, right?: Int16Array | null): Int8Array
|
||||
flush(): Int8Array
|
||||
}
|
||||
|
||||
export class WavHeader {
|
||||
static readHeader(data: DataView): {
|
||||
channels: number
|
||||
sampleRate: number
|
||||
}
|
||||
}
|
||||
|
||||
const lamejs: {
|
||||
Mp3Encoder: typeof Mp3Encoder
|
||||
WavHeader: typeof WavHeader
|
||||
}
|
||||
|
||||
export default lamejs
|
||||
}
|
||||
|
||||
declare module 'lamejs/src/js/MPEGMode' {
|
||||
const MPEGMode: any
|
||||
export default MPEGMode
|
||||
}
|
||||
|
||||
declare module 'lamejs/src/js/Lame' {
|
||||
const Lame: any
|
||||
export default Lame
|
||||
}
|
||||
|
||||
declare module 'lamejs/src/js/BitStream' {
|
||||
const BitStream: any
|
||||
export default BitStream
|
||||
}
|
||||
4
dify/web/types/mdx.d.ts
vendored
Normal file
4
dify/web/types/mdx.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
declare module '*.mdx' {
|
||||
const MDXComponent: (props?: Record<string, unknown>) => JSX.Element
|
||||
export default MDXComponent
|
||||
}
|
||||
47
dify/web/types/pipeline.tsx
Normal file
47
dify/web/types/pipeline.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
import type { CredentialTypeEnum } from '@/app/components/plugins/plugin-auth'
|
||||
|
||||
export type DataSourceNodeProcessingResponse = {
|
||||
event: 'datasource_processing'
|
||||
total: number
|
||||
completed: number
|
||||
}
|
||||
|
||||
export type DataSourceNodeError = {
|
||||
event: 'datasource_error'
|
||||
message: string
|
||||
code?: string
|
||||
}
|
||||
|
||||
export type OnlineDriveFile = {
|
||||
id: string
|
||||
name: string
|
||||
size: number
|
||||
type: 'file' | 'folder'
|
||||
}
|
||||
|
||||
export type OnlineDriveData = {
|
||||
bucket: string
|
||||
files: OnlineDriveFile[]
|
||||
is_truncated: boolean
|
||||
next_page_parameters: Record<string, any>
|
||||
}
|
||||
|
||||
export type DataSourceNodeCompletedResponse = {
|
||||
event: 'datasource_completed'
|
||||
data: any
|
||||
time_consuming: number
|
||||
}
|
||||
|
||||
export type DataSourceNodeErrorResponse = {
|
||||
event: 'datasource_error'
|
||||
error: string
|
||||
}
|
||||
|
||||
export type DataSourceCredential = {
|
||||
avatar_url?: string
|
||||
credential: Record<string, any>
|
||||
id: string
|
||||
is_default: boolean
|
||||
name: string
|
||||
type: CredentialTypeEnum
|
||||
}
|
||||
23
dify/web/types/react-18-input-autosize.d.ts
vendored
Normal file
23
dify/web/types/react-18-input-autosize.d.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
declare module 'react-18-input-autosize' {
|
||||
import type { CSSProperties, ChangeEvent, FocusEvent, KeyboardEvent } from 'react'
|
||||
|
||||
export type AutosizeInputProps = {
|
||||
value?: string | number
|
||||
defaultValue?: string | number
|
||||
onChange?: (event: ChangeEvent<HTMLInputElement>) => void
|
||||
onFocus?: (event: FocusEvent<HTMLInputElement>) => void
|
||||
onBlur?: (event: FocusEvent<HTMLInputElement>) => void
|
||||
onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void
|
||||
placeholder?: string
|
||||
className?: string
|
||||
inputClassName?: string
|
||||
style?: CSSProperties
|
||||
inputStyle?: CSSProperties
|
||||
minWidth?: number | string
|
||||
maxWidth?: number | string
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
const AutosizeInput: React.FC<AutosizeInputProps>
|
||||
export default AutosizeInput
|
||||
}
|
||||
418
dify/web/types/workflow.ts
Normal file
418
dify/web/types/workflow.ts
Normal file
@@ -0,0 +1,418 @@
|
||||
import type { Viewport } from 'reactflow'
|
||||
import type { BlockEnum, CommonNodeType, ConversationVariable, Edge, EnvironmentVariable, InputVar, Node, ValueSelector, VarType, Variable } from '@/app/components/workflow/types'
|
||||
import type { TransferMethod } from '@/types/app'
|
||||
import type { ErrorHandleTypeEnum } from '@/app/components/workflow/nodes/_base/components/error-handle/types'
|
||||
import type { RAGPipelineVariables } from '@/models/pipeline'
|
||||
import type { BeforeRunFormProps } from '@/app/components/workflow/nodes/_base/components/before-run-form'
|
||||
import type { SpecialResultPanelProps } from '@/app/components/workflow/run/special-result-panel'
|
||||
import type { RefObject } from 'react'
|
||||
|
||||
export type AgentLogItem = {
|
||||
node_execution_id: string,
|
||||
message_id: string,
|
||||
node_id: string,
|
||||
parent_id?: string,
|
||||
label: string,
|
||||
data: object, // debug data
|
||||
error?: string,
|
||||
status: string,
|
||||
metadata?: {
|
||||
elapsed_time?: number
|
||||
provider?: string
|
||||
icon?: string
|
||||
},
|
||||
}
|
||||
|
||||
export type AgentLogItemWithChildren = AgentLogItem & {
|
||||
hasCircle?: boolean
|
||||
children: AgentLogItemWithChildren[]
|
||||
}
|
||||
|
||||
export type NodeTracing = {
|
||||
id: string
|
||||
index: number
|
||||
predecessor_node_id: string
|
||||
node_id: string
|
||||
iteration_id?: string
|
||||
loop_id?: string
|
||||
node_type: BlockEnum
|
||||
title: string
|
||||
inputs: any
|
||||
inputs_truncated: boolean
|
||||
process_data: any
|
||||
process_data_truncated: boolean
|
||||
outputs?: Record<string, any>
|
||||
outputs_truncated: boolean
|
||||
outputs_full_content?: {
|
||||
download_url: string
|
||||
}
|
||||
status: string
|
||||
parallel_run_id?: string
|
||||
error?: string
|
||||
elapsed_time: number
|
||||
execution_metadata?: {
|
||||
total_tokens: number
|
||||
total_price: number
|
||||
currency: string
|
||||
iteration_id?: string
|
||||
iteration_index?: number
|
||||
loop_id?: string
|
||||
loop_index?: number
|
||||
parallel_id?: string
|
||||
parallel_start_node_id?: string
|
||||
parent_parallel_id?: string
|
||||
parent_parallel_start_node_id?: string
|
||||
parallel_mode_run_id?: string
|
||||
iteration_duration_map?: IterationDurationMap
|
||||
loop_duration_map?: LoopDurationMap
|
||||
error_strategy?: ErrorHandleTypeEnum
|
||||
agent_log?: AgentLogItem[]
|
||||
tool_info?: {
|
||||
agent_strategy?: string
|
||||
icon?: string
|
||||
}
|
||||
loop_variable_map?: Record<string, any>
|
||||
}
|
||||
metadata: {
|
||||
iterator_length: number
|
||||
iterator_index: number
|
||||
loop_length: number
|
||||
loop_index: number
|
||||
}
|
||||
created_at: number
|
||||
created_by: {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
}
|
||||
iterDurationMap?: IterationDurationMap
|
||||
loopDurationMap?: LoopDurationMap
|
||||
finished_at: number
|
||||
extras?: any
|
||||
expand?: boolean // for UI
|
||||
details?: NodeTracing[][] // iteration or loop detail
|
||||
retryDetail?: NodeTracing[] // retry detail
|
||||
retry_index?: number
|
||||
parallelDetail?: { // parallel detail. if is in parallel, this field will be set
|
||||
isParallelStartNode?: boolean
|
||||
parallelTitle?: string
|
||||
branchTitle?: string
|
||||
children?: NodeTracing[]
|
||||
}
|
||||
parallel_id?: string
|
||||
parallel_start_node_id?: string
|
||||
parent_parallel_id?: string
|
||||
parent_parallel_start_node_id?: string
|
||||
agentLog?: AgentLogItemWithChildren[] // agent log
|
||||
}
|
||||
|
||||
export type FetchWorkflowDraftResponse = {
|
||||
id: string
|
||||
graph: {
|
||||
nodes: Node[]
|
||||
edges: Edge[]
|
||||
viewport?: Viewport
|
||||
}
|
||||
features?: any
|
||||
created_at: number
|
||||
created_by: {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
}
|
||||
hash: string
|
||||
updated_at: number
|
||||
updated_by: {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
},
|
||||
tool_published: boolean
|
||||
environment_variables?: EnvironmentVariable[]
|
||||
conversation_variables?: ConversationVariable[]
|
||||
rag_pipeline_variables?: RAGPipelineVariables
|
||||
version: string
|
||||
marked_name: string
|
||||
marked_comment: string
|
||||
}
|
||||
|
||||
export type VersionHistory = FetchWorkflowDraftResponse
|
||||
|
||||
export type FetchWorkflowDraftPageParams = {
|
||||
url: string
|
||||
initialPage: number
|
||||
limit: number
|
||||
userId?: string
|
||||
namedOnly?: boolean
|
||||
}
|
||||
|
||||
export type FetchWorkflowDraftPageResponse = {
|
||||
items: VersionHistory[]
|
||||
has_more: boolean
|
||||
page: number
|
||||
}
|
||||
|
||||
export type NodeTracingListResponse = {
|
||||
data: NodeTracing[]
|
||||
}
|
||||
|
||||
export type WorkflowStartedResponse = {
|
||||
task_id: string
|
||||
workflow_run_id: string
|
||||
event: string
|
||||
data: {
|
||||
id: string
|
||||
workflow_id: string
|
||||
created_at: number
|
||||
}
|
||||
}
|
||||
|
||||
export type WorkflowFinishedResponse = {
|
||||
task_id: string
|
||||
workflow_run_id: string
|
||||
event: string
|
||||
data: {
|
||||
id: string
|
||||
workflow_id: string
|
||||
status: string
|
||||
outputs: any
|
||||
error: string
|
||||
elapsed_time: number
|
||||
total_tokens: number
|
||||
total_steps: number
|
||||
created_at: number
|
||||
created_by: {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
}
|
||||
finished_at: number
|
||||
files?: FileResponse[]
|
||||
}
|
||||
}
|
||||
|
||||
export type NodeStartedResponse = {
|
||||
task_id: string
|
||||
workflow_run_id: string
|
||||
event: string
|
||||
data: NodeTracing
|
||||
}
|
||||
|
||||
export type FileResponse = {
|
||||
related_id: string
|
||||
extension: string
|
||||
filename: string
|
||||
size: number
|
||||
mime_type: string
|
||||
transfer_method: TransferMethod
|
||||
type: string
|
||||
url: string
|
||||
upload_file_id: string
|
||||
remote_url: string
|
||||
}
|
||||
|
||||
export type NodeFinishedResponse = {
|
||||
task_id: string
|
||||
workflow_run_id: string
|
||||
event: string
|
||||
data: NodeTracing
|
||||
}
|
||||
|
||||
export type IterationStartedResponse = {
|
||||
task_id: string
|
||||
workflow_run_id: string
|
||||
event: string
|
||||
data: NodeTracing
|
||||
}
|
||||
|
||||
export type IterationNextResponse = {
|
||||
task_id: string
|
||||
workflow_run_id: string
|
||||
event: string
|
||||
data: NodeTracing
|
||||
}
|
||||
|
||||
export type IterationFinishedResponse = {
|
||||
task_id: string
|
||||
workflow_run_id: string
|
||||
event: string
|
||||
data: NodeTracing
|
||||
}
|
||||
|
||||
export type LoopStartedResponse = {
|
||||
task_id: string
|
||||
workflow_run_id: string
|
||||
event: string
|
||||
data: NodeTracing
|
||||
}
|
||||
|
||||
export type LoopNextResponse = {
|
||||
task_id: string
|
||||
workflow_run_id: string
|
||||
event: string
|
||||
data: NodeTracing
|
||||
}
|
||||
|
||||
export type LoopFinishedResponse = {
|
||||
task_id: string
|
||||
workflow_run_id: string
|
||||
event: string
|
||||
data: NodeTracing
|
||||
}
|
||||
|
||||
export type ParallelBranchStartedResponse = {
|
||||
task_id: string
|
||||
workflow_run_id: string
|
||||
event: string
|
||||
data: NodeTracing
|
||||
}
|
||||
|
||||
export type ParallelBranchFinishedResponse = {
|
||||
task_id: string
|
||||
workflow_run_id: string
|
||||
event: string
|
||||
data: NodeTracing
|
||||
}
|
||||
|
||||
export type TextChunkResponse = {
|
||||
task_id: string
|
||||
workflow_run_id: string
|
||||
event: string
|
||||
data: {
|
||||
text: string
|
||||
}
|
||||
}
|
||||
|
||||
export type TextReplaceResponse = {
|
||||
task_id: string
|
||||
workflow_run_id: string
|
||||
event: string
|
||||
data: {
|
||||
text: string
|
||||
}
|
||||
}
|
||||
|
||||
export type AgentLogResponse = {
|
||||
task_id: string
|
||||
event: string
|
||||
data: AgentLogItemWithChildren
|
||||
}
|
||||
|
||||
export type WorkflowRunHistory = {
|
||||
id: string
|
||||
version: string
|
||||
conversation_id?: string
|
||||
message_id?: string
|
||||
graph: {
|
||||
nodes: Node[]
|
||||
edges: Edge[]
|
||||
viewport?: Viewport
|
||||
}
|
||||
inputs: Record<string, string>
|
||||
status: string
|
||||
outputs: Record<string, any>
|
||||
error?: string
|
||||
elapsed_time: number
|
||||
total_tokens: number
|
||||
total_steps: number
|
||||
created_at: number
|
||||
finished_at: number
|
||||
created_by_account: {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
}
|
||||
}
|
||||
export type WorkflowRunHistoryResponse = {
|
||||
data: WorkflowRunHistory[]
|
||||
}
|
||||
|
||||
export type ChatRunHistoryResponse = {
|
||||
data: WorkflowRunHistory[]
|
||||
}
|
||||
|
||||
export type NodesDefaultConfigsResponse = {
|
||||
type: string
|
||||
config: any
|
||||
}[]
|
||||
|
||||
export type ConversationVariableResponse = {
|
||||
data: (ConversationVariable & { updated_at: number; created_at: number })[]
|
||||
has_more: boolean
|
||||
limit: number
|
||||
total: number
|
||||
page: number
|
||||
}
|
||||
|
||||
export type IterationDurationMap = Record<string, number>
|
||||
export type LoopDurationMap = Record<string, number>
|
||||
export type LoopVariableMap = Record<string, any>
|
||||
|
||||
export type WorkflowConfigResponse = {
|
||||
parallel_depth_limit: number
|
||||
}
|
||||
|
||||
export type PublishWorkflowParams = {
|
||||
url: string
|
||||
title: string
|
||||
releaseNotes: string
|
||||
}
|
||||
|
||||
export type UpdateWorkflowParams = {
|
||||
url: string
|
||||
title: string
|
||||
releaseNotes: string
|
||||
}
|
||||
|
||||
export type PanelExposedType = {
|
||||
singleRunParams: Pick<BeforeRunFormProps, 'forms'> & Partial<SpecialResultPanelProps>
|
||||
}
|
||||
|
||||
export type PanelProps = {
|
||||
getInputVars: (textList: string[]) => InputVar[]
|
||||
toVarInputs: (variables: Variable[]) => InputVar[]
|
||||
runInputData: Record<string, any>
|
||||
runInputDataRef: RefObject<Record<string, any>>
|
||||
setRunInputData: (data: Record<string, any>) => void
|
||||
runResult: any
|
||||
}
|
||||
|
||||
export type NodeRunResult = NodeTracing
|
||||
|
||||
// Var Inspect
|
||||
export enum VarInInspectType {
|
||||
conversation = 'conversation',
|
||||
environment = 'env',
|
||||
node = 'node',
|
||||
system = 'sys',
|
||||
}
|
||||
|
||||
export type FullContent = {
|
||||
size_bytes: number
|
||||
download_url: string
|
||||
}
|
||||
|
||||
export type VarInInspect = {
|
||||
id: string
|
||||
type: VarInInspectType
|
||||
name: string
|
||||
description: string
|
||||
selector: ValueSelector // can get node id from selector[0]
|
||||
value_type: VarType
|
||||
value: any
|
||||
edited: boolean
|
||||
visible: boolean
|
||||
is_truncated: boolean
|
||||
full_content: FullContent
|
||||
schemaType?: string
|
||||
}
|
||||
|
||||
export type NodeWithVar = {
|
||||
nodeId: string
|
||||
nodePayload: CommonNodeType
|
||||
nodeType: BlockEnum
|
||||
title: string
|
||||
vars: VarInInspect[]
|
||||
isSingRunRunning?: boolean
|
||||
isValueFetched?: boolean
|
||||
}
|
||||
Reference in New Issue
Block a user