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 5.1KB

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