Skip to content

Commit a98386b

Browse files
committed
initial commit
0 parents  commit a98386b

19 files changed

+12543
-0
lines changed

.editorconfig

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# top-most EditorConfig file
2+
root = true
3+
4+
# defaults
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
indent_size = 2
11+
indent_style = space
12+
13+
[*.md]
14+
trim_trailing_whitespace = false
15+
16+
[*.yml]
17+
indent_size = 4
18+
19+
[electron-builder.yml]
20+
indent_size = 2
21+
22+
[*.py]
23+
indent_size = 4

.eslintrc.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module.exports = {
2+
env: { es2020: true, node: true },
3+
extends: [
4+
'eslint:recommended',
5+
'plugin:@typescript-eslint/eslint-recommended',
6+
'plugin:@typescript-eslint/recommended',
7+
'plugin:typescript-sort-keys/recommended',
8+
'prettier',
9+
'plugin:prettier/recommended', // should always be at the end
10+
],
11+
parser: '@typescript-eslint/parser',
12+
parserOptions: { ecmaVersion: 2020 },
13+
plugins: [
14+
'@typescript-eslint',
15+
'prettier',
16+
'typescript-sort-keys',
17+
'simple-import-sort',
18+
'import',
19+
],
20+
rules: {
21+
'@typescript-eslint/no-empty-function': 'off',
22+
'@typescript-eslint/no-explicit-any': 'off',
23+
'@typescript-eslint/no-unsafe-argument': 'off',
24+
'@typescript-eslint/no-unsafe-assignment': 'off',
25+
'@typescript-eslint/no-unsafe-call': 'off',
26+
'@typescript-eslint/no-unsafe-member-access': 'off',
27+
curly: ['error', 'multi-line'],
28+
eqeqeq: ['error', 'always', { null: 'ignore' }],
29+
'no-throw-literal': 'error',
30+
'react/prop-types': 'off',
31+
'simple-import-sort/exports': 'error',
32+
'simple-import-sort/imports': 'error',
33+
'sort-keys': ['error', 'asc', { caseSensitive: true, natural: true }],
34+
},
35+
settings: {
36+
'import/parsers': { '@typescript-eslint/parser': ['.ts'] },
37+
react: { version: 'detect' },
38+
},
39+
}

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text eol=lf

.github/workflows/main.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
on: [push]
3+
jobs:
4+
build:
5+
name: Build, lint, and test on Node ${{ matrix.node }}
6+
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
node: ['18.x', '19.x', '20.x']
11+
12+
steps:
13+
- name: Checkout repo
14+
uses: actions/checkout@v3
15+
16+
- name: Use Node ${{ matrix.node }}
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: ${{ matrix.node }}
20+
21+
- name: Install deps and build (with cache)
22+
uses: bahmutov/npm-install@v1
23+
24+
- name: Lint
25+
run: yarn lint
26+
27+
- name: Test
28+
run: yarn test --ci --coverage --maxWorkers=2
29+
30+
- name: Build
31+
run: yarn build

