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

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