You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

declarations.ts 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. import type { SchemaRoot } from '@/app/components/workflow/nodes/llm/types'
  2. export type FormValue = Record<string, any>
  3. export type TypeWithI18N<T = string> = {
  4. en_US: T
  5. zh_Hans: T
  6. [key: string]: T
  7. }
  8. export enum FormTypeEnum {
  9. textInput = 'text-input',
  10. textNumber = 'number-input',
  11. secretInput = 'secret-input',
  12. select = 'select',
  13. radio = 'radio',
  14. boolean = 'boolean',
  15. files = 'files',
  16. file = 'file',
  17. modelSelector = 'model-selector',
  18. toolSelector = 'tool-selector',
  19. multiToolSelector = 'array[tools]',
  20. appSelector = 'app-selector',
  21. any = 'any',
  22. object = 'object',
  23. array = 'array',
  24. dynamicSelect = 'dynamic-select',
  25. }
  26. export type FormOption = {
  27. label: TypeWithI18N
  28. value: string
  29. show_on: FormShowOnObject[]
  30. icon?: string
  31. }
  32. export enum ModelTypeEnum {
  33. textGeneration = 'llm',
  34. textEmbedding = 'text-embedding',
  35. rerank = 'rerank',
  36. speech2text = 'speech2text',
  37. moderation = 'moderation',
  38. tts = 'tts',
  39. }
  40. export const MODEL_TYPE_TEXT = {
  41. [ModelTypeEnum.textGeneration]: 'LLM',
  42. [ModelTypeEnum.textEmbedding]: 'Text Embedding',
  43. [ModelTypeEnum.rerank]: 'Rerank',
  44. [ModelTypeEnum.speech2text]: 'Speech2text',
  45. [ModelTypeEnum.moderation]: 'Moderation',
  46. [ModelTypeEnum.tts]: 'TTS',
  47. }
  48. export enum ConfigurationMethodEnum {
  49. predefinedModel = 'predefined-model',
  50. customizableModel = 'customizable-model',
  51. fetchFromRemote = 'fetch-from-remote',
  52. }
  53. export enum ModelFeatureEnum {
  54. toolCall = 'tool-call',
  55. multiToolCall = 'multi-tool-call',
  56. agentThought = 'agent-thought',
  57. streamToolCall = 'stream-tool-call',
  58. vision = 'vision',
  59. video = 'video',
  60. document = 'document',
  61. audio = 'audio',
  62. StructuredOutput = 'structured-output',
  63. }
  64. export enum ModelFeatureTextEnum {
  65. toolCall = 'Tool Call',
  66. multiToolCall = 'Multi Tool Call',
  67. agentThought = 'Agent Thought',
  68. vision = 'Vision',
  69. video = 'Video',
  70. document = 'Document',
  71. audio = 'Audio',
  72. }
  73. export enum ModelStatusEnum {
  74. active = 'active',
  75. noConfigure = 'no-configure',
  76. quotaExceeded = 'quota-exceeded',
  77. noPermission = 'no-permission',
  78. disabled = 'disabled',
  79. }
  80. export const MODEL_STATUS_TEXT: { [k: string]: TypeWithI18N } = {
  81. 'no-configure': {
  82. en_US: 'No Configure',
  83. zh_Hans: '未配置凭据',
  84. },
  85. 'quota-exceeded': {
  86. en_US: 'Quota Exceeded',
  87. zh_Hans: '额度不足',
  88. },
  89. 'no-permission': {
  90. en_US: 'No Permission',
  91. zh_Hans: '无使用权限',
  92. },
  93. }
  94. export enum CustomConfigurationStatusEnum {
  95. active = 'active',
  96. noConfigure = 'no-configure',
  97. }
  98. export type FormShowOnObject = {
  99. variable: string
  100. value: string
  101. }
  102. export type CredentialFormSchemaBase = {
  103. name: string
  104. variable: string
  105. label: TypeWithI18N
  106. type: FormTypeEnum
  107. required: boolean
  108. default?: string
  109. tooltip?: TypeWithI18N
  110. show_on: FormShowOnObject[]
  111. url?: string
  112. scope?: string
  113. input_schema?: SchemaRoot
  114. }
  115. export type CredentialFormSchemaTextInput = CredentialFormSchemaBase & {
  116. max_length?: number;
  117. placeholder?: TypeWithI18N,
  118. template?: {
  119. enabled: boolean
  120. },
  121. auto_generate?: {
  122. type: string
  123. }
  124. }
  125. export type CredentialFormSchemaNumberInput = CredentialFormSchemaBase & { min?: number; max?: number; placeholder?: TypeWithI18N }
  126. export type CredentialFormSchemaSelect = CredentialFormSchemaBase & { options: FormOption[]; placeholder?: TypeWithI18N }
  127. export type CredentialFormSchemaRadio = CredentialFormSchemaBase & { options: FormOption[] }
  128. export type CredentialFormSchemaSecretInput = CredentialFormSchemaBase & { placeholder?: TypeWithI18N }
  129. export type CredentialFormSchema = CredentialFormSchemaTextInput | CredentialFormSchemaSelect | CredentialFormSchemaRadio | CredentialFormSchemaSecretInput
  130. export type ModelItem = {
  131. model: string
  132. label: TypeWithI18N
  133. model_type: ModelTypeEnum
  134. features?: ModelFeatureEnum[]
  135. fetch_from: ConfigurationMethodEnum
  136. status: ModelStatusEnum
  137. model_properties: Record<string, string | number>
  138. load_balancing_enabled: boolean
  139. deprecated?: boolean
  140. }
  141. export enum PreferredProviderTypeEnum {
  142. system = 'system',
  143. custom = 'custom',
  144. }
  145. export enum CurrentSystemQuotaTypeEnum {
  146. trial = 'trial',
  147. free = 'free',
  148. paid = 'paid',
  149. }
  150. export enum QuotaUnitEnum {
  151. times = 'times',
  152. tokens = 'tokens',
  153. credits = 'credits',
  154. }
  155. export type QuotaConfiguration = {
  156. quota_type: CurrentSystemQuotaTypeEnum
  157. quota_unit: QuotaUnitEnum
  158. quota_limit: number
  159. quota_used: number
  160. last_used: number
  161. is_valid: boolean
  162. }
  163. export type ModelProvider = {
  164. provider: string
  165. label: TypeWithI18N
  166. description?: TypeWithI18N
  167. help: {
  168. title: TypeWithI18N
  169. url: TypeWithI18N
  170. }
  171. icon_small: TypeWithI18N
  172. icon_large: TypeWithI18N
  173. background?: string
  174. supported_model_types: ModelTypeEnum[]
  175. configurate_methods: ConfigurationMethodEnum[]
  176. provider_credential_schema: {
  177. credential_form_schemas: CredentialFormSchema[]
  178. }
  179. model_credential_schema: {
  180. model: {
  181. label: TypeWithI18N
  182. placeholder: TypeWithI18N
  183. }
  184. credential_form_schemas: CredentialFormSchema[]
  185. }
  186. preferred_provider_type: PreferredProviderTypeEnum
  187. custom_configuration: {
  188. status: CustomConfigurationStatusEnum
  189. }
  190. system_configuration: {
  191. enabled: boolean
  192. current_quota_type: CurrentSystemQuotaTypeEnum
  193. quota_configurations: QuotaConfiguration[]
  194. }
  195. }
  196. export type Model = {
  197. provider: string
  198. icon_large: TypeWithI18N
  199. icon_small: TypeWithI18N
  200. label: TypeWithI18N
  201. models: ModelItem[]
  202. status: ModelStatusEnum
  203. }
  204. export type DefaultModelResponse = {
  205. model: string
  206. model_type: ModelTypeEnum
  207. provider: {
  208. provider: string
  209. icon_large: TypeWithI18N
  210. icon_small: TypeWithI18N
  211. }
  212. }
  213. export type DefaultModel = {
  214. provider: string
  215. model: string
  216. }
  217. export type CustomConfigurationModelFixedFields = {
  218. __model_name: string
  219. __model_type: ModelTypeEnum
  220. }
  221. export type ModelParameterRule = {
  222. default?: number | string | boolean | string[]
  223. help?: TypeWithI18N
  224. label: TypeWithI18N
  225. min?: number
  226. max?: number
  227. name: string
  228. precision?: number
  229. required: false
  230. type: string
  231. use_template?: string
  232. options?: string[]
  233. tagPlaceholder?: TypeWithI18N
  234. }
  235. export type ModelLoadBalancingConfigEntry = {
  236. /** model balancing config entry id */
  237. id?: string
  238. /** is config entry enabled */
  239. enabled?: boolean
  240. /** config entry name */
  241. name: string
  242. /** model balancing credential */
  243. credentials: Record<string, string | undefined | boolean>
  244. /** is config entry currently removed from Round-robin queue */
  245. in_cooldown?: boolean
  246. /** cooldown time (in seconds) */
  247. ttl?: number
  248. }
  249. export type ModelLoadBalancingConfig = {
  250. enabled: boolean
  251. configs: ModelLoadBalancingConfigEntry[]
  252. }