.gitignore

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# database
12+
/prisma/db.sqlite
13+
/prisma/db.sqlite-journal
14+
15+
# next.js
16+
/.next/
17+
/out/
18+
next-env.d.ts
19+
20+
# production
21+
/build
22+
dist
23+
24+
# misc
25+
.DS_Store
26+
*.pem
27+
28+
# debug
29+
npm-debug.log*
30+
yarn-debug.log*
31+
yarn-error.log*
32+
.pnpm-debug.log*
33+
34+
# local env files
35+
# do not commit any .env files to git, except for the .env.example file. https://create.t3.gg/en/usage/env-variables#using-environment-variables
36+
.env
37+
.env*.local
38+
generated
39+
40+
# vercel
41+
.vercel
42+
43+
# typescript
44+
*.tsbuildinfo
45+
46+
# yarn
47+
.pnp.*
48+
.yarn/*
49+
!.yarn/patches
50+
!.yarn/plugins
51+
!.yarn/releases
52+
!.yarn/sdks
53+
!.yarn/versions

.npmignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.tsbuildinfo
2+
*.log
3+
tests/
4+
src/
5+
.eslintrc.js
6+
jest.config.js
7+
.editorconfig
8+
.prettierrc
9+
yarn.lock
10+
.github/
11+
tsconfig.json
12+
.yarn/

.prettierrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"printWidth": 80,
6+
"endOfLine": "lf"
7+
}

.yarn/releases/yarn-3.6.3.cjs

+874
Large diffs are not rendered by default.

.yarnrc.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nodeLinker: node-modules
2+
3+
yarnPath: .yarn/releases/yarn-3.6.3.cjs

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Ahoy Labs, Inc.
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.

README.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<h1 align="center">GGUF.js</h1>
2+
3+
<h3 align="center">Download, manage, and run Llama GGUF files easily with <a href="https://faraday.dev">Faraday.dev</a></h3>
4+
5+
![gguf](https://github.com/Oblomov/clinfo/assets/6139501/748f2773-1b4f-4d55-9353-6fb68b7bf603)
6+
7+
A Javascript library (with Typescript types) to parse metadata for [GGML](https://github.com/ggerganov/ggml) based GGUF files.
8+
9+
Supported Architectures
10+
11+
- `Llama`
12+
- `MPT`
13+
- `GPTNeoX`
14+
- `GPTJ`
15+
- `GPT2`
16+
- `Bloom`
17+
- `Falcon`
18+
- `RWKV`
19+
20+
This library goal is to be 1-to-1 with [the spec](https://github.com/philpax/ggml/blob/gguf-spec/docs/gguf.md). PRs welcome!
21+
22+
## Install
23+
24+
```sh
25+
yarn add gguf
26+
```
27+
28+
or
29+
30+
```sh
31+
npm install gguf
32+
```
33+
34+
## Usage
35+
36+
```ts
37+
import gguf, { isLLamaMetadata } from 'gguf'
38+
39+
// pass in a file path, gguf.js will only load in what is needed for the metadata
40+
// not the whole file
41+
const { metadata, error } = await gguf('./llama2.gguf')
42+
43+
if (error) {
44+
throw error
45+
}
46+
47+
// helper function to give full type safety
48+
// see more in `src/index.ts`
49+
if (isLLamaMetadata(metadata)) {
50+
console.log(`context length: ${metadata.llama.context_length}`)
51+
}
52+
```
53+
54+
## TypeScript
55+
56+
Typescript is supported by default and all definitions are in [`src/metadataTypes`](https://github.com/ahoylabs/gguf.js/blob/main/src/metadataTypes.ts)
57+
58+
## License
59+
60+
MIT © [Ahoy Labs, Inc.](https://faraday.dev)

package.json

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"name": "gguf",
3+
"version": "1.0.0",
4+
"license": "MIT",
5+
"author": "Ben Williams <[email protected]>",
6+
"main": "dist/index.js",
7+
"module": "dist/gguf.esm.js",
8+
"typings": "dist/index.d.ts",
9+
"files": [
10+
"dist"
11+
],
12+
"scripts": {
13+
"analyze": "size-limit --why",
14+
"build": "dts build",
15+
"lint": "dts lint",
16+
"prepare": "dts build",
17+
"size": "size-limit",
18+
"start": "dts watch",
19+
"generate-zodValidators": "ts-to-zod src/metadataTypes.ts src/zodValidators.ts",
20+
"test": "dts test"
21+
},
22+
"jest": {
23+
"testEnvironment": "node"
24+
},
25+
"engines": {
26+
"node": ">=18"
27+
},
28+
"size-limit": [
29+
{
30+
"path": "dist/gguf.cjs.production.min.js",
31+
"limit": "10 KB"
32+
},
33+
{
34+
"path": "dist/gguf.esm.js",
35+
"limit": "10 KB"
36+
}
37+
],
38+
"devDependencies": {
39+
"@size-limit/preset-small-lib": "^9.0.0",
40+
"@tsconfig/recommended": "^1.0.2",
41+
"@types/fs-extra": "^11.0.1",
42+
"@types/node": "^20.5.9",
43+
"@typescript-eslint/eslint-plugin": "^6.4.0",
44+
"@typescript-eslint/parser": "^6.4.0",
45+
"dts-cli": "^2.0.3",
46+
"eslint": "^8.47.0",
47+
"eslint-config-prettier": "^9.0.0",
48+
"eslint-import-resolver-typescript": "^3.6.0",
49+
"eslint-plugin-import": "^2.28.0",
50+
"eslint-plugin-prettier": "^5.0.0",
51+
"eslint-plugin-react": "^7.33.1",
52+
"eslint-plugin-react-hooks": "^4.6.0",
53+
"eslint-plugin-simple-import-sort": "^10.0.0",
54+
"eslint-plugin-typescript-sort-keys": "^2.3.0",
55+
"prettier": "^3.0.1",
56+
"size-limit": "^9.0.0",
57+
"ts-to-zod": "^3.1.3",
58+
"tslib": "^2.6.2",
59+
"typescript": "^5.2.2"
60+
},
61+
"dependencies": {
62+
"fs-extra": "^11.1.1",
63+
"zod": "^3.22.2"
64+
},
65+
"packageManager": "[email protected]"
66+
}

0 commit comments

Comments
 (0)