interfaces.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. export type Fetch = typeof fetch
  2. export interface Config {
  3. host: string
  4. fetch?: Fetch
  5. proxy?: boolean
  6. headers?: HeadersInit
  7. }
  8. // request types
  9. export interface Options {
  10. numa: boolean
  11. num_ctx: number
  12. num_batch: number
  13. num_gpu: number
  14. main_gpu: number
  15. low_vram: boolean
  16. f16_kv: boolean
  17. logits_all: boolean
  18. vocab_only: boolean
  19. use_mmap: boolean
  20. use_mlock: boolean
  21. embedding_only: boolean
  22. num_thread: number
  23. // Runtime options
  24. num_keep: number
  25. seed: number
  26. num_predict: number
  27. top_k: number
  28. top_p: number
  29. tfs_z: number
  30. typical_p: number
  31. repeat_last_n: number
  32. temperature: number
  33. repeat_penalty: number
  34. presence_penalty: number
  35. frequency_penalty: number
  36. mirostat: number
  37. mirostat_tau: number
  38. mirostat_eta: number
  39. penalize_newline: boolean
  40. stop: string[]
  41. }
  42. export interface GenerateRequest {
  43. model: string
  44. prompt: string
  45. suffix?: string
  46. system?: string
  47. template?: string
  48. context?: number[]
  49. stream?: boolean
  50. raw?: boolean
  51. format?: string | object
  52. images?: Uint8Array[] | string[]
  53. keep_alive?: string | number // a number (seconds) or a string with a duration unit suffix ("300ms", "1.5h", "2h45m", etc)
  54. think?: boolean
  55. options?: Partial<Options>
  56. }
  57. export interface Message {
  58. role: string
  59. content: string
  60. thinking?: string
  61. images?: Uint8Array[] | string[]
  62. tool_calls?: ToolCall[]
  63. tool_name?: string
  64. }
  65. export interface ToolCall {
  66. function: {
  67. name: string;
  68. arguments: {
  69. [key: string]: any;
  70. };
  71. };
  72. }
  73. export interface Tool {
  74. type: string;
  75. function: {
  76. name?: string;
  77. description?: string;
  78. type?: string;
  79. parameters?: {
  80. type?: string;
  81. $defs?: any;
  82. items?: any;
  83. required?: string[];
  84. properties?: {
  85. [key: string]: {
  86. type?: string | string[];
  87. items?: any;
  88. description?: string;
  89. enum?: any[];
  90. };
  91. };
  92. };
  93. };
  94. }
  95. export interface ChatRequest {
  96. model: string
  97. messages?: Message[]
  98. stream?: boolean
  99. format?: string | object
  100. keep_alive?: string | number // a number (seconds) or a string with a duration unit suffix ("300ms", "1.5h", "2h45m", etc)
  101. tools?: Tool[]
  102. think?: boolean
  103. options?: Partial<Options>
  104. }
  105. export interface PullRequest {
  106. model: string
  107. insecure?: boolean
  108. stream?: boolean
  109. }
  110. export interface PushRequest {
  111. model: string
  112. insecure?: boolean
  113. stream?: boolean
  114. }
  115. export interface CreateRequest {
  116. model: string
  117. from?: string
  118. stream?: boolean
  119. quantize?: string
  120. template?: string
  121. license?: string | string[]
  122. system?: string
  123. parameters?: Record<string, unknown>
  124. messages?: Message[]
  125. adapters?: Record<string, string>
  126. }
  127. export interface DeleteRequest {
  128. model: string
  129. }
  130. export interface CopyRequest {
  131. source: string
  132. destination: string
  133. }
  134. export interface ShowRequest {
  135. model: string
  136. system?: string
  137. template?: string
  138. options?: Partial<Options>
  139. }
  140. export interface EmbedRequest {
  141. model: string
  142. input: string | string[]
  143. truncate?: boolean
  144. keep_alive?: string | number // a number (seconds) or a string with a duration unit suffix ("300ms", "1.5h", "2h45m", etc)
  145. options?: Partial<Options>
  146. }
  147. export interface EmbeddingsRequest {
  148. model: string
  149. prompt: string
  150. keep_alive?: string | number // a number (seconds) or a string with a duration unit suffix ("300ms", "1.5h", "2h45m", etc)
  151. options?: Partial<Options>
  152. }
  153. // response types
  154. export interface GenerateResponse {
  155. model: string
  156. created_at: Date
  157. response: string
  158. thinking?: string
  159. done: boolean
  160. done_reason: string
  161. context: number[]
  162. total_duration: number
  163. load_duration: number
  164. prompt_eval_count: number
  165. prompt_eval_duration: number
  166. eval_count: number
  167. eval_duration: number
  168. }
  169. export interface ChatResponse {
  170. model: string
  171. created_at: Date
  172. message: Message
  173. done: boolean
  174. done_reason: string
  175. total_duration: number
  176. load_duration: number
  177. prompt_eval_count: number
  178. prompt_eval_duration: number
  179. eval_count: number
  180. eval_duration: number
  181. }
  182. export interface EmbedResponse {
  183. model: string
  184. embeddings: number[][]
  185. total_duration: number
  186. load_duration: number
  187. prompt_eval_count: number
  188. }
  189. export interface EmbeddingsResponse {
  190. embedding: number[]
  191. }
  192. export interface ProgressResponse {
  193. status: string
  194. digest: string
  195. total: number
  196. completed: number
  197. }
  198. export interface ModelResponse {
  199. name: string
  200. modified_at: Date
  201. model: string
  202. size: number
  203. digest: string
  204. details: ModelDetails
  205. expires_at: Date
  206. size_vram: number
  207. }
  208. export interface ModelDetails {
  209. parent_model: string
  210. format: string
  211. family: string
  212. families: string[]
  213. parameter_size: string
  214. quantization_level: string
  215. }
  216. export interface ShowResponse {
  217. license: string
  218. modelfile: string
  219. parameters: string
  220. template: string
  221. system: string
  222. details: ModelDetails
  223. messages: Message[]
  224. modified_at: Date
  225. model_info: Map<string, any>,
  226. capabilities: string[],
  227. projector_info?: Map<string, any>
  228. }
  229. export interface ListResponse {
  230. models: ModelResponse[]
  231. }
  232. export interface ErrorResponse {
  233. error: string
  234. }
  235. export interface StatusResponse {
  236. status: string
  237. }