Skip to content

Commit

Permalink
add prettier config
Browse files Browse the repository at this point in the history
  • Loading branch information
BruceMacD authored Jan 21, 2024
2 parents 6ff57b3 + a952248 commit f5b7350
Show file tree
Hide file tree
Showing 10 changed files with 613 additions and 573 deletions.
60 changes: 23 additions & 37 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,38 +1,24 @@
module.exports = {
env: {
commonjs: true,
es2021: true,
node: true,
jest: true
},
parserOptions: {
ecmaVersion: "latest"
},
parser: "@typescript-eslint/parser",
extends: [
"eslint:recommended"
],
rules: {
curly: [1, "all"],
// disallow single quotes
quotes: [1, "double", { allowTemplateLiterals: true }],
// force semi-colons
semi: 1,
// allow tabs
"no-tabs": [0],
// use tab indentation
indent: [1, "tab", {
SwitchCase: 1
}],
// prevent commar dangles
"comma-dangle": [1, "never"],
// allow paren-less arrow functions
"arrow-parens": 0,
// allow async-await
"generator-star-spacing": 0,
"no-unused-vars": [0, { args: "after-used", vars: "local" }],
"no-constant-condition": 0,
// allow debugger during development
"no-debugger": process.env.NODE_ENV === "production" ? 2 : 0
}
};
env: {
commonjs: true,
es2021: true,
node: true,
jest: true,
},
parserOptions: {
ecmaVersion: 'latest',
},
parser: '@typescript-eslint/parser',
extends: ['eslint:recommended'],
rules: {
curly: [1, 'all'],
// allow paren-less arrow functions
'arrow-parens': 0,
// allow async-await
'generator-star-spacing': 0,
'no-unused-vars': [0, { args: 'after-used', vars: 'local' }],
'no-constant-condition': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
},
}
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "http://json.schemastore.org/prettierrc",
"semi": false,
"printWidth": 90,
"trailingComma": "all",
"singleQuote": true,
"endOfLine": "lf"
}
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# ollama

Interface with an ollama instance over HTTP.

## Table of Contents
Expand Down Expand Up @@ -26,12 +27,12 @@ npm i ollama
## Usage

```javascript
import { Ollama } from "ollama";
import { Ollama } from 'ollama'

const ollama = new Ollama();
const ollama = new Ollama()

for await (const token of ollama.generate("llama2", "What is a llama?")) {
process.stdout.write(token);
for await (const token of ollama.generate('llama2', 'What is a llama?')) {
process.stdout.write(token)
}
```

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

```javascript
new Ollama(config);
new Ollama(config)
```

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

```javascript
ollama.generate(model, prompt, [options]);
ollama.generate(model, prompt, [options])
```

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

```javascript
ollama.create(name, path);
ollama.create(name, path)
```

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

```javascript
ollama.tags();
ollama.tags()
```

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

```javascript
ollama.copy(source, destination);
ollama.copy(source, destination)
```

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

```javascript
ollama.delete(model);
ollama.delete(model)
```

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

```javascript
ollama.pull(name);
ollama.pull(name)
```

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

```javascript
ollama.embeddings(model, prompt, [parameters]);
ollama.embeddings(model, prompt, [parameters])
```

- `model` `<string>` The name of the model to generate embeddings for.
Expand Down
36 changes: 18 additions & 18 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
maxWorkers: 1,
extensionsToTreatAsEsm: [".ts"],
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1"
},
transform: {
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
"^.+\\.tsx?$": [
"ts-jest",
{
useESM: true
}
]
}
};
preset: 'ts-jest',
testEnvironment: 'node',
maxWorkers: 1,
extensionsToTreatAsEsm: ['.ts'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
transform: {
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
useESM: true,
},
],
},
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"format": "prettier --write .",
"test": "jest --config=jest.config.cjs ./test/*",
"build": "mkdir -p dist && touch dist/cleanup && rm dist/* && tsc -b",
"lint": "eslint ./src/* ./test/*",
Expand All @@ -27,6 +28,7 @@
"eslint": "^8.29.0",
"eslint-plugin-jest": "^27.1.4",
"jest": "^29.3.0",
"prettier": "^3.2.4",
"ts-jest": "^29.0.3",
"typescript": "^4.8.4"
},
Expand Down
Loading

0 comments on commit f5b7350

Please sign in to comment.