declarations.ts 5.1 KB

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