Spaces:
Runtime error
Runtime error
Thomas G. Lopes
commited on
extra params (#95)
Browse files- eslint.config.mts +2 -0
- package.json +1 -1
- pnpm-lock.yaml +55 -55
- src/lib/components/dialog.svelte +11 -1
- src/lib/components/inference-playground/extra-params-modal.svelte +137 -0
- src/lib/components/inference-playground/generation-config.svelte +20 -4
- src/lib/components/inference-playground/structured-output-modal.svelte +108 -107
- src/lib/components/info-popover.svelte +56 -0
- src/lib/state/conversations.svelte.ts +3 -0
- src/lib/types.ts +1 -1
- src/lib/utils/business.svelte.ts +13 -0
- src/lib/utils/form.svelte.ts +20 -6
- src/lib/utils/object.svelte.ts +12 -0
eslint.config.mts
CHANGED
|
@@ -61,6 +61,8 @@ export default ts.config(
|
|
| 61 |
},
|
| 62 |
],
|
| 63 |
|
|
|
|
|
|
|
| 64 |
"object-shorthand": ["error", "always"],
|
| 65 |
"svelte/no-at-html-tags": "off",
|
| 66 |
"svelte/require-each-key": "off",
|
|
|
|
| 61 |
},
|
| 62 |
],
|
| 63 |
|
| 64 |
+
"@typescript-eslint/no-this-alias": "off",
|
| 65 |
+
|
| 66 |
"object-shorthand": ["error", "always"],
|
| 67 |
"svelte/no-at-html-tags": "off",
|
| 68 |
"svelte/require-each-key": "off",
|
package.json
CHANGED
|
@@ -59,7 +59,7 @@
|
|
| 59 |
"prettier-plugin-tailwindcss": "^0.6.11",
|
| 60 |
"runed": "^0.25.0",
|
| 61 |
"shiki": "^3.4.0",
|
| 62 |
-
"svelte": "^5.36.
|
| 63 |
"svelte-check": "^4.0.0",
|
| 64 |
"tailwind-merge": "^3.0.2",
|
| 65 |
"tailwindcss": "^4.0.9",
|
|
|
|
| 59 |
"prettier-plugin-tailwindcss": "^0.6.11",
|
| 60 |
"runed": "^0.25.0",
|
| 61 |
"shiki": "^3.4.0",
|
| 62 |
+
"svelte": "^5.36.16",
|
| 63 |
"svelte-check": "^4.0.0",
|
| 64 |
"tailwind-merge": "^3.0.2",
|
| 65 |
"tailwindcss": "^4.0.9",
|
pnpm-lock.yaml
CHANGED
|
@@ -13,7 +13,7 @@ importers:
|
|
| 13 |
version: 2.0.3
|
| 14 |
eslint-plugin-svelte:
|
| 15 |
specifier: ^3.11.0
|
| 16 |
-
version: 3.11.0(eslint@9.22.0(jiti@2.4.2))(svelte@5.36.
|
| 17 |
remult:
|
| 18 |
specifier: ^3.0.2
|
| 19 |
version: 3.0.2
|
|
@@ -62,16 +62,16 @@ importers:
|
|
| 62 |
version: 3.0.0
|
| 63 |
'@sveltejs/adapter-auto':
|
| 64 |
specifier: ^3.2.2
|
| 65 |
-
version: 3.3.1(@sveltejs/kit@2.18.0(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.
|
| 66 |
'@sveltejs/adapter-node':
|
| 67 |
specifier: ^5.2.0
|
| 68 |
-
version: 5.2.12(@sveltejs/kit@2.18.0(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.
|
| 69 |
'@sveltejs/kit':
|
| 70 |
specifier: ^2.5.27
|
| 71 |
-
version: 2.18.0(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.
|
| 72 |
'@sveltejs/vite-plugin-svelte':
|
| 73 |
specifier: ^4.0.0
|
| 74 |
-
version: 4.0.4(svelte@5.36.
|
| 75 |
'@tailwindcss/container-queries':
|
| 76 |
specifier: ^0.1.1
|
| 77 |
version: 0.1.1(tailwindcss@4.0.9)
|
|
@@ -83,7 +83,7 @@ importers:
|
|
| 83 |
version: 6.6.3
|
| 84 |
'@testing-library/svelte':
|
| 85 |
specifier: ^5.2.4
|
| 86 |
-
version: 5.2.8(svelte@5.36.
|
| 87 |
'@types/node':
|
| 88 |
specifier: ^22.14.1
|
| 89 |
version: 22.14.1
|
|
@@ -122,7 +122,7 @@ importers:
|
|
| 122 |
version: 26.1.0
|
| 123 |
melt:
|
| 124 |
specifier: ^0.36.0
|
| 125 |
-
version: 0.36.0(@floating-ui/dom@1.6.13)(svelte@5.36.
|
| 126 |
openai:
|
| 127 |
specifier: ^4.90.0
|
| 128 |
version: 4.90.0(ws@8.18.2)
|
|
@@ -137,22 +137,22 @@ importers:
|
|
| 137 |
version: 3.5.3
|
| 138 |
prettier-plugin-svelte:
|
| 139 |
specifier: ^3.4.0
|
| 140 |
-
version: 3.4.0(prettier@3.5.3)(svelte@5.36.
|
| 141 |
prettier-plugin-tailwindcss:
|
| 142 |
specifier: ^0.6.11
|
| 143 |
-
version: 0.6.11(prettier-plugin-svelte@3.4.0(prettier@3.5.3)(svelte@5.36.
|
| 144 |
runed:
|
| 145 |
specifier: ^0.25.0
|
| 146 |
-
version: 0.25.0(svelte@5.36.
|
| 147 |
shiki:
|
| 148 |
specifier: ^3.4.0
|
| 149 |
version: 3.4.0
|
| 150 |
svelte:
|
| 151 |
-
specifier: ^5.36.
|
| 152 |
-
version: 5.36.
|
| 153 |
svelte-check:
|
| 154 |
specifier: ^4.0.0
|
| 155 |
-
version: 4.1.5(picomatch@4.0.2)(svelte@5.36.
|
| 156 |
tailwind-merge:
|
| 157 |
specifier: ^3.0.2
|
| 158 |
version: 3.0.2
|
|
@@ -173,7 +173,7 @@ importers:
|
|
| 173 |
version: 8.26.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.2)
|
| 174 |
unplugin-icons:
|
| 175 |
specifier: ^22.1.0
|
| 176 |
-
version: 22.1.0(svelte@5.36.
|
| 177 |
vite:
|
| 178 |
specifier: ^5.4.4
|
| 179 |
version: 5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)
|
|
@@ -182,7 +182,7 @@ importers:
|
|
| 182 |
version: 3.1.4(@types/node@22.14.1)(@vitest/browser@3.1.4)(jsdom@26.1.0)(lightningcss@1.29.1)
|
| 183 |
vitest-browser-svelte:
|
| 184 |
specifier: ^0.1.0
|
| 185 |
-
version: 0.1.0(@vitest/browser@3.1.4)(svelte@5.36.
|
| 186 |
|
| 187 |
packages:
|
| 188 |
|
|
@@ -2844,8 +2844,8 @@ packages:
|
|
| 2844 |
svelte:
|
| 2845 |
optional: true
|
| 2846 |
|
| 2847 |
-
svelte@5.36.
|
| 2848 |
-
resolution: {integrity: sha512-
|
| 2849 |
engines: {node: '>=18'}
|
| 2850 |
|
| 2851 |
symbol-tree@3.2.4:
|
|
@@ -3927,22 +3927,22 @@ snapshots:
|
|
| 3927 |
dependencies:
|
| 3928 |
acorn: 8.14.0
|
| 3929 |
|
| 3930 |
-
'@sveltejs/adapter-auto@3.3.1(@sveltejs/kit@2.18.0(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.
|
| 3931 |
dependencies:
|
| 3932 |
-
'@sveltejs/kit': 2.18.0(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.
|
| 3933 |
import-meta-resolve: 4.1.0
|
| 3934 |
|
| 3935 |
-
'@sveltejs/adapter-node@5.2.12(@sveltejs/kit@2.18.0(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.
|
| 3936 |
dependencies:
|
| 3937 |
'@rollup/plugin-commonjs': 28.0.2(rollup@4.34.9)
|
| 3938 |
'@rollup/plugin-json': 6.1.0(rollup@4.34.9)
|
| 3939 |
'@rollup/plugin-node-resolve': 16.0.0(rollup@4.34.9)
|
| 3940 |
-
'@sveltejs/kit': 2.18.0(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.
|
| 3941 |
rollup: 4.34.9
|
| 3942 |
|
| 3943 |
-
'@sveltejs/kit@2.18.0(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.
|
| 3944 |
dependencies:
|
| 3945 |
-
'@sveltejs/vite-plugin-svelte': 4.0.4(svelte@5.36.
|
| 3946 |
'@types/cookie': 0.6.0
|
| 3947 |
cookie: 0.6.0
|
| 3948 |
devalue: 5.1.1
|
|
@@ -3954,26 +3954,26 @@ snapshots:
|
|
| 3954 |
sade: 1.8.1
|
| 3955 |
set-cookie-parser: 2.7.1
|
| 3956 |
sirv: 3.0.1
|
| 3957 |
-
svelte: 5.36.
|
| 3958 |
vite: 5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)
|
| 3959 |
|
| 3960 |
-
'@sveltejs/vite-plugin-svelte-inspector@3.0.1(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.
|
| 3961 |
dependencies:
|
| 3962 |
-
'@sveltejs/vite-plugin-svelte': 4.0.4(svelte@5.36.
|
| 3963 |
debug: 4.4.0
|
| 3964 |
-
svelte: 5.36.
|
| 3965 |
vite: 5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)
|
| 3966 |
transitivePeerDependencies:
|
| 3967 |
- supports-color
|
| 3968 |
|
| 3969 |
-
'@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.
|
| 3970 |
dependencies:
|
| 3971 |
-
'@sveltejs/vite-plugin-svelte-inspector': 3.0.1(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.
|
| 3972 |
debug: 4.4.0
|
| 3973 |
deepmerge: 4.3.1
|
| 3974 |
kleur: 4.1.5
|
| 3975 |
magic-string: 0.30.17
|
| 3976 |
-
svelte: 5.36.
|
| 3977 |
vite: 5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)
|
| 3978 |
vitefu: 1.0.6(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1))
|
| 3979 |
transitivePeerDependencies:
|
|
@@ -4066,10 +4066,10 @@ snapshots:
|
|
| 4066 |
lodash: 4.17.21
|
| 4067 |
redent: 3.0.0
|
| 4068 |
|
| 4069 |
-
'@testing-library/svelte@5.2.8(svelte@5.36.
|
| 4070 |
dependencies:
|
| 4071 |
'@testing-library/dom': 10.4.0
|
| 4072 |
-
svelte: 5.36.
|
| 4073 |
optionalDependencies:
|
| 4074 |
vite: 5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)
|
| 4075 |
vitest: 3.1.4(@types/node@22.14.1)(@vitest/browser@3.1.4)(jsdom@26.1.0)(lightningcss@1.29.1)
|
|
@@ -4618,7 +4618,7 @@ snapshots:
|
|
| 4618 |
optionalDependencies:
|
| 4619 |
eslint-config-prettier: 10.1.1(eslint@9.22.0(jiti@2.4.2))
|
| 4620 |
|
| 4621 |
-
eslint-plugin-svelte@3.11.0(eslint@9.22.0(jiti@2.4.2))(svelte@5.36.
|
| 4622 |
dependencies:
|
| 4623 |
'@eslint-community/eslint-utils': 4.7.0(eslint@9.22.0(jiti@2.4.2))
|
| 4624 |
'@jridgewell/sourcemap-codec': 1.5.0
|
|
@@ -4630,9 +4630,9 @@ snapshots:
|
|
| 4630 |
postcss-load-config: 3.1.4(postcss@8.5.3)
|
| 4631 |
postcss-safe-parser: 7.0.1(postcss@8.5.3)
|
| 4632 |
semver: 7.7.2
|
| 4633 |
-
svelte-eslint-parser: 1.3.0(svelte@5.36.
|
| 4634 |
optionalDependencies:
|
| 4635 |
-
svelte: 5.36.
|
| 4636 |
transitivePeerDependencies:
|
| 4637 |
- ts-node
|
| 4638 |
|
|
@@ -5207,14 +5207,14 @@ snapshots:
|
|
| 5207 |
unist-util-visit: 5.0.0
|
| 5208 |
vfile: 6.0.3
|
| 5209 |
|
| 5210 |
-
melt@0.36.0(@floating-ui/dom@1.6.13)(svelte@5.36.
|
| 5211 |
dependencies:
|
| 5212 |
'@floating-ui/dom': 1.6.13
|
| 5213 |
dequal: 2.0.3
|
| 5214 |
jest-axe: 9.0.0
|
| 5215 |
nanoid: 5.1.5
|
| 5216 |
-
runed: 0.23.4(svelte@5.36.
|
| 5217 |
-
svelte: 5.36.
|
| 5218 |
|
| 5219 |
merge2@1.4.1: {}
|
| 5220 |
|
|
@@ -5473,16 +5473,16 @@ snapshots:
|
|
| 5473 |
dependencies:
|
| 5474 |
fast-diff: 1.3.0
|
| 5475 |
|
| 5476 |
-
prettier-plugin-svelte@3.4.0(prettier@3.5.3)(svelte@5.36.
|
| 5477 |
dependencies:
|
| 5478 |
prettier: 3.5.3
|
| 5479 |
-
svelte: 5.36.
|
| 5480 |
|
| 5481 |
-
prettier-plugin-tailwindcss@0.6.11(prettier-plugin-svelte@3.4.0(prettier@3.5.3)(svelte@5.36.
|
| 5482 |
dependencies:
|
| 5483 |
prettier: 3.5.3
|
| 5484 |
optionalDependencies:
|
| 5485 |
-
prettier-plugin-svelte: 3.4.0(prettier@3.5.3)(svelte@5.36.
|
| 5486 |
|
| 5487 |
prettier@3.5.3: {}
|
| 5488 |
|
|
@@ -5623,15 +5623,15 @@ snapshots:
|
|
| 5623 |
dependencies:
|
| 5624 |
queue-microtask: 1.2.3
|
| 5625 |
|
| 5626 |
-
runed@0.23.4(svelte@5.36.
|
| 5627 |
dependencies:
|
| 5628 |
esm-env: 1.2.2
|
| 5629 |
-
svelte: 5.36.
|
| 5630 |
|
| 5631 |
-
runed@0.25.0(svelte@5.36.
|
| 5632 |
dependencies:
|
| 5633 |
esm-env: 1.2.2
|
| 5634 |
-
svelte: 5.36.
|
| 5635 |
|
| 5636 |
rxjs@7.8.2:
|
| 5637 |
dependencies:
|
|
@@ -5761,19 +5761,19 @@ snapshots:
|
|
| 5761 |
|
| 5762 |
supports-preserve-symlinks-flag@1.0.0: {}
|
| 5763 |
|
| 5764 |
-
svelte-check@4.1.5(picomatch@4.0.2)(svelte@5.36.
|
| 5765 |
dependencies:
|
| 5766 |
'@jridgewell/trace-mapping': 0.3.25
|
| 5767 |
chokidar: 4.0.3
|
| 5768 |
fdir: 6.4.3(picomatch@4.0.2)
|
| 5769 |
picocolors: 1.1.1
|
| 5770 |
sade: 1.8.1
|
| 5771 |
-
svelte: 5.36.
|
| 5772 |
typescript: 5.8.2
|
| 5773 |
transitivePeerDependencies:
|
| 5774 |
- picomatch
|
| 5775 |
|
| 5776 |
-
svelte-eslint-parser@1.3.0(svelte@5.36.
|
| 5777 |
dependencies:
|
| 5778 |
eslint-scope: 8.3.0
|
| 5779 |
eslint-visitor-keys: 4.2.0
|
|
@@ -5782,9 +5782,9 @@ snapshots:
|
|
| 5782 |
postcss-scss: 4.0.9(postcss@8.5.3)
|
| 5783 |
postcss-selector-parser: 7.1.0
|
| 5784 |
optionalDependencies:
|
| 5785 |
-
svelte: 5.36.
|
| 5786 |
|
| 5787 |
-
svelte@5.36.
|
| 5788 |
dependencies:
|
| 5789 |
'@ampproject/remapping': 2.3.0
|
| 5790 |
'@jridgewell/sourcemap-codec': 1.5.0
|
|
@@ -5956,7 +5956,7 @@ snapshots:
|
|
| 5956 |
unist-util-is: 6.0.0
|
| 5957 |
unist-util-visit-parents: 6.0.1
|
| 5958 |
|
| 5959 |
-
unplugin-icons@22.1.0(svelte@5.36.
|
| 5960 |
dependencies:
|
| 5961 |
'@antfu/install-pkg': 1.0.0
|
| 5962 |
'@iconify/utils': 2.3.0
|
|
@@ -5964,7 +5964,7 @@ snapshots:
|
|
| 5964 |
local-pkg: 1.1.1
|
| 5965 |
unplugin: 2.2.0
|
| 5966 |
optionalDependencies:
|
| 5967 |
-
svelte: 5.36.
|
| 5968 |
transitivePeerDependencies:
|
| 5969 |
- supports-color
|
| 5970 |
|
|
@@ -6040,10 +6040,10 @@ snapshots:
|
|
| 6040 |
optionalDependencies:
|
| 6041 |
vite: 5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)
|
| 6042 |
|
| 6043 |
-
vitest-browser-svelte@0.1.0(@vitest/browser@3.1.4)(svelte@5.36.
|
| 6044 |
dependencies:
|
| 6045 |
'@vitest/browser': 3.1.4(playwright@1.52.0)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1))(vitest@3.1.4)
|
| 6046 |
-
svelte: 5.36.
|
| 6047 |
vitest: 3.1.4(@types/node@22.14.1)(@vitest/browser@3.1.4)(jsdom@26.1.0)(lightningcss@1.29.1)
|
| 6048 |
|
| 6049 |
vitest@3.1.4(@types/node@22.14.1)(@vitest/browser@3.1.4)(jsdom@26.1.0)(lightningcss@1.29.1):
|
|
|
|
| 13 |
version: 2.0.3
|
| 14 |
eslint-plugin-svelte:
|
| 15 |
specifier: ^3.11.0
|
| 16 |
+
version: 3.11.0(eslint@9.22.0(jiti@2.4.2))(svelte@5.36.16)
|
| 17 |
remult:
|
| 18 |
specifier: ^3.0.2
|
| 19 |
version: 3.0.2
|
|
|
|
| 62 |
version: 3.0.0
|
| 63 |
'@sveltejs/adapter-auto':
|
| 64 |
specifier: ^3.2.2
|
| 65 |
+
version: 3.3.1(@sveltejs/kit@2.18.0(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)))(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)))
|
| 66 |
'@sveltejs/adapter-node':
|
| 67 |
specifier: ^5.2.0
|
| 68 |
+
version: 5.2.12(@sveltejs/kit@2.18.0(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)))(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)))
|
| 69 |
'@sveltejs/kit':
|
| 70 |
specifier: ^2.5.27
|
| 71 |
+
version: 2.18.0(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)))(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1))
|
| 72 |
'@sveltejs/vite-plugin-svelte':
|
| 73 |
specifier: ^4.0.0
|
| 74 |
+
version: 4.0.4(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1))
|
| 75 |
'@tailwindcss/container-queries':
|
| 76 |
specifier: ^0.1.1
|
| 77 |
version: 0.1.1(tailwindcss@4.0.9)
|
|
|
|
| 83 |
version: 6.6.3
|
| 84 |
'@testing-library/svelte':
|
| 85 |
specifier: ^5.2.4
|
| 86 |
+
version: 5.2.8(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1))(vitest@3.1.4)
|
| 87 |
'@types/node':
|
| 88 |
specifier: ^22.14.1
|
| 89 |
version: 22.14.1
|
|
|
|
| 122 |
version: 26.1.0
|
| 123 |
melt:
|
| 124 |
specifier: ^0.36.0
|
| 125 |
+
version: 0.36.0(@floating-ui/dom@1.6.13)(svelte@5.36.16)
|
| 126 |
openai:
|
| 127 |
specifier: ^4.90.0
|
| 128 |
version: 4.90.0(ws@8.18.2)
|
|
|
|
| 137 |
version: 3.5.3
|
| 138 |
prettier-plugin-svelte:
|
| 139 |
specifier: ^3.4.0
|
| 140 |
+
version: 3.4.0(prettier@3.5.3)(svelte@5.36.16)
|
| 141 |
prettier-plugin-tailwindcss:
|
| 142 |
specifier: ^0.6.11
|
| 143 |
+
version: 0.6.11(prettier-plugin-svelte@3.4.0(prettier@3.5.3)(svelte@5.36.16))(prettier@3.5.3)
|
| 144 |
runed:
|
| 145 |
specifier: ^0.25.0
|
| 146 |
+
version: 0.25.0(svelte@5.36.16)
|
| 147 |
shiki:
|
| 148 |
specifier: ^3.4.0
|
| 149 |
version: 3.4.0
|
| 150 |
svelte:
|
| 151 |
+
specifier: ^5.36.16
|
| 152 |
+
version: 5.36.16
|
| 153 |
svelte-check:
|
| 154 |
specifier: ^4.0.0
|
| 155 |
+
version: 4.1.5(picomatch@4.0.2)(svelte@5.36.16)(typescript@5.8.2)
|
| 156 |
tailwind-merge:
|
| 157 |
specifier: ^3.0.2
|
| 158 |
version: 3.0.2
|
|
|
|
| 173 |
version: 8.26.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.2)
|
| 174 |
unplugin-icons:
|
| 175 |
specifier: ^22.1.0
|
| 176 |
+
version: 22.1.0(svelte@5.36.16)
|
| 177 |
vite:
|
| 178 |
specifier: ^5.4.4
|
| 179 |
version: 5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)
|
|
|
|
| 182 |
version: 3.1.4(@types/node@22.14.1)(@vitest/browser@3.1.4)(jsdom@26.1.0)(lightningcss@1.29.1)
|
| 183 |
vitest-browser-svelte:
|
| 184 |
specifier: ^0.1.0
|
| 185 |
+
version: 0.1.0(@vitest/browser@3.1.4)(svelte@5.36.16)(vitest@3.1.4)
|
| 186 |
|
| 187 |
packages:
|
| 188 |
|
|
|
|
| 2844 |
svelte:
|
| 2845 |
optional: true
|
| 2846 |
|
| 2847 |
+
svelte@5.36.16:
|
| 2848 |
+
resolution: {integrity: sha512-C7HnyISfvZEofs7T4p7+bmjrbQlhd6lZfgV2tLYg6Eb3nUFM/Zu9dGlSg+GWbUBU/WPw6zDPOFNZAx9qXsoCkg==}
|
| 2849 |
engines: {node: '>=18'}
|
| 2850 |
|
| 2851 |
symbol-tree@3.2.4:
|
|
|
|
| 3927 |
dependencies:
|
| 3928 |
acorn: 8.14.0
|
| 3929 |
|
| 3930 |
+
'@sveltejs/adapter-auto@3.3.1(@sveltejs/kit@2.18.0(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)))(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)))':
|
| 3931 |
dependencies:
|
| 3932 |
+
'@sveltejs/kit': 2.18.0(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)))(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1))
|
| 3933 |
import-meta-resolve: 4.1.0
|
| 3934 |
|
| 3935 |
+
'@sveltejs/adapter-node@5.2.12(@sveltejs/kit@2.18.0(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)))(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)))':
|
| 3936 |
dependencies:
|
| 3937 |
'@rollup/plugin-commonjs': 28.0.2(rollup@4.34.9)
|
| 3938 |
'@rollup/plugin-json': 6.1.0(rollup@4.34.9)
|
| 3939 |
'@rollup/plugin-node-resolve': 16.0.0(rollup@4.34.9)
|
| 3940 |
+
'@sveltejs/kit': 2.18.0(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)))(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1))
|
| 3941 |
rollup: 4.34.9
|
| 3942 |
|
| 3943 |
+
'@sveltejs/kit@2.18.0(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)))(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1))':
|
| 3944 |
dependencies:
|
| 3945 |
+
'@sveltejs/vite-plugin-svelte': 4.0.4(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1))
|
| 3946 |
'@types/cookie': 0.6.0
|
| 3947 |
cookie: 0.6.0
|
| 3948 |
devalue: 5.1.1
|
|
|
|
| 3954 |
sade: 1.8.1
|
| 3955 |
set-cookie-parser: 2.7.1
|
| 3956 |
sirv: 3.0.1
|
| 3957 |
+
svelte: 5.36.16
|
| 3958 |
vite: 5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)
|
| 3959 |
|
| 3960 |
+
'@sveltejs/vite-plugin-svelte-inspector@3.0.1(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)))(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1))':
|
| 3961 |
dependencies:
|
| 3962 |
+
'@sveltejs/vite-plugin-svelte': 4.0.4(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1))
|
| 3963 |
debug: 4.4.0
|
| 3964 |
+
svelte: 5.36.16
|
| 3965 |
vite: 5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)
|
| 3966 |
transitivePeerDependencies:
|
| 3967 |
- supports-color
|
| 3968 |
|
| 3969 |
+
'@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1))':
|
| 3970 |
dependencies:
|
| 3971 |
+
'@sveltejs/vite-plugin-svelte-inspector': 3.0.1(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)))(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1))
|
| 3972 |
debug: 4.4.0
|
| 3973 |
deepmerge: 4.3.1
|
| 3974 |
kleur: 4.1.5
|
| 3975 |
magic-string: 0.30.17
|
| 3976 |
+
svelte: 5.36.16
|
| 3977 |
vite: 5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)
|
| 3978 |
vitefu: 1.0.6(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1))
|
| 3979 |
transitivePeerDependencies:
|
|
|
|
| 4066 |
lodash: 4.17.21
|
| 4067 |
redent: 3.0.0
|
| 4068 |
|
| 4069 |
+
'@testing-library/svelte@5.2.8(svelte@5.36.16)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1))(vitest@3.1.4)':
|
| 4070 |
dependencies:
|
| 4071 |
'@testing-library/dom': 10.4.0
|
| 4072 |
+
svelte: 5.36.16
|
| 4073 |
optionalDependencies:
|
| 4074 |
vite: 5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)
|
| 4075 |
vitest: 3.1.4(@types/node@22.14.1)(@vitest/browser@3.1.4)(jsdom@26.1.0)(lightningcss@1.29.1)
|
|
|
|
| 4618 |
optionalDependencies:
|
| 4619 |
eslint-config-prettier: 10.1.1(eslint@9.22.0(jiti@2.4.2))
|
| 4620 |
|
| 4621 |
+
eslint-plugin-svelte@3.11.0(eslint@9.22.0(jiti@2.4.2))(svelte@5.36.16):
|
| 4622 |
dependencies:
|
| 4623 |
'@eslint-community/eslint-utils': 4.7.0(eslint@9.22.0(jiti@2.4.2))
|
| 4624 |
'@jridgewell/sourcemap-codec': 1.5.0
|
|
|
|
| 4630 |
postcss-load-config: 3.1.4(postcss@8.5.3)
|
| 4631 |
postcss-safe-parser: 7.0.1(postcss@8.5.3)
|
| 4632 |
semver: 7.7.2
|
| 4633 |
+
svelte-eslint-parser: 1.3.0(svelte@5.36.16)
|
| 4634 |
optionalDependencies:
|
| 4635 |
+
svelte: 5.36.16
|
| 4636 |
transitivePeerDependencies:
|
| 4637 |
- ts-node
|
| 4638 |
|
|
|
|
| 5207 |
unist-util-visit: 5.0.0
|
| 5208 |
vfile: 6.0.3
|
| 5209 |
|
| 5210 |
+
melt@0.36.0(@floating-ui/dom@1.6.13)(svelte@5.36.16):
|
| 5211 |
dependencies:
|
| 5212 |
'@floating-ui/dom': 1.6.13
|
| 5213 |
dequal: 2.0.3
|
| 5214 |
jest-axe: 9.0.0
|
| 5215 |
nanoid: 5.1.5
|
| 5216 |
+
runed: 0.23.4(svelte@5.36.16)
|
| 5217 |
+
svelte: 5.36.16
|
| 5218 |
|
| 5219 |
merge2@1.4.1: {}
|
| 5220 |
|
|
|
|
| 5473 |
dependencies:
|
| 5474 |
fast-diff: 1.3.0
|
| 5475 |
|
| 5476 |
+
prettier-plugin-svelte@3.4.0(prettier@3.5.3)(svelte@5.36.16):
|
| 5477 |
dependencies:
|
| 5478 |
prettier: 3.5.3
|
| 5479 |
+
svelte: 5.36.16
|
| 5480 |
|
| 5481 |
+
prettier-plugin-tailwindcss@0.6.11(prettier-plugin-svelte@3.4.0(prettier@3.5.3)(svelte@5.36.16))(prettier@3.5.3):
|
| 5482 |
dependencies:
|
| 5483 |
prettier: 3.5.3
|
| 5484 |
optionalDependencies:
|
| 5485 |
+
prettier-plugin-svelte: 3.4.0(prettier@3.5.3)(svelte@5.36.16)
|
| 5486 |
|
| 5487 |
prettier@3.5.3: {}
|
| 5488 |
|
|
|
|
| 5623 |
dependencies:
|
| 5624 |
queue-microtask: 1.2.3
|
| 5625 |
|
| 5626 |
+
runed@0.23.4(svelte@5.36.16):
|
| 5627 |
dependencies:
|
| 5628 |
esm-env: 1.2.2
|
| 5629 |
+
svelte: 5.36.16
|
| 5630 |
|
| 5631 |
+
runed@0.25.0(svelte@5.36.16):
|
| 5632 |
dependencies:
|
| 5633 |
esm-env: 1.2.2
|
| 5634 |
+
svelte: 5.36.16
|
| 5635 |
|
| 5636 |
rxjs@7.8.2:
|
| 5637 |
dependencies:
|
|
|
|
| 5761 |
|
| 5762 |
supports-preserve-symlinks-flag@1.0.0: {}
|
| 5763 |
|
| 5764 |
+
svelte-check@4.1.5(picomatch@4.0.2)(svelte@5.36.16)(typescript@5.8.2):
|
| 5765 |
dependencies:
|
| 5766 |
'@jridgewell/trace-mapping': 0.3.25
|
| 5767 |
chokidar: 4.0.3
|
| 5768 |
fdir: 6.4.3(picomatch@4.0.2)
|
| 5769 |
picocolors: 1.1.1
|
| 5770 |
sade: 1.8.1
|
| 5771 |
+
svelte: 5.36.16
|
| 5772 |
typescript: 5.8.2
|
| 5773 |
transitivePeerDependencies:
|
| 5774 |
- picomatch
|
| 5775 |
|
| 5776 |
+
svelte-eslint-parser@1.3.0(svelte@5.36.16):
|
| 5777 |
dependencies:
|
| 5778 |
eslint-scope: 8.3.0
|
| 5779 |
eslint-visitor-keys: 4.2.0
|
|
|
|
| 5782 |
postcss-scss: 4.0.9(postcss@8.5.3)
|
| 5783 |
postcss-selector-parser: 7.1.0
|
| 5784 |
optionalDependencies:
|
| 5785 |
+
svelte: 5.36.16
|
| 5786 |
|
| 5787 |
+
svelte@5.36.16:
|
| 5788 |
dependencies:
|
| 5789 |
'@ampproject/remapping': 2.3.0
|
| 5790 |
'@jridgewell/sourcemap-codec': 1.5.0
|
|
|
|
| 5956 |
unist-util-is: 6.0.0
|
| 5957 |
unist-util-visit-parents: 6.0.1
|
| 5958 |
|
| 5959 |
+
unplugin-icons@22.1.0(svelte@5.36.16):
|
| 5960 |
dependencies:
|
| 5961 |
'@antfu/install-pkg': 1.0.0
|
| 5962 |
'@iconify/utils': 2.3.0
|
|
|
|
| 5964 |
local-pkg: 1.1.1
|
| 5965 |
unplugin: 2.2.0
|
| 5966 |
optionalDependencies:
|
| 5967 |
+
svelte: 5.36.16
|
| 5968 |
transitivePeerDependencies:
|
| 5969 |
- supports-color
|
| 5970 |
|
|
|
|
| 6040 |
optionalDependencies:
|
| 6041 |
vite: 5.4.14(@types/node@22.14.1)(lightningcss@1.29.1)
|
| 6042 |
|
| 6043 |
+
vitest-browser-svelte@0.1.0(@vitest/browser@3.1.4)(svelte@5.36.16)(vitest@3.1.4):
|
| 6044 |
dependencies:
|
| 6045 |
'@vitest/browser': 3.1.4(playwright@1.52.0)(vite@5.4.14(@types/node@22.14.1)(lightningcss@1.29.1))(vitest@3.1.4)
|
| 6046 |
+
svelte: 5.36.16
|
| 6047 |
vitest: 3.1.4(@types/node@22.14.1)(@vitest/browser@3.1.4)(jsdom@26.1.0)(lightningcss@1.29.1)
|
| 6048 |
|
| 6049 |
vitest@3.1.4(@types/node@22.14.1)(@vitest/browser@3.1.4)(jsdom@26.1.0)(lightningcss@1.29.1):
|
src/lib/components/dialog.svelte
CHANGED
|
@@ -27,7 +27,17 @@
|
|
| 27 |
});
|
| 28 |
</script>
|
| 29 |
|
| 30 |
-
<dialog
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
{#if open}
|
| 32 |
<form class="fixed inset-0 z-50 flex items-center justify-center overflow-hidden bg-black/85" onsubmit={onSubmit}>
|
| 33 |
<div
|
|
|
|
| 27 |
});
|
| 28 |
</script>
|
| 29 |
|
| 30 |
+
<dialog
|
| 31 |
+
bind:this={dialog}
|
| 32 |
+
oncancel={e => {
|
| 33 |
+
e.preventDefault();
|
| 34 |
+
onClose?.();
|
| 35 |
+
}}
|
| 36 |
+
onclose={e => {
|
| 37 |
+
e.preventDefault();
|
| 38 |
+
onClose?.();
|
| 39 |
+
}}
|
| 40 |
+
>
|
| 41 |
{#if open}
|
| 42 |
<form class="fixed inset-0 z-50 flex items-center justify-center overflow-hidden bg-black/85" onsubmit={onSubmit}>
|
| 43 |
<div
|
src/lib/components/inference-playground/extra-params-modal.svelte
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts" module>
|
| 2 |
+
let open = $state(false);
|
| 3 |
+
|
| 4 |
+
export function openExtraParamsModal() {
|
| 5 |
+
open = true;
|
| 6 |
+
}
|
| 7 |
+
</script>
|
| 8 |
+
|
| 9 |
+
<script lang="ts">
|
| 10 |
+
import type { ConversationClass } from "$lib/state/conversations.svelte.js";
|
| 11 |
+
import { createFieldValidation } from "$lib/utils/form.svelte";
|
| 12 |
+
import { deleteKey, entries, renameKey } from "$lib/utils/object.svelte";
|
| 13 |
+
import { onchange } from "$lib/utils/template.js";
|
| 14 |
+
import IconX from "~icons/carbon/close";
|
| 15 |
+
import Dialog from "../dialog.svelte";
|
| 16 |
+
import InfoPopover from "../info-popover.svelte";
|
| 17 |
+
import { watch } from "runed";
|
| 18 |
+
|
| 19 |
+
interface Props {
|
| 20 |
+
conversation: ConversationClass;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
let { conversation }: Props = $props();
|
| 24 |
+
|
| 25 |
+
type Field = {
|
| 26 |
+
value: string;
|
| 27 |
+
} & ReturnType<typeof createFieldValidation>;
|
| 28 |
+
|
| 29 |
+
let fields = $state<Record<string, Field>>({});
|
| 30 |
+
|
| 31 |
+
watch(
|
| 32 |
+
() => open,
|
| 33 |
+
() => {
|
| 34 |
+
if (!open) return;
|
| 35 |
+
// Sync with conversation.extraParams
|
| 36 |
+
fields = Object.fromEntries(
|
| 37 |
+
entries(conversation.data.extraParams ?? {}).map(([key, value]) => [
|
| 38 |
+
key,
|
| 39 |
+
Object.assign(createFieldValidation({ validate: validateParamValue }), { value }),
|
| 40 |
+
]),
|
| 41 |
+
);
|
| 42 |
+
},
|
| 43 |
+
);
|
| 44 |
+
|
| 45 |
+
function validateParamValue(v: string) {
|
| 46 |
+
if (!v) return "Value cannot be empty";
|
| 47 |
+
try {
|
| 48 |
+
JSON.parse(v);
|
| 49 |
+
} catch {
|
| 50 |
+
return "Value is not valid JSON";
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
async function close() {
|
| 55 |
+
fields = {};
|
| 56 |
+
open = false;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
async function save() {
|
| 60 |
+
Object.values(fields).forEach(f => f.validate());
|
| 61 |
+
if (!Object.values(fields).every(f => f.valid)) return;
|
| 62 |
+
open = false;
|
| 63 |
+
// Set conversation.extraParams
|
| 64 |
+
conversation.update({
|
| 65 |
+
extraParams: Object.fromEntries(entries(fields).map(([key, field]) => [key, field.value])),
|
| 66 |
+
});
|
| 67 |
+
}
|
| 68 |
+
</script>
|
| 69 |
+
|
| 70 |
+
<Dialog
|
| 71 |
+
class="!w-2xl max-w-[90vw]"
|
| 72 |
+
title="Edit Extra Parameters"
|
| 73 |
+
{open}
|
| 74 |
+
onClose={() => {
|
| 75 |
+
close();
|
| 76 |
+
}}
|
| 77 |
+
onSubmit={e => {
|
| 78 |
+
e.preventDefault();
|
| 79 |
+
}}
|
| 80 |
+
>
|
| 81 |
+
<div class="flex items-center gap-2">
|
| 82 |
+
<h2 class="font-semibold">Parameters</h2>
|
| 83 |
+
<InfoPopover content="These parameters are passed as JSON parameters, as is." />
|
| 84 |
+
<button
|
| 85 |
+
type="button"
|
| 86 |
+
class="btn-sm ml-auto flex items-center justify-center rounded-md"
|
| 87 |
+
onclick={() => {
|
| 88 |
+
const prevLength = Object.keys(fields).length ?? 0;
|
| 89 |
+
const key = `newParam${prevLength + 1}`;
|
| 90 |
+
fields[key] = Object.assign(createFieldValidation({ validate: validateParamValue }), { value: "" });
|
| 91 |
+
}}
|
| 92 |
+
>
|
| 93 |
+
Add parameter
|
| 94 |
+
</button>
|
| 95 |
+
</div>
|
| 96 |
+
|
| 97 |
+
<div class="mt-4 flex flex-col gap-4">
|
| 98 |
+
{#each entries(fields) as [key, field]}
|
| 99 |
+
<div class="flex items-start gap-2">
|
| 100 |
+
<label class="flex grow flex-col gap-1">
|
| 101 |
+
<p class="text-xs font-medium text-gray-500 dark:text-gray-400">Key</p>
|
| 102 |
+
<input
|
| 103 |
+
type="text"
|
| 104 |
+
class="w-full rounded-md border border-gray-300 bg-white px-2 py-1 text-sm text-gray-900 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-gray-700 dark:bg-gray-800 dark:text-white"
|
| 105 |
+
value={key}
|
| 106 |
+
{...onchange(k => (fields = renameKey(fields, key, k)))}
|
| 107 |
+
/>
|
| 108 |
+
</label>
|
| 109 |
+
<label class="flex grow flex-col gap-1">
|
| 110 |
+
<p class="text-xs font-medium text-gray-500 dark:text-gray-400">Value</p>
|
| 111 |
+
<input
|
| 112 |
+
type="text"
|
| 113 |
+
class="w-full rounded-md border border-gray-300 bg-white px-2 py-1 font-mono text-sm text-gray-900 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-gray-700 dark:bg-gray-800 dark:text-white"
|
| 114 |
+
{...field.attrs}
|
| 115 |
+
bind:value={field.value}
|
| 116 |
+
/>
|
| 117 |
+
{#if field.msg}
|
| 118 |
+
<p class="text-xs text-red-500">{field.msg}</p>
|
| 119 |
+
{/if}
|
| 120 |
+
</label>
|
| 121 |
+
<button
|
| 122 |
+
type="button"
|
| 123 |
+
class="btn-xs mt-5 rounded-md text-red-500 hover:text-red-600 dark:text-red-400 dark:hover:text-red-500"
|
| 124 |
+
onclick={() => (fields = deleteKey(fields, key))}
|
| 125 |
+
>
|
| 126 |
+
<IconX />
|
| 127 |
+
</button>
|
| 128 |
+
</div>
|
| 129 |
+
{:else}
|
| 130 |
+
<p class="text-sm text-gray-500">No parameters defined yet.</p>
|
| 131 |
+
{/each}
|
| 132 |
+
</div>
|
| 133 |
+
|
| 134 |
+
{#snippet footer()}
|
| 135 |
+
<button class="btn ml-auto" onclick={save}> Save </button>
|
| 136 |
+
{/snippet}
|
| 137 |
+
</Dialog>
|
src/lib/components/inference-playground/generation-config.svelte
CHANGED
|
@@ -6,7 +6,9 @@
|
|
| 6 |
import { watch } from "runed";
|
| 7 |
import IconX from "~icons/carbon/close";
|
| 8 |
import { GENERATION_CONFIG_KEYS, GENERATION_CONFIG_SETTINGS } from "./generation-config-settings.js";
|
| 9 |
-
import StructuredOutputModal from "./structured-output-modal.svelte";
|
|
|
|
|
|
|
| 10 |
|
| 11 |
interface Props {
|
| 12 |
conversation: ConversationClass;
|
|
@@ -42,7 +44,7 @@
|
|
| 42 |
});
|
| 43 |
}
|
| 44 |
|
| 45 |
-
|
| 46 |
</script>
|
| 47 |
|
| 48 |
<div class="flex flex-col gap-y-7 {classNames}">
|
|
@@ -115,13 +117,27 @@
|
|
| 115 |
class="peer sr-only"
|
| 116 |
id="structured-output"
|
| 117 |
/>
|
| 118 |
-
<button class="btn-mini" type="button" onclick={
|
| 119 |
<div
|
| 120 |
class="peer relative h-5 w-9 rounded-full bg-gray-200 peer-checked:bg-black peer-focus:outline-hidden after:absolute after:start-[2px] after:top-[2px] after:h-4 after:w-4 after:rounded-full after:border after:border-gray-300 after:bg-white after:transition-all after:content-[''] peer-checked:after:translate-x-full peer-checked:after:border-white dark:border-gray-600 dark:bg-gray-700 dark:peer-checked:bg-blue-600"
|
| 121 |
></div>
|
| 122 |
</div>
|
| 123 |
</label>
|
| 124 |
{/if}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
</div>
|
| 126 |
|
| 127 |
-
<StructuredOutputModal {conversation}
|
|
|
|
|
|
| 6 |
import { watch } from "runed";
|
| 7 |
import IconX from "~icons/carbon/close";
|
| 8 |
import { GENERATION_CONFIG_KEYS, GENERATION_CONFIG_SETTINGS } from "./generation-config-settings.js";
|
| 9 |
+
import StructuredOutputModal, { openStructuredOutputModal } from "./structured-output-modal.svelte";
|
| 10 |
+
import ExtraParamsModal, { openExtraParamsModal } from "./extra-params-modal.svelte";
|
| 11 |
+
import { cn } from "$lib/utils/cn.js";
|
| 12 |
|
| 13 |
interface Props {
|
| 14 |
conversation: ConversationClass;
|
|
|
|
| 44 |
});
|
| 45 |
}
|
| 46 |
|
| 47 |
+
const extraParamsLen = $derived(Object.keys(conversation.data.extraParams ?? {}).length);
|
| 48 |
</script>
|
| 49 |
|
| 50 |
<div class="flex flex-col gap-y-7 {classNames}">
|
|
|
|
| 117 |
class="peer sr-only"
|
| 118 |
id="structured-output"
|
| 119 |
/>
|
| 120 |
+
<button class="btn-mini" type="button" onclick={openStructuredOutputModal}> edit </button>
|
| 121 |
<div
|
| 122 |
class="peer relative h-5 w-9 rounded-full bg-gray-200 peer-checked:bg-black peer-focus:outline-hidden after:absolute after:start-[2px] after:top-[2px] after:h-4 after:w-4 after:rounded-full after:border after:border-gray-300 after:bg-white after:transition-all after:content-[''] peer-checked:after:translate-x-full peer-checked:after:border-white dark:border-gray-600 dark:bg-gray-700 dark:peer-checked:bg-blue-600"
|
| 123 |
></div>
|
| 124 |
</div>
|
| 125 |
</label>
|
| 126 |
{/if}
|
| 127 |
+
|
| 128 |
+
<div class="mt-2 flex items-center gap-2">
|
| 129 |
+
<span class="text-sm font-medium text-gray-900 dark:text-gray-300">Extra parameters</span>
|
| 130 |
+
<span
|
| 131 |
+
class={cn(
|
| 132 |
+
"rounded-md bg-black px-2 py-1 text-xs font-semibold text-white dark:bg-blue-600",
|
| 133 |
+
!extraParamsLen && "hidden",
|
| 134 |
+
)}
|
| 135 |
+
>
|
| 136 |
+
{extraParamsLen}
|
| 137 |
+
</span>
|
| 138 |
+
<button class="btn-mini ml-auto" type="button" onclick={openExtraParamsModal}>edit</button>
|
| 139 |
+
</div>
|
| 140 |
</div>
|
| 141 |
|
| 142 |
+
<StructuredOutputModal {conversation} />
|
| 143 |
+
<ExtraParamsModal {conversation} />
|
src/lib/components/inference-playground/structured-output-modal.svelte
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<script lang="ts">
|
| 2 |
import { isDark } from "$lib/spells/is-dark.svelte";
|
| 3 |
import { Synced } from "$lib/spells/synced.svelte";
|
|
@@ -14,10 +22,9 @@
|
|
| 14 |
|
| 15 |
interface Props {
|
| 16 |
conversation: ConversationClass;
|
| 17 |
-
open: boolean;
|
| 18 |
}
|
| 19 |
|
| 20 |
-
let { conversation
|
| 21 |
|
| 22 |
let tempSchema = $derived(conversation.data.structuredOutput?.schema ?? "");
|
| 23 |
|
|
@@ -124,122 +131,116 @@
|
|
| 124 |
</div>
|
| 125 |
|
| 126 |
{#if radioGroup.value === "form"}
|
| 127 |
-
<div class="fade-y -mx-2
|
| 128 |
<!-- Properties Section -->
|
| 129 |
-
<
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
schemaObj.current.schema?.properties ?? {},
|
| 140 |
-
propertyName,
|
| 141 |
-
value,
|
| 142 |
-
);
|
| 143 |
-
updateSchemaNested({ properties: updatedProperties });
|
| 144 |
-
}
|
| 145 |
}
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
}
|
| 154 |
}
|
| 155 |
}
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
} else {
|
| 165 |
-
updatedRequired = updatedRequired.filter(name => name !== name);
|
| 166 |
}
|
| 167 |
-
|
|
|
|
| 168 |
}
|
|
|
|
| 169 |
}
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
}
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
|
|
|
| 184 |
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
</div>
|
| 226 |
</div>
|
|
|
|
| 227 |
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
</div>
|
| 243 |
</div>
|
| 244 |
</div>
|
| 245 |
</div>
|
|
|
|
| 1 |
+
<script lang="ts" module>
|
| 2 |
+
let open = $state(false);
|
| 3 |
+
|
| 4 |
+
export function openStructuredOutputModal() {
|
| 5 |
+
open = true;
|
| 6 |
+
}
|
| 7 |
+
</script>
|
| 8 |
+
|
| 9 |
<script lang="ts">
|
| 10 |
import { isDark } from "$lib/spells/is-dark.svelte";
|
| 11 |
import { Synced } from "$lib/spells/synced.svelte";
|
|
|
|
| 22 |
|
| 23 |
interface Props {
|
| 24 |
conversation: ConversationClass;
|
|
|
|
| 25 |
}
|
| 26 |
|
| 27 |
+
let { conversation }: Props = $props();
|
| 28 |
|
| 29 |
let tempSchema = $derived(conversation.data.structuredOutput?.schema ?? "");
|
| 30 |
|
|
|
|
| 131 |
</div>
|
| 132 |
|
| 133 |
{#if radioGroup.value === "form"}
|
| 134 |
+
<div class="fade-y -mx-2 -mb-4 max-h-200 space-y-4 overflow-auto px-2 py-4 text-left">
|
| 135 |
<!-- Properties Section -->
|
| 136 |
+
<h3 class="text-lg leading-6 font-medium text-gray-900 dark:text-gray-100">Properties</h3>
|
| 137 |
+
{#if schemaObj.current.schema?.properties}
|
| 138 |
+
<div class="mt-3 space-y-3">
|
| 139 |
+
{#each Object.entries(schemaObj.current.schema.properties) as [propertyName, propertyDefinition]}
|
| 140 |
+
<SchemaProperty
|
| 141 |
+
bind:name={
|
| 142 |
+
() => propertyName,
|
| 143 |
+
value => {
|
| 144 |
+
const updatedProperties = renameKey(schemaObj.current.schema?.properties ?? {}, propertyName, value);
|
| 145 |
+
updateSchemaNested({ properties: updatedProperties });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
}
|
| 147 |
+
}
|
| 148 |
+
bind:definition={
|
| 149 |
+
() => propertyDefinition,
|
| 150 |
+
v => {
|
| 151 |
+
const updatedProperties = { ...schemaObj.current.schema?.properties };
|
| 152 |
+
if (updatedProperties && updatedProperties[propertyName]) {
|
| 153 |
+
updatedProperties[propertyName] = v;
|
| 154 |
+
updateSchemaNested({ properties: updatedProperties });
|
| 155 |
}
|
| 156 |
}
|
| 157 |
+
}
|
| 158 |
+
bind:required={
|
| 159 |
+
() => schemaObj.current.schema?.required?.includes(propertyName) ?? false,
|
| 160 |
+
v => {
|
| 161 |
+
let updatedRequired = [...(schemaObj.current.schema?.required || [])];
|
| 162 |
+
if (v) {
|
| 163 |
+
if (!updatedRequired.includes(propertyName)) {
|
| 164 |
+
updatedRequired.push(propertyName);
|
|
|
|
|
|
|
| 165 |
}
|
| 166 |
+
} else {
|
| 167 |
+
updatedRequired = updatedRequired.filter(name => name !== name);
|
| 168 |
}
|
| 169 |
+
updateSchemaNested({ required: updatedRequired });
|
| 170 |
}
|
| 171 |
+
}
|
| 172 |
+
onDelete={() => {
|
| 173 |
+
const updatedProperties = { ...schemaObj.current.schema?.properties };
|
| 174 |
+
if (!updatedProperties || !updatedProperties[propertyName]) return;
|
| 175 |
+
delete updatedProperties[propertyName];
|
| 176 |
+
updateSchemaNested({ properties: updatedProperties });
|
| 177 |
+
}}
|
| 178 |
+
/>
|
| 179 |
+
{:else}
|
| 180 |
+
<p class="mt-3 text-sm text-gray-500">No properties defined yet.</p>
|
| 181 |
+
{/each}
|
| 182 |
+
</div>
|
| 183 |
+
{:else}
|
| 184 |
+
<p class="mt-3 text-sm text-gray-500">No properties defined yet.</p>
|
| 185 |
+
{/if}
|
| 186 |
|
| 187 |
+
<button
|
| 188 |
+
type="button"
|
| 189 |
+
class="btn-sm mt-4 flex w-full items-center justify-center rounded-md"
|
| 190 |
+
onclick={() => {
|
| 191 |
+
const newPropertyName = `newProperty${Object.keys(schemaObj.current.schema?.properties || {}).length + 1}`;
|
| 192 |
+
const updatedProperties = {
|
| 193 |
+
...(schemaObj.current.schema?.properties || {}),
|
| 194 |
+
[newPropertyName]: { type: "string" as const },
|
| 195 |
+
};
|
| 196 |
+
updateSchemaNested({ properties: updatedProperties });
|
| 197 |
+
}}
|
| 198 |
+
>
|
| 199 |
+
Add property
|
| 200 |
+
</button>
|
| 201 |
+
</div>
|
| 202 |
|
| 203 |
+
<!-- Strict and Additional Properties -->
|
| 204 |
+
<div class="border-t border-gray-200 pt-4 dark:border-gray-700">
|
| 205 |
+
<h3 class="text-lg leading-6 font-medium text-gray-900 dark:text-gray-100">Options</h3>
|
| 206 |
+
<div class="mt-3 space-y-2">
|
| 207 |
+
<div class="relative flex items-start">
|
| 208 |
+
<div class="flex h-5 items-center">
|
| 209 |
+
<input
|
| 210 |
+
id="additionalProperties"
|
| 211 |
+
name="additionalProperties"
|
| 212 |
+
type="checkbox"
|
| 213 |
+
class="h-4 w-4 rounded border border-gray-300 bg-white text-blue-600 focus:ring-blue-500 dark:border-gray-700 dark:bg-gray-800"
|
| 214 |
+
checked={schemaObj.current.schema?.additionalProperties !== undefined
|
| 215 |
+
? schemaObj.current.schema.additionalProperties
|
| 216 |
+
: true}
|
| 217 |
+
onchange={e => updateSchemaNested({ additionalProperties: e.currentTarget.checked })}
|
| 218 |
+
/>
|
| 219 |
+
</div>
|
| 220 |
+
<div class="ml-3 text-sm">
|
| 221 |
+
<label for="additionalProperties" class="font-medium text-gray-700 dark:text-gray-300">
|
| 222 |
+
Allow additional properties
|
| 223 |
+
</label>
|
| 224 |
+
<p id="additionalProperties-description" class="text-gray-500">
|
| 225 |
+
If unchecked, only properties defined in the schema are allowed.
|
| 226 |
+
</p>
|
|
|
|
| 227 |
</div>
|
| 228 |
+
</div>
|
| 229 |
|
| 230 |
+
<div class="relative flex items-start">
|
| 231 |
+
<div class="flex h-5 items-center">
|
| 232 |
+
<input
|
| 233 |
+
id="strict"
|
| 234 |
+
name="strict"
|
| 235 |
+
type="checkbox"
|
| 236 |
+
class="h-4 w-4 rounded border border-gray-300 bg-white text-blue-600 focus:ring-blue-500 dark:border-gray-700 dark:bg-gray-800"
|
| 237 |
+
checked={schemaObj.current.strict !== undefined ? schemaObj.current.strict : false}
|
| 238 |
+
onchange={e => updateSchema({ strict: e.currentTarget.checked })}
|
| 239 |
+
/>
|
| 240 |
+
</div>
|
| 241 |
+
<div class="ml-3 text-sm">
|
| 242 |
+
<label for="strict" class="font-medium text-gray-700 dark:text-gray-300">Strict mode</label>
|
| 243 |
+
<p id="strict-description" class="text-gray-500">Enforces stricter validation rules.</p>
|
|
|
|
| 244 |
</div>
|
| 245 |
</div>
|
| 246 |
</div>
|
src/lib/components/info-popover.svelte
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { cn } from "$lib/utils/cn.js";
|
| 3 |
+
import { Popover } from "melt/builders";
|
| 4 |
+
import InfoIcon from "~icons/carbon/information";
|
| 5 |
+
|
| 6 |
+
type Props = {
|
| 7 |
+
class?: string;
|
| 8 |
+
content?: string;
|
| 9 |
+
};
|
| 10 |
+
|
| 11 |
+
let { class: classes, content }: Props = $props();
|
| 12 |
+
|
| 13 |
+
const popover = new Popover({
|
| 14 |
+
floatingConfig: {
|
| 15 |
+
computePosition: { placement: "top" },
|
| 16 |
+
},
|
| 17 |
+
});
|
| 18 |
+
</script>
|
| 19 |
+
|
| 20 |
+
<button
|
| 21 |
+
type="button"
|
| 22 |
+
class={cn("btn-xs rounded-md text-gray-500 hover:text-gray-600 dark:text-gray-400 dark:hover:text-gray-500", classes)}
|
| 23 |
+
{...popover.trigger}
|
| 24 |
+
>
|
| 25 |
+
<InfoIcon />
|
| 26 |
+
</button>
|
| 27 |
+
|
| 28 |
+
<div
|
| 29 |
+
{...popover.content}
|
| 30 |
+
class="max-w-xs overflow-visible rounded-xl bg-white p-0 text-center shadow-xl dark:bg-gray-700"
|
| 31 |
+
>
|
| 32 |
+
<div {...popover.arrow} class="!z-10 size-2 rounded-tl !bg-white dark:!bg-gray-700"></div>
|
| 33 |
+
<p class="px-4 py-1 text-sm text-gray-700 dark:text-white">{content}</p>
|
| 34 |
+
</div>
|
| 35 |
+
|
| 36 |
+
<style>
|
| 37 |
+
[data-melt-popover-content] {
|
| 38 |
+
border: 0;
|
| 39 |
+
|
| 40 |
+
position: absolute;
|
| 41 |
+
pointer-events: none;
|
| 42 |
+
opacity: 0;
|
| 43 |
+
|
| 44 |
+
transform: scale(0.9);
|
| 45 |
+
|
| 46 |
+
transition: 0.3s;
|
| 47 |
+
transition-property: opacity, transform;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
[data-melt-popover-content][data-open] {
|
| 51 |
+
pointer-events: auto;
|
| 52 |
+
opacity: 1;
|
| 53 |
+
|
| 54 |
+
transform: scale(1);
|
| 55 |
+
}
|
| 56 |
+
</style>
|
src/lib/state/conversations.svelte.ts
CHANGED
|
@@ -29,6 +29,9 @@ export class ConversationEntity {
|
|
| 29 |
@Fields.json()
|
| 30 |
config: GenerationConfig = {};
|
| 31 |
|
|
|
|
|
|
|
|
|
|
| 32 |
@Fields.json()
|
| 33 |
structuredOutput?: {
|
| 34 |
enabled?: boolean;
|
|
|
|
| 29 |
@Fields.json()
|
| 30 |
config: GenerationConfig = {};
|
| 31 |
|
| 32 |
+
@Fields.json()
|
| 33 |
+
extraParams?: Record<string, string>;
|
| 34 |
+
|
| 35 |
@Fields.json()
|
| 36 |
structuredOutput?: {
|
| 37 |
enabled?: boolean;
|
src/lib/types.ts
CHANGED
|
@@ -15,7 +15,7 @@ export type Conversation = {
|
|
| 15 |
systemMessage: ConversationMessage;
|
| 16 |
streaming: boolean;
|
| 17 |
provider?: string;
|
| 18 |
-
} & Pick<ConversationEntityMembers, "structuredOutput">;
|
| 19 |
|
| 20 |
export type ConversationWithCustomModel = Conversation & {
|
| 21 |
model: CustomModel;
|
|
|
|
| 15 |
systemMessage: ConversationMessage;
|
| 16 |
streaming: boolean;
|
| 17 |
provider?: string;
|
| 18 |
+
} & Pick<ConversationEntityMembers, "structuredOutput" | "extraParams">;
|
| 19 |
|
| 20 |
export type ConversationWithCustomModel = Conversation & {
|
| 21 |
model: CustomModel;
|
src/lib/utils/business.svelte.ts
CHANGED
|
@@ -127,8 +127,21 @@ async function getCompletionMetadata(
|
|
| 127 |
];
|
| 128 |
const parsed = await Promise.all(messages.map(parseMessage));
|
| 129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
const baseArgs = {
|
| 131 |
...data.config,
|
|
|
|
| 132 |
messages: parsed,
|
| 133 |
model: model.id,
|
| 134 |
response_format: getResponseFormatObj(conversation),
|
|
|
|
| 127 |
];
|
| 128 |
const parsed = await Promise.all(messages.map(parseMessage));
|
| 129 |
|
| 130 |
+
const extraParams = data.extraParams
|
| 131 |
+
? Object.fromEntries(
|
| 132 |
+
Object.entries(data.extraParams).map(([key, value]) => {
|
| 133 |
+
try {
|
| 134 |
+
return [key, JSON.parse(value as string)];
|
| 135 |
+
} catch {
|
| 136 |
+
return [key, value];
|
| 137 |
+
}
|
| 138 |
+
}),
|
| 139 |
+
)
|
| 140 |
+
: {};
|
| 141 |
+
|
| 142 |
const baseArgs = {
|
| 143 |
...data.config,
|
| 144 |
+
...extraParams,
|
| 145 |
messages: parsed,
|
| 146 |
model: model.id,
|
| 147 |
response_format: getResponseFormatObj(conversation),
|
src/lib/utils/form.svelte.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
export type CreateFieldValidationArgs = {
|
| 2 |
validate: (v: string) => string | void | undefined;
|
| 3 |
};
|
|
@@ -6,11 +9,11 @@ export function createFieldValidation(args: CreateFieldValidationArgs) {
|
|
| 6 |
let valid = $state(true);
|
| 7 |
let msg = $state<string>();
|
| 8 |
|
| 9 |
-
const
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
};
|
| 15 |
|
| 16 |
const oninput = (e: Event & { currentTarget: HTMLInputElement }) => {
|
|
@@ -20,7 +23,15 @@ export function createFieldValidation(args: CreateFieldValidationArgs) {
|
|
| 20 |
msg = m ? m : undefined;
|
| 21 |
};
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
return {
|
|
|
|
| 24 |
get valid() {
|
| 25 |
return valid;
|
| 26 |
},
|
|
@@ -34,6 +45,9 @@ export function createFieldValidation(args: CreateFieldValidationArgs) {
|
|
| 34 |
attrs: {
|
| 35 |
onblur,
|
| 36 |
oninput,
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
| 38 |
};
|
| 39 |
}
|
|
|
|
| 1 |
+
import { createAttachmentKey } from "svelte/attachments";
|
| 2 |
+
import type { HTMLInputAttributes } from "svelte/elements";
|
| 3 |
+
|
| 4 |
export type CreateFieldValidationArgs = {
|
| 5 |
validate: (v: string) => string | void | undefined;
|
| 6 |
};
|
|
|
|
| 9 |
let valid = $state(true);
|
| 10 |
let msg = $state<string>();
|
| 11 |
|
| 12 |
+
const key = createAttachmentKey();
|
| 13 |
+
let node: HTMLInputElement;
|
| 14 |
+
|
| 15 |
+
const onblur = (_e: Event & { currentTarget: HTMLInputElement }) => {
|
| 16 |
+
validate();
|
| 17 |
};
|
| 18 |
|
| 19 |
const oninput = (e: Event & { currentTarget: HTMLInputElement }) => {
|
|
|
|
| 23 |
msg = m ? m : undefined;
|
| 24 |
};
|
| 25 |
|
| 26 |
+
const validate = () => {
|
| 27 |
+
const v = node.value;
|
| 28 |
+
const m = args.validate(v);
|
| 29 |
+
valid = !m;
|
| 30 |
+
msg = m ? m : undefined;
|
| 31 |
+
};
|
| 32 |
+
|
| 33 |
return {
|
| 34 |
+
validate,
|
| 35 |
get valid() {
|
| 36 |
return valid;
|
| 37 |
},
|
|
|
|
| 45 |
attrs: {
|
| 46 |
onblur,
|
| 47 |
oninput,
|
| 48 |
+
[key]: el => {
|
| 49 |
+
node = el;
|
| 50 |
+
},
|
| 51 |
+
} as const satisfies HTMLInputAttributes,
|
| 52 |
};
|
| 53 |
}
|
src/lib/utils/object.svelte.ts
CHANGED
|
@@ -102,3 +102,15 @@ export function renameKey<T extends object>(
|
|
| 102 |
}
|
| 103 |
return result;
|
| 104 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
}
|
| 103 |
return result;
|
| 104 |
}
|
| 105 |
+
|
| 106 |
+
export function unmutableSet<T extends object>(obj: T, key: keyof T, value: T[keyof T]) {
|
| 107 |
+
const newObj = { ...obj };
|
| 108 |
+
newObj[key] = value;
|
| 109 |
+
return newObj;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
export function deleteKey<T extends object>(obj: T, key: keyof T) {
|
| 113 |
+
const newObj = { ...obj };
|
| 114 |
+
delete newObj[key];
|
| 115 |
+
return newObj;
|
| 116 |
+
}
|