|
import type { AnnotationReplyConfig, ChatPromptConfig, CompletionPromptConfig, DatasetConfigs, PromptMode } from '@/models/debug'
|
|
import type { CollectionType } from '@/app/components/tools/types'
|
|
import type { LanguagesSupported } from '@/i18n/language'
|
|
import type { Tag } from '@/app/components/base/tag-management/constant'
|
|
|
|
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
|
|
}
|
|
|
|
|
|
|
|
|
|
export const AppModes = ['advanced-chat', 'agent-chat', 'chat', 'completion', 'workflow'] as const
|
|
export type AppMode = typeof AppModes[number]
|
|
|
|
|
|
|
|
|
|
export const VariableTypes = ['string', 'number', 'select'] as const
|
|
export type VariableType = typeof VariableTypes[number]
|
|
|
|
|
|
|
|
|
|
export type PromptVariable = {
|
|
|
|
key: string
|
|
|
|
name: string
|
|
|
|
type: VariableType
|
|
required: boolean
|
|
|
|
options?: string[]
|
|
max_length?: number
|
|
}
|
|
|
|
export type TextTypeFormItem = {
|
|
default: string
|
|
label: string
|
|
variable: string
|
|
required: boolean
|
|
max_length: number
|
|
}
|
|
|
|
export type SelectTypeFormItem = {
|
|
default: string
|
|
label: string
|
|
variable: string
|
|
required: boolean
|
|
options: string[]
|
|
}
|
|
|
|
export type ParagraphTypeFormItem = {
|
|
default: string
|
|
label: string
|
|
variable: string
|
|
required: boolean
|
|
}
|
|
|
|
|
|
|
|
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
|
|
}
|
|
|
|
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 ModelConfig = {
|
|
opening_statement: string
|
|
suggested_questions?: string[]
|
|
pre_prompt: string
|
|
prompt_type: PromptMode
|
|
chat_prompt_config: ChatPromptConfig | {}
|
|
completion_prompt_config: CompletionPromptConfig | {}
|
|
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
|
|
}
|
|
retriever_resource: {
|
|
enabled: boolean
|
|
}
|
|
sensitive_word_avoidance: {
|
|
enabled: boolean
|
|
}
|
|
annotation_reply?: AnnotationReplyConfig
|
|
agent_mode: {
|
|
enabled: boolean
|
|
strategy?: AgentStrategy
|
|
tools: ToolItem[]
|
|
}
|
|
model: {
|
|
|
|
provider: string
|
|
|
|
name: string
|
|
mode: ModelModeType
|
|
|
|
completion_params: {
|
|
|
|
max_tokens: number
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
temperature: number
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
top_p: number
|
|
|
|
echo: boolean
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stop: string[]
|
|
|
|
|
|
|
|
|
|
presence_penalty: number
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
frequency_penalty: number
|
|
}
|
|
}
|
|
dataset_configs: DatasetConfigs
|
|
file_upload?: {
|
|
image: VisionSettings
|
|
}
|
|
files?: VisionFile[]
|
|
created_at?: number
|
|
}
|
|
|
|
export type Language = typeof LanguagesSupported[number]
|
|
|
|
|
|
|
|
|
|
export type SiteConfig = {
|
|
|
|
access_token: string
|
|
|
|
title: string
|
|
|
|
description: string
|
|
|
|
author: string
|
|
|
|
support_email: string
|
|
|
|
|
|
|
|
|
|
default_language: Language
|
|
|
|
customize_domain: string
|
|
|
|
theme: string
|
|
|
|
customize_token_strategy: 'must' | 'allow' | 'not_allow'
|
|
|
|
prompt_public: boolean
|
|
|
|
app_base_url: string
|
|
|
|
copyright: string
|
|
|
|
privacy_policy: string
|
|
|
|
custom_disclaimer: string
|
|
|
|
icon: string
|
|
icon_background: string
|
|
}
|
|
|
|
|
|
|
|
|
|
export type App = {
|
|
|
|
id: string
|
|
|
|
name: string
|
|
|
|
description: string
|
|
|
|
|
|
icon: string
|
|
|
|
icon_background: string
|
|
|
|
|
|
mode: AppMode
|
|
|
|
enable_site: boolean
|
|
|
|
enable_api: boolean
|
|
|
|
api_rpm: number
|
|
|
|
api_rph: number
|
|
|
|
is_demo: boolean
|
|
|
|
model_config: ModelConfig
|
|
app_model_config: ModelConfig
|
|
|
|
created_at: number
|
|
|
|
site: SiteConfig
|
|
|
|
api_base_url: string
|
|
tags: Tag[]
|
|
}
|
|
|
|
|
|
|
|
|
|
export type AppTemplate = {
|
|
|
|
name: string
|
|
|
|
description: string
|
|
|
|
mode: AppMode
|
|
|
|
model_config: ModelConfig
|
|
}
|
|
|
|
export enum Resolution {
|
|
low = 'low',
|
|
high = 'high',
|
|
}
|
|
|
|
export enum TransferMethod {
|
|
all = 'all',
|
|
local_file = 'local_file',
|
|
remote_url = 'remote_url',
|
|
}
|
|
|
|
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
|
|
}
|
|
|