declarations.ts 5.2 KB

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