declarations.ts 5.9 KB

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