declarations.ts 6.0 KB

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