declarations.ts 6.2 KB

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