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

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