Skip to content

Commit 5fcdf9b

Browse files
authored
feat: function calling (#139)
* feat: function calling support * feat: stateless `LlamaChat` * feat: improve chat wrapper * feat: `LlamaText` util * test: add basic model-dependent tests * fix: threads parameter * fix: disable Metal for `x64` arch by default
1 parent 4757af8 commit 5fcdf9b

File tree

73 files changed

+6456
-2652
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+6456
-2652
lines changed

.config/typedoc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
"useCodeBlocks": true,
2020
"expandObjects": true,
2121
"parametersFormat": "table",
22-
"hideInPageTOC": true
22+
"hideInPageTOC": true,
23+
"docsRoot": "../docs"
2324
}

.github/workflows/build.yml

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,19 @@ jobs:
176176
await $`mkdir -p llamaBins`;
177177
178178
for (const arch of arches) {
179+
const additionalFlags = [];
179180
let buildNodeVersion = nodeVersion;
180181
181182
if (process.env.ARTIFACT_NAME === "win" && arch === "arm64") {
182183
buildNodeVersion = windowsOnArmNodeVersion;
184+
} else if (process.env.ARTIFACT_NAME === "mac" && arch === "x64") {
185+
additionalFlags.push("--no-metal");
183186
}
184187
185188
console.log(`Building ${arch} for node ${buildNodeVersion}`);
186189
187-
const binName = `${process.env.ARTIFACT_NAME}-${arch}`;
188-
await $`node ./dist/cli/cli.js build --arch ${arch} --nodeTarget ${buildNodeVersion}`;
190+
const binName = `${process.env.ARTIFACT_NAME}-${arch}`;
191+
await $`node ./dist/cli/cli.js build --arch ${arch} --nodeTarget ${buildNodeVersion} ${additionalFlags}`;
189192
await $`mv ./llama/build/Release ${"./llamaBins/" + binName}`;
190193
}
191194
@@ -237,6 +240,53 @@ jobs:
237240
- name: Run standalone tests
238241
run: npm run test:standalone
239242

243+
model-dependent-tests:
244+
name: Model dependent tests
245+
runs-on: macos-13
246+
needs:
247+
- build
248+
steps:
249+
- uses: actions/checkout@v3
250+
- uses: actions/setup-node@v3
251+
with:
252+
node-version: "20"
253+
254+
- name: Download build artifact
255+
uses: actions/download-artifact@v3
256+
with:
257+
name: build
258+
path: dist
259+
260+
- name: Download llama.cpp artifact
261+
uses: actions/download-artifact@v3
262+
with:
263+
name: llama.cpp
264+
path: llama/llama.cpp
265+
266+
- name: Install dependencies on macOS
267+
run: |
268+
brew install cmake ninja
269+
alias make=cmake
270+
271+
- name: Install modules
272+
run: npm ci
273+
274+
- name: Build binary
275+
run: node ./dist/cli/cli.js build
276+
277+
- name: Cache models
278+
id: cache-test-models
279+
uses: actions/cache@v3
280+
with:
281+
path: "test/.models/**.gguf"
282+
key: cache-test-models-${{ runner.os }}-${{ github.workflow }}
283+
284+
- name: Download models or ensure all models are downloaded
285+
run: npm run dev:setup:downloadAllTestModels
286+
287+
- name: Run model dependent tests
288+
run: npm run test:modelDependent
289+
240290
release:
241291
name: Release
242292
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/beta'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ node_modules
1010
/.env
1111
/.eslintcache
1212
/.vitepress/.cache
13+
/test/.models
1314
/coverage
1415

1516
/llama/compile_commands.json

0 commit comments

Comments
 (0)