Skip to content

Commit 9ff3b31

Browse files
committed
add prettier config
1 parent 6ff57b3 commit 9ff3b31

File tree

10 files changed

+596
-556
lines changed

10 files changed

+596
-556
lines changed

.eslintrc.cjs

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,24 @@
11
module.exports = {
2-
env: {
3-
commonjs: true,
4-
es2021: true,
5-
node: true,
6-
jest: true
7-
},
8-
parserOptions: {
9-
ecmaVersion: "latest"
10-
},
11-
parser: "@typescript-eslint/parser",
12-
extends: [
13-
"eslint:recommended"
14-
],
15-
rules: {
16-
curly: [1, "all"],
17-
// disallow single quotes
18-
quotes: [1, "double", { allowTemplateLiterals: true }],
19-
// force semi-colons
20-
semi: 1,
21-
// allow tabs
22-
"no-tabs": [0],
23-
// use tab indentation
24-
indent: [1, "tab", {
25-
SwitchCase: 1
26-
}],
27-
// prevent commar dangles
28-
"comma-dangle": [1, "never"],
29-
// allow paren-less arrow functions
30-
"arrow-parens": 0,
31-
// allow async-await
32-
"generator-star-spacing": 0,
33-
"no-unused-vars": [0, { args: "after-used", vars: "local" }],
34-
"no-constant-condition": 0,
35-
// allow debugger during development
36-
"no-debugger": process.env.NODE_ENV === "production" ? 2 : 0
37-
}
38-
};
2+
env: {
3+
commonjs: true,
4+
es2021: true,
5+
node: true,
6+
jest: true,
7+
},
8+
parserOptions: {
9+
ecmaVersion: 'latest',
10+
},
11+
parser: '@typescript-eslint/parser',
12+
extends: ['eslint:recommended'],
13+
rules: {
14+
curly: [1, 'all'],
15+
// allow paren-less arrow functions
16+
'arrow-parens': 0,
17+
// allow async-await
18+
'generator-star-spacing': 0,
19+
'no-unused-vars': [0, { args: 'after-used', vars: 'local' }],
20+
'no-constant-condition': 0,
21+
// allow debugger during development
22+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
23+
},
24+
}

.prettierrc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "http://json.schemastore.org/prettierrc",
3+
"semi": false,
4+
"printWidth": 90,
5+
"trailingComma": "all",
6+
"singleQuote": true,
7+
"endOfLine": "lf"
8+
}

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# ollama
2+
23
Interface with an ollama instance over HTTP.
34

45
## Table of Contents
@@ -26,12 +27,12 @@ npm i ollama
2627
## Usage
2728

2829
```javascript
29-
import { Ollama } from "ollama";
30+
import { Ollama } from 'ollama'
3031

31-
const ollama = new Ollama();
32+
const ollama = new Ollama()
3233

33-
for await (const token of ollama.generate("llama2", "What is a llama?")) {
34-
process.stdout.write(token);
34+
for await (const token of ollama.generate('llama2', 'What is a llama?')) {
35+
process.stdout.write(token)
3536
}
3637
```
3738

@@ -42,7 +43,7 @@ The API aims to mirror the [HTTP API for Ollama](https://github.com/jmorganca/ol
4243
### Ollama
4344

4445
```javascript
45-
new Ollama(config);
46+
new Ollama(config)
4647
```
4748

4849
- `config` `<Object>` The configuration object for Ollama.
@@ -53,7 +54,7 @@ Create a new API handler for ollama.
5354
### generate
5455

5556
```javascript
56-
ollama.generate(model, prompt, [options]);
57+
ollama.generate(model, prompt, [options])
5758
```
5859

5960
- `model` `<string>` The name of the model to use for the prompt.
@@ -70,7 +71,7 @@ Generate a response for a given prompt with a provided model. The final response
7071
### create
7172

7273
```javascript
73-
ollama.create(name, path);
74+
ollama.create(name, path)
7475
```
7576

7677
- `name` `<string>` The name of the model.
@@ -82,7 +83,7 @@ Create a model from a Modelfile.
8283
### tags
8384

8485
```javascript
85-
ollama.tags();
86+
ollama.tags()
8687
```
8788

8889
- Returns: `Promise<Tag[]>` A list of tags.
@@ -92,7 +93,7 @@ List models that are available locally.
9293
### copy
9394

9495
```javascript
95-
ollama.copy(source, destination);
96+
ollama.copy(source, destination)
9697
```
9798

9899
- `source` `<string>` The name of the model to copy.
@@ -104,7 +105,7 @@ Copy a model. Creates a model with another name from an existing model.
104105
### delete
105106

106107
```javascript
107-
ollama.delete(model);
108+
ollama.delete(model)
108109
```
109110

110111
- `model` `<string>` The name of the model to delete.
@@ -115,7 +116,7 @@ Delete a model and its data.
115116
### pull
116117

117118
```javascript
118-
ollama.pull(name);
119+
ollama.pull(name)
119120
```
120121

121122
- `name` `<string>` The name of the model to download.
@@ -126,7 +127,7 @@ Download a model from a the model registry. Cancelled pulls are resumed from whe
126127
### embeddings
127128

128129
```javascript
129-
ollama.embeddings(model, prompt, [parameters]);
130+
ollama.embeddings(model, prompt, [parameters])
130131
```
131132

132133
- `model` `<string>` The name of the model to generate embeddings for.

jest.config.cjs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
/** @type {import('ts-jest').JestConfigWithTsJest} */
22
module.exports = {
3-
preset: "ts-jest",
4-
testEnvironment: "node",
5-
maxWorkers: 1,
6-
extensionsToTreatAsEsm: [".ts"],
7-
moduleNameMapper: {
8-
"^(\\.{1,2}/.*)\\.js$": "$1"
9-
},
10-
transform: {
11-
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
12-
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
13-
"^.+\\.tsx?$": [
14-
"ts-jest",
15-
{
16-
useESM: true
17-
}
18-
]
19-
}
20-
};
3+
preset: 'ts-jest',
4+
testEnvironment: 'node',
5+
maxWorkers: 1,
6+
extensionsToTreatAsEsm: ['.ts'],
7+
moduleNameMapper: {
8+
'^(\\.{1,2}/.*)\\.js$': '$1',
9+
},
10+
transform: {
11+
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
12+
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
13+
'^.+\\.tsx?$': [
14+
'ts-jest',
15+
{
16+
useESM: true,
17+
},
18+
],
19+
},
20+
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"main": "dist/index.js",
77
"types": "dist/index.d.ts",
88
"scripts": {
9+
"format": "prettier --write .",
910
"test": "jest --config=jest.config.cjs ./test/*",
1011
"build": "mkdir -p dist && touch dist/cleanup && rm dist/* && tsc -b",
1112
"lint": "eslint ./src/* ./test/*",
@@ -27,6 +28,7 @@
2728
"eslint": "^8.29.0",
2829
"eslint-plugin-jest": "^27.1.4",
2930
"jest": "^29.3.0",
31+
"prettier": "^3.2.4",
3032
"ts-jest": "^29.0.3",
3133
"typescript": "^4.8.4"
3234
},

0 commit comments

Comments
 (0)