notdiamond 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENCE +21 -0
- package/README.md +88 -0
- package/package.json +90 -0
package/LICENCE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Maxime Golfier
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# NotDiamond Node API Library
|
|
2
|
+
|
|
3
|
+
This library provides convenient access to the NotDiamond model routing API from TypeScript or JavaScript.
|
|
4
|
+
|
|
5
|
+
To learn how to use the NotDiamond API, check out our [API Reference and Documentation.](https://notdiamond.readme.io/v0.1.0-beta/docs/getting-started)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install notdiamond
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
You can import in Deno via:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import NotDiamond from 'https://deno.land/x/notdiamond@v1.0.0/mod.ts';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
The full API of this library can be found in `api.md` file along with many code examples. The code below shows how to get started using the chat completions API.
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import NotDiamond from 'notdiamond';
|
|
25
|
+
|
|
26
|
+
const notdiamond = new NotDiamond();
|
|
27
|
+
|
|
28
|
+
async function main() {
|
|
29
|
+
const { providers, session_id } = await notdiamond.hashModelSelect({
|
|
30
|
+
messages: [{ content: 'What is 12x12?', role: 'user' }],
|
|
31
|
+
llmProviders: [
|
|
32
|
+
{ provider: 'openai', model: 'gpt-4o' },
|
|
33
|
+
{ provider: 'anthropic', model: 'claude-3-opus-20240229' },
|
|
34
|
+
{ provider: 'google', model: 'gemini-1.5-pro' },
|
|
35
|
+
],
|
|
36
|
+
preferenceWeights: { quality: 0.7, cost: 0.1, latency: 0.2 },
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
console.log(providers);
|
|
40
|
+
console.log(session_id);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
main();
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### TO DELETE
|
|
47
|
+
|
|
48
|
+
A simple node boilerplate made in typescript using swc which generates `cjs` and `esm` modules.
|
|
49
|
+
|
|
50
|
+
## Clone repository and install dependencies
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
git clone https://github.com/maxgfr/typescript-swc-starter # For cloning the repository
|
|
54
|
+
cd typescript-swc-starter # To navigate to the repository root
|
|
55
|
+
yarn # Install dependencies
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
:warning: You have to use at least `node@20` to run this project.
|
|
59
|
+
|
|
60
|
+
## Commands
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
yarn dev # For running the code in development thanks to swc and nodemon
|
|
64
|
+
|
|
65
|
+
yarn test # For running unit test
|
|
66
|
+
yarn test:watch # For watching unit test
|
|
67
|
+
|
|
68
|
+
yarn lint # For linting the code
|
|
69
|
+
yarn lint:fix # For linting the code and fix issues
|
|
70
|
+
|
|
71
|
+
yarn bundle # For generating bundling in cjs and esm
|
|
72
|
+
|
|
73
|
+
yarn start:cjs # For running the code builded in cjs
|
|
74
|
+
yarn start:esm # For running the code builded in esm
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Publish to npm
|
|
78
|
+
|
|
79
|
+
Set `NPM_TOKEN` in your Github actions secret, and that's it :)
|
|
80
|
+
|
|
81
|
+

|
|
82
|
+
|
|
83
|
+
To test this package, just do that :
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { sayHello } from 'typescript-swc-starter';
|
|
87
|
+
sayHello();
|
|
88
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "notdiamond",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"author": "not-diamond",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"description": "TS/JS client for the NotDiamond API",
|
|
8
|
+
"main": "./dist/index.cjs",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/Not-Diamond/notdiamond-node.git"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/Not-Diamond/notdiamond-node/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/Not-Diamond/notdiamond-node#readme",
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"keywords": [
|
|
28
|
+
"boilerplate",
|
|
29
|
+
"typescript",
|
|
30
|
+
"release",
|
|
31
|
+
"swc"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"prepare": "husky install",
|
|
35
|
+
"start:cjs": "node ./dist/index.cjs",
|
|
36
|
+
"start:esm": "node ./dist/index.mjs",
|
|
37
|
+
"dev": "nodemon",
|
|
38
|
+
"develop": "node --no-warnings=ExperimentalWarning --loader ts-node/esm ./src/index.ts",
|
|
39
|
+
"test": "jest --passWithNoTests",
|
|
40
|
+
"test:watch": "jest --watch --passWithNoTests",
|
|
41
|
+
"test:coverage": "jest --coverage --passWithNoTests",
|
|
42
|
+
"clean": "rimraf build && rimraf dist",
|
|
43
|
+
"build": "swc ./src -d build",
|
|
44
|
+
"build:watch": "swc ./src -d build -w",
|
|
45
|
+
"lint": "eslint ./src --ext .ts",
|
|
46
|
+
"lint:fix": "eslint ./src --ext .ts --fix",
|
|
47
|
+
"prettier": "prettier '**/*.{ts,json,md}'",
|
|
48
|
+
"prettier:write": "prettier --write '**/*.{ts,json,md}'",
|
|
49
|
+
"type-check": "tsc --noEmit",
|
|
50
|
+
"lint-staged": "lint-staged",
|
|
51
|
+
"release": "semantic-release",
|
|
52
|
+
"bundle": "unbuild"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"dotenv": "^16.4.5"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
59
|
+
"@semantic-release/commit-analyzer": "^12.0.0",
|
|
60
|
+
"@semantic-release/git": "^10.0.1",
|
|
61
|
+
"@semantic-release/github": "^10.0.0",
|
|
62
|
+
"@semantic-release/npm": "^12.0.0",
|
|
63
|
+
"@semantic-release/release-notes-generator": "^13.0.0",
|
|
64
|
+
"@swc/cli": "0.3.12",
|
|
65
|
+
"@swc/core": "1.5.7",
|
|
66
|
+
"@swc/jest": "0.2.36",
|
|
67
|
+
"@types/jest": "29.5.12",
|
|
68
|
+
"@types/node": "20.12.12",
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "7.9.0",
|
|
70
|
+
"@typescript-eslint/parser": "7.9.0",
|
|
71
|
+
"eslint": "8.57.0",
|
|
72
|
+
"eslint-config-prettier": "9.1.0",
|
|
73
|
+
"eslint-plugin-jest": "27.9.0",
|
|
74
|
+
"eslint-plugin-prettier": "5.1.3",
|
|
75
|
+
"husky": "^9.0.0",
|
|
76
|
+
"jest": "29.7.0",
|
|
77
|
+
"lint-staged": "^15.0.0",
|
|
78
|
+
"nodemon": "3.1.0",
|
|
79
|
+
"prettier": "3.2.5",
|
|
80
|
+
"regenerator-runtime": "^0.14.0",
|
|
81
|
+
"rimraf": "5.0.7",
|
|
82
|
+
"semantic-release": "^23.0.0",
|
|
83
|
+
"ts-node": "^10.9.1",
|
|
84
|
+
"typescript": "5.4.5",
|
|
85
|
+
"unbuild": "^2.0.0"
|
|
86
|
+
},
|
|
87
|
+
"resolutions": {
|
|
88
|
+
"wrap-ansi": "7.0.0"
|
|
89
|
+
}
|
|
90
|
+
}
|