declarations.ts 5.2 KB

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