test for functions tools

This commit is contained in:
熊潇 2025-04-30 16:06:35 +08:00
parent abac483610
commit b07bcc5454
5 changed files with 327 additions and 167 deletions

View File

@ -1,2 +0,0 @@
config.json
.env*

View File

@ -23,7 +23,7 @@
"keywords": [], "keywords": [],
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)", "author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
"license": "MIT", "license": "MIT",
"packageManager": "pnpm@10.9.0", "packageManager": "pnpm@10.10.0",
"type": "module", "type": "module",
"publishConfig": { "publishConfig": {
"registry": "https://registry.npmjs.org/", "registry": "https://registry.npmjs.org/",
@ -43,13 +43,13 @@
"@kevisual/code-center-module": "0.0.18", "@kevisual/code-center-module": "0.0.18",
"@kevisual/mark": "0.0.7", "@kevisual/mark": "0.0.7",
"@kevisual/router": "0.0.13", "@kevisual/router": "0.0.13",
"@kevisual/types": "^0.0.6", "@kevisual/types": "^0.0.9",
"@kevisual/use-config": "^1.0.11", "@kevisual/use-config": "^1.0.11",
"@types/bun": "^1.2.10", "@types/bun": "^1.2.11",
"@types/crypto-js": "^4.2.2", "@types/crypto-js": "^4.2.2",
"@types/formidable": "^3.4.5", "@types/formidable": "^3.4.5",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/node": "^22.15.2", "@types/node": "^22.15.3",
"@vitejs/plugin-basic-ssl": "^2.0.0", "@vitejs/plugin-basic-ssl": "^2.0.0",
"cookie": "^1.0.2", "cookie": "^1.0.2",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
@ -60,12 +60,12 @@
"ioredis": "^5.6.1", "ioredis": "^5.6.1",
"json5": "^2.2.3", "json5": "^2.2.3",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"openai": "^4.96.0", "openai": "4.96.2",
"pino": "^9.6.0", "pino": "^9.6.0",
"pino-pretty": "^13.0.0", "pino-pretty": "^13.0.0",
"pm2": "^6.0.5", "pm2": "^6.0.5",
"rimraf": "^6.0.1", "rimraf": "^6.0.1",
"rollup": "^4.40.0", "rollup": "^4.40.1",
"rollup-plugin-dts": "^6.2.1", "rollup-plugin-dts": "^6.2.1",
"sequelize": "^6.37.7", "sequelize": "^6.37.7",
"tape": "^5.9.0", "tape": "^5.9.0",

329
pnpm-lock.yaml generated
View File

@ -18,14 +18,14 @@ importers:
specifier: 0.0.13 specifier: 0.0.13
version: 0.0.13 version: 0.0.13
'@kevisual/types': '@kevisual/types':
specifier: ^0.0.6 specifier: ^0.0.9
version: 0.0.6 version: 0.0.9
'@kevisual/use-config': '@kevisual/use-config':
specifier: ^1.0.11 specifier: ^1.0.11
version: 1.0.11(dotenv@16.5.0) version: 1.0.11(dotenv@16.5.0)
'@types/bun': '@types/bun':
specifier: ^1.2.10 specifier: ^1.2.11
version: 1.2.10 version: 1.2.11
'@types/crypto-js': '@types/crypto-js':
specifier: ^4.2.2 specifier: ^4.2.2
version: 4.2.2 version: 4.2.2
@ -36,11 +36,11 @@ importers:
specifier: ^4.17.12 specifier: ^4.17.12
version: 4.17.12 version: 4.17.12
'@types/node': '@types/node':
specifier: ^22.15.2 specifier: ^22.15.3
version: 22.15.2 version: 22.15.3
'@vitejs/plugin-basic-ssl': '@vitejs/plugin-basic-ssl':
specifier: ^2.0.0 specifier: ^2.0.0
version: 2.0.0(vite@6.3.3(@types/node@22.15.2)(tsx@4.19.3)) version: 2.0.0(vite@6.3.3(@types/node@22.15.3)(tsx@4.19.3))
cookie: cookie:
specifier: ^1.0.2 specifier: ^1.0.2
version: 1.0.2 version: 1.0.2
@ -69,8 +69,8 @@ importers:
specifier: ^4.17.21 specifier: ^4.17.21
version: 4.17.21 version: 4.17.21
openai: openai:
specifier: ^4.96.0 specifier: 4.96.2
version: 4.96.0(ws@8.18.1)(zod@3.24.2) version: 4.96.2(ws@8.18.1)(zod@3.24.2)
pino: pino:
specifier: ^9.6.0 specifier: ^9.6.0
version: 9.6.0 version: 9.6.0
@ -84,11 +84,11 @@ importers:
specifier: ^6.0.1 specifier: ^6.0.1
version: 6.0.1 version: 6.0.1
rollup: rollup:
specifier: ^4.40.0 specifier: ^4.40.1
version: 4.40.0 version: 4.40.1
rollup-plugin-dts: rollup-plugin-dts:
specifier: ^6.2.1 specifier: ^6.2.1
version: 6.2.1(rollup@4.40.0)(typescript@5.8.3) version: 6.2.1(rollup@4.40.1)(typescript@5.8.3)
sequelize: sequelize:
specifier: ^6.37.7 specifier: ^6.37.7
version: 6.37.7(pg@8.14.1) version: 6.37.7(pg@8.14.1)
@ -103,7 +103,7 @@ importers:
version: 5.8.3 version: 5.8.3
vite: vite:
specifier: ^6.3.3 specifier: ^6.3.3
version: 6.3.3(@types/node@22.15.2)(tsx@4.19.3) version: 6.3.3(@types/node@22.15.3)(tsx@4.19.3)
packages: packages:
@ -304,8 +304,8 @@ packages:
'@kevisual/router@0.0.7': '@kevisual/router@0.0.7':
resolution: {integrity: sha512-4n1Tp4YLoraJv7jtfy7jbuLGyAj0B2QkTlnlEDHCUTlEUOvOkjtf7DHAe2SL92fTgXhSbod0I/0vUcDF85oj/w==} resolution: {integrity: sha512-4n1Tp4YLoraJv7jtfy7jbuLGyAj0B2QkTlnlEDHCUTlEUOvOkjtf7DHAe2SL92fTgXhSbod0I/0vUcDF85oj/w==}
'@kevisual/types@0.0.6': '@kevisual/types@0.0.9':
resolution: {integrity: sha512-7yxe1QmuC5g7lI/1Hm+zXly8if0z+ZqGM1SVOVv2VNRwRAVYBJDc365zWCCfRwE+5YaB2daWTe5zBOU4EkltkQ==} resolution: {integrity: sha512-SDJ7GMbOx7Ghz2kreHqym56ccAJS3t93y+NS0+afTLxcq2+cKcoEy2F8WXEv0mnJ6EsDp5AbA7Jv5TZA1Jbc3A==}
'@kevisual/use-config@1.0.11': '@kevisual/use-config@1.0.11':
resolution: {integrity: sha512-ccilQTRZTpO075L67ZBXhr8Lp3i73/W5cCMT5enMjVrnJT5K0i5JH5IbzBhF6WY5Rj8dmVsAyyjJe24ClyM7Eg==} resolution: {integrity: sha512-ccilQTRZTpO075L67ZBXhr8Lp3i73/W5cCMT5enMjVrnJT5K0i5JH5IbzBhF6WY5Rj8dmVsAyyjJe24ClyM7Eg==}
@ -420,103 +420,114 @@ packages:
rollup: rollup:
optional: true optional: true
'@rollup/rollup-android-arm-eabi@4.40.0': '@rollup/rollup-android-arm-eabi@4.40.1':
resolution: {integrity: sha512-+Fbls/diZ0RDerhE8kyC6hjADCXA1K4yVNlH0EYfd2XjyH0UGgzaQ8MlT0pCXAThfxv3QUAczHaL+qSv1E4/Cg==} resolution: {integrity: sha512-kxz0YeeCrRUHz3zyqvd7n+TVRlNyTifBsmnmNPtk3hQURUyG9eAB+usz6DAwagMusjx/zb3AjvDUvhFGDAexGw==}
cpu: [arm] cpu: [arm]
os: [android] os: [android]
'@rollup/rollup-android-arm64@4.40.0': '@rollup/rollup-android-arm64@4.40.1':
resolution: {integrity: sha512-PPA6aEEsTPRz+/4xxAmaoWDqh67N7wFbgFUJGMnanCFs0TV99M0M8QhhaSCks+n6EbQoFvLQgYOGXxlMGQe/6w==} resolution: {integrity: sha512-PPkxTOisoNC6TpnDKatjKkjRMsdaWIhyuMkA4UsBXT9WEZY4uHezBTjs6Vl4PbqQQeu6oION1w2voYZv9yquCw==}
cpu: [arm64] cpu: [arm64]
os: [android] os: [android]
'@rollup/rollup-darwin-arm64@4.40.0': '@rollup/rollup-darwin-arm64@4.40.1':
resolution: {integrity: sha512-GwYOcOakYHdfnjjKwqpTGgn5a6cUX7+Ra2HeNj/GdXvO2VJOOXCiYYlRFU4CubFM67EhbmzLOmACKEfvp3J1kQ==} resolution: {integrity: sha512-VWXGISWFY18v/0JyNUy4A46KCFCb9NVsH+1100XP31lud+TzlezBbz24CYzbnA4x6w4hx+NYCXDfnvDVO6lcAA==}
cpu: [arm64] cpu: [arm64]
os: [darwin] os: [darwin]
'@rollup/rollup-darwin-x64@4.40.0': '@rollup/rollup-darwin-x64@4.40.1':
resolution: {integrity: sha512-CoLEGJ+2eheqD9KBSxmma6ld01czS52Iw0e2qMZNpPDlf7Z9mj8xmMemxEucinev4LgHalDPczMyxzbq+Q+EtA==} resolution: {integrity: sha512-nIwkXafAI1/QCS7pxSpv/ZtFW6TXcNUEHAIA9EIyw5OzxJZQ1YDrX+CL6JAIQgZ33CInl1R6mHet9Y/UZTg2Bw==}
cpu: [x64] cpu: [x64]
os: [darwin] os: [darwin]
'@rollup/rollup-freebsd-arm64@4.40.0': '@rollup/rollup-freebsd-arm64@4.40.1':
resolution: {integrity: sha512-r7yGiS4HN/kibvESzmrOB/PxKMhPTlz+FcGvoUIKYoTyGd5toHp48g1uZy1o1xQvybwwpqpe010JrcGG2s5nkg==} resolution: {integrity: sha512-BdrLJ2mHTrIYdaS2I99mriyJfGGenSaP+UwGi1kB9BLOCu9SR8ZpbkmmalKIALnRw24kM7qCN0IOm6L0S44iWw==}
cpu: [arm64] cpu: [arm64]
os: [freebsd] os: [freebsd]
'@rollup/rollup-freebsd-x64@4.40.0': '@rollup/rollup-freebsd-x64@4.40.1':
resolution: {integrity: sha512-mVDxzlf0oLzV3oZOr0SMJ0lSDd3xC4CmnWJ8Val8isp9jRGl5Dq//LLDSPFrasS7pSm6m5xAcKaw3sHXhBjoRw==} resolution: {integrity: sha512-VXeo/puqvCG8JBPNZXZf5Dqq7BzElNJzHRRw3vjBE27WujdzuOPecDPc/+1DcdcTptNBep3861jNq0mYkT8Z6Q==}
cpu: [x64] cpu: [x64]
os: [freebsd] os: [freebsd]
'@rollup/rollup-linux-arm-gnueabihf@4.40.0': '@rollup/rollup-linux-arm-gnueabihf@4.40.1':
resolution: {integrity: sha512-y/qUMOpJxBMy8xCXD++jeu8t7kzjlOCkoxxajL58G62PJGBZVl/Gwpm7JK9+YvlB701rcQTzjUZ1JgUoPTnoQA==} resolution: {integrity: sha512-ehSKrewwsESPt1TgSE/na9nIhWCosfGSFqv7vwEtjyAqZcvbGIg4JAcV7ZEh2tfj/IlfBeZjgOXm35iOOjadcg==}
cpu: [arm] cpu: [arm]
os: [linux] os: [linux]
libc: [glibc]
'@rollup/rollup-linux-arm-musleabihf@4.40.0': '@rollup/rollup-linux-arm-musleabihf@4.40.1':
resolution: {integrity: sha512-GoCsPibtVdJFPv/BOIvBKO/XmwZLwaNWdyD8TKlXuqp0veo2sHE+A/vpMQ5iSArRUz/uaoj4h5S6Pn0+PdhRjg==} resolution: {integrity: sha512-m39iO/aaurh5FVIu/F4/Zsl8xppd76S4qoID8E+dSRQvTyZTOI2gVk3T4oqzfq1PtcvOfAVlwLMK3KRQMaR8lg==}
cpu: [arm] cpu: [arm]
os: [linux] os: [linux]
libc: [musl]
'@rollup/rollup-linux-arm64-gnu@4.40.0': '@rollup/rollup-linux-arm64-gnu@4.40.1':
resolution: {integrity: sha512-L5ZLphTjjAD9leJzSLI7rr8fNqJMlGDKlazW2tX4IUF9P7R5TMQPElpH82Q7eNIDQnQlAyiNVfRPfP2vM5Avvg==} resolution: {integrity: sha512-Y+GHnGaku4aVLSgrT0uWe2o2Rq8te9hi+MwqGF9r9ORgXhmHK5Q71N757u0F8yU1OIwUIFy6YiJtKjtyktk5hg==}
cpu: [arm64] cpu: [arm64]
os: [linux] os: [linux]
libc: [glibc]
'@rollup/rollup-linux-arm64-musl@4.40.0': '@rollup/rollup-linux-arm64-musl@4.40.1':
resolution: {integrity: sha512-ATZvCRGCDtv1Y4gpDIXsS+wfFeFuLwVxyUBSLawjgXK2tRE6fnsQEkE4csQQYWlBlsFztRzCnBvWVfcae/1qxQ==} resolution: {integrity: sha512-jEwjn3jCA+tQGswK3aEWcD09/7M5wGwc6+flhva7dsQNRZZTe30vkalgIzV4tjkopsTS9Jd7Y1Bsj6a4lzz8gQ==}
cpu: [arm64] cpu: [arm64]
os: [linux] os: [linux]
libc: [musl]
'@rollup/rollup-linux-loongarch64-gnu@4.40.0': '@rollup/rollup-linux-loongarch64-gnu@4.40.1':
resolution: {integrity: sha512-wG9e2XtIhd++QugU5MD9i7OnpaVb08ji3P1y/hNbxrQ3sYEelKJOq1UJ5dXczeo6Hj2rfDEL5GdtkMSVLa/AOg==} resolution: {integrity: sha512-ySyWikVhNzv+BV/IDCsrraOAZ3UaC8SZB67FZlqVwXwnFhPihOso9rPOxzZbjp81suB1O2Topw+6Ug3JNegejQ==}
cpu: [loong64] cpu: [loong64]
os: [linux] os: [linux]
libc: [glibc]
'@rollup/rollup-linux-powerpc64le-gnu@4.40.0': '@rollup/rollup-linux-powerpc64le-gnu@4.40.1':
resolution: {integrity: sha512-vgXfWmj0f3jAUvC7TZSU/m/cOE558ILWDzS7jBhiCAFpY2WEBn5jqgbqvmzlMjtp8KlLcBlXVD2mkTSEQE6Ixw==} resolution: {integrity: sha512-BvvA64QxZlh7WZWqDPPdt0GH4bznuL6uOO1pmgPnnv86rpUpc8ZxgZwcEgXvo02GRIZX1hQ0j0pAnhwkhwPqWg==}
cpu: [ppc64] cpu: [ppc64]
os: [linux] os: [linux]
libc: [glibc]
'@rollup/rollup-linux-riscv64-gnu@4.40.0': '@rollup/rollup-linux-riscv64-gnu@4.40.1':
resolution: {integrity: sha512-uJkYTugqtPZBS3Z136arevt/FsKTF/J9dEMTX/cwR7lsAW4bShzI2R0pJVw+hcBTWF4dxVckYh72Hk3/hWNKvA==} resolution: {integrity: sha512-EQSP+8+1VuSulm9RKSMKitTav89fKbHymTf25n5+Yr6gAPZxYWpj3DzAsQqoaHAk9YX2lwEyAf9S4W8F4l3VBQ==}
cpu: [riscv64] cpu: [riscv64]
os: [linux] os: [linux]
libc: [glibc]
'@rollup/rollup-linux-riscv64-musl@4.40.0': '@rollup/rollup-linux-riscv64-musl@4.40.1':
resolution: {integrity: sha512-rKmSj6EXQRnhSkE22+WvrqOqRtk733x3p5sWpZilhmjnkHkpeCgWsFFo0dGnUGeA+OZjRl3+VYq+HyCOEuwcxQ==} resolution: {integrity: sha512-n/vQ4xRZXKuIpqukkMXZt9RWdl+2zgGNx7Uda8NtmLJ06NL8jiHxUawbwC+hdSq1rrw/9CghCpEONor+l1e2gA==}
cpu: [riscv64] cpu: [riscv64]
os: [linux] os: [linux]
libc: [musl]
'@rollup/rollup-linux-s390x-gnu@4.40.0': '@rollup/rollup-linux-s390x-gnu@4.40.1':
resolution: {integrity: sha512-SpnYlAfKPOoVsQqmTFJ0usx0z84bzGOS9anAC0AZ3rdSo3snecihbhFTlJZ8XMwzqAcodjFU4+/SM311dqE5Sw==} resolution: {integrity: sha512-h8d28xzYb98fMQKUz0w2fMc1XuGzLLjdyxVIbhbil4ELfk5/orZlSTpF/xdI9C8K0I8lCkq+1En2RJsawZekkg==}
cpu: [s390x] cpu: [s390x]
os: [linux] os: [linux]
libc: [glibc]
'@rollup/rollup-linux-x64-gnu@4.40.0': '@rollup/rollup-linux-x64-gnu@4.40.1':
resolution: {integrity: sha512-RcDGMtqF9EFN8i2RYN2W+64CdHruJ5rPqrlYw+cgM3uOVPSsnAQps7cpjXe9be/yDp8UC7VLoCoKC8J3Kn2FkQ==} resolution: {integrity: sha512-XiK5z70PEFEFqcNj3/zRSz/qX4bp4QIraTy9QjwJAb/Z8GM7kVUsD0Uk8maIPeTyPCP03ChdI+VVmJriKYbRHQ==}
cpu: [x64] cpu: [x64]
os: [linux] os: [linux]
libc: [glibc]
'@rollup/rollup-linux-x64-musl@4.40.0': '@rollup/rollup-linux-x64-musl@4.40.1':
resolution: {integrity: sha512-HZvjpiUmSNx5zFgwtQAV1GaGazT2RWvqeDi0hV+AtC8unqqDSsaFjPxfsO6qPtKRRg25SisACWnJ37Yio8ttaw==} resolution: {integrity: sha512-2BRORitq5rQ4Da9blVovzNCMaUlyKrzMSvkVR0D4qPuOy/+pMCrh1d7o01RATwVy+6Fa1WBw+da7QPeLWU/1mQ==}
cpu: [x64] cpu: [x64]
os: [linux] os: [linux]
libc: [musl]
'@rollup/rollup-win32-arm64-msvc@4.40.0': '@rollup/rollup-win32-arm64-msvc@4.40.1':
resolution: {integrity: sha512-UtZQQI5k/b8d7d3i9AZmA/t+Q4tk3hOC0tMOMSq2GlMYOfxbesxG4mJSeDp0EHs30N9bsfwUvs3zF4v/RzOeTQ==} resolution: {integrity: sha512-b2bcNm9Kbde03H+q+Jjw9tSfhYkzrDUf2d5MAd1bOJuVplXvFhWz7tRtWvD8/ORZi7qSCy0idW6tf2HgxSXQSg==}
cpu: [arm64] cpu: [arm64]
os: [win32] os: [win32]
'@rollup/rollup-win32-ia32-msvc@4.40.0': '@rollup/rollup-win32-ia32-msvc@4.40.1':
resolution: {integrity: sha512-+m03kvI2f5syIqHXCZLPVYplP8pQch9JHyXKZ3AGMKlg8dCyr2PKHjwRLiW53LTrN/Nc3EqHOKxUxzoSPdKddA==} resolution: {integrity: sha512-DfcogW8N7Zg7llVEfpqWMZcaErKfsj9VvmfSyRjCyo4BI3wPEfrzTtJkZG6gKP/Z92wFm6rz2aDO7/JfiR/whA==}
cpu: [ia32] cpu: [ia32]
os: [win32] os: [win32]
'@rollup/rollup-win32-x64-msvc@4.40.0': '@rollup/rollup-win32-x64-msvc@4.40.1':
resolution: {integrity: sha512-lpPE1cLfP5oPzVjKMx10pgBmKELQnFJXHgvtHCtuJWOv8MxqdEIMNtgHgBFf7Ea2/7EuVwa9fodWUfXAlXZLZQ==} resolution: {integrity: sha512-ECyOuDeH3C1I8jH2MK1RtBJW+YPMvSfT0a5NN0nHfQYnDSJ6tUiZH3gzwVP5/Kfh/+Tt7tpWVF9LXNTnhTJ3kA==}
cpu: [x64] cpu: [x64]
os: [win32] os: [win32]
@ -526,8 +537,8 @@ packages:
'@tootallnate/quickjs-emscripten@0.23.0': '@tootallnate/quickjs-emscripten@0.23.0':
resolution: {integrity: sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==} resolution: {integrity: sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==}
'@types/bun@1.2.10': '@types/bun@1.2.11':
resolution: {integrity: sha512-eilv6WFM3M0c9ztJt7/g80BDusK98z/FrFwseZgT4bXCq2vPhXD4z8R3oddmAn+R/Nmz9vBn4kweJKmGTZj+lg==} resolution: {integrity: sha512-ZLbbI91EmmGwlWTRWuV6J19IUiUC5YQ3TCEuSHI3usIP75kuoA8/0PVF+LTrbEnVc8JIhpElWOxv1ocI1fJBbw==}
'@types/cors@2.8.17': '@types/cors@2.8.17':
resolution: {integrity: sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==} resolution: {integrity: sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==}
@ -571,8 +582,8 @@ packages:
'@types/node@18.19.86': '@types/node@18.19.86':
resolution: {integrity: sha512-fifKayi175wLyKyc5qUfyENhQ1dCNI1UNjp653d8kuYcPQN5JhX3dGuP/XmvPTg/xRBn1VTLpbmi+H/Mr7tLfQ==} resolution: {integrity: sha512-fifKayi175wLyKyc5qUfyENhQ1dCNI1UNjp653d8kuYcPQN5JhX3dGuP/XmvPTg/xRBn1VTLpbmi+H/Mr7tLfQ==}
'@types/node@22.15.2': '@types/node@22.15.3':
resolution: {integrity: sha512-uKXqKN9beGoMdBfcaTY1ecwz6ctxuJAcUlwE55938g0ZJ8lRxwAZqRz2AJ4pzpt5dHdTPMB863UZ0ESiFUcP7A==} resolution: {integrity: sha512-lX7HFZeHf4QG/J7tBZqrCAXwz9J5RD56Y6MpP0eJkka8p+K0RY/yBTW7CYFJ4VGCclxqOLKmiGP5juQc6MKgcw==}
'@types/resolve@1.20.2': '@types/resolve@1.20.2':
resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==}
@ -715,8 +726,8 @@ packages:
buffer-from@1.1.2: buffer-from@1.1.2:
resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==}
bun-types@1.2.10: bun-types@1.2.11:
resolution: {integrity: sha512-b5ITZMnVdf3m1gMvJHG+gIfeJHiQPJak0f7925Hxu6ZN5VKA8AGy4GZ4lM+Xkn6jtWxg5S3ldWvfmXdvnkp3GQ==} resolution: {integrity: sha512-dbkp5Lo8HDrXkLrONm6bk+yiiYQSntvFUzQp0v3pzTAsXk6FtgVMjdQ+lzFNVAmQFUkPQZ3WMZqH5tTo+Dp/IA==}
call-bind-apply-helpers@1.0.2: call-bind-apply-helpers@1.0.2:
resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==} resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==}
@ -1573,8 +1584,8 @@ packages:
once@1.4.0: once@1.4.0:
resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}
openai@4.96.0: openai@4.96.2:
resolution: {integrity: sha512-dKoW56i02Prv2XQolJ9Rl9Svqubqkzg3QpwEOBuSVZLk05Shelu7s+ErRTwFc1Bs3JZ2qBqBfVpXQiJhwOGG8A==} resolution: {integrity: sha512-R2XnxvMsizkROr7BV3uNp1q/3skwPZ7fmPjO1bXLnfB4Tu5xKxrT1EVwzjhxn0MZKBKAvOaGWS63jTMN6KrIXA==}
hasBin: true hasBin: true
peerDependencies: peerDependencies:
ws: ^8.18.0 ws: ^8.18.0
@ -1846,8 +1857,8 @@ packages:
rollup-pluginutils@2.8.2: rollup-pluginutils@2.8.2:
resolution: {integrity: sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==} resolution: {integrity: sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==}
rollup@4.40.0: rollup@4.40.1:
resolution: {integrity: sha512-Noe455xmA96nnqH5piFtLobsGbCij7Tu+tb3c1vYjNbTkfzGqXqQXG3wJaYXkRZuQ0vEYN4bhwg7QnIrqB5B+w==} resolution: {integrity: sha512-C5VvvgCCyfyotVITIAv+4efVytl5F7wt+/I2i9q9GZcEXW9BP52YYOXC58igUi+LFZVHukErIIqQSWwv/M3WRw==}
engines: {node: '>=18.0.0', npm: '>=8.0.0'} engines: {node: '>=18.0.0', npm: '>=8.0.0'}
hasBin: true hasBin: true
@ -2468,20 +2479,20 @@ snapshots:
'@kevisual/rollup-tools@0.0.1(esbuild@0.25.2)': '@kevisual/rollup-tools@0.0.1(esbuild@0.25.2)':
dependencies: dependencies:
'@rollup/plugin-alias': 5.1.1(rollup@4.40.0) '@rollup/plugin-alias': 5.1.1(rollup@4.40.1)
'@rollup/plugin-commonjs': 28.0.3(rollup@4.40.0) '@rollup/plugin-commonjs': 28.0.3(rollup@4.40.1)
'@rollup/plugin-json': 6.1.0(rollup@4.40.0) '@rollup/plugin-json': 6.1.0(rollup@4.40.1)
'@rollup/plugin-node-resolve': 15.3.1(rollup@4.40.0) '@rollup/plugin-node-resolve': 15.3.1(rollup@4.40.1)
'@rollup/plugin-replace': 6.0.2(rollup@4.40.0) '@rollup/plugin-replace': 6.0.2(rollup@4.40.1)
'@rollup/plugin-typescript': 12.1.2(rollup@4.40.0)(tslib@2.8.1)(typescript@5.8.3) '@rollup/plugin-typescript': 12.1.2(rollup@4.40.1)(tslib@2.8.1)(typescript@5.8.3)
'@types/node': 22.15.2 '@types/node': 22.15.3
chalk: 5.4.1 chalk: 5.4.1
commander: 12.1.0 commander: 12.1.0
glob: 11.0.1 glob: 11.0.1
rollup: 4.40.0 rollup: 4.40.1
rollup-plugin-copy: 3.5.0 rollup-plugin-copy: 3.5.0
rollup-plugin-dts: 6.2.1(rollup@4.40.0)(typescript@5.8.3) rollup-plugin-dts: 6.2.1(rollup@4.40.1)(typescript@5.8.3)
rollup-plugin-esbuild: 6.2.1(esbuild@0.25.2)(rollup@4.40.0) rollup-plugin-esbuild: 6.2.1(esbuild@0.25.2)(rollup@4.40.1)
rollup-plugin-inject: 3.0.2 rollup-plugin-inject: 3.0.2
tslib: 2.8.1 tslib: 2.8.1
typescript: 5.8.3 typescript: 5.8.3
@ -2503,7 +2514,7 @@ snapshots:
- bufferutil - bufferutil
- utf-8-validate - utf-8-validate
'@kevisual/types@0.0.6': {} '@kevisual/types@0.0.9': {}
'@kevisual/use-config@1.0.11(dotenv@16.5.0)': '@kevisual/use-config@1.0.11(dotenv@16.5.0)':
dependencies: dependencies:
@ -2587,13 +2598,13 @@ snapshots:
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
'@rollup/plugin-alias@5.1.1(rollup@4.40.0)': '@rollup/plugin-alias@5.1.1(rollup@4.40.1)':
optionalDependencies: optionalDependencies:
rollup: 4.40.0 rollup: 4.40.1
'@rollup/plugin-commonjs@28.0.3(rollup@4.40.0)': '@rollup/plugin-commonjs@28.0.3(rollup@4.40.1)':
dependencies: dependencies:
'@rollup/pluginutils': 5.1.4(rollup@4.40.0) '@rollup/pluginutils': 5.1.4(rollup@4.40.1)
commondir: 1.0.1 commondir: 1.0.1
estree-walker: 2.0.2 estree-walker: 2.0.2
fdir: 6.4.3(picomatch@4.0.2) fdir: 6.4.3(picomatch@4.0.2)
@ -2601,119 +2612,119 @@ snapshots:
magic-string: 0.30.17 magic-string: 0.30.17
picomatch: 4.0.2 picomatch: 4.0.2
optionalDependencies: optionalDependencies:
rollup: 4.40.0 rollup: 4.40.1
'@rollup/plugin-json@6.1.0(rollup@4.40.0)': '@rollup/plugin-json@6.1.0(rollup@4.40.1)':
dependencies: dependencies:
'@rollup/pluginutils': 5.1.4(rollup@4.40.0) '@rollup/pluginutils': 5.1.4(rollup@4.40.1)
optionalDependencies: optionalDependencies:
rollup: 4.40.0 rollup: 4.40.1
'@rollup/plugin-node-resolve@15.3.1(rollup@4.40.0)': '@rollup/plugin-node-resolve@15.3.1(rollup@4.40.1)':
dependencies: dependencies:
'@rollup/pluginutils': 5.1.4(rollup@4.40.0) '@rollup/pluginutils': 5.1.4(rollup@4.40.1)
'@types/resolve': 1.20.2 '@types/resolve': 1.20.2
deepmerge: 4.3.1 deepmerge: 4.3.1
is-module: 1.0.0 is-module: 1.0.0
resolve: 1.22.10 resolve: 1.22.10
optionalDependencies: optionalDependencies:
rollup: 4.40.0 rollup: 4.40.1
'@rollup/plugin-replace@6.0.2(rollup@4.40.0)': '@rollup/plugin-replace@6.0.2(rollup@4.40.1)':
dependencies: dependencies:
'@rollup/pluginutils': 5.1.4(rollup@4.40.0) '@rollup/pluginutils': 5.1.4(rollup@4.40.1)
magic-string: 0.30.17 magic-string: 0.30.17
optionalDependencies: optionalDependencies:
rollup: 4.40.0 rollup: 4.40.1
'@rollup/plugin-typescript@12.1.2(rollup@4.40.0)(tslib@2.8.1)(typescript@5.8.3)': '@rollup/plugin-typescript@12.1.2(rollup@4.40.1)(tslib@2.8.1)(typescript@5.8.3)':
dependencies: dependencies:
'@rollup/pluginutils': 5.1.4(rollup@4.40.0) '@rollup/pluginutils': 5.1.4(rollup@4.40.1)
resolve: 1.22.10 resolve: 1.22.10
typescript: 5.8.3 typescript: 5.8.3
optionalDependencies: optionalDependencies:
rollup: 4.40.0 rollup: 4.40.1
tslib: 2.8.1 tslib: 2.8.1
'@rollup/pluginutils@5.1.4(rollup@4.40.0)': '@rollup/pluginutils@5.1.4(rollup@4.40.1)':
dependencies: dependencies:
'@types/estree': 1.0.7 '@types/estree': 1.0.7
estree-walker: 2.0.2 estree-walker: 2.0.2
picomatch: 4.0.2 picomatch: 4.0.2
optionalDependencies: optionalDependencies:
rollup: 4.40.0 rollup: 4.40.1
'@rollup/rollup-android-arm-eabi@4.40.0': '@rollup/rollup-android-arm-eabi@4.40.1':
optional: true optional: true
'@rollup/rollup-android-arm64@4.40.0': '@rollup/rollup-android-arm64@4.40.1':
optional: true optional: true
'@rollup/rollup-darwin-arm64@4.40.0': '@rollup/rollup-darwin-arm64@4.40.1':
optional: true optional: true
'@rollup/rollup-darwin-x64@4.40.0': '@rollup/rollup-darwin-x64@4.40.1':
optional: true optional: true
'@rollup/rollup-freebsd-arm64@4.40.0': '@rollup/rollup-freebsd-arm64@4.40.1':
optional: true optional: true
'@rollup/rollup-freebsd-x64@4.40.0': '@rollup/rollup-freebsd-x64@4.40.1':
optional: true optional: true
'@rollup/rollup-linux-arm-gnueabihf@4.40.0': '@rollup/rollup-linux-arm-gnueabihf@4.40.1':
optional: true optional: true
'@rollup/rollup-linux-arm-musleabihf@4.40.0': '@rollup/rollup-linux-arm-musleabihf@4.40.1':
optional: true optional: true
'@rollup/rollup-linux-arm64-gnu@4.40.0': '@rollup/rollup-linux-arm64-gnu@4.40.1':
optional: true optional: true
'@rollup/rollup-linux-arm64-musl@4.40.0': '@rollup/rollup-linux-arm64-musl@4.40.1':
optional: true optional: true
'@rollup/rollup-linux-loongarch64-gnu@4.40.0': '@rollup/rollup-linux-loongarch64-gnu@4.40.1':
optional: true optional: true
'@rollup/rollup-linux-powerpc64le-gnu@4.40.0': '@rollup/rollup-linux-powerpc64le-gnu@4.40.1':
optional: true optional: true
'@rollup/rollup-linux-riscv64-gnu@4.40.0': '@rollup/rollup-linux-riscv64-gnu@4.40.1':
optional: true optional: true
'@rollup/rollup-linux-riscv64-musl@4.40.0': '@rollup/rollup-linux-riscv64-musl@4.40.1':
optional: true optional: true
'@rollup/rollup-linux-s390x-gnu@4.40.0': '@rollup/rollup-linux-s390x-gnu@4.40.1':
optional: true optional: true
'@rollup/rollup-linux-x64-gnu@4.40.0': '@rollup/rollup-linux-x64-gnu@4.40.1':
optional: true optional: true
'@rollup/rollup-linux-x64-musl@4.40.0': '@rollup/rollup-linux-x64-musl@4.40.1':
optional: true optional: true
'@rollup/rollup-win32-arm64-msvc@4.40.0': '@rollup/rollup-win32-arm64-msvc@4.40.1':
optional: true optional: true
'@rollup/rollup-win32-ia32-msvc@4.40.0': '@rollup/rollup-win32-ia32-msvc@4.40.1':
optional: true optional: true
'@rollup/rollup-win32-x64-msvc@4.40.0': '@rollup/rollup-win32-x64-msvc@4.40.1':
optional: true optional: true
'@socket.io/component-emitter@3.1.2': {} '@socket.io/component-emitter@3.1.2': {}
'@tootallnate/quickjs-emscripten@0.23.0': {} '@tootallnate/quickjs-emscripten@0.23.0': {}
'@types/bun@1.2.10': '@types/bun@1.2.11':
dependencies: dependencies:
bun-types: 1.2.10 bun-types: 1.2.11
'@types/cors@2.8.17': '@types/cors@2.8.17':
dependencies: dependencies:
'@types/node': 22.15.2 '@types/node': 22.15.3
'@types/crypto-js@4.2.2': {} '@types/crypto-js@4.2.2': {}
@ -2725,16 +2736,16 @@ snapshots:
'@types/formidable@3.4.5': '@types/formidable@3.4.5':
dependencies: dependencies:
'@types/node': 22.15.2 '@types/node': 22.15.3
'@types/fs-extra@8.1.5': '@types/fs-extra@8.1.5':
dependencies: dependencies:
'@types/node': 22.15.2 '@types/node': 22.15.3
'@types/glob@7.2.0': '@types/glob@7.2.0':
dependencies: dependencies:
'@types/minimatch': 5.1.2 '@types/minimatch': 5.1.2
'@types/node': 22.15.2 '@types/node': 22.15.3
'@types/lodash-es@4.17.12': '@types/lodash-es@4.17.12':
dependencies: dependencies:
@ -2748,18 +2759,18 @@ snapshots:
'@types/node-fetch@2.6.12': '@types/node-fetch@2.6.12':
dependencies: dependencies:
'@types/node': 22.15.2 '@types/node': 22.15.3
form-data: 4.0.2 form-data: 4.0.2
'@types/node-forge@1.3.11': '@types/node-forge@1.3.11':
dependencies: dependencies:
'@types/node': 22.15.2 '@types/node': 22.15.3
'@types/node@18.19.86': '@types/node@18.19.86':
dependencies: dependencies:
undici-types: 5.26.5 undici-types: 5.26.5
'@types/node@22.15.2': '@types/node@22.15.3':
dependencies: dependencies:
undici-types: 6.21.0 undici-types: 6.21.0
@ -2767,9 +2778,9 @@ snapshots:
'@types/validator@13.12.3': {} '@types/validator@13.12.3': {}
'@vitejs/plugin-basic-ssl@2.0.0(vite@6.3.3(@types/node@22.15.2)(tsx@4.19.3))': '@vitejs/plugin-basic-ssl@2.0.0(vite@6.3.3(@types/node@22.15.3)(tsx@4.19.3))':
dependencies: dependencies:
vite: 6.3.3(@types/node@22.15.2)(tsx@4.19.3) vite: 6.3.3(@types/node@22.15.3)(tsx@4.19.3)
abort-controller@3.0.0: abort-controller@3.0.0:
dependencies: dependencies:
@ -2885,9 +2896,9 @@ snapshots:
buffer-from@1.1.2: {} buffer-from@1.1.2: {}
bun-types@1.2.10: bun-types@1.2.11:
dependencies: dependencies:
'@types/node': 22.15.2 '@types/node': 22.15.3
call-bind-apply-helpers@1.0.2: call-bind-apply-helpers@1.0.2:
dependencies: dependencies:
@ -3103,7 +3114,7 @@ snapshots:
engine.io@6.6.4: engine.io@6.6.4:
dependencies: dependencies:
'@types/cors': 2.8.17 '@types/cors': 2.8.17
'@types/node': 22.15.2 '@types/node': 22.15.3
accepts: 1.3.8 accepts: 1.3.8
base64id: 2.0.0 base64id: 2.0.0
cookie: 0.7.2 cookie: 0.7.2
@ -3824,7 +3835,7 @@ snapshots:
dependencies: dependencies:
wrappy: 1.0.2 wrappy: 1.0.2
openai@4.96.0(ws@8.18.1)(zod@3.24.2): openai@4.96.2(ws@8.18.1)(zod@3.24.2):
dependencies: dependencies:
'@types/node': 18.19.86 '@types/node': 18.19.86
'@types/node-fetch': 2.6.12 '@types/node-fetch': 2.6.12
@ -4166,21 +4177,21 @@ snapshots:
globby: 10.0.1 globby: 10.0.1
is-plain-object: 3.0.1 is-plain-object: 3.0.1
rollup-plugin-dts@6.2.1(rollup@4.40.0)(typescript@5.8.3): rollup-plugin-dts@6.2.1(rollup@4.40.1)(typescript@5.8.3):
dependencies: dependencies:
magic-string: 0.30.17 magic-string: 0.30.17
rollup: 4.40.0 rollup: 4.40.1
typescript: 5.8.3 typescript: 5.8.3
optionalDependencies: optionalDependencies:
'@babel/code-frame': 7.26.2 '@babel/code-frame': 7.26.2
rollup-plugin-esbuild@6.2.1(esbuild@0.25.2)(rollup@4.40.0): rollup-plugin-esbuild@6.2.1(esbuild@0.25.2)(rollup@4.40.1):
dependencies: dependencies:
debug: 4.4.0 debug: 4.4.0
es-module-lexer: 1.6.0 es-module-lexer: 1.6.0
esbuild: 0.25.2 esbuild: 0.25.2
get-tsconfig: 4.10.0 get-tsconfig: 4.10.0
rollup: 4.40.0 rollup: 4.40.1
unplugin-utils: 0.2.4 unplugin-utils: 0.2.4
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
@ -4195,30 +4206,30 @@ snapshots:
dependencies: dependencies:
estree-walker: 0.6.1 estree-walker: 0.6.1
rollup@4.40.0: rollup@4.40.1:
dependencies: dependencies:
'@types/estree': 1.0.7 '@types/estree': 1.0.7
optionalDependencies: optionalDependencies:
'@rollup/rollup-android-arm-eabi': 4.40.0 '@rollup/rollup-android-arm-eabi': 4.40.1
'@rollup/rollup-android-arm64': 4.40.0 '@rollup/rollup-android-arm64': 4.40.1
'@rollup/rollup-darwin-arm64': 4.40.0 '@rollup/rollup-darwin-arm64': 4.40.1
'@rollup/rollup-darwin-x64': 4.40.0 '@rollup/rollup-darwin-x64': 4.40.1
'@rollup/rollup-freebsd-arm64': 4.40.0 '@rollup/rollup-freebsd-arm64': 4.40.1
'@rollup/rollup-freebsd-x64': 4.40.0 '@rollup/rollup-freebsd-x64': 4.40.1
'@rollup/rollup-linux-arm-gnueabihf': 4.40.0 '@rollup/rollup-linux-arm-gnueabihf': 4.40.1
'@rollup/rollup-linux-arm-musleabihf': 4.40.0 '@rollup/rollup-linux-arm-musleabihf': 4.40.1
'@rollup/rollup-linux-arm64-gnu': 4.40.0 '@rollup/rollup-linux-arm64-gnu': 4.40.1
'@rollup/rollup-linux-arm64-musl': 4.40.0 '@rollup/rollup-linux-arm64-musl': 4.40.1
'@rollup/rollup-linux-loongarch64-gnu': 4.40.0 '@rollup/rollup-linux-loongarch64-gnu': 4.40.1
'@rollup/rollup-linux-powerpc64le-gnu': 4.40.0 '@rollup/rollup-linux-powerpc64le-gnu': 4.40.1
'@rollup/rollup-linux-riscv64-gnu': 4.40.0 '@rollup/rollup-linux-riscv64-gnu': 4.40.1
'@rollup/rollup-linux-riscv64-musl': 4.40.0 '@rollup/rollup-linux-riscv64-musl': 4.40.1
'@rollup/rollup-linux-s390x-gnu': 4.40.0 '@rollup/rollup-linux-s390x-gnu': 4.40.1
'@rollup/rollup-linux-x64-gnu': 4.40.0 '@rollup/rollup-linux-x64-gnu': 4.40.1
'@rollup/rollup-linux-x64-musl': 4.40.0 '@rollup/rollup-linux-x64-musl': 4.40.1
'@rollup/rollup-win32-arm64-msvc': 4.40.0 '@rollup/rollup-win32-arm64-msvc': 4.40.1
'@rollup/rollup-win32-ia32-msvc': 4.40.0 '@rollup/rollup-win32-ia32-msvc': 4.40.1
'@rollup/rollup-win32-x64-msvc': 4.40.0 '@rollup/rollup-win32-x64-msvc': 4.40.1
fsevents: 2.3.3 fsevents: 2.3.3
run-parallel@1.2.0: run-parallel@1.2.0:
@ -4605,16 +4616,16 @@ snapshots:
vary@1.1.2: {} vary@1.1.2: {}
vite@6.3.3(@types/node@22.15.2)(tsx@4.19.3): vite@6.3.3(@types/node@22.15.3)(tsx@4.19.3):
dependencies: dependencies:
esbuild: 0.25.2 esbuild: 0.25.2
fdir: 6.4.4(picomatch@4.0.2) fdir: 6.4.4(picomatch@4.0.2)
picomatch: 4.0.2 picomatch: 4.0.2
postcss: 8.5.3 postcss: 8.5.3
rollup: 4.40.0 rollup: 4.40.1
tinyglobby: 0.2.13 tinyglobby: 0.2.13
optionalDependencies: optionalDependencies:
'@types/node': 22.15.2 '@types/node': 22.15.3
fsevents: 2.3.3 fsevents: 2.3.3
tsx: 4.19.3 tsx: 4.19.3
@ -4681,7 +4692,7 @@ snapshots:
wkx@0.5.0: wkx@0.5.0:
dependencies: dependencies:
'@types/node': 22.15.2 '@types/node': 22.15.3
wrap-ansi@7.0.0: wrap-ansi@7.0.0:
dependencies: dependencies:

