declarations.ts 5.9 KB

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