Skip to content

Commit

Permalink
JavaScript API PS (#99)
Browse files Browse the repository at this point in the history
* JavaScript API PS

* PS Rename

* Readme

* Delete List Example
  • Loading branch information
royjhan authored Jun 5, 2024
1 parent 305eb0b commit 944c54c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 10 additions & 0 deletions src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ export interface ModelResponse {
size: number
digest: string
details: ModelDetails
expires_at: Date
size_vram: number
}

export interface ModelDetails {
Expand Down

0 comments on commit 944c54c

Please sign in to comment.