View File

@ -0,0 +1,35 @@
curl --request POST \
--url https://api.siliconflow.cn/v1/chat/completions \
--header 'Authorization: Bearer sk-qbiigkzoaamuqxtwlgkugodncebkfbosemadfubjrseobpvx' \
--header 'Content-Type: application/json' \
--data '{
"model": "Qwen/Qwen3-14B",
"messages": [
{
"role": "user",
"content": "计算a+b的值"
}
],
"stream": false,
"max_tokens": 512,
"stop": null,
"temperature": 0.7,
"top_p": 0.7,
"top_k": 50,
"frequency_penalty": 0.5,
"n": 1,
"response_format": {
"type": "text"
},
"tools": [
{
"type": "function",
"function": {
"description": "计算abc算法的值a=1b=2c=3",
"name": "compouted",
"parameters": {},
"strict": false
}
}
]
}'

116
src/test/func-call/demo.ts Normal file
View File

@ -0,0 +1,116 @@
import { SiliconFlow } from '../../provider/chat-adapter/siliconflow.ts';
import { Ollama } from '../../provider/chat-adapter/ollama.ts';
import dotenv from 'dotenv';
dotenv.config();
const siliconflow = new SiliconFlow({
apiKey: process.env.SILICONFLOW_API_KEY,
model: 'Qwen/Qwen3-14B',
});
const ollama = new Ollama({
model: 'qwen3:32b',
apiKey: process.env.OLLAMA_API_KEY,
baseURL: process.env.OLLAMA_BASE_URL,
});
const main = async () => {
const usage = await siliconflow.getUsageInfo();
console.log(usage);
};
// 1. 定义工具函数
const availableFunctions: Record<string, (args: any) => Promise<any>> = {
get_time: async (args: { location: string }) => {
// 模拟API调用
console.log('time', args);
return {
time: '2022-03-22 12:00:00',
};
},
get_location: async (args: { symbol: string }) => {
// 模拟API调用
console.log('location', args);
return {
city: 'Beijing',
};
},
};
// main();
const funcCall = async (model = siliconflow) => {
const tools = [
{
type: 'function',
function: {
name: 'get_time',
description: '获取当前时间',
parameters: {
type: 'object',
properties: {
place: {
type: 'string',
description: '位置',
},
},
required: ['place'],
},
},
},
{
type: 'function',
function: {
name: 'get_location',
description: '获取当前位置',
// parameters: {},
parameters: {},
strict: false,
},
},
];
const messages: any[] = [{ role: 'user', content: '获取当前位置的当前时间' }];
const res = await model.chat(messages, {
tools: tools as any,
});
console.log(res.choices[0]);
const assistantMessage = res.choices[0].message;
const finish_reason = res.choices[0].finish_reason;
messages.push(assistantMessage);
let toolCalls = assistantMessage.tool_calls;
console.log("toolCalls", JSON.stringify(toolCalls));
let maxRetries = 3;
while (toolCalls && toolCalls.length > 0) {
// 处理每个函数调用
for (const toolCall of toolCalls) {
const functionName = toolCall.function.name;
const functionArgs = JSON.parse(toolCall.function.arguments);
// 调用本地函数
const functionResponse = await availableFunctions[functionName](functionArgs);
// 将结果添加到消息历史
messages.push({
role: 'tool',
name: functionName,
content: JSON.stringify(functionResponse),
tool_call_id: toolCall.id,
});
}
// 第二次调用 - 将函数结果发送给模型获取最终回复
const secondResponse = await model.chat(messages, {
tools: tools as any,
});
const finalMessage = secondResponse.choices[0].message;
messages.push(finalMessage);
const _toolCalls = finalMessage.tool_calls;
console.log("toolCalls", JSON.stringify(toolCalls) ,finalMessage.role);
toolCalls = _toolCalls ? _toolCalls : [];
maxRetries--;
if (maxRetries <= 0) {
break;
}
console.log('tool calls', toolCalls);
}
console.log(messages);
};
funcCall(ollama as any);