declarations.ts 4.9 KB

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