Spaces:
Sleeping
Sleeping
feat: improve tool calling & add tools to qwen 2.5 72b (#1615)
Browse files* fix: clean up tool calling
more inline with latest changes in transformers lib and adds tool calling to qwen 2.5 72b
* fix: add more field name options
* fix: make tool calls a bit more robust
- chart/env/prod.yaml +1 -7
- package-lock.json +76 -51
- package.json +3 -3
- src/lib/server/models.ts +7 -20
- src/lib/server/textGeneration/tools.ts +74 -22
- src/lib/server/websearch/search/endpoints/bing.ts +0 -2
chart/env/prod.yaml
CHANGED
|
@@ -50,7 +50,6 @@ envVars:
|
|
| 50 |
[
|
| 51 |
{
|
| 52 |
"name": "Qwen/Qwen2.5-72B-Instruct",
|
| 53 |
-
"tokenizer": "Qwen/Qwen2.5-72B-Instruct",
|
| 54 |
"description": "The latest Qwen open model with improved role-playing, long text generation and structured data understanding.",
|
| 55 |
"modelUrl": "https://huggingface.co/Qwen/Qwen2.5-72B-Instruct",
|
| 56 |
"websiteUrl": "https://qwenlm.github.io/blog/qwen2.5/",
|
|
@@ -62,6 +61,7 @@ envVars:
|
|
| 62 |
"truncate": 28672,
|
| 63 |
"max_new_tokens": 3072
|
| 64 |
},
|
|
|
|
| 65 |
"promptExamples": [
|
| 66 |
{
|
| 67 |
"title": "Write an email from bullet list",
|
|
@@ -80,7 +80,6 @@ envVars:
|
|
| 80 |
{
|
| 81 |
"name": "meta-llama/Meta-Llama-3.1-70B-Instruct",
|
| 82 |
"id": "meta-llama/Meta-Llama-3.1-70B-Instruct",
|
| 83 |
-
"tokenizer": "nsarrazin/llama3.1-tokenizer",
|
| 84 |
"description": "Ideal for everyday use. A fast and extremely capable model matching closed source models' capabilities.",
|
| 85 |
"modelUrl": "https://huggingface.co/meta-llama/Meta-Llama-3.1-70B-Instruct",
|
| 86 |
"websiteUrl": "https://llama.meta.com/",
|
|
@@ -110,7 +109,6 @@ envVars:
|
|
| 110 |
},
|
| 111 |
{
|
| 112 |
"name": "CohereForAI/c4ai-command-r-plus-08-2024",
|
| 113 |
-
"tokenizer": "nsarrazin/c4ai-command-r-v01-tokenizer",
|
| 114 |
"description": "Cohere's largest language model, optimized for conversational interaction and tool use. Now with the 2024 update!",
|
| 115 |
"modelUrl": "https://huggingface.co/CohereForAI/c4ai-command-r-plus-08-2024",
|
| 116 |
"websiteUrl": "https://docs.cohere.com/docs/command-r-plus",
|
|
@@ -350,10 +348,6 @@ envVars:
|
|
| 350 |
},
|
| 351 |
{
|
| 352 |
"name": "llhf/Meta-Llama-3.1-8B-Instruct",
|
| 353 |
-
"tokenizer": {
|
| 354 |
-
"tokenizerUrl": "https://huggingface.co/nsarrazin/llama3.1-tokenizer/resolve/main/tokenizer.json",
|
| 355 |
-
"tokenizerConfigUrl": "https://huggingface.co/nsarrazin/llama3.1-tokenizer/raw/main/tokenizer_config.json"
|
| 356 |
-
},
|
| 357 |
"parameters": {
|
| 358 |
"temperature": 0.6,
|
| 359 |
"stop": ["<|endoftext|>", "<|eot_id|>"]
|
|
|
|
| 50 |
[
|
| 51 |
{
|
| 52 |
"name": "Qwen/Qwen2.5-72B-Instruct",
|
|
|
|
| 53 |
"description": "The latest Qwen open model with improved role-playing, long text generation and structured data understanding.",
|
| 54 |
"modelUrl": "https://huggingface.co/Qwen/Qwen2.5-72B-Instruct",
|
| 55 |
"websiteUrl": "https://qwenlm.github.io/blog/qwen2.5/",
|
|
|
|
| 61 |
"truncate": 28672,
|
| 62 |
"max_new_tokens": 3072
|
| 63 |
},
|
| 64 |
+
"tools": true,
|
| 65 |
"promptExamples": [
|
| 66 |
{
|
| 67 |
"title": "Write an email from bullet list",
|
|
|
|
| 80 |
{
|
| 81 |
"name": "meta-llama/Meta-Llama-3.1-70B-Instruct",
|
| 82 |
"id": "meta-llama/Meta-Llama-3.1-70B-Instruct",
|
|
|
|
| 83 |
"description": "Ideal for everyday use. A fast and extremely capable model matching closed source models' capabilities.",
|
| 84 |
"modelUrl": "https://huggingface.co/meta-llama/Meta-Llama-3.1-70B-Instruct",
|
| 85 |
"websiteUrl": "https://llama.meta.com/",
|
|
|
|
| 109 |
},
|
| 110 |
{
|
| 111 |
"name": "CohereForAI/c4ai-command-r-plus-08-2024",
|
|
|
|
| 112 |
"description": "Cohere's largest language model, optimized for conversational interaction and tool use. Now with the 2024 update!",
|
| 113 |
"modelUrl": "https://huggingface.co/CohereForAI/c4ai-command-r-plus-08-2024",
|
| 114 |
"websiteUrl": "https://docs.cohere.com/docs/command-r-plus",
|
|
|
|
| 348 |
},
|
| 349 |
{
|
| 350 |
"name": "llhf/Meta-Llama-3.1-8B-Instruct",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 351 |
"parameters": {
|
| 352 |
"temperature": 0.6,
|
| 353 |
"stop": ["<|endoftext|>", "<|eot_id|>"]
|
package-lock.json
CHANGED
|
@@ -10,10 +10,10 @@
|
|
| 10 |
"dependencies": {
|
| 11 |
"@aws-sdk/credential-providers": "^3.592.0",
|
| 12 |
"@cliqz/adblocker-playwright": "^1.27.2",
|
| 13 |
-
"@gradio/client": "^1.
|
| 14 |
"@huggingface/hub": "^0.5.1",
|
| 15 |
-
"@huggingface/inference": "^2.
|
| 16 |
-
"@huggingface/transformers": "^3.
|
| 17 |
"@iconify-json/bi": "^1.1.21",
|
| 18 |
"@playwright/browser-chromium": "^1.43.1",
|
| 19 |
"@resvg/resvg-js": "^2.6.2",
|
|
@@ -1929,9 +1929,10 @@
|
|
| 1929 |
}
|
| 1930 |
},
|
| 1931 |
"node_modules/@gradio/client": {
|
| 1932 |
-
"version": "1.
|
| 1933 |
-
"resolved": "https://registry.npmjs.org/@gradio/client/-/client-1.
|
| 1934 |
-
"integrity": "sha512-
|
|
|
|
| 1935 |
"dependencies": {
|
| 1936 |
"@types/eventsource": "^1.1.15",
|
| 1937 |
"bufferutil": "^4.0.7",
|
|
@@ -1959,37 +1960,41 @@
|
|
| 1959 |
}
|
| 1960 |
},
|
| 1961 |
"node_modules/@huggingface/inference": {
|
| 1962 |
-
"version": "2.8.
|
| 1963 |
-
"resolved": "https://registry.npmjs.org/@huggingface/inference/-/inference-2.8.
|
| 1964 |
-
"integrity": "sha512-
|
|
|
|
| 1965 |
"dependencies": {
|
| 1966 |
-
"@huggingface/tasks": "^0.
|
| 1967 |
},
|
| 1968 |
"engines": {
|
| 1969 |
"node": ">=18"
|
| 1970 |
}
|
| 1971 |
},
|
| 1972 |
"node_modules/@huggingface/jinja": {
|
| 1973 |
-
"version": "0.3.
|
| 1974 |
-
"resolved": "https://registry.npmjs.org/@huggingface/jinja/-/jinja-0.3.
|
| 1975 |
-
"integrity": "sha512-
|
|
|
|
| 1976 |
"engines": {
|
| 1977 |
"node": ">=18"
|
| 1978 |
}
|
| 1979 |
},
|
| 1980 |
"node_modules/@huggingface/tasks": {
|
| 1981 |
-
"version": "0.
|
| 1982 |
-
"resolved": "https://registry.npmjs.org/@huggingface/tasks/-/tasks-0.
|
| 1983 |
-
"integrity": "sha512-
|
|
|
|
| 1984 |
},
|
| 1985 |
"node_modules/@huggingface/transformers": {
|
| 1986 |
-
"version": "3.
|
| 1987 |
-
"resolved": "https://registry.npmjs.org/@huggingface/transformers/-/transformers-3.
|
| 1988 |
-
"integrity": "sha512
|
|
|
|
| 1989 |
"dependencies": {
|
| 1990 |
-
"@huggingface/jinja": "^0.3.
|
| 1991 |
-
"onnxruntime-node": "1.
|
| 1992 |
-
"onnxruntime-web": "1.20.
|
| 1993 |
"sharp": "^0.33.5"
|
| 1994 |
}
|
| 1995 |
},
|
|
@@ -2639,6 +2644,7 @@
|
|
| 2639 |
"version": "4.0.1",
|
| 2640 |
"resolved": "https://registry.npmjs.org/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz",
|
| 2641 |
"integrity": "sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==",
|
|
|
|
| 2642 |
"dependencies": {
|
| 2643 |
"minipass": "^7.0.4"
|
| 2644 |
},
|
|
@@ -2808,27 +2814,32 @@
|
|
| 2808 |
"node_modules/@protobufjs/aspromise": {
|
| 2809 |
"version": "1.1.2",
|
| 2810 |
"resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz",
|
| 2811 |
-
"integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ=="
|
|
|
|
| 2812 |
},
|
| 2813 |
"node_modules/@protobufjs/base64": {
|
| 2814 |
"version": "1.1.2",
|
| 2815 |
"resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz",
|
| 2816 |
-
"integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg=="
|
|
|
|
| 2817 |
},
|
| 2818 |
"node_modules/@protobufjs/codegen": {
|
| 2819 |
"version": "2.0.4",
|
| 2820 |
"resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz",
|
| 2821 |
-
"integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg=="
|
|
|
|
| 2822 |
},
|
| 2823 |
"node_modules/@protobufjs/eventemitter": {
|
| 2824 |
"version": "1.1.0",
|
| 2825 |
"resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz",
|
| 2826 |
-
"integrity": "sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q=="
|
|
|
|
| 2827 |
},
|
| 2828 |
"node_modules/@protobufjs/fetch": {
|
| 2829 |
"version": "1.1.0",
|
| 2830 |
"resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz",
|
| 2831 |
"integrity": "sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==",
|
|
|
|
| 2832 |
"dependencies": {
|
| 2833 |
"@protobufjs/aspromise": "^1.1.1",
|
| 2834 |
"@protobufjs/inquire": "^1.1.0"
|
|
@@ -2837,27 +2848,32 @@
|
|
| 2837 |
"node_modules/@protobufjs/float": {
|
| 2838 |
"version": "1.0.2",
|
| 2839 |
"resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz",
|
| 2840 |
-
"integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ=="
|
|
|
|
| 2841 |
},
|
| 2842 |
"node_modules/@protobufjs/inquire": {
|
| 2843 |
"version": "1.1.0",
|
| 2844 |
"resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz",
|
| 2845 |
-
"integrity": "sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q=="
|
|
|
|
| 2846 |
},
|
| 2847 |
"node_modules/@protobufjs/path": {
|
| 2848 |
"version": "1.1.2",
|
| 2849 |
"resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz",
|
| 2850 |
-
"integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA=="
|
|
|
|
| 2851 |
},
|
| 2852 |
"node_modules/@protobufjs/pool": {
|
| 2853 |
"version": "1.1.0",
|
| 2854 |
"resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz",
|
| 2855 |
-
"integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw=="
|
|
|
|
| 2856 |
},
|
| 2857 |
"node_modules/@protobufjs/utf8": {
|
| 2858 |
"version": "1.1.0",
|
| 2859 |
"resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz",
|
| 2860 |
-
"integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw=="
|
|
|
|
| 2861 |
},
|
| 2862 |
"node_modules/@remusao/guess-url-type": {
|
| 2863 |
"version": "1.3.0",
|
|
@@ -5512,6 +5528,7 @@
|
|
| 5512 |
"version": "3.0.0",
|
| 5513 |
"resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz",
|
| 5514 |
"integrity": "sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==",
|
|
|
|
| 5515 |
"engines": {
|
| 5516 |
"node": ">=18"
|
| 5517 |
}
|
|
@@ -7103,7 +7120,8 @@
|
|
| 7103 |
"node_modules/flatbuffers": {
|
| 7104 |
"version": "1.12.0",
|
| 7105 |
"resolved": "https://registry.npmjs.org/flatbuffers/-/flatbuffers-1.12.0.tgz",
|
| 7106 |
-
"integrity": "sha512-c7CZADjRcl6j0PlvFy0ZqXQ67qSEZfrVPynmnL+2zPc+NtMvrF8Y0QceMo7QqnSPc7+uWjUIAbvCQ5WIKlMVdQ=="
|
|
|
|
| 7107 |
},
|
| 7108 |
"node_modules/flatted": {
|
| 7109 |
"version": "3.3.1",
|
|
@@ -7489,7 +7507,8 @@
|
|
| 7489 |
"node_modules/guid-typescript": {
|
| 7490 |
"version": "1.0.9",
|
| 7491 |
"resolved": "https://registry.npmjs.org/guid-typescript/-/guid-typescript-1.0.9.tgz",
|
| 7492 |
-
"integrity": "sha512-Y8T4vYhEfwJOTbouREvG+3XDsjr8E3kIr7uf+JZ0BYloFsttiHU0WfvANVsR7TxNUJa/WpCnw/Ino/p+DeBhBQ=="
|
|
|
|
| 7493 |
},
|
| 7494 |
"node_modules/handlebars": {
|
| 7495 |
"version": "4.7.8",
|
|
@@ -8749,7 +8768,8 @@
|
|
| 8749 |
"node_modules/long": {
|
| 8750 |
"version": "5.2.3",
|
| 8751 |
"resolved": "https://registry.npmjs.org/long/-/long-5.2.3.tgz",
|
| 8752 |
-
"integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q=="
|
|
|
|
| 8753 |
},
|
| 8754 |
"node_modules/loupe": {
|
| 8755 |
"version": "3.1.2",
|
|
@@ -8988,6 +9008,7 @@
|
|
| 8988 |
"version": "3.0.1",
|
| 8989 |
"resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.0.1.tgz",
|
| 8990 |
"integrity": "sha512-umcy022ILvb5/3Djuu8LWeqUa8D68JaBzlttKeMWen48SjabqS3iY5w/vzeMzMUNhLDifyhbOwKDSznB1vvrwg==",
|
|
|
|
| 8991 |
"dependencies": {
|
| 8992 |
"minipass": "^7.0.4",
|
| 8993 |
"rimraf": "^5.0.5"
|
|
@@ -9000,6 +9021,7 @@
|
|
| 9000 |
"version": "5.0.10",
|
| 9001 |
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.10.tgz",
|
| 9002 |
"integrity": "sha512-l0OE8wL34P4nJH/H2ffoaniAokM2qSmrtXHmlpvYr5AVVX8msAyW0l8NVJFDxlSK4u3Uh/f41cQheDVdnYijwQ==",
|
|
|
|
| 9003 |
"dependencies": {
|
| 9004 |
"glob": "^10.3.7"
|
| 9005 |
},
|
|
@@ -9677,43 +9699,41 @@
|
|
| 9677 |
}
|
| 9678 |
},
|
| 9679 |
"node_modules/onnxruntime-common": {
|
| 9680 |
-
"version": "1.
|
| 9681 |
-
"resolved": "https://registry.npmjs.org/onnxruntime-common/-/onnxruntime-common-1.
|
| 9682 |
-
"integrity": "sha512-
|
|
|
|
| 9683 |
},
|
| 9684 |
"node_modules/onnxruntime-node": {
|
| 9685 |
-
"version": "1.
|
| 9686 |
-
"resolved": "https://registry.npmjs.org/onnxruntime-node/-/onnxruntime-node-1.
|
| 9687 |
-
"integrity": "sha512-
|
| 9688 |
"hasInstallScript": true,
|
|
|
|
| 9689 |
"os": [
|
| 9690 |
"win32",
|
| 9691 |
"darwin",
|
| 9692 |
"linux"
|
| 9693 |
],
|
| 9694 |
"dependencies": {
|
| 9695 |
-
"onnxruntime-common": "1.
|
| 9696 |
"tar": "^7.0.1"
|
| 9697 |
}
|
| 9698 |
},
|
| 9699 |
"node_modules/onnxruntime-web": {
|
| 9700 |
-
"version": "1.20.
|
| 9701 |
-
"resolved": "https://registry.npmjs.org/onnxruntime-web/-/onnxruntime-web-1.20.
|
| 9702 |
-
"integrity": "sha512-
|
|
|
|
| 9703 |
"dependencies": {
|
| 9704 |
"flatbuffers": "^1.12.0",
|
| 9705 |
"guid-typescript": "^1.0.9",
|
| 9706 |
"long": "^5.2.3",
|
| 9707 |
-
"onnxruntime-common": "1.20.
|
| 9708 |
"platform": "^1.3.6",
|
| 9709 |
"protobufjs": "^7.2.4"
|
| 9710 |
}
|
| 9711 |
},
|
| 9712 |
-
"node_modules/onnxruntime-web/node_modules/onnxruntime-common": {
|
| 9713 |
-
"version": "1.20.0-dev.20240827-5d54dc1462",
|
| 9714 |
-
"resolved": "https://registry.npmjs.org/onnxruntime-common/-/onnxruntime-common-1.20.0-dev.20240827-5d54dc1462.tgz",
|
| 9715 |
-
"integrity": "sha512-oR+xPRD64OI+w9nRLXQi9rEXYZ5W9BhqVi688sUTreU9J6pK182JYblmHjvapCg+Tta6MbkAsr3T1NZHM3tB1g=="
|
| 9716 |
-
},
|
| 9717 |
"node_modules/openai": {
|
| 9718 |
"version": "4.58.1",
|
| 9719 |
"resolved": "https://registry.npmjs.org/openai/-/openai-4.58.1.tgz",
|
|
@@ -10245,7 +10265,8 @@
|
|
| 10245 |
"node_modules/platform": {
|
| 10246 |
"version": "1.3.6",
|
| 10247 |
"resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz",
|
| 10248 |
-
"integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg=="
|
|
|
|
| 10249 |
},
|
| 10250 |
"node_modules/playwright": {
|
| 10251 |
"version": "1.47.0",
|
|
@@ -10631,6 +10652,7 @@
|
|
| 10631 |
"resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.4.0.tgz",
|
| 10632 |
"integrity": "sha512-mRUWCc3KUU4w1jU8sGxICXH/gNS94DvI1gxqDvBzhj1JpcsimQkYiOJfwsPUykUI5ZaspFbSgmBLER8IrQ3tqw==",
|
| 10633 |
"hasInstallScript": true,
|
|
|
|
| 10634 |
"dependencies": {
|
| 10635 |
"@protobufjs/aspromise": "^1.1.2",
|
| 10636 |
"@protobufjs/base64": "^1.1.2",
|
|
@@ -12124,6 +12146,7 @@
|
|
| 12124 |
"version": "7.4.3",
|
| 12125 |
"resolved": "https://registry.npmjs.org/tar/-/tar-7.4.3.tgz",
|
| 12126 |
"integrity": "sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==",
|
|
|
|
| 12127 |
"dependencies": {
|
| 12128 |
"@isaacs/fs-minipass": "^4.0.0",
|
| 12129 |
"chownr": "^3.0.0",
|
|
@@ -12152,6 +12175,7 @@
|
|
| 12152 |
"version": "3.0.1",
|
| 12153 |
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz",
|
| 12154 |
"integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==",
|
|
|
|
| 12155 |
"bin": {
|
| 12156 |
"mkdirp": "dist/cjs/src/bin.js"
|
| 12157 |
},
|
|
@@ -12166,6 +12190,7 @@
|
|
| 12166 |
"version": "5.0.0",
|
| 12167 |
"resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz",
|
| 12168 |
"integrity": "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==",
|
|
|
|
| 12169 |
"engines": {
|
| 12170 |
"node": ">=18"
|
| 12171 |
}
|
|
|
|
| 10 |
"dependencies": {
|
| 11 |
"@aws-sdk/credential-providers": "^3.592.0",
|
| 12 |
"@cliqz/adblocker-playwright": "^1.27.2",
|
| 13 |
+
"@gradio/client": "^1.8.0",
|
| 14 |
"@huggingface/hub": "^0.5.1",
|
| 15 |
+
"@huggingface/inference": "^2.8.1",
|
| 16 |
+
"@huggingface/transformers": "^3.1.1",
|
| 17 |
"@iconify-json/bi": "^1.1.21",
|
| 18 |
"@playwright/browser-chromium": "^1.43.1",
|
| 19 |
"@resvg/resvg-js": "^2.6.2",
|
|
|
|
| 1929 |
}
|
| 1930 |
},
|
| 1931 |
"node_modules/@gradio/client": {
|
| 1932 |
+
"version": "1.8.0",
|
| 1933 |
+
"resolved": "https://registry.npmjs.org/@gradio/client/-/client-1.8.0.tgz",
|
| 1934 |
+
"integrity": "sha512-0Nxi+AuEL/ICdnZ6TSxRif1yS2A0HtJnggtWhN/8sqwFxx5UAGN29/vnJONcVfe3g9nctDJCvik3uDHkzQHFGw==",
|
| 1935 |
+
"license": "ISC",
|
| 1936 |
"dependencies": {
|
| 1937 |
"@types/eventsource": "^1.1.15",
|
| 1938 |
"bufferutil": "^4.0.7",
|
|
|
|
| 1960 |
}
|
| 1961 |
},
|
| 1962 |
"node_modules/@huggingface/inference": {
|
| 1963 |
+
"version": "2.8.1",
|
| 1964 |
+
"resolved": "https://registry.npmjs.org/@huggingface/inference/-/inference-2.8.1.tgz",
|
| 1965 |
+
"integrity": "sha512-EfsNtY9OR6JCNaUa5bZu2mrs48iqeTz0Gutwf+fU0Kypx33xFQB4DKMhp8u4Ee6qVbLbNWvTHuWwlppLQl4p4Q==",
|
| 1966 |
+
"license": "MIT",
|
| 1967 |
"dependencies": {
|
| 1968 |
+
"@huggingface/tasks": "^0.12.9"
|
| 1969 |
},
|
| 1970 |
"engines": {
|
| 1971 |
"node": ">=18"
|
| 1972 |
}
|
| 1973 |
},
|
| 1974 |
"node_modules/@huggingface/jinja": {
|
| 1975 |
+
"version": "0.3.2",
|
| 1976 |
+
"resolved": "https://registry.npmjs.org/@huggingface/jinja/-/jinja-0.3.2.tgz",
|
| 1977 |
+
"integrity": "sha512-F2FvuIc+w1blGsaqJI/OErRbWH6bVJDCBI8Rm5D86yZ2wlwrGERsfIaru7XUv9eYC3DMP3ixDRRtF0h6d8AZcQ==",
|
| 1978 |
+
"license": "MIT",
|
| 1979 |
"engines": {
|
| 1980 |
"node": ">=18"
|
| 1981 |
}
|
| 1982 |
},
|
| 1983 |
"node_modules/@huggingface/tasks": {
|
| 1984 |
+
"version": "0.12.30",
|
| 1985 |
+
"resolved": "https://registry.npmjs.org/@huggingface/tasks/-/tasks-0.12.30.tgz",
|
| 1986 |
+
"integrity": "sha512-A1ITdxbEzx9L8wKR8pF7swyrTLxWNDFIGDLUWInxvks2ruQ8PLRBZe8r0EcjC3CDdtlj9jV1V4cgV35K/iy3GQ==",
|
| 1987 |
+
"license": "MIT"
|
| 1988 |
},
|
| 1989 |
"node_modules/@huggingface/transformers": {
|
| 1990 |
+
"version": "3.1.1",
|
| 1991 |
+
"resolved": "https://registry.npmjs.org/@huggingface/transformers/-/transformers-3.1.1.tgz",
|
| 1992 |
+
"integrity": "sha512-/OpCiSKIowo5w5rJAOH3pgZKvpT6DOfDYw9br9Fp8w3qm4oyxc6dOhrxdRLVrmqLbE8rp5dKCePUW34ZBsinsg==",
|
| 1993 |
+
"license": "Apache-2.0",
|
| 1994 |
"dependencies": {
|
| 1995 |
+
"@huggingface/jinja": "^0.3.2",
|
| 1996 |
+
"onnxruntime-node": "1.20.1",
|
| 1997 |
+
"onnxruntime-web": "1.20.1",
|
| 1998 |
"sharp": "^0.33.5"
|
| 1999 |
}
|
| 2000 |
},
|
|
|
|
| 2644 |
"version": "4.0.1",
|
| 2645 |
"resolved": "https://registry.npmjs.org/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz",
|
| 2646 |
"integrity": "sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==",
|
| 2647 |
+
"license": "ISC",
|
| 2648 |
"dependencies": {
|
| 2649 |
"minipass": "^7.0.4"
|
| 2650 |
},
|
|
|
|
| 2814 |
"node_modules/@protobufjs/aspromise": {
|
| 2815 |
"version": "1.1.2",
|
| 2816 |
"resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz",
|
| 2817 |
+
"integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==",
|
| 2818 |
+
"license": "BSD-3-Clause"
|
| 2819 |
},
|
| 2820 |
"node_modules/@protobufjs/base64": {
|
| 2821 |
"version": "1.1.2",
|
| 2822 |
"resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz",
|
| 2823 |
+
"integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==",
|
| 2824 |
+
"license": "BSD-3-Clause"
|
| 2825 |
},
|
| 2826 |
"node_modules/@protobufjs/codegen": {
|
| 2827 |
"version": "2.0.4",
|
| 2828 |
"resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz",
|
| 2829 |
+
"integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==",
|
| 2830 |
+
"license": "BSD-3-Clause"
|
| 2831 |
},
|
| 2832 |
"node_modules/@protobufjs/eventemitter": {
|
| 2833 |
"version": "1.1.0",
|
| 2834 |
"resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz",
|
| 2835 |
+
"integrity": "sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==",
|
| 2836 |
+
"license": "BSD-3-Clause"
|
| 2837 |
},
|
| 2838 |
"node_modules/@protobufjs/fetch": {
|
| 2839 |
"version": "1.1.0",
|
| 2840 |
"resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz",
|
| 2841 |
"integrity": "sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==",
|
| 2842 |
+
"license": "BSD-3-Clause",
|
| 2843 |
"dependencies": {
|
| 2844 |
"@protobufjs/aspromise": "^1.1.1",
|
| 2845 |
"@protobufjs/inquire": "^1.1.0"
|
|
|
|
| 2848 |
"node_modules/@protobufjs/float": {
|
| 2849 |
"version": "1.0.2",
|
| 2850 |
"resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz",
|
| 2851 |
+
"integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==",
|
| 2852 |
+
"license": "BSD-3-Clause"
|
| 2853 |
},
|
| 2854 |
"node_modules/@protobufjs/inquire": {
|
| 2855 |
"version": "1.1.0",
|
| 2856 |
"resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz",
|
| 2857 |
+
"integrity": "sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==",
|
| 2858 |
+
"license": "BSD-3-Clause"
|
| 2859 |
},
|
| 2860 |
"node_modules/@protobufjs/path": {
|
| 2861 |
"version": "1.1.2",
|
| 2862 |
"resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz",
|
| 2863 |
+
"integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==",
|
| 2864 |
+
"license": "BSD-3-Clause"
|
| 2865 |
},
|
| 2866 |
"node_modules/@protobufjs/pool": {
|
| 2867 |
"version": "1.1.0",
|
| 2868 |
"resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz",
|
| 2869 |
+
"integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==",
|
| 2870 |
+
"license": "BSD-3-Clause"
|
| 2871 |
},
|
| 2872 |
"node_modules/@protobufjs/utf8": {
|
| 2873 |
"version": "1.1.0",
|
| 2874 |
"resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz",
|
| 2875 |
+
"integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==",
|
| 2876 |
+
"license": "BSD-3-Clause"
|
| 2877 |
},
|
| 2878 |
"node_modules/@remusao/guess-url-type": {
|
| 2879 |
"version": "1.3.0",
|
|
|
|
| 5528 |
"version": "3.0.0",
|
| 5529 |
"resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz",
|
| 5530 |
"integrity": "sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==",
|
| 5531 |
+
"license": "BlueOak-1.0.0",
|
| 5532 |
"engines": {
|
| 5533 |
"node": ">=18"
|
| 5534 |
}
|
|
|
|
| 7120 |
"node_modules/flatbuffers": {
|
| 7121 |
"version": "1.12.0",
|
| 7122 |
"resolved": "https://registry.npmjs.org/flatbuffers/-/flatbuffers-1.12.0.tgz",
|
| 7123 |
+
"integrity": "sha512-c7CZADjRcl6j0PlvFy0ZqXQ67qSEZfrVPynmnL+2zPc+NtMvrF8Y0QceMo7QqnSPc7+uWjUIAbvCQ5WIKlMVdQ==",
|
| 7124 |
+
"license": "SEE LICENSE IN LICENSE.txt"
|
| 7125 |
},
|
| 7126 |
"node_modules/flatted": {
|
| 7127 |
"version": "3.3.1",
|
|
|
|
| 7507 |
"node_modules/guid-typescript": {
|
| 7508 |
"version": "1.0.9",
|
| 7509 |
"resolved": "https://registry.npmjs.org/guid-typescript/-/guid-typescript-1.0.9.tgz",
|
| 7510 |
+
"integrity": "sha512-Y8T4vYhEfwJOTbouREvG+3XDsjr8E3kIr7uf+JZ0BYloFsttiHU0WfvANVsR7TxNUJa/WpCnw/Ino/p+DeBhBQ==",
|
| 7511 |
+
"license": "ISC"
|
| 7512 |
},
|
| 7513 |
"node_modules/handlebars": {
|
| 7514 |
"version": "4.7.8",
|
|
|
|
| 8768 |
"node_modules/long": {
|
| 8769 |
"version": "5.2.3",
|
| 8770 |
"resolved": "https://registry.npmjs.org/long/-/long-5.2.3.tgz",
|
| 8771 |
+
"integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==",
|
| 8772 |
+
"license": "Apache-2.0"
|
| 8773 |
},
|
| 8774 |
"node_modules/loupe": {
|
| 8775 |
"version": "3.1.2",
|
|
|
|
| 9008 |
"version": "3.0.1",
|
| 9009 |
"resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.0.1.tgz",
|
| 9010 |
"integrity": "sha512-umcy022ILvb5/3Djuu8LWeqUa8D68JaBzlttKeMWen48SjabqS3iY5w/vzeMzMUNhLDifyhbOwKDSznB1vvrwg==",
|
| 9011 |
+
"license": "MIT",
|
| 9012 |
"dependencies": {
|
| 9013 |
"minipass": "^7.0.4",
|
| 9014 |
"rimraf": "^5.0.5"
|
|
|
|
| 9021 |
"version": "5.0.10",
|
| 9022 |
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.10.tgz",
|
| 9023 |
"integrity": "sha512-l0OE8wL34P4nJH/H2ffoaniAokM2qSmrtXHmlpvYr5AVVX8msAyW0l8NVJFDxlSK4u3Uh/f41cQheDVdnYijwQ==",
|
| 9024 |
+
"license": "ISC",
|
| 9025 |
"dependencies": {
|
| 9026 |
"glob": "^10.3.7"
|
| 9027 |
},
|
|
|
|
| 9699 |
}
|
| 9700 |
},
|
| 9701 |
"node_modules/onnxruntime-common": {
|
| 9702 |
+
"version": "1.20.1",
|
| 9703 |
+
"resolved": "https://registry.npmjs.org/onnxruntime-common/-/onnxruntime-common-1.20.1.tgz",
|
| 9704 |
+
"integrity": "sha512-YiU0s0IzYYC+gWvqD1HzLc46Du1sXpSiwzKb63PACIJr6LfL27VsXSXQvt68EzD3V0D5Bc0vyJTjmMxp0ylQiw==",
|
| 9705 |
+
"license": "MIT"
|
| 9706 |
},
|
| 9707 |
"node_modules/onnxruntime-node": {
|
| 9708 |
+
"version": "1.20.1",
|
| 9709 |
+
"resolved": "https://registry.npmjs.org/onnxruntime-node/-/onnxruntime-node-1.20.1.tgz",
|
| 9710 |
+
"integrity": "sha512-di/I4HDXRw+FLgq+TyHmQEDd3cEp9iFFZm0r4uJ1Wd7b/WE1VXtKWo8yemex347c6GNF/3Pv86ZfPhIWxORr0w==",
|
| 9711 |
"hasInstallScript": true,
|
| 9712 |
+
"license": "MIT",
|
| 9713 |
"os": [
|
| 9714 |
"win32",
|
| 9715 |
"darwin",
|
| 9716 |
"linux"
|
| 9717 |
],
|
| 9718 |
"dependencies": {
|
| 9719 |
+
"onnxruntime-common": "1.20.1",
|
| 9720 |
"tar": "^7.0.1"
|
| 9721 |
}
|
| 9722 |
},
|
| 9723 |
"node_modules/onnxruntime-web": {
|
| 9724 |
+
"version": "1.20.1",
|
| 9725 |
+
"resolved": "https://registry.npmjs.org/onnxruntime-web/-/onnxruntime-web-1.20.1.tgz",
|
| 9726 |
+
"integrity": "sha512-TePF6XVpLL1rWVMIl5Y9ACBQcyCNFThZON/jgElNd9Txb73CIEGlklhYR3UEr1cp5r0rbGI6nDwwrs79g7WjoA==",
|
| 9727 |
+
"license": "MIT",
|
| 9728 |
"dependencies": {
|
| 9729 |
"flatbuffers": "^1.12.0",
|
| 9730 |
"guid-typescript": "^1.0.9",
|
| 9731 |
"long": "^5.2.3",
|
| 9732 |
+
"onnxruntime-common": "1.20.1",
|
| 9733 |
"platform": "^1.3.6",
|
| 9734 |
"protobufjs": "^7.2.4"
|
| 9735 |
}
|
| 9736 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9737 |
"node_modules/openai": {
|
| 9738 |
"version": "4.58.1",
|
| 9739 |
"resolved": "https://registry.npmjs.org/openai/-/openai-4.58.1.tgz",
|
|
|
|
| 10265 |
"node_modules/platform": {
|
| 10266 |
"version": "1.3.6",
|
| 10267 |
"resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz",
|
| 10268 |
+
"integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==",
|
| 10269 |
+
"license": "MIT"
|
| 10270 |
},
|
| 10271 |
"node_modules/playwright": {
|
| 10272 |
"version": "1.47.0",
|
|
|
|
| 10652 |
"resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.4.0.tgz",
|
| 10653 |
"integrity": "sha512-mRUWCc3KUU4w1jU8sGxICXH/gNS94DvI1gxqDvBzhj1JpcsimQkYiOJfwsPUykUI5ZaspFbSgmBLER8IrQ3tqw==",
|
| 10654 |
"hasInstallScript": true,
|
| 10655 |
+
"license": "BSD-3-Clause",
|
| 10656 |
"dependencies": {
|
| 10657 |
"@protobufjs/aspromise": "^1.1.2",
|
| 10658 |
"@protobufjs/base64": "^1.1.2",
|
|
|
|
| 12146 |
"version": "7.4.3",
|
| 12147 |
"resolved": "https://registry.npmjs.org/tar/-/tar-7.4.3.tgz",
|
| 12148 |
"integrity": "sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==",
|
| 12149 |
+
"license": "ISC",
|
| 12150 |
"dependencies": {
|
| 12151 |
"@isaacs/fs-minipass": "^4.0.0",
|
| 12152 |
"chownr": "^3.0.0",
|
|
|
|
| 12175 |
"version": "3.0.1",
|
| 12176 |
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz",
|
| 12177 |
"integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==",
|
| 12178 |
+
"license": "MIT",
|
| 12179 |
"bin": {
|
| 12180 |
"mkdirp": "dist/cjs/src/bin.js"
|
| 12181 |
},
|
|
|
|
| 12190 |
"version": "5.0.0",
|
| 12191 |
"resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz",
|
| 12192 |
"integrity": "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==",
|
| 12193 |
+
"license": "BlueOak-1.0.0",
|
| 12194 |
"engines": {
|
| 12195 |
"node": ">=18"
|
| 12196 |
}
|
package.json
CHANGED
|
@@ -63,10 +63,10 @@
|
|
| 63 |
"dependencies": {
|
| 64 |
"@aws-sdk/credential-providers": "^3.592.0",
|
| 65 |
"@cliqz/adblocker-playwright": "^1.27.2",
|
| 66 |
-
"@gradio/client": "^1.
|
| 67 |
"@huggingface/hub": "^0.5.1",
|
| 68 |
-
"@huggingface/inference": "^2.
|
| 69 |
-
"@huggingface/transformers": "^3.
|
| 70 |
"@iconify-json/bi": "^1.1.21",
|
| 71 |
"@playwright/browser-chromium": "^1.43.1",
|
| 72 |
"@resvg/resvg-js": "^2.6.2",
|
|
|
|
| 63 |
"dependencies": {
|
| 64 |
"@aws-sdk/credential-providers": "^3.592.0",
|
| 65 |
"@cliqz/adblocker-playwright": "^1.27.2",
|
| 66 |
+
"@gradio/client": "^1.8.0",
|
| 67 |
"@huggingface/hub": "^0.5.1",
|
| 68 |
+
"@huggingface/inference": "^2.8.1",
|
| 69 |
+
"@huggingface/transformers": "^3.1.1",
|
| 70 |
"@iconify-json/bi": "^1.1.21",
|
| 71 |
"@playwright/browser-chromium": "^1.43.1",
|
| 72 |
"@resvg/resvg-js": "^2.6.2",
|
src/lib/server/models.ts
CHANGED
|
@@ -129,7 +129,11 @@ async function getChatPromptRender(
|
|
| 129 |
toolResults,
|
| 130 |
continueMessage,
|
| 131 |
}: ChatTemplateInput) => {
|
| 132 |
-
let formattedMessages: {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
content: message.content,
|
| 134 |
role: message.from,
|
| 135 |
}));
|
|
@@ -166,7 +170,7 @@ async function getChatPromptRender(
|
|
| 166 |
if (isHuggingChat && id.startsWith("CohereForAI")) {
|
| 167 |
formattedMessages = [
|
| 168 |
{
|
| 169 |
-
role:
|
| 170 |
content:
|
| 171 |
"\n\n<results>\n" +
|
| 172 |
toolResults
|
|
@@ -226,20 +230,6 @@ async function getChatPromptRender(
|
|
| 226 |
tools = [];
|
| 227 |
}
|
| 228 |
|
| 229 |
-
const chatTemplate = tools?.length ? "tool_use" : undefined;
|
| 230 |
-
|
| 231 |
-
const documents = (toolResults ?? []).flatMap((result) => {
|
| 232 |
-
if (result.status === ToolResultStatus.Error) {
|
| 233 |
-
return [{ title: `Tool "${result.call.name}" error`, text: "\n" + result.message }];
|
| 234 |
-
}
|
| 235 |
-
return result.outputs.flatMap((output) =>
|
| 236 |
-
Object.entries(output).map(([title, text]) => ({
|
| 237 |
-
title: `Tool "${result.call.name}" ${title}`,
|
| 238 |
-
text: "\n" + text,
|
| 239 |
-
}))
|
| 240 |
-
);
|
| 241 |
-
});
|
| 242 |
-
|
| 243 |
const mappedTools =
|
| 244 |
tools?.map((tool) => {
|
| 245 |
const inputs: Record<
|
|
@@ -271,9 +261,7 @@ async function getChatPromptRender(
|
|
| 271 |
const output = tokenizer.apply_chat_template(formattedMessages, {
|
| 272 |
tokenize: false,
|
| 273 |
add_generation_prompt: !continueMessage,
|
| 274 |
-
|
| 275 |
-
tools: mappedTools,
|
| 276 |
-
documents,
|
| 277 |
});
|
| 278 |
|
| 279 |
if (typeof output !== "string") {
|
|
@@ -282,7 +270,6 @@ async function getChatPromptRender(
|
|
| 282 |
|
| 283 |
return output;
|
| 284 |
};
|
| 285 |
-
|
| 286 |
return renderTemplate;
|
| 287 |
}
|
| 288 |
|
|
|
|
| 129 |
toolResults,
|
| 130 |
continueMessage,
|
| 131 |
}: ChatTemplateInput) => {
|
| 132 |
+
let formattedMessages: {
|
| 133 |
+
role: string;
|
| 134 |
+
content: string;
|
| 135 |
+
tool_calls?: { id: string; tool_call_id: string; output: string }[];
|
| 136 |
+
}[] = messages.map((message) => ({
|
| 137 |
content: message.content,
|
| 138 |
role: message.from,
|
| 139 |
}));
|
|
|
|
| 170 |
if (isHuggingChat && id.startsWith("CohereForAI")) {
|
| 171 |
formattedMessages = [
|
| 172 |
{
|
| 173 |
+
role: "user",
|
| 174 |
content:
|
| 175 |
"\n\n<results>\n" +
|
| 176 |
toolResults
|
|
|
|
| 230 |
tools = [];
|
| 231 |
}
|
| 232 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
const mappedTools =
|
| 234 |
tools?.map((tool) => {
|
| 235 |
const inputs: Record<
|
|
|
|
| 261 |
const output = tokenizer.apply_chat_template(formattedMessages, {
|
| 262 |
tokenize: false,
|
| 263 |
add_generation_prompt: !continueMessage,
|
| 264 |
+
tools: mappedTools.length ? mappedTools : undefined,
|
|
|
|
|
|
|
| 265 |
});
|
| 266 |
|
| 267 |
if (typeof output !== "string") {
|
|
|
|
| 270 |
|
| 271 |
return output;
|
| 272 |
};
|
|
|
|
| 273 |
return renderTemplate;
|
| 274 |
}
|
| 275 |
|
src/lib/server/textGeneration/tools.ts
CHANGED
|
@@ -184,11 +184,12 @@ export async function* runTools(
|
|
| 184 |
? [...formattedMessages.slice(0, -1), fileMsg, ...formattedMessages.slice(-1)]
|
| 185 |
: messages;
|
| 186 |
|
|
|
|
| 187 |
// do the function calling bits here
|
| 188 |
for await (const output of await endpoint({
|
| 189 |
messages: formattedMessages,
|
| 190 |
preprompt,
|
| 191 |
-
generateSettings: assistant?.generateSettings,
|
| 192 |
tools: tools.map((tool) => ({
|
| 193 |
...tool,
|
| 194 |
inputs: tool.inputs.map((input) => ({
|
|
@@ -204,24 +205,44 @@ export async function* runTools(
|
|
| 204 |
continue;
|
| 205 |
}
|
| 206 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
// look for a code blocks of ```json and parse them
|
| 208 |
// if they're valid json, add them to the calls array
|
| 209 |
if (output.generated_text) {
|
| 210 |
try {
|
| 211 |
const rawCalls = await extractJson(output.generated_text);
|
| 212 |
const newCalls = rawCalls
|
| 213 |
-
.filter(isExternalToolCall)
|
| 214 |
.map((call) => externalToToolCall(call, tools))
|
| 215 |
.filter((call) => call !== undefined) as ToolCall[];
|
| 216 |
|
| 217 |
calls.push(...newCalls);
|
| 218 |
} catch (e) {
|
| 219 |
-
logger.
|
|
|
|
|
|
|
|
|
|
| 220 |
// error parsing the calls
|
| 221 |
yield {
|
| 222 |
type: MessageUpdateType.Status,
|
| 223 |
status: MessageUpdateStatus.Error,
|
| 224 |
-
message: "Error while parsing tool calls
|
| 225 |
};
|
| 226 |
}
|
| 227 |
}
|
|
@@ -239,36 +260,33 @@ export async function* runTools(
|
|
| 239 |
return toolResults.filter((result): result is ToolResult => result !== undefined);
|
| 240 |
}
|
| 241 |
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
type ExternalToolCall = z.infer<typeof externalToolCall>;
|
| 248 |
-
|
| 249 |
-
function isExternalToolCall(call: unknown): call is ExternalToolCall {
|
| 250 |
-
return externalToolCall.safeParse(call).success;
|
| 251 |
-
}
|
| 252 |
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
const tool = tools.find((tool) => toolHasName(call.tool_name, tool));
|
| 256 |
|
|
|
|
| 257 |
if (!tool) {
|
| 258 |
-
logger.debug(
|
| 259 |
-
|
|
|
|
|
|
|
| 260 |
}
|
| 261 |
|
| 262 |
const parametersWithDefaults: Record<string, string> = {};
|
| 263 |
|
| 264 |
for (const input of tool.inputs) {
|
| 265 |
-
const value =
|
| 266 |
|
| 267 |
// Required so ensure it's there, otherwise return undefined
|
| 268 |
if (input.paramType === "required") {
|
| 269 |
if (value === undefined) {
|
| 270 |
logger.debug(
|
| 271 |
-
`Model requested tool "${
|
| 272 |
);
|
| 273 |
return;
|
| 274 |
}
|
|
@@ -285,7 +303,41 @@ function externalToToolCall(call: ExternalToolCall, tools: Tool[]): ToolCall | u
|
|
| 285 |
}
|
| 286 |
|
| 287 |
return {
|
| 288 |
-
name:
|
| 289 |
parameters: parametersWithDefaults,
|
| 290 |
};
|
| 291 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
? [...formattedMessages.slice(0, -1), fileMsg, ...formattedMessages.slice(-1)]
|
| 185 |
: messages;
|
| 186 |
|
| 187 |
+
let rawText = "";
|
| 188 |
// do the function calling bits here
|
| 189 |
for await (const output of await endpoint({
|
| 190 |
messages: formattedMessages,
|
| 191 |
preprompt,
|
| 192 |
+
generateSettings: { temperature: 0.1, ...assistant?.generateSettings },
|
| 193 |
tools: tools.map((tool) => ({
|
| 194 |
...tool,
|
| 195 |
inputs: tool.inputs.map((input) => ({
|
|
|
|
| 205 |
continue;
|
| 206 |
}
|
| 207 |
|
| 208 |
+
if (output.token.text) {
|
| 209 |
+
rawText += output.token.text;
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
// if we dont see a tool call in the first 25 chars, something is going wrong and we abort
|
| 213 |
+
if (rawText.length > 25 && !(rawText.includes("```json") || rawText.includes("{"))) {
|
| 214 |
+
return [];
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
// if we see a directly_answer tool call, we skip the rest
|
| 218 |
+
if (
|
| 219 |
+
rawText.includes("directly_answer") ||
|
| 220 |
+
rawText.includes("directlyAnswer") ||
|
| 221 |
+
rawText.includes("directly-answer")
|
| 222 |
+
) {
|
| 223 |
+
return [];
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
// look for a code blocks of ```json and parse them
|
| 227 |
// if they're valid json, add them to the calls array
|
| 228 |
if (output.generated_text) {
|
| 229 |
try {
|
| 230 |
const rawCalls = await extractJson(output.generated_text);
|
| 231 |
const newCalls = rawCalls
|
|
|
|
| 232 |
.map((call) => externalToToolCall(call, tools))
|
| 233 |
.filter((call) => call !== undefined) as ToolCall[];
|
| 234 |
|
| 235 |
calls.push(...newCalls);
|
| 236 |
} catch (e) {
|
| 237 |
+
logger.warn(
|
| 238 |
+
{ rawCall: output.generated_text, error: extractJson },
|
| 239 |
+
"Error while parsing tool calls"
|
| 240 |
+
);
|
| 241 |
// error parsing the calls
|
| 242 |
yield {
|
| 243 |
type: MessageUpdateType.Status,
|
| 244 |
status: MessageUpdateStatus.Error,
|
| 245 |
+
message: "Error while parsing tool calls.",
|
| 246 |
};
|
| 247 |
}
|
| 248 |
}
|
|
|
|
| 260 |
return toolResults.filter((result): result is ToolResult => result !== undefined);
|
| 261 |
}
|
| 262 |
|
| 263 |
+
function externalToToolCall(call: unknown, tools: Tool[]): ToolCall | undefined {
|
| 264 |
+
// Early return if invalid input
|
| 265 |
+
if (!isValidCallObject(call)) {
|
| 266 |
+
return undefined;
|
| 267 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
|
| 269 |
+
const parsedCall = parseExternalCall(call);
|
| 270 |
+
if (!parsedCall) return undefined;
|
|
|
|
| 271 |
|
| 272 |
+
const tool = tools.find((tool) => toolHasName(parsedCall.tool_name, tool));
|
| 273 |
if (!tool) {
|
| 274 |
+
logger.debug(
|
| 275 |
+
`Model requested tool that does not exist: "${parsedCall.tool_name}". Skipping tool...`
|
| 276 |
+
);
|
| 277 |
+
return undefined;
|
| 278 |
}
|
| 279 |
|
| 280 |
const parametersWithDefaults: Record<string, string> = {};
|
| 281 |
|
| 282 |
for (const input of tool.inputs) {
|
| 283 |
+
const value = parsedCall.parameters[input.name];
|
| 284 |
|
| 285 |
// Required so ensure it's there, otherwise return undefined
|
| 286 |
if (input.paramType === "required") {
|
| 287 |
if (value === undefined) {
|
| 288 |
logger.debug(
|
| 289 |
+
`Model requested tool "${parsedCall.tool_name}" but was missing required parameter "${input.name}". Skipping tool...`
|
| 290 |
);
|
| 291 |
return;
|
| 292 |
}
|
|
|
|
| 303 |
}
|
| 304 |
|
| 305 |
return {
|
| 306 |
+
name: parsedCall.tool_name,
|
| 307 |
parameters: parametersWithDefaults,
|
| 308 |
};
|
| 309 |
}
|
| 310 |
+
|
| 311 |
+
// Helper functions
|
| 312 |
+
function isValidCallObject(call: unknown): call is Record<string, unknown> {
|
| 313 |
+
return typeof call === "object" && call !== null;
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
function parseExternalCall(callObj: Record<string, unknown>) {
|
| 317 |
+
const nameFields = ["tool_name", "name"] as const;
|
| 318 |
+
const parametersFields = ["parameters", "arguments", "parameter_definitions"] as const;
|
| 319 |
+
|
| 320 |
+
const groupedCall = {
|
| 321 |
+
tool_name: "" as string,
|
| 322 |
+
parameters: undefined as Record<string, string> | undefined,
|
| 323 |
+
};
|
| 324 |
+
|
| 325 |
+
for (const name of nameFields) {
|
| 326 |
+
if (callObj[name]) {
|
| 327 |
+
groupedCall.tool_name = callObj[name] as string;
|
| 328 |
+
}
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
for (const name of parametersFields) {
|
| 332 |
+
if (callObj[name]) {
|
| 333 |
+
groupedCall.parameters = callObj[name] as Record<string, string>;
|
| 334 |
+
}
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
return z
|
| 338 |
+
.object({
|
| 339 |
+
tool_name: z.string(),
|
| 340 |
+
parameters: z.record(z.any()),
|
| 341 |
+
})
|
| 342 |
+
.parse(groupedCall);
|
| 343 |
+
}
|
src/lib/server/websearch/search/endpoints/bing.ts
CHANGED
|
@@ -27,8 +27,6 @@ export default async function search(query: string): Promise<WebSearchSource[]>
|
|
| 27 |
);
|
| 28 |
}
|
| 29 |
|
| 30 |
-
console.log(data["webPages"]?.["value"]);
|
| 31 |
-
|
| 32 |
// Adapt the data structure from the Bing response to match the WebSearchSource type
|
| 33 |
const webPages = data["webPages"]?.["value"] ?? [];
|
| 34 |
return webPages.map((page: any) => ({
|
|
|
|
| 27 |
);
|
| 28 |
}
|
| 29 |
|
|
|
|
|
|
|
| 30 |
// Adapt the data structure from the Bing response to match the WebSearchSource type
|
| 31 |
const webPages = data["webPages"]?.["value"] ?? [];
|
| 32 |
return webPages.map((page: any) => ({
|