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.3KB

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. streamToolCall = 'stream-tool-call',
  52. vision = 'vision',
  53. video = 'video',
  54. document = 'document',
  55. audio = 'audio',
  56. }
  57. export enum ModelFeatureTextEnum {
  58. toolCall = 'Tool Call',
  59. multiToolCall = 'Multi Tool Call',
  60. agentThought = 'Agent Thought',
  61. vision = 'Vision',
  62. video = 'Video',
  63. document = 'Document',
  64. audio = 'Audio',
  65. }
  66. export enum ModelStatusEnum {
  67. active = 'active',
  68. noConfigure = 'no-configure',
  69. quotaExceeded = 'quota-exceeded',
  70. noPermission = 'no-permission',
  71. disabled = 'disabled',
  72. }
  73. export const MODEL_STATUS_TEXT: { [k: string]: TypeWithI18N } = {
  74. 'no-configure': {
  75. en_US: 'No Configure',
  76. zh_Hans: '未配置凭据',
  77. },
  78. 'quota-exceeded': {
  79. en_US: 'Quota Exceeded',
  80. zh_Hans: '额度不足',
  81. },
  82. 'no-permission': {
  83. en_US: 'No Permission',
  84. zh_Hans: '无使用权限',
  85. },
  86. }
  87. export enum CustomConfigurationStatusEnum {
  88. active = 'active',
  89. noConfigure = 'no-configure',
  90. }
  91. export type FormShowOnObject = {
  92. variable: string
  93. value: string
  94. }
  95. export type CredentialFormSchemaBase = {
  96. variable: string
  97. label: TypeWithI18N
  98. type: FormTypeEnum
  99. required: boolean
  100. default?: string
  101. tooltip?: TypeWithI18N
  102. show_on: FormShowOnObject[]
  103. url?: string
  104. scope?: string
  105. }
  106. export type CredentialFormSchemaTextInput = CredentialFormSchemaBase & {
  107. max_length?: number;
  108. placeholder?: TypeWithI18N,
  109. template?: {
  110. enabled: boolean
  111. },
  112. auto_generate?: {
  113. type: string
  114. }
  115. }
  116. export type CredentialFormSchemaNumberInput = CredentialFormSchemaBase & { min?: number; max?: number; placeholder?: TypeWithI18N }
  117. export type CredentialFormSchemaSelect = CredentialFormSchemaBase & { options: FormOption[]; placeholder?: TypeWithI18N }
  118. export type CredentialFormSchemaRadio = CredentialFormSchemaBase & { options: FormOption[] }
  119. export type CredentialFormSchemaSecretInput = CredentialFormSchemaBase & { placeholder?: TypeWithI18N }
  120. export type CredentialFormSchema = CredentialFormSchemaTextInput | CredentialFormSchemaSelect | CredentialFormSchemaRadio | CredentialFormSchemaSecretInput
  121. export type ModelItem = {
  122. model: string
  123. label: TypeWithI18N
  124. model_type: ModelTypeEnum
  125. features?: ModelFeatureEnum[]
  126. fetch_from: ConfigurationMethodEnum
  127. status: ModelStatusEnum
  128. model_properties: Record<string, string | number>
  129. load_balancing_enabled: boolean
  130. deprecated?: boolean
  131. }
  132. export enum PreferredProviderTypeEnum {
  133. system = 'system',
  134. custom = 'custom',
  135. }
  136. export enum CurrentSystemQuotaTypeEnum {
  137. trial = 'trial',
  138. free = 'free',
  139. paid = 'paid',
  140. }
  141. export enum QuotaUnitEnum {
  142. times = 'times',
  143. tokens = 'tokens',
  144. credits = 'credits',
  145. }
  146. export type QuotaConfiguration = {
  147. quota_type: CurrentSystemQuotaTypeEnum
  148. quota_unit: QuotaUnitEnum
  149. quota_limit: number
  150. quota_used: number
  151. last_used: number
  152. is_valid: boolean
  153. }
  154. export type ModelProvider = {
  155. provider: string
  156. label: TypeWithI18N
  157. description?: TypeWithI18N
  158. help: {
  159. title: TypeWithI18N
  160. url: TypeWithI18N
  161. }
  162. icon_small: TypeWithI18N
  163. icon_large: TypeWithI18N
  164. background?: string
  165. supported_model_types: ModelTypeEnum[]
  166. configurate_methods: ConfigurationMethodEnum[]
  167. provider_credential_schema: {
  168. credential_form_schemas: CredentialFormSchema[]
  169. }
  170. model_credential_schema: {
  171. model: {
  172. label: TypeWithI18N
  173. placeholder: TypeWithI18N
  174. }
  175. credential_form_schemas: CredentialFormSchema[]
  176. }
  177. preferred_provider_type: PreferredProviderTypeEnum
  178. custom_configuration: {
  179. status: CustomConfigurationStatusEnum
  180. }
  181. system_configuration: {
  182. enabled: boolean
  183. current_quota_type: CurrentSystemQuotaTypeEnum
  184. quota_configurations: QuotaConfiguration[]
  185. }
  186. }
  187. export type Model = {
  188. provider: string
  189. icon_large: TypeWithI18N
  190. icon_small: TypeWithI18N
  191. label: TypeWithI18N
  192. models: ModelItem[]
  193. status: ModelStatusEnum
  194. }
  195. export type DefaultModelResponse = {
  196. model: string
  197. model_type: ModelTypeEnum
  198. provider: {
  199. provider: string
  200. icon_large: TypeWithI18N
  201. icon_small: TypeWithI18N
  202. }
  203. }
  204. export type DefaultModel = {
  205. provider: string
  206. model: string
  207. }
  208. export type CustomConfigurationModelFixedFields = {
  209. __model_name: string
  210. __model_type: ModelTypeEnum
  211. }
  212. export type ModelParameterRule = {
  213. default?: number | string | boolean | string[]
  214. help?: TypeWithI18N
  215. label: TypeWithI18N
  216. min?: number
  217. max?: number
  218. name: string
  219. precision?: number
  220. required: false
  221. type: string
  222. use_template?: string
  223. options?: string[]
  224. tagPlaceholder?: TypeWithI18N
  225. }
  226. export type ModelLoadBalancingConfigEntry = {
  227. /** model balancing config entry id */
  228. id?: string
  229. /** is config entry enabled */
  230. enabled?: boolean
  231. /** config entry name */
  232. name: string
  233. /** model balancing credential */
  234. credentials: Record<string, string | undefined | boolean>
  235. /** is config entry currently removed from Round-robin queue */
  236. in_cooldown?: boolean
  237. /** cooldown time (in seconds) */
  238. ttl?: number
  239. }
  240. export type ModelLoadBalancingConfig = {
  241. enabled: boolean
  242. configs: ModelLoadBalancingConfigEntry[]
  243. }