Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
biw committed Sep 8, 2023
0 parents commit a98386b
Show file tree
Hide file tree
Showing 19 changed files with 12,543 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# top-most EditorConfig file
root = true

# defaults
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_size = 2
indent_style = space

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 4

[electron-builder.yml]
indent_size = 2

[*.py]
indent_size = 4
39 changes: 39 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
env: { es2020: true, node: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:typescript-sort-keys/recommended',
'prettier',
'plugin:prettier/recommended', // should always be at the end
],
parser: '@typescript-eslint/parser',
parserOptions: { ecmaVersion: 2020 },
plugins: [
'@typescript-eslint',
'prettier',
'typescript-sort-keys',
'simple-import-sort',
'import',
],
rules: {
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
curly: ['error', 'multi-line'],
eqeqeq: ['error', 'always', { null: 'ignore' }],
'no-throw-literal': 'error',
'react/prop-types': 'off',
'simple-import-sort/exports': 'error',
'simple-import-sort/imports': 'error',
'sort-keys': ['error', 'asc', { caseSensitive: true, natural: true }],
},
settings: {
'import/parsers': { '@typescript-eslint/parser': ['.ts'] },
react: { version: 'detect' },
},
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text eol=lf
31 changes: 31 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI
on: [push]
jobs:
build:
name: Build, lint, and test on Node ${{ matrix.node }}

runs-on: ubuntu-latest
strategy:
matrix:
node: ['18.x', '19.x', '20.x']

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1

- name: Lint
run: yarn lint

- name: Test
run: yarn test --ci --coverage --maxWorkers=2

- name: Build
run: yarn build
53 changes: 53 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# database
/prisma/db.sqlite
/prisma/db.sqlite-journal

# next.js
/.next/
/out/
next-env.d.ts

# production
/build
dist

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
# 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
.env
.env*.local
generated

# vercel
.vercel

# typescript
*.tsbuildinfo

# yarn
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
12 changes: 12 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*.tsbuildinfo
*.log
tests/
src/
.eslintrc.js
jest.config.js
.editorconfig
.prettierrc
yarn.lock
.github/
tsconfig.json
.yarn/
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "all",
"printWidth": 80,
"endOfLine": "lf"
}
874 changes: 874 additions & 0 deletions .yarn/releases/yarn-3.6.3.cjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.6.3.cjs
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Ahoy Labs, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<h1 align="center">GGUF.js</h1>

<h3 align="center">Download, manage, and run Llama GGUF files easily with <a href="https://faraday.dev">Faraday.dev</a></h3>

![gguf](https://github.com/Oblomov/clinfo/assets/6139501/748f2773-1b4f-4d55-9353-6fb68b7bf603)

A Javascript library (with Typescript types) to parse metadata for [GGML](https://github.com/ggerganov/ggml) based GGUF files.

Supported Architectures

- `Llama`
- `MPT`
- `GPTNeoX`
- `GPTJ`
- `GPT2`
- `Bloom`
- `Falcon`
- `RWKV`

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!

## Install

```sh
yarn add gguf
```

or

```sh
npm install gguf
```

## Usage

```ts
import gguf, { isLLamaMetadata } from 'gguf'

// pass in a file path, gguf.js will only load in what is needed for the metadata
// not the whole file
const { metadata, error } = await gguf('./llama2.gguf')

if (error) {
throw error
}

// helper function to give full type safety
// see more in `src/index.ts`
if (isLLamaMetadata(metadata)) {
console.log(`context length: ${metadata.llama.context_length}`)
}
```

## TypeScript

Typescript is supported by default and all definitions are in [`src/metadataTypes`](https://github.com/ahoylabs/gguf.js/blob/main/src/metadataTypes.ts)

## License

MIT © [Ahoy Labs, Inc.](https://faraday.dev)
66 changes: 66 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "gguf",
"version": "1.0.0",
"license": "MIT",
"author": "Ben Williams <[email protected]>",
"main": "dist/index.js",
"module": "dist/gguf.esm.js",
"typings": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"analyze": "size-limit --why",
"build": "dts build",
"lint": "dts lint",
"prepare": "dts build",
"size": "size-limit",
"start": "dts watch",
"generate-zodValidators": "ts-to-zod src/metadataTypes.ts src/zodValidators.ts",
"test": "dts test"
},
"jest": {
"testEnvironment": "node"
},
"engines": {
"node": ">=18"
},
"size-limit": [
{
"path": "dist/gguf.cjs.production.min.js",
"limit": "10 KB"
},
{
"path": "dist/gguf.esm.js",
"limit": "10 KB"
}
],
"devDependencies": {
"@size-limit/preset-small-lib": "^9.0.0",
"@tsconfig/recommended": "^1.0.2",
"@types/fs-extra": "^11.0.1",
"@types/node": "^20.5.9",
"@typescript-eslint/eslint-plugin": "^6.4.0",
"@typescript-eslint/parser": "^6.4.0",
"dts-cli": "^2.0.3",
"eslint": "^8.47.0",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-typescript": "^3.6.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-react": "^7.33.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-typescript-sort-keys": "^2.3.0",
"prettier": "^3.0.1",
"size-limit": "^9.0.0",
"ts-to-zod": "^3.1.3",
"tslib": "^2.6.2",
"typescript": "^5.2.2"
},
"dependencies": {
"fs-extra": "^11.1.1",
"zod": "^3.22.2"
},
"packageManager": "[email protected]"
}
Loading

0 comments on commit a98386b

Please sign in to comment.