2
0
Эх сурвалжийг харах

JavaScript API PS (#99)

* JavaScript API PS

* PS Rename

* Readme

* Delete List Example
royjhan 1 жил өмнө
parent
commit
944c54c286
3 өөрчлөгдсөн 20 нэмэгдсэн , 0 устгасан
  1. 8 0
      README.md
  2. 10 0
      src/browser.ts
  3. 2 0
      src/interfaces.ts

+ 8 - 0
README.md

@@ -187,6 +187,14 @@ ollama.embeddings(request)
   - `options` `<Options>`: (Optional) Options to configure the runtime.
 - Returns: `<EmbeddingsResponse>`
 
+### ps
+
+```javascript
+ollama.ps()
+```
+
+- Returns: `<ListResponse>`
+
 ## Custom client
 
 A custom client can be created with the following fields:

+ 10 - 0
src/browser.ts

@@ -278,6 +278,16 @@ export class Ollama {
     })
     return (await response.json()) as EmbeddingsResponse
   }
+
+  /**
+   * Lists the running models on the server
+   * @returns {Promise<ListResponse>} - The response object.
+   * @throws {Error} - If the response body is missing.
+   */
+  async ps(): Promise<ListResponse> {
+    const response = await utils.get(this.fetch, `${this.config.host}/api/ps`)
+    return (await response.json()) as ListResponse
+  }
 }
 
 export default new Ollama()

+ 2 - 0
src/interfaces.ts

@@ -166,6 +166,8 @@ export interface ModelResponse {
   size: number
   digest: string
   details: ModelDetails
+  expires_at: Date
+  size_vram: number
 }
 
 export interface ModelDetails {