palettecn 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +10 -0
- package/dist/web/nitro.json +17 -0
- package/dist/web/public/assets/abap-BdvmRIgS.js +1 -0
- package/dist/web/public/assets/actionscript-3-et0rQaqm.js +1 -0
- package/dist/web/public/assets/ada-DPgrustg.js +1 -0
- package/dist/web/public/assets/andromeeda-DJl1yeV_.js +1 -0
- package/dist/web/public/assets/angular-html-Dm7s7tSx.js +1 -0
- package/dist/web/public/assets/angular-ts-B_ywTULt.js +1 -0
- package/dist/web/public/assets/apache-CFpsYX8S.js +1 -0
- package/dist/web/public/assets/apex-CN5n6pbI.js +1 -0
- package/dist/web/public/assets/apl-Dm11wHHc.js +1 -0
- package/dist/web/public/assets/applescript-JrY23hsL.js +1 -0
- package/dist/web/public/assets/ara-DR83hn3A.js +1 -0
- package/dist/web/public/assets/asciidoc-Dpu9XLB1.js +1 -0
- package/dist/web/public/assets/asm-BYI3A31V.js +1 -0
- package/dist/web/public/assets/astro-DP1naDCT.js +1 -0
- package/dist/web/public/assets/aurora-x-Nav5jnoQ.js +1 -0
- package/dist/web/public/assets/awk-BIoTx_w6.js +1 -0
- package/dist/web/public/assets/ayu-dark-H5QV5J7K.js +1 -0
- package/dist/web/public/assets/ayu-light-BrwTNGnU.js +1 -0
- package/dist/web/public/assets/ayu-mirage-Bg6FpF5w.js +1 -0
- package/dist/web/public/assets/ballerina-BFvDNd4T.js +1 -0
- package/dist/web/public/assets/bat-DtQkx7Ny.js +1 -0
- package/dist/web/public/assets/beancount-BIjKALa1.js +1 -0
- package/dist/web/public/assets/berry-BPkDN_EZ.js +1 -0
- package/dist/web/public/assets/bibtex-Dur2CNW6.js +1 -0
- package/dist/web/public/assets/bicep-BMz1bZ7m.js +1 -0
- package/dist/web/public/assets/bird2-91rdr9s7.js +1 -0
- package/dist/web/public/assets/blade-DD5O596X.js +1 -0
- package/dist/web/public/assets/bsl-FmB7U2qd.js +1 -0
- package/dist/web/public/assets/bundle-mjs-Bso3xn9x.js +1 -0
- package/dist/web/public/assets/c-DqqBLLyl.js +1 -0
- package/dist/web/public/assets/c3-CJTbEooS.js +1 -0
- package/dist/web/public/assets/cadence-C0GI7BZZ.js +1 -0
- package/dist/web/public/assets/cairo-B5JMmIC0.js +1 -0
- package/dist/web/public/assets/catppuccin-frappe-D76-cUjK.js +1 -0
- package/dist/web/public/assets/catppuccin-latte-DUHNJ_6_.js +1 -0
- package/dist/web/public/assets/catppuccin-macchiato-CFhPH2wd.js +1 -0
- package/dist/web/public/assets/catppuccin-mocha-BRD0cvUW.js +1 -0
- package/dist/web/public/assets/chunk-FRKYWMV7-DUkk3w4h.js +122 -0
- package/dist/web/public/assets/clarity-KgUVrNfC.js +1 -0
- package/dist/web/public/assets/clojure-BhQuoGIG.js +1 -0
- package/dist/web/public/assets/cmake-CA59gUFQ.js +1 -0
- package/dist/web/public/assets/cobol-CCFShgGZ.js +1 -0
- package/dist/web/public/assets/codeowners-CD36YqjJ.js +1 -0
- package/dist/web/public/assets/codeql-CrMosKUt.js +1 -0
- package/dist/web/public/assets/coffee-C-Mn3tBT.js +1 -0
- package/dist/web/public/assets/common-lisp-DYnOjAFz.js +1 -0
- package/dist/web/public/assets/components-DiZ1dSl3.js +77 -0
- package/dist/web/public/assets/coq-BaHtq3Qt.js +1 -0
- package/dist/web/public/assets/cpp-D8Y73ItU.js +1 -0
- package/dist/web/public/assets/crystal-CnXWqbxx.js +1 -0
- package/dist/web/public/assets/csharp-D6sghVPa.js +1 -0
- package/dist/web/public/assets/css-CUGjdPw_.js +1 -0
- package/dist/web/public/assets/csv-DuxyxUAI.js +1 -0
- package/dist/web/public/assets/cue-D9NRAX0_.js +1 -0
- package/dist/web/public/assets/cypher-HJRdtilF.js +1 -0
- package/dist/web/public/assets/d-B4Ont7_X.js +1 -0
- package/dist/web/public/assets/dark-plus-DZSBycyp.js +1 -0
- package/dist/web/public/assets/dart-Dp4asavE.js +1 -0
- package/dist/web/public/assets/dax-DBUubp6S.js +1 -0
- package/dist/web/public/assets/desktop-DQ0n6zIQ.js +1 -0
- package/dist/web/public/assets/diff-CFHlrffC.js +1 -0
- package/dist/web/public/assets/docker-BuefmsF5.js +1 -0
- package/dist/web/public/assets/dotenv-BKTsUQ_r.js +1 -0
- package/dist/web/public/assets/dracula-MOn9qacs.js +1 -0
- package/dist/web/public/assets/dracula-soft-C4r_sC_D.js +1 -0
- package/dist/web/public/assets/dream-maker-BNdv5lLS.js +1 -0
- package/dist/web/public/assets/edge-C-Mi8Oda.js +1 -0
- package/dist/web/public/assets/elixir-CTS5wQtX.js +1 -0
- package/dist/web/public/assets/elm-rM310x8D.js +1 -0
- package/dist/web/public/assets/emacs-lisp-D9FIGRtM.js +1 -0
- package/dist/web/public/assets/erb-oaGjGVGO.js +1 -0
- package/dist/web/public/assets/erlang-q4Mkyw3m.js +1 -0
- package/dist/web/public/assets/everforest-dark-CNa2QFRn.js +1 -0
- package/dist/web/public/assets/everforest-light-DRbUDqJT.js +1 -0
- package/dist/web/public/assets/fennel-DpqQTaVZ.js +1 -0
- package/dist/web/public/assets/field-1-Ujza0S5j.js +1 -0
- package/dist/web/public/assets/fish-hyk5x6Q4.js +1 -0
- package/dist/web/public/assets/fluent-DMll-MGX.js +1 -0
- package/dist/web/public/assets/fortran-fixed-form-BmdfKovV.js +1 -0
- package/dist/web/public/assets/fortran-free-form-MCAifii4.js +1 -0
- package/dist/web/public/assets/fsharp-DLlBn9Nl.js +1 -0
- package/dist/web/public/assets/gdresource-BzFzBRli.js +1 -0
- package/dist/web/public/assets/gdscript-D3R4J0Cv.js +1 -0
- package/dist/web/public/assets/gdshader-BAubtqqN.js +1 -0
- package/dist/web/public/assets/genie-BnIIX2pC.js +1 -0
- package/dist/web/public/assets/gherkin-CL3NUuB1.js +1 -0
- package/dist/web/public/assets/git-commit-BYPE8h85.js +1 -0
- package/dist/web/public/assets/git-rebase-Bmmgf6eN.js +1 -0
- package/dist/web/public/assets/github-dark-default-C6I2oE4c.js +1 -0
- package/dist/web/public/assets/github-dark-dimmed-DEqwxg6D.js +1 -0
- package/dist/web/public/assets/github-dark-high-contrast-DDt3j0cs.js +1 -0
- package/dist/web/public/assets/github-dark-oLN6SDKl.js +1 -0
- package/dist/web/public/assets/github-light-DaN-N2Gj.js +1 -0
- package/dist/web/public/assets/github-light-default-B3EwMbS7.js +1 -0
- package/dist/web/public/assets/github-light-high-contrast-Cl9D0f_e.js +1 -0
- package/dist/web/public/assets/gleam-Cvj8QRtQ.js +1 -0
- package/dist/web/public/assets/glimmer-js-CahbROb1.js +1 -0
- package/dist/web/public/assets/glimmer-ts-JMFYNbot.js +1 -0
- package/dist/web/public/assets/global-XWAvxWcA.css +2 -0
- package/dist/web/public/assets/glsl-BCuCNM3V.js +1 -0
- package/dist/web/public/assets/gn-DxCHSEMl.js +1 -0
- package/dist/web/public/assets/gnuplot-CkGXHK7B.js +1 -0
- package/dist/web/public/assets/go-B_NLCuTj.js +1 -0
- package/dist/web/public/assets/graphql-RXOfHGfI.js +1 -0
- package/dist/web/public/assets/groovy-DVge8oRs.js +1 -0
- package/dist/web/public/assets/gruvbox-dark-hard-BwZz1yni.js +1 -0
- package/dist/web/public/assets/gruvbox-dark-medium-Bqy6jkuO.js +1 -0
- package/dist/web/public/assets/gruvbox-dark-soft-DjUvyUfH.js +1 -0
- package/dist/web/public/assets/gruvbox-light-hard-BTLmfPdm.js +1 -0
- package/dist/web/public/assets/gruvbox-light-medium-DeWqsWs6.js +1 -0
- package/dist/web/public/assets/gruvbox-light-soft-BL8ld-1F.js +1 -0
- package/dist/web/public/assets/hack-BBQpwyf_.js +1 -0
- package/dist/web/public/assets/haml-mWELc9kh.js +1 -0
- package/dist/web/public/assets/handlebars-COrUo8cC.js +1 -0
- package/dist/web/public/assets/haskell-DRmM8XlQ.js +1 -0
- package/dist/web/public/assets/haxe-BEhq8ZEr.js +1 -0
- package/dist/web/public/assets/hcl-B5ZIaGS0.js +1 -0
- package/dist/web/public/assets/highlighted-body-TPN3WLV5-YJgGFx4e.js +1 -0
- package/dist/web/public/assets/hjson-B9uRLqIO.js +1 -0
- package/dist/web/public/assets/hlsl-Hv1kKjrS.js +1 -0
- package/dist/web/public/assets/horizon-ClXGBjWw.js +1 -0
- package/dist/web/public/assets/horizon-bright-CvUCr3ux.js +1 -0
- package/dist/web/public/assets/houston-NqkqG60q.js +1 -0
- package/dist/web/public/assets/html-cmigv1ou.js +1 -0
- package/dist/web/public/assets/html-derivative-B3me0pSu.js +1 -0
- package/dist/web/public/assets/http-BojM9cyU.js +1 -0
- package/dist/web/public/assets/hurl-BxEmMiGP.js +1 -0
- package/dist/web/public/assets/hxml-CoBuVbfs.js +1 -0
- package/dist/web/public/assets/hy-CeISYGGU.js +1 -0
- package/dist/web/public/assets/imba-xjcDFXUW.js +1 -0
- package/dist/web/public/assets/ini-D0ZCSj6e.js +1 -0
- package/dist/web/public/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/dist/web/public/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/dist/web/public/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/dist/web/public/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/dist/web/public/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/dist/web/public/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/dist/web/public/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/dist/web/public/assets/java-BvheClGI.js +1 -0
- package/dist/web/public/assets/javascript-DjlJORDg.js +1 -0
- package/dist/web/public/assets/jinja-Bi4sG72X.js +1 -0
- package/dist/web/public/assets/jison-BTz5Ik2Y.js +1 -0
- package/dist/web/public/assets/json-CiTd40Rg.js +1 -0
- package/dist/web/public/assets/json5-FR9EyF7a.js +1 -0
- package/dist/web/public/assets/jsonc-CHIeFfsD.js +1 -0
- package/dist/web/public/assets/jsonl-B4WQkwTf.js +1 -0
- package/dist/web/public/assets/jsonnet-vd-gzGkL.js +1 -0
- package/dist/web/public/assets/jssm-C_bj1LkZ.js +1 -0
- package/dist/web/public/assets/jsx-Bx-RZMFH.js +1 -0
- package/dist/web/public/assets/jsx-runtime-n8k0hwt8.js +1 -0
- package/dist/web/public/assets/julia-BKcIfSxk.js +1 -0
- package/dist/web/public/assets/just-IkZCagAs.js +1 -0
- package/dist/web/public/assets/kanagawa-dragon-B3Cz89vt.js +1 -0
- package/dist/web/public/assets/kanagawa-lotus-CRe_W5Ft.js +1 -0
- package/dist/web/public/assets/kanagawa-wave-BPqZ5XB7.js +1 -0
- package/dist/web/public/assets/kdl-BzL_Ak31.js +1 -0
- package/dist/web/public/assets/kotlin-BQQFk6ql.js +1 -0
- package/dist/web/public/assets/kusto-vWe6OLKV.js +1 -0
- package/dist/web/public/assets/laserwave-CwtvEUcj.js +1 -0
- package/dist/web/public/assets/latex-9N90_WFU.js +1 -0
- package/dist/web/public/assets/lean-CaqenOqv.js +1 -0
- package/dist/web/public/assets/less-CERnPzn6.js +1 -0
- package/dist/web/public/assets/light-plus-B9_M_OKq.js +1 -0
- package/dist/web/public/assets/liquid-CQLPDP7m.js +1 -0
- package/dist/web/public/assets/llvm-BylJXvm7.js +1 -0
- package/dist/web/public/assets/log-CBBcNcbO.js +1 -0
- package/dist/web/public/assets/logo-r-8Jc8Xk.js +1 -0
- package/dist/web/public/assets/lua-BBL6LXKd.js +1 -0
- package/dist/web/public/assets/luau-B2g7L-zP.js +1 -0
- package/dist/web/public/assets/main-0lKVDR64.css +2 -0
- package/dist/web/public/assets/main-CcNf0BOb.js +126 -0
- package/dist/web/public/assets/make-DK-HzJ2w.js +1 -0
- package/dist/web/public/assets/markdown-FgdsukgR.js +1 -0
- package/dist/web/public/assets/marko-CLZwt2N2.js +1 -0
- package/dist/web/public/assets/material-theme-DOJ9PS4O.js +1 -0
- package/dist/web/public/assets/material-theme-darker-DOurH5jT.js +1 -0
- package/dist/web/public/assets/material-theme-lighter-BfPWxCP6.js +1 -0
- package/dist/web/public/assets/material-theme-ocean-BcO5PKoq.js +1 -0
- package/dist/web/public/assets/material-theme-palenight-ClWQBDDd.js +1 -0
- package/dist/web/public/assets/matlab-DwyUVNXd.js +1 -0
- package/dist/web/public/assets/mdc-Bo8CRPg4.js +1 -0
- package/dist/web/public/assets/mdx-3EBShbsD.js +1 -0
- package/dist/web/public/assets/mermaid-ByG2-SLz.js +1 -0
- package/dist/web/public/assets/mermaid-O7DHMXV3-COAgR3aM.js +1 -0
- package/dist/web/public/assets/min-dark-ClJ2x5pc.js +1 -0
- package/dist/web/public/assets/min-light-BsOUz5iE.js +1 -0
- package/dist/web/public/assets/mipsasm-BKDtQCf3.js +1 -0
- package/dist/web/public/assets/mojo-DmEAK7iv.js +1 -0
- package/dist/web/public/assets/monokai-BKc3VADO.js +1 -0
- package/dist/web/public/assets/moonbit-Qm8v_cKN.js +1 -0
- package/dist/web/public/assets/move-CMectUPk.js +1 -0
- package/dist/web/public/assets/narrat-Bdm8NaK8.js +1 -0
- package/dist/web/public/assets/nextflow-BpSt05nC.js +1 -0
- package/dist/web/public/assets/nextflow-groovy-BZ-bqJ-u.js +1 -0
- package/dist/web/public/assets/nginx-ChZL5FWE.js +1 -0
- package/dist/web/public/assets/night-owl-CbFc5pXO.js +1 -0
- package/dist/web/public/assets/night-owl-light-zYbVCVuz.js +1 -0
- package/dist/web/public/assets/nim-5JnPAJWa.js +1 -0
- package/dist/web/public/assets/nix-P5P-2qHs.js +1 -0
- package/dist/web/public/assets/nord-C7hKGudV.js +1 -0
- package/dist/web/public/assets/nushell-DKPnC5RG.js +1 -0
- package/dist/web/public/assets/objective-c-BPwXtM0v.js +1 -0
- package/dist/web/public/assets/objective-cpp-CWYEdWNG.js +1 -0
- package/dist/web/public/assets/ocaml-CL7OJ02v.js +1 -0
- package/dist/web/public/assets/odin-Dtay25eA.js +1 -0
- package/dist/web/public/assets/one-dark-pro-CrdFNNwF.js +1 -0
- package/dist/web/public/assets/one-light-BUiz8X4B.js +1 -0
- package/dist/web/public/assets/openscad-WD4sXUUp.js +1 -0
- package/dist/web/public/assets/pascal-A6-MZnZ8.js +1 -0
- package/dist/web/public/assets/perl-Yq3AfnVV.js +1 -0
- package/dist/web/public/assets/php-CCj0foPx.js +1 -0
- package/dist/web/public/assets/pkl-cmPbg8fI.js +1 -0
- package/dist/web/public/assets/plastic-DtQ_LnDB.js +1 -0
- package/dist/web/public/assets/plsql-DwmuVd7q.js +1 -0
- package/dist/web/public/assets/po-CkVxkZaj.js +1 -0
- package/dist/web/public/assets/poimandres-Dt0xZuaa.js +1 -0
- package/dist/web/public/assets/polar-hStNz_W2.js +1 -0
- package/dist/web/public/assets/postcss-ZIk0AQ7M.js +1 -0
- package/dist/web/public/assets/powerquery-D0gqoHHD.js +1 -0
- package/dist/web/public/assets/powershell-DXB5HoVh.js +1 -0
- package/dist/web/public/assets/prisma-DmTrfxC0.js +1 -0
- package/dist/web/public/assets/prolog-CdoyriEj.js +1 -0
- package/dist/web/public/assets/proto-4MrN11dS.js +1 -0
- package/dist/web/public/assets/pug-svYJKDOQ.js +1 -0
- package/dist/web/public/assets/puppet-MEaLGpAP.js +1 -0
- package/dist/web/public/assets/purescript-CPxCorqB.js +1 -0
- package/dist/web/public/assets/python-f4fp5z0z.js +1 -0
- package/dist/web/public/assets/qml-BzEtWdqI.js +1 -0
- package/dist/web/public/assets/qmldir-DCjSceJ_.js +1 -0
- package/dist/web/public/assets/qss-BdM02NUc.js +1 -0
- package/dist/web/public/assets/r-luosIeJH.js +1 -0
- package/dist/web/public/assets/racket-D2tfa8Zc.js +1 -0
- package/dist/web/public/assets/raku-KeGPJVZg.js +1 -0
- package/dist/web/public/assets/razor-Bokxs4Qx.js +1 -0
- package/dist/web/public/assets/red-C0qZ-1lN.js +1 -0
- package/dist/web/public/assets/reg-DdnswvOj.js +1 -0
- package/dist/web/public/assets/regexp-CYC8h6V9.js +1 -0
- package/dist/web/public/assets/rel-RhzEfSRc.js +1 -0
- package/dist/web/public/assets/riscv-dS5TzX10.js +1 -0
- package/dist/web/public/assets/ron-CQjQSCVp.js +1 -0
- package/dist/web/public/assets/rose-pine-C89ViLdr.js +1 -0
- package/dist/web/public/assets/rose-pine-dawn-Dq2gf0yi.js +1 -0
- package/dist/web/public/assets/rose-pine-moon-CBDvXVs_.js +1 -0
- package/dist/web/public/assets/rosmsg-nvjuSIGu.js +1 -0
- package/dist/web/public/assets/routes-BXqJCOpL.js +542 -0
- package/dist/web/public/assets/rst-1xwvVGf7.js +1 -0
- package/dist/web/public/assets/ruby-Blad-eDx.js +1 -0
- package/dist/web/public/assets/rust-rV8q_xyI.js +1 -0
- package/dist/web/public/assets/sas-DUPWtptg.js +1 -0
- package/dist/web/public/assets/sass-CuxdoNN0.js +1 -0
- package/dist/web/public/assets/scala-Df4L7N3R.js +1 -0
- package/dist/web/public/assets/scheme-DalRmAPH.js +1 -0
- package/dist/web/public/assets/scss-CYQ8LEwP.js +1 -0
- package/dist/web/public/assets/sdbl-B_TmFnGf.js +1 -0
- package/dist/web/public/assets/shaderlab-DYEMDY3e.js +1 -0
- package/dist/web/public/assets/shellscript-DjKZ34ac.js +1 -0
- package/dist/web/public/assets/shellsession-C3kcnBnh.js +1 -0
- package/dist/web/public/assets/slack-dark-ak_jOeLl.js +1 -0
- package/dist/web/public/assets/slack-ochin-ByiYhLwu.js +1 -0
- package/dist/web/public/assets/smalltalk-DTTnjjZJ.js +1 -0
- package/dist/web/public/assets/snazzy-light-BBRYeY60.js +1 -0
- package/dist/web/public/assets/solarized-dark-BtoLnWkw.js +1 -0
- package/dist/web/public/assets/solarized-light-CtzUA7GI.js +1 -0
- package/dist/web/public/assets/solidity-CSIHEQ2t.js +1 -0
- package/dist/web/public/assets/soy-BN0uzUAI.js +1 -0
- package/dist/web/public/assets/sparql-B6k9tA6Q.js +1 -0
- package/dist/web/public/assets/splunk-DkRzN7V_.js +1 -0
- package/dist/web/public/assets/sql-Bx-WX28V.js +1 -0
- package/dist/web/public/assets/ssh-config-Bqp7ng33.js +1 -0
- package/dist/web/public/assets/stata-HAj7doU8.js +1 -0
- package/dist/web/public/assets/stylus-CdbCxDLX.js +1 -0
- package/dist/web/public/assets/surrealql-BkGf0I3k.js +1 -0
- package/dist/web/public/assets/svelte-DtWg6ssL.js +1 -0
- package/dist/web/public/assets/swift-yRu2dtgr.js +1 -0
- package/dist/web/public/assets/synthwave-84-2WIu6MHX.js +1 -0
- package/dist/web/public/assets/system-verilog-GUE_oP1V.js +1 -0
- package/dist/web/public/assets/systemd-FLIJAQZV.js +1 -0
- package/dist/web/public/assets/talonscript-DTR-8ILs.js +1 -0
- package/dist/web/public/assets/tasl-WHNWP-1F.js +1 -0
- package/dist/web/public/assets/tcl-BaBXNNp6.js +1 -0
- package/dist/web/public/assets/templ-Dc9vj00n.js +1 -0
- package/dist/web/public/assets/terraform-uJUFpr8t.js +1 -0
- package/dist/web/public/assets/tex-DA3dAz55.js +1 -0
- package/dist/web/public/assets/tokyo-night-BbogFqAr.js +1 -0
- package/dist/web/public/assets/toml-CyR4Gqq1.js +1 -0
- package/dist/web/public/assets/ts-tags-BD1j21LH.js +1 -0
- package/dist/web/public/assets/tsv-COLVYI6A.js +1 -0
- package/dist/web/public/assets/tsx-CFm2E6uK.js +1 -0
- package/dist/web/public/assets/turtle-PQwt4gkb.js +1 -0
- package/dist/web/public/assets/twig-DrUXy85s.js +1 -0
- package/dist/web/public/assets/typescript-Dy-5sXFx.js +1 -0
- package/dist/web/public/assets/typespec-Bb7qHV0g.js +1 -0
- package/dist/web/public/assets/typst-Bj_JElGz.js +1 -0
- package/dist/web/public/assets/v-BTkrtik4.js +1 -0
- package/dist/web/public/assets/vala-AXT1CI9v.js +1 -0
- package/dist/web/public/assets/vb-DzTKUgW8.js +1 -0
- package/dist/web/public/assets/verilog-aI3j5Xj8.js +1 -0
- package/dist/web/public/assets/vesper-BmnwIC_B.js +1 -0
- package/dist/web/public/assets/vhdl-4IgBB7vO.js +1 -0
- package/dist/web/public/assets/viml-D_XMKSR6.js +1 -0
- package/dist/web/public/assets/vitesse-black-DhmxIXiA.js +1 -0
- package/dist/web/public/assets/vitesse-dark-dvEH_9qt.js +1 -0
- package/dist/web/public/assets/vitesse-light-Ca0W2L1O.js +1 -0
- package/dist/web/public/assets/vue-DC_yTvy2.js +1 -0
- package/dist/web/public/assets/vue-html-Bp8x4gdt.js +1 -0
- package/dist/web/public/assets/vue-vine-ZcUkuUUp.js +1 -0
- package/dist/web/public/assets/vyper-Dz2f7-FK.js +1 -0
- package/dist/web/public/assets/wasm-CuXPCj65.js +1 -0
- package/dist/web/public/assets/wasm-DHkXUMsP.js +1 -0
- package/dist/web/public/assets/wenyan-BRAtM0Iv.js +1 -0
- package/dist/web/public/assets/wgsl-CMpn9jTa.js +1 -0
- package/dist/web/public/assets/wikitext-DRmBVmVA.js +1 -0
- package/dist/web/public/assets/wit-Drp_HLqJ.js +1 -0
- package/dist/web/public/assets/wolfram-C33umj7M.js +1 -0
- package/dist/web/public/assets/xml-BHoOtGbO.js +1 -0
- package/dist/web/public/assets/xsl-CN1PlFqm.js +1 -0
- package/dist/web/public/assets/yaml-DT0mpn8u.js +1 -0
- package/dist/web/public/assets/zenscript-BlYQ_Frf.js +1 -0
- package/dist/web/public/assets/zig-Buk7I0y-.js +1 -0
- package/dist/web/server/_chunks/ssr-renderer.mjs +15 -0
- package/dist/web/server/_libs/@ai-sdk/anthropic+[...].mjs +14021 -0
- package/dist/web/server/_libs/@ai-sdk/moonshotai+[...].mjs +898 -0
- package/dist/web/server/_libs/@ai-sdk/react+[...].mjs +8969 -0
- package/dist/web/server/_libs/@emotion/is-prop-valid+[...].mjs +34 -0
- package/dist/web/server/_libs/@floating-ui/core+[...].mjs +698 -0
- package/dist/web/server/_libs/@floating-ui/dom+[...].mjs +644 -0
- package/dist/web/server/_libs/@floating-ui/react-dom+[...].mjs +475 -0
- package/dist/web/server/_libs/@lobehub/icons+[...].mjs +3079 -0
- package/dist/web/server/_libs/@radix-ui/react-arrow+[...].mjs +184 -0
- package/dist/web/server/_libs/@radix-ui/react-collapsible+[...].mjs +374 -0
- package/dist/web/server/_libs/@radix-ui/react-dialog+[...].mjs +1503 -0
- package/dist/web/server/_libs/@radix-ui/react-menu+[...].mjs +1236 -0
- package/dist/web/server/_libs/@radix-ui/react-select+[...].mjs +1007 -0
- package/dist/web/server/_libs/@shikijs/core+[...].mjs +9017 -0
- package/dist/web/server/_libs/@shikijs/engine-javascript+[...].mjs +3159 -0
- package/dist/web/server/_libs/@streamdown/math+[...].mjs +37559 -0
- package/dist/web/server/_libs/@tanstack/react-router+[...].mjs +14074 -0
- package/dist/web/server/_libs/_.mjs +3 -0
- package/dist/web/server/_libs/_2.mjs +3 -0
- package/dist/web/server/_libs/_3.mjs +2 -0
- package/dist/web/server/_libs/_4.mjs +2 -0
- package/dist/web/server/_libs/ai-sdk__gateway+vercel__oidc.mjs +1255 -0
- package/dist/web/server/_libs/ai-sdk__google.mjs +1630 -0
- package/dist/web/server/_libs/ai-sdk__openai+zod.mjs +4951 -0
- package/dist/web/server/_libs/ai-sdk__provider-utils.mjs +411 -0
- package/dist/web/server/_libs/ai-sdk__provider.mjs +222 -0
- package/dist/web/server/_libs/bail.mjs +13 -0
- package/dist/web/server/_libs/character-entities.mjs +2135 -0
- package/dist/web/server/_libs/class-variance-authority+clsx.mjs +69 -0
- package/dist/web/server/_libs/color+[...].mjs +2185 -0
- package/dist/web/server/_libs/copy-text-to-clipboard.mjs +40 -0
- package/dist/web/server/_libs/d3-array.mjs +231 -0
- package/dist/web/server/_libs/d3-color.mjs +330 -0
- package/dist/web/server/_libs/d3-format.mjs +252 -0
- package/dist/web/server/_libs/d3-interpolate.mjs +207 -0
- package/dist/web/server/_libs/d3-path.mjs +77 -0
- package/dist/web/server/_libs/d3-scale+[...].mjs +1907 -0
- package/dist/web/server/_libs/d3-shape.mjs +818 -0
- package/dist/web/server/_libs/date-fns.mjs +3012 -0
- package/dist/web/server/_libs/date-fns__tz.mjs +249 -0
- package/dist/web/server/_libs/decimal.js-light.mjs +884 -0
- package/dist/web/server/_libs/decode-named-character-reference+[...].mjs +19 -0
- package/dist/web/server/_libs/dexie.mjs +3745 -0
- package/dist/web/server/_libs/escape-string-regexp.mjs +7 -0
- package/dist/web/server/_libs/estree-util-is-identifier-name.mjs +20 -0
- package/dist/web/server/_libs/eventemitter3.mjs +237 -0
- package/dist/web/server/_libs/extend.mjs +75 -0
- package/dist/web/server/_libs/fast-equals.mjs +423 -0
- package/dist/web/server/_libs/framer-motion+[...].mjs +9573 -0
- package/dist/web/server/_libs/fuzzysort.mjs +621 -0
- package/dist/web/server/_libs/h3+rou3+srvx.mjs +1158 -0
- package/dist/web/server/_libs/hast-util-raw+[...].mjs +800 -0
- package/dist/web/server/_libs/hast-util-sanitize.mjs +780 -0
- package/dist/web/server/_libs/hast-util-to-jsx-runtime+[...].mjs +853 -0
- package/dist/web/server/_libs/hookable.mjs +41 -0
- package/dist/web/server/_libs/html-url-attributes.mjs +44 -0
- package/dist/web/server/_libs/is-plain-obj.mjs +8 -0
- package/dist/web/server/_libs/lodash.mjs +4532 -0
- package/dist/web/server/_libs/lucide-react.mjs +605 -0
- package/dist/web/server/_libs/markdown-table.mjs +289 -0
- package/dist/web/server/_libs/marked.mjs +1511 -0
- package/dist/web/server/_libs/mdast-util-find-and-replace.mjs +198 -0
- package/dist/web/server/_libs/mdast-util-from-markdown+[...].mjs +8121 -0
- package/dist/web/server/_libs/mdast-util-gfm+[...].mjs +2060 -0
- package/dist/web/server/_libs/mdast-util-to-hast+[...].mjs +1770 -0
- package/dist/web/server/_libs/micromark-extension-gfm+[...].mjs +2235 -0
- package/dist/web/server/_libs/nanoid.mjs +26 -0
- package/dist/web/server/_libs/next-themes.mjs +124 -0
- package/dist/web/server/_libs/prop-types.mjs +69 -0
- package/dist/web/server/_libs/radix-ui__number.mjs +6 -0
- package/dist/web/server/_libs/radix-ui__primitive.mjs +9 -0
- package/dist/web/server/_libs/radix-ui__react-collection.mjs +80 -0
- package/dist/web/server/_libs/radix-ui__react-direction.mjs +11 -0
- package/dist/web/server/_libs/radix-ui__react-label.mjs +23 -0
- package/dist/web/server/_libs/radix-ui__react-menubar.mjs +400 -0
- package/dist/web/server/_libs/radix-ui__react-popover.mjs +251 -0
- package/dist/web/server/_libs/radix-ui__react-progress.mjs +81 -0
- package/dist/web/server/_libs/radix-ui__react-scroll-area.mjs +669 -0
- package/dist/web/server/_libs/radix-ui__react-separator.mjs +32 -0
- package/dist/web/server/_libs/radix-ui__react-slider.mjs +464 -0
- package/dist/web/server/_libs/radix-ui__react-switch.mjs +120 -0
- package/dist/web/server/_libs/radix-ui__react-tabs.mjs +145 -0
- package/dist/web/server/_libs/radix-ui__react-tooltip.mjs +494 -0
- package/dist/web/server/_libs/react-day-picker.mjs +3510 -0
- package/dist/web/server/_libs/react-is.mjs +48 -0
- package/dist/web/server/_libs/react-resizable-panels.mjs +1517 -0
- package/dist/web/server/_libs/react-smooth.mjs +1024 -0
- package/dist/web/server/_libs/recharts+[...].mjs +12998 -0
- package/dist/web/server/_libs/rehype-harden.mjs +210 -0
- package/dist/web/server/_libs/rehype-raw.mjs +37 -0
- package/dist/web/server/_libs/rehype-sanitize.mjs +27 -0
- package/dist/web/server/_libs/remark-gfm.mjs +34 -0
- package/dist/web/server/_libs/remark-parse.mjs +37 -0
- package/dist/web/server/_libs/remark-rehype.mjs +169 -0
- package/dist/web/server/_libs/remend.mjs +544 -0
- package/dist/web/server/_libs/scule.mjs +55 -0
- package/dist/web/server/_libs/shiki+streamdown__code.mjs +1748 -0
- package/dist/web/server/_libs/shiki.mjs +16 -0
- package/dist/web/server/_libs/shikijs__engine-oniguruma.mjs +387 -0
- package/dist/web/server/_libs/shikijs__langs.mjs +1357 -0
- package/dist/web/server/_libs/shikijs__themes.mjs +268 -0
- package/dist/web/server/_libs/sonner.mjs +909 -0
- package/dist/web/server/_libs/streamdown+[...].mjs +5842 -0
- package/dist/web/server/_libs/tanstack__history.mjs +342 -0
- package/dist/web/server/_libs/tanstack__query-core.mjs +2073 -0
- package/dist/web/server/_libs/tanstack__react-query.mjs +146 -0
- package/dist/web/server/_libs/tanstack__router-core.mjs +6 -0
- package/dist/web/server/_libs/tanstack__zod-adapter.mjs +16 -0
- package/dist/web/server/_libs/ufo.mjs +64 -0
- package/dist/web/server/_libs/ungap__structured-clone.mjs +197 -0
- package/dist/web/server/_libs/use-stick-to-bottom.mjs +410 -0
- package/dist/web/server/_libs/vercel__oidc.mjs +393 -0
- package/dist/web/server/_libs/zhipu-ai-provider.mjs +13483 -0
- package/dist/web/server/_libs/zustand.mjs +48 -0
- package/dist/web/server/_runtime.mjs +35 -0
- package/dist/web/server/_ssr/components-BzCiScpA.mjs +1452 -0
- package/dist/web/server/_ssr/dist-3Mu7PF0n.mjs +137 -0
- package/dist/web/server/_ssr/dist-BRaLXgxZ.mjs +17 -0
- package/dist/web/server/_ssr/field-1-agM60DBf.mjs +167 -0
- package/dist/web/server/_ssr/get-providers-BoYkp0Of.mjs +40 -0
- package/dist/web/server/_ssr/initialize-provider-B6W8V5Eg.mjs +19 -0
- package/dist/web/server/_ssr/model-list-CDFjdz2P.mjs +60 -0
- package/dist/web/server/_ssr/router-BmmOCtJZ.mjs +168 -0
- package/dist/web/server/_ssr/routes-CvlpZK4Q.mjs +2630 -0
- package/dist/web/server/_ssr/schemas-DsZ5O3zp.mjs +67 -0
- package/dist/web/server/_ssr/send-message-DUT1vRvx.mjs +135 -0
- package/dist/web/server/_ssr/ssr.mjs +5253 -0
- package/dist/web/server/_ssr/start-rewezkfD.mjs +4 -0
- package/dist/web/server/_ssr/submit-key-CcCv6-yy.mjs +62 -0
- package/dist/web/server/_ssr/suggestions-B0Uc3p7F.mjs +38 -0
- package/dist/web/server/_ssr/use-providers-Bwqg2U3N.mjs +1554 -0
- package/dist/web/server/_tanstack-start-manifest_v-BMIvh4y6.mjs +60 -0
- package/dist/web/server/index.mjs +2531 -0
- package/dist/web/server/node_modules/tslib/modules/index.js +70 -0
- package/dist/web/server/node_modules/tslib/modules/package.json +3 -0
- package/dist/web/server/node_modules/tslib/package.json +47 -0
- package/dist/web/server/node_modules/tslib/tslib.js +484 -0
- package/package.json +32 -0
|
@@ -0,0 +1,1630 @@
|
|
|
1
|
+
import { A as lazySchema, B as resolve, Ct as union, I as parseProviderOptions, J as zodSchema, K as withUserAgentSuffix, R as postJsonToApi, S as generateId, St as string, X as AISDKError, _ as createProviderToolFactoryWithOutputSchema, bt as record, c as convertToBase64, dt as boolean, f as createEventSourceResponseHandler, g as createProviderToolFactory, h as createJsonResponseHandler, j as loadApiKey, m as createJsonErrorResponseHandler, o as combineHeaders, ot as _enum, q as withoutTrailingSlash, rt as UnsupportedFunctionalityError, tt as TooManyEmbeddingValuesForCallError, u as convertUint8ArrayToBase64, ut as array, vt as number, w as getFromApi, wt as unknown, y as delay, yt as object } from "./@ai-sdk/anthropic+[...].mjs";
|
|
2
|
+
//#region ../../node_modules/.pnpm/@ai-sdk+google@3.0.43_zod@4.3.6/node_modules/@ai-sdk/google/dist/index.mjs
|
|
3
|
+
var VERSION = "3.0.43";
|
|
4
|
+
var googleFailedResponseHandler = createJsonErrorResponseHandler({
|
|
5
|
+
errorSchema: lazySchema(() => zodSchema(object({ error: object({
|
|
6
|
+
code: number().nullable(),
|
|
7
|
+
message: string(),
|
|
8
|
+
status: string()
|
|
9
|
+
}) }))),
|
|
10
|
+
errorToMessage: (data) => data.error.message
|
|
11
|
+
});
|
|
12
|
+
var googleEmbeddingModelOptions = lazySchema(() => zodSchema(object({
|
|
13
|
+
outputDimensionality: number().optional(),
|
|
14
|
+
taskType: _enum([
|
|
15
|
+
"SEMANTIC_SIMILARITY",
|
|
16
|
+
"CLASSIFICATION",
|
|
17
|
+
"CLUSTERING",
|
|
18
|
+
"RETRIEVAL_DOCUMENT",
|
|
19
|
+
"RETRIEVAL_QUERY",
|
|
20
|
+
"QUESTION_ANSWERING",
|
|
21
|
+
"FACT_VERIFICATION",
|
|
22
|
+
"CODE_RETRIEVAL_QUERY"
|
|
23
|
+
]).optional()
|
|
24
|
+
})));
|
|
25
|
+
var GoogleGenerativeAIEmbeddingModel = class {
|
|
26
|
+
constructor(modelId, config) {
|
|
27
|
+
this.specificationVersion = "v3";
|
|
28
|
+
this.maxEmbeddingsPerCall = 2048;
|
|
29
|
+
this.supportsParallelCalls = true;
|
|
30
|
+
this.modelId = modelId;
|
|
31
|
+
this.config = config;
|
|
32
|
+
}
|
|
33
|
+
get provider() {
|
|
34
|
+
return this.config.provider;
|
|
35
|
+
}
|
|
36
|
+
async doEmbed({ values, headers, abortSignal, providerOptions }) {
|
|
37
|
+
const googleOptions = await parseProviderOptions({
|
|
38
|
+
provider: "google",
|
|
39
|
+
providerOptions,
|
|
40
|
+
schema: googleEmbeddingModelOptions
|
|
41
|
+
});
|
|
42
|
+
if (values.length > this.maxEmbeddingsPerCall) throw new TooManyEmbeddingValuesForCallError({
|
|
43
|
+
provider: this.provider,
|
|
44
|
+
modelId: this.modelId,
|
|
45
|
+
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
46
|
+
values
|
|
47
|
+
});
|
|
48
|
+
const mergedHeaders = combineHeaders(await resolve(this.config.headers), headers);
|
|
49
|
+
if (values.length === 1) {
|
|
50
|
+
const { responseHeaders: responseHeaders2, value: response2, rawValue: rawValue2 } = await postJsonToApi({
|
|
51
|
+
url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
|
|
52
|
+
headers: mergedHeaders,
|
|
53
|
+
body: {
|
|
54
|
+
model: `models/${this.modelId}`,
|
|
55
|
+
content: { parts: [{ text: values[0] }] },
|
|
56
|
+
outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
|
|
57
|
+
taskType: googleOptions == null ? void 0 : googleOptions.taskType
|
|
58
|
+
},
|
|
59
|
+
failedResponseHandler: googleFailedResponseHandler,
|
|
60
|
+
successfulResponseHandler: createJsonResponseHandler(googleGenerativeAISingleEmbeddingResponseSchema),
|
|
61
|
+
abortSignal,
|
|
62
|
+
fetch: this.config.fetch
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
warnings: [],
|
|
66
|
+
embeddings: [response2.embedding.values],
|
|
67
|
+
usage: void 0,
|
|
68
|
+
response: {
|
|
69
|
+
headers: responseHeaders2,
|
|
70
|
+
body: rawValue2
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const { responseHeaders, value: response, rawValue } = await postJsonToApi({
|
|
75
|
+
url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
|
|
76
|
+
headers: mergedHeaders,
|
|
77
|
+
body: { requests: values.map((value) => ({
|
|
78
|
+
model: `models/${this.modelId}`,
|
|
79
|
+
content: {
|
|
80
|
+
role: "user",
|
|
81
|
+
parts: [{ text: value }]
|
|
82
|
+
},
|
|
83
|
+
outputDimensionality: googleOptions == null ? void 0 : googleOptions.outputDimensionality,
|
|
84
|
+
taskType: googleOptions == null ? void 0 : googleOptions.taskType
|
|
85
|
+
})) },
|
|
86
|
+
failedResponseHandler: googleFailedResponseHandler,
|
|
87
|
+
successfulResponseHandler: createJsonResponseHandler(googleGenerativeAITextEmbeddingResponseSchema),
|
|
88
|
+
abortSignal,
|
|
89
|
+
fetch: this.config.fetch
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
warnings: [],
|
|
93
|
+
embeddings: response.embeddings.map((item) => item.values),
|
|
94
|
+
usage: void 0,
|
|
95
|
+
response: {
|
|
96
|
+
headers: responseHeaders,
|
|
97
|
+
body: rawValue
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
var googleGenerativeAITextEmbeddingResponseSchema = lazySchema(() => zodSchema(object({ embeddings: array(object({ values: array(number()) })) })));
|
|
103
|
+
var googleGenerativeAISingleEmbeddingResponseSchema = lazySchema(() => zodSchema(object({ embedding: object({ values: array(number()) }) })));
|
|
104
|
+
function convertGoogleGenerativeAIUsage(usage) {
|
|
105
|
+
var _a, _b, _c, _d;
|
|
106
|
+
if (usage == null) return {
|
|
107
|
+
inputTokens: {
|
|
108
|
+
total: void 0,
|
|
109
|
+
noCache: void 0,
|
|
110
|
+
cacheRead: void 0,
|
|
111
|
+
cacheWrite: void 0
|
|
112
|
+
},
|
|
113
|
+
outputTokens: {
|
|
114
|
+
total: void 0,
|
|
115
|
+
text: void 0,
|
|
116
|
+
reasoning: void 0
|
|
117
|
+
},
|
|
118
|
+
raw: void 0
|
|
119
|
+
};
|
|
120
|
+
const promptTokens = (_a = usage.promptTokenCount) != null ? _a : 0;
|
|
121
|
+
const candidatesTokens = (_b = usage.candidatesTokenCount) != null ? _b : 0;
|
|
122
|
+
const cachedContentTokens = (_c = usage.cachedContentTokenCount) != null ? _c : 0;
|
|
123
|
+
const thoughtsTokens = (_d = usage.thoughtsTokenCount) != null ? _d : 0;
|
|
124
|
+
return {
|
|
125
|
+
inputTokens: {
|
|
126
|
+
total: promptTokens,
|
|
127
|
+
noCache: promptTokens - cachedContentTokens,
|
|
128
|
+
cacheRead: cachedContentTokens,
|
|
129
|
+
cacheWrite: void 0
|
|
130
|
+
},
|
|
131
|
+
outputTokens: {
|
|
132
|
+
total: candidatesTokens + thoughtsTokens,
|
|
133
|
+
text: candidatesTokens,
|
|
134
|
+
reasoning: thoughtsTokens
|
|
135
|
+
},
|
|
136
|
+
raw: usage
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
|
|
140
|
+
if (jsonSchema == null) return;
|
|
141
|
+
if (isEmptyObjectSchema(jsonSchema)) {
|
|
142
|
+
if (isRoot) return;
|
|
143
|
+
if (typeof jsonSchema === "object" && jsonSchema.description) return {
|
|
144
|
+
type: "object",
|
|
145
|
+
description: jsonSchema.description
|
|
146
|
+
};
|
|
147
|
+
return { type: "object" };
|
|
148
|
+
}
|
|
149
|
+
if (typeof jsonSchema === "boolean") return {
|
|
150
|
+
type: "boolean",
|
|
151
|
+
properties: {}
|
|
152
|
+
};
|
|
153
|
+
const { type, description, required, properties, items, allOf, anyOf, oneOf, format, const: constValue, minLength, enum: enumValues } = jsonSchema;
|
|
154
|
+
const result = {};
|
|
155
|
+
if (description) result.description = description;
|
|
156
|
+
if (required) result.required = required;
|
|
157
|
+
if (format) result.format = format;
|
|
158
|
+
if (constValue !== void 0) result.enum = [constValue];
|
|
159
|
+
if (type) if (Array.isArray(type)) {
|
|
160
|
+
const hasNull = type.includes("null");
|
|
161
|
+
const nonNullTypes = type.filter((t) => t !== "null");
|
|
162
|
+
if (nonNullTypes.length === 0) result.type = "null";
|
|
163
|
+
else {
|
|
164
|
+
result.anyOf = nonNullTypes.map((t) => ({ type: t }));
|
|
165
|
+
if (hasNull) result.nullable = true;
|
|
166
|
+
}
|
|
167
|
+
} else result.type = type;
|
|
168
|
+
if (enumValues !== void 0) result.enum = enumValues;
|
|
169
|
+
if (properties != null) result.properties = Object.entries(properties).reduce((acc, [key, value]) => {
|
|
170
|
+
acc[key] = convertJSONSchemaToOpenAPISchema(value, false);
|
|
171
|
+
return acc;
|
|
172
|
+
}, {});
|
|
173
|
+
if (items) result.items = Array.isArray(items) ? items.map((item) => convertJSONSchemaToOpenAPISchema(item, false)) : convertJSONSchemaToOpenAPISchema(items, false);
|
|
174
|
+
if (allOf) result.allOf = allOf.map((item) => convertJSONSchemaToOpenAPISchema(item, false));
|
|
175
|
+
if (anyOf) if (anyOf.some((schema) => typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null")) {
|
|
176
|
+
const nonNullSchemas = anyOf.filter((schema) => !(typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null"));
|
|
177
|
+
if (nonNullSchemas.length === 1) {
|
|
178
|
+
const converted = convertJSONSchemaToOpenAPISchema(nonNullSchemas[0], false);
|
|
179
|
+
if (typeof converted === "object") {
|
|
180
|
+
result.nullable = true;
|
|
181
|
+
Object.assign(result, converted);
|
|
182
|
+
}
|
|
183
|
+
} else {
|
|
184
|
+
result.anyOf = nonNullSchemas.map((item) => convertJSONSchemaToOpenAPISchema(item, false));
|
|
185
|
+
result.nullable = true;
|
|
186
|
+
}
|
|
187
|
+
} else result.anyOf = anyOf.map((item) => convertJSONSchemaToOpenAPISchema(item, false));
|
|
188
|
+
if (oneOf) result.oneOf = oneOf.map((item) => convertJSONSchemaToOpenAPISchema(item, false));
|
|
189
|
+
if (minLength !== void 0) result.minLength = minLength;
|
|
190
|
+
return result;
|
|
191
|
+
}
|
|
192
|
+
function isEmptyObjectSchema(jsonSchema) {
|
|
193
|
+
return jsonSchema != null && typeof jsonSchema === "object" && jsonSchema.type === "object" && (jsonSchema.properties == null || Object.keys(jsonSchema.properties).length === 0) && !jsonSchema.additionalProperties;
|
|
194
|
+
}
|
|
195
|
+
function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
196
|
+
var _a, _b, _c;
|
|
197
|
+
const systemInstructionParts = [];
|
|
198
|
+
const contents = [];
|
|
199
|
+
let systemMessagesAllowed = true;
|
|
200
|
+
const isGemmaModel = (_a = options == null ? void 0 : options.isGemmaModel) != null ? _a : false;
|
|
201
|
+
const providerOptionsName = (_b = options == null ? void 0 : options.providerOptionsName) != null ? _b : "google";
|
|
202
|
+
for (const { role, content } of prompt) switch (role) {
|
|
203
|
+
case "system":
|
|
204
|
+
if (!systemMessagesAllowed) throw new UnsupportedFunctionalityError({ functionality: "system messages are only supported at the beginning of the conversation" });
|
|
205
|
+
systemInstructionParts.push({ text: content });
|
|
206
|
+
break;
|
|
207
|
+
case "user": {
|
|
208
|
+
systemMessagesAllowed = false;
|
|
209
|
+
const parts = [];
|
|
210
|
+
for (const part of content) switch (part.type) {
|
|
211
|
+
case "text":
|
|
212
|
+
parts.push({ text: part.text });
|
|
213
|
+
break;
|
|
214
|
+
case "file": {
|
|
215
|
+
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
216
|
+
parts.push(part.data instanceof URL ? { fileData: {
|
|
217
|
+
mimeType: mediaType,
|
|
218
|
+
fileUri: part.data.toString()
|
|
219
|
+
} } : { inlineData: {
|
|
220
|
+
mimeType: mediaType,
|
|
221
|
+
data: convertToBase64(part.data)
|
|
222
|
+
} });
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
contents.push({
|
|
227
|
+
role: "user",
|
|
228
|
+
parts
|
|
229
|
+
});
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
case "assistant":
|
|
233
|
+
systemMessagesAllowed = false;
|
|
234
|
+
contents.push({
|
|
235
|
+
role: "model",
|
|
236
|
+
parts: content.map((part) => {
|
|
237
|
+
var _a2, _b2, _c2, _d;
|
|
238
|
+
const providerOpts = (_d = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) != null ? _d : providerOptionsName !== "google" ? (_b2 = part.providerOptions) == null ? void 0 : _b2.google : (_c2 = part.providerOptions) == null ? void 0 : _c2.vertex;
|
|
239
|
+
const thoughtSignature = (providerOpts == null ? void 0 : providerOpts.thoughtSignature) != null ? String(providerOpts.thoughtSignature) : void 0;
|
|
240
|
+
switch (part.type) {
|
|
241
|
+
case "text": return part.text.length === 0 ? void 0 : {
|
|
242
|
+
text: part.text,
|
|
243
|
+
thoughtSignature
|
|
244
|
+
};
|
|
245
|
+
case "reasoning": return part.text.length === 0 ? void 0 : {
|
|
246
|
+
text: part.text,
|
|
247
|
+
thought: true,
|
|
248
|
+
thoughtSignature
|
|
249
|
+
};
|
|
250
|
+
case "file":
|
|
251
|
+
if (part.data instanceof URL) throw new UnsupportedFunctionalityError({ functionality: "File data URLs in assistant messages are not supported" });
|
|
252
|
+
return {
|
|
253
|
+
inlineData: {
|
|
254
|
+
mimeType: part.mediaType,
|
|
255
|
+
data: convertToBase64(part.data)
|
|
256
|
+
},
|
|
257
|
+
thoughtSignature
|
|
258
|
+
};
|
|
259
|
+
case "tool-call": return {
|
|
260
|
+
functionCall: {
|
|
261
|
+
name: part.toolName,
|
|
262
|
+
args: part.input
|
|
263
|
+
},
|
|
264
|
+
thoughtSignature
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
}).filter((part) => part !== void 0)
|
|
268
|
+
});
|
|
269
|
+
break;
|
|
270
|
+
case "tool": {
|
|
271
|
+
systemMessagesAllowed = false;
|
|
272
|
+
const parts = [];
|
|
273
|
+
for (const part of content) {
|
|
274
|
+
if (part.type === "tool-approval-response") continue;
|
|
275
|
+
const output = part.output;
|
|
276
|
+
if (output.type === "content") for (const contentPart of output.value) switch (contentPart.type) {
|
|
277
|
+
case "text":
|
|
278
|
+
parts.push({ functionResponse: {
|
|
279
|
+
name: part.toolName,
|
|
280
|
+
response: {
|
|
281
|
+
name: part.toolName,
|
|
282
|
+
content: contentPart.text
|
|
283
|
+
}
|
|
284
|
+
} });
|
|
285
|
+
break;
|
|
286
|
+
case "image-data":
|
|
287
|
+
parts.push({ inlineData: {
|
|
288
|
+
mimeType: contentPart.mediaType,
|
|
289
|
+
data: contentPart.data
|
|
290
|
+
} }, { text: "Tool executed successfully and returned this image as a response" });
|
|
291
|
+
break;
|
|
292
|
+
default:
|
|
293
|
+
parts.push({ text: JSON.stringify(contentPart) });
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
else parts.push({ functionResponse: {
|
|
297
|
+
name: part.toolName,
|
|
298
|
+
response: {
|
|
299
|
+
name: part.toolName,
|
|
300
|
+
content: output.type === "execution-denied" ? (_c = output.reason) != null ? _c : "Tool execution denied." : output.value
|
|
301
|
+
}
|
|
302
|
+
} });
|
|
303
|
+
}
|
|
304
|
+
contents.push({
|
|
305
|
+
role: "user",
|
|
306
|
+
parts
|
|
307
|
+
});
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (isGemmaModel && systemInstructionParts.length > 0 && contents.length > 0 && contents[0].role === "user") {
|
|
312
|
+
const systemText = systemInstructionParts.map((part) => part.text).join("\n\n");
|
|
313
|
+
contents[0].parts.unshift({ text: systemText + "\n\n" });
|
|
314
|
+
}
|
|
315
|
+
return {
|
|
316
|
+
systemInstruction: systemInstructionParts.length > 0 && !isGemmaModel ? { parts: systemInstructionParts } : void 0,
|
|
317
|
+
contents
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
function getModelPath(modelId) {
|
|
321
|
+
return modelId.includes("/") ? modelId : `models/${modelId}`;
|
|
322
|
+
}
|
|
323
|
+
var googleLanguageModelOptions = lazySchema(() => zodSchema(object({
|
|
324
|
+
responseModalities: array(_enum(["TEXT", "IMAGE"])).optional(),
|
|
325
|
+
thinkingConfig: object({
|
|
326
|
+
thinkingBudget: number().optional(),
|
|
327
|
+
includeThoughts: boolean().optional(),
|
|
328
|
+
thinkingLevel: _enum([
|
|
329
|
+
"minimal",
|
|
330
|
+
"low",
|
|
331
|
+
"medium",
|
|
332
|
+
"high"
|
|
333
|
+
]).optional()
|
|
334
|
+
}).optional(),
|
|
335
|
+
cachedContent: string().optional(),
|
|
336
|
+
structuredOutputs: boolean().optional(),
|
|
337
|
+
safetySettings: array(object({
|
|
338
|
+
category: _enum([
|
|
339
|
+
"HARM_CATEGORY_UNSPECIFIED",
|
|
340
|
+
"HARM_CATEGORY_HATE_SPEECH",
|
|
341
|
+
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
342
|
+
"HARM_CATEGORY_HARASSMENT",
|
|
343
|
+
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
344
|
+
"HARM_CATEGORY_CIVIC_INTEGRITY"
|
|
345
|
+
]),
|
|
346
|
+
threshold: _enum([
|
|
347
|
+
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
348
|
+
"BLOCK_LOW_AND_ABOVE",
|
|
349
|
+
"BLOCK_MEDIUM_AND_ABOVE",
|
|
350
|
+
"BLOCK_ONLY_HIGH",
|
|
351
|
+
"BLOCK_NONE",
|
|
352
|
+
"OFF"
|
|
353
|
+
])
|
|
354
|
+
})).optional(),
|
|
355
|
+
threshold: _enum([
|
|
356
|
+
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
357
|
+
"BLOCK_LOW_AND_ABOVE",
|
|
358
|
+
"BLOCK_MEDIUM_AND_ABOVE",
|
|
359
|
+
"BLOCK_ONLY_HIGH",
|
|
360
|
+
"BLOCK_NONE",
|
|
361
|
+
"OFF"
|
|
362
|
+
]).optional(),
|
|
363
|
+
audioTimestamp: boolean().optional(),
|
|
364
|
+
labels: record(string(), string()).optional(),
|
|
365
|
+
mediaResolution: _enum([
|
|
366
|
+
"MEDIA_RESOLUTION_UNSPECIFIED",
|
|
367
|
+
"MEDIA_RESOLUTION_LOW",
|
|
368
|
+
"MEDIA_RESOLUTION_MEDIUM",
|
|
369
|
+
"MEDIA_RESOLUTION_HIGH"
|
|
370
|
+
]).optional(),
|
|
371
|
+
imageConfig: object({
|
|
372
|
+
aspectRatio: _enum([
|
|
373
|
+
"1:1",
|
|
374
|
+
"2:3",
|
|
375
|
+
"3:2",
|
|
376
|
+
"3:4",
|
|
377
|
+
"4:3",
|
|
378
|
+
"4:5",
|
|
379
|
+
"5:4",
|
|
380
|
+
"9:16",
|
|
381
|
+
"16:9",
|
|
382
|
+
"21:9",
|
|
383
|
+
"1:8",
|
|
384
|
+
"8:1",
|
|
385
|
+
"1:4",
|
|
386
|
+
"4:1"
|
|
387
|
+
]).optional(),
|
|
388
|
+
imageSize: _enum([
|
|
389
|
+
"1K",
|
|
390
|
+
"2K",
|
|
391
|
+
"4K",
|
|
392
|
+
"512"
|
|
393
|
+
]).optional()
|
|
394
|
+
}).optional(),
|
|
395
|
+
retrievalConfig: object({ latLng: object({
|
|
396
|
+
latitude: number(),
|
|
397
|
+
longitude: number()
|
|
398
|
+
}).optional() }).optional()
|
|
399
|
+
})));
|
|
400
|
+
function prepareTools({ tools, toolChoice, modelId }) {
|
|
401
|
+
var _a;
|
|
402
|
+
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
403
|
+
const toolWarnings = [];
|
|
404
|
+
const isLatest = [
|
|
405
|
+
"gemini-flash-latest",
|
|
406
|
+
"gemini-flash-lite-latest",
|
|
407
|
+
"gemini-pro-latest"
|
|
408
|
+
].some((id) => id === modelId);
|
|
409
|
+
const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest;
|
|
410
|
+
const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3");
|
|
411
|
+
if (tools == null) return {
|
|
412
|
+
tools: void 0,
|
|
413
|
+
toolConfig: void 0,
|
|
414
|
+
toolWarnings
|
|
415
|
+
};
|
|
416
|
+
const hasFunctionTools = tools.some((tool) => tool.type === "function");
|
|
417
|
+
const hasProviderTools = tools.some((tool) => tool.type === "provider");
|
|
418
|
+
if (hasFunctionTools && hasProviderTools) toolWarnings.push({
|
|
419
|
+
type: "unsupported",
|
|
420
|
+
feature: `combination of function and provider-defined tools`
|
|
421
|
+
});
|
|
422
|
+
if (hasProviderTools) {
|
|
423
|
+
const googleTools2 = [];
|
|
424
|
+
tools.filter((tool) => tool.type === "provider").forEach((tool) => {
|
|
425
|
+
switch (tool.id) {
|
|
426
|
+
case "google.google_search":
|
|
427
|
+
if (isGemini2orNewer) googleTools2.push({ googleSearch: { ...tool.args } });
|
|
428
|
+
else toolWarnings.push({
|
|
429
|
+
type: "unsupported",
|
|
430
|
+
feature: `provider-defined tool ${tool.id}`,
|
|
431
|
+
details: "Google Search requires Gemini 2.0 or newer."
|
|
432
|
+
});
|
|
433
|
+
break;
|
|
434
|
+
case "google.enterprise_web_search":
|
|
435
|
+
if (isGemini2orNewer) googleTools2.push({ enterpriseWebSearch: {} });
|
|
436
|
+
else toolWarnings.push({
|
|
437
|
+
type: "unsupported",
|
|
438
|
+
feature: `provider-defined tool ${tool.id}`,
|
|
439
|
+
details: "Enterprise Web Search requires Gemini 2.0 or newer."
|
|
440
|
+
});
|
|
441
|
+
break;
|
|
442
|
+
case "google.url_context":
|
|
443
|
+
if (isGemini2orNewer) googleTools2.push({ urlContext: {} });
|
|
444
|
+
else toolWarnings.push({
|
|
445
|
+
type: "unsupported",
|
|
446
|
+
feature: `provider-defined tool ${tool.id}`,
|
|
447
|
+
details: "The URL context tool is not supported with other Gemini models than Gemini 2."
|
|
448
|
+
});
|
|
449
|
+
break;
|
|
450
|
+
case "google.code_execution":
|
|
451
|
+
if (isGemini2orNewer) googleTools2.push({ codeExecution: {} });
|
|
452
|
+
else toolWarnings.push({
|
|
453
|
+
type: "unsupported",
|
|
454
|
+
feature: `provider-defined tool ${tool.id}`,
|
|
455
|
+
details: "The code execution tools is not supported with other Gemini models than Gemini 2."
|
|
456
|
+
});
|
|
457
|
+
break;
|
|
458
|
+
case "google.file_search":
|
|
459
|
+
if (supportsFileSearch) googleTools2.push({ fileSearch: { ...tool.args } });
|
|
460
|
+
else toolWarnings.push({
|
|
461
|
+
type: "unsupported",
|
|
462
|
+
feature: `provider-defined tool ${tool.id}`,
|
|
463
|
+
details: "The file search tool is only supported with Gemini 2.5 models and Gemini 3 models."
|
|
464
|
+
});
|
|
465
|
+
break;
|
|
466
|
+
case "google.vertex_rag_store":
|
|
467
|
+
if (isGemini2orNewer) googleTools2.push({ retrieval: { vertex_rag_store: {
|
|
468
|
+
rag_resources: { rag_corpus: tool.args.ragCorpus },
|
|
469
|
+
similarity_top_k: tool.args.topK
|
|
470
|
+
} } });
|
|
471
|
+
else toolWarnings.push({
|
|
472
|
+
type: "unsupported",
|
|
473
|
+
feature: `provider-defined tool ${tool.id}`,
|
|
474
|
+
details: "The RAG store tool is not supported with other Gemini models than Gemini 2."
|
|
475
|
+
});
|
|
476
|
+
break;
|
|
477
|
+
case "google.google_maps":
|
|
478
|
+
if (isGemini2orNewer) googleTools2.push({ googleMaps: {} });
|
|
479
|
+
else toolWarnings.push({
|
|
480
|
+
type: "unsupported",
|
|
481
|
+
feature: `provider-defined tool ${tool.id}`,
|
|
482
|
+
details: "The Google Maps grounding tool is not supported with Gemini models other than Gemini 2 or newer."
|
|
483
|
+
});
|
|
484
|
+
break;
|
|
485
|
+
default:
|
|
486
|
+
toolWarnings.push({
|
|
487
|
+
type: "unsupported",
|
|
488
|
+
feature: `provider-defined tool ${tool.id}`
|
|
489
|
+
});
|
|
490
|
+
break;
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
return {
|
|
494
|
+
tools: googleTools2.length > 0 ? googleTools2 : void 0,
|
|
495
|
+
toolConfig: void 0,
|
|
496
|
+
toolWarnings
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
const functionDeclarations = [];
|
|
500
|
+
for (const tool of tools) switch (tool.type) {
|
|
501
|
+
case "function":
|
|
502
|
+
functionDeclarations.push({
|
|
503
|
+
name: tool.name,
|
|
504
|
+
description: (_a = tool.description) != null ? _a : "",
|
|
505
|
+
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
506
|
+
});
|
|
507
|
+
break;
|
|
508
|
+
default:
|
|
509
|
+
toolWarnings.push({
|
|
510
|
+
type: "unsupported",
|
|
511
|
+
feature: `function tool ${tool.name}`
|
|
512
|
+
});
|
|
513
|
+
break;
|
|
514
|
+
}
|
|
515
|
+
if (toolChoice == null) return {
|
|
516
|
+
tools: [{ functionDeclarations }],
|
|
517
|
+
toolConfig: void 0,
|
|
518
|
+
toolWarnings
|
|
519
|
+
};
|
|
520
|
+
const type = toolChoice.type;
|
|
521
|
+
switch (type) {
|
|
522
|
+
case "auto": return {
|
|
523
|
+
tools: [{ functionDeclarations }],
|
|
524
|
+
toolConfig: { functionCallingConfig: { mode: "AUTO" } },
|
|
525
|
+
toolWarnings
|
|
526
|
+
};
|
|
527
|
+
case "none": return {
|
|
528
|
+
tools: [{ functionDeclarations }],
|
|
529
|
+
toolConfig: { functionCallingConfig: { mode: "NONE" } },
|
|
530
|
+
toolWarnings
|
|
531
|
+
};
|
|
532
|
+
case "required": return {
|
|
533
|
+
tools: [{ functionDeclarations }],
|
|
534
|
+
toolConfig: { functionCallingConfig: { mode: "ANY" } },
|
|
535
|
+
toolWarnings
|
|
536
|
+
};
|
|
537
|
+
case "tool": return {
|
|
538
|
+
tools: [{ functionDeclarations }],
|
|
539
|
+
toolConfig: { functionCallingConfig: {
|
|
540
|
+
mode: "ANY",
|
|
541
|
+
allowedFunctionNames: [toolChoice.toolName]
|
|
542
|
+
} },
|
|
543
|
+
toolWarnings
|
|
544
|
+
};
|
|
545
|
+
default: throw new UnsupportedFunctionalityError({ functionality: `tool choice type: ${type}` });
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
function mapGoogleGenerativeAIFinishReason({ finishReason, hasToolCalls }) {
|
|
549
|
+
switch (finishReason) {
|
|
550
|
+
case "STOP": return hasToolCalls ? "tool-calls" : "stop";
|
|
551
|
+
case "MAX_TOKENS": return "length";
|
|
552
|
+
case "IMAGE_SAFETY":
|
|
553
|
+
case "RECITATION":
|
|
554
|
+
case "SAFETY":
|
|
555
|
+
case "BLOCKLIST":
|
|
556
|
+
case "PROHIBITED_CONTENT":
|
|
557
|
+
case "SPII": return "content-filter";
|
|
558
|
+
case "MALFORMED_FUNCTION_CALL": return "error";
|
|
559
|
+
default: return "other";
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
var GoogleGenerativeAILanguageModel = class {
|
|
563
|
+
constructor(modelId, config) {
|
|
564
|
+
this.specificationVersion = "v3";
|
|
565
|
+
var _a;
|
|
566
|
+
this.modelId = modelId;
|
|
567
|
+
this.config = config;
|
|
568
|
+
this.generateId = (_a = config.generateId) != null ? _a : generateId;
|
|
569
|
+
}
|
|
570
|
+
get provider() {
|
|
571
|
+
return this.config.provider;
|
|
572
|
+
}
|
|
573
|
+
get supportedUrls() {
|
|
574
|
+
var _a, _b, _c;
|
|
575
|
+
return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
|
|
576
|
+
}
|
|
577
|
+
async getArgs({ prompt, maxOutputTokens, temperature, topP, topK, frequencyPenalty, presencePenalty, stopSequences, responseFormat, seed, tools, toolChoice, providerOptions }) {
|
|
578
|
+
var _a;
|
|
579
|
+
const warnings = [];
|
|
580
|
+
const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
|
|
581
|
+
let googleOptions = await parseProviderOptions({
|
|
582
|
+
provider: providerOptionsName,
|
|
583
|
+
providerOptions,
|
|
584
|
+
schema: googleLanguageModelOptions
|
|
585
|
+
});
|
|
586
|
+
if (googleOptions == null && providerOptionsName !== "google") googleOptions = await parseProviderOptions({
|
|
587
|
+
provider: "google",
|
|
588
|
+
providerOptions,
|
|
589
|
+
schema: googleLanguageModelOptions
|
|
590
|
+
});
|
|
591
|
+
if ((tools == null ? void 0 : tools.some((tool) => tool.type === "provider" && tool.id === "google.vertex_rag_store")) && !this.config.provider.startsWith("google.vertex.")) warnings.push({
|
|
592
|
+
type: "other",
|
|
593
|
+
message: `The 'vertex_rag_store' tool is only supported with the Google Vertex provider and might not be supported or could behave unexpectedly with the current Google provider (${this.config.provider}).`
|
|
594
|
+
});
|
|
595
|
+
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
596
|
+
const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(prompt, {
|
|
597
|
+
isGemmaModel,
|
|
598
|
+
providerOptionsName
|
|
599
|
+
});
|
|
600
|
+
const { tools: googleTools2, toolConfig: googleToolConfig, toolWarnings } = prepareTools({
|
|
601
|
+
tools,
|
|
602
|
+
toolChoice,
|
|
603
|
+
modelId: this.modelId
|
|
604
|
+
});
|
|
605
|
+
return {
|
|
606
|
+
args: {
|
|
607
|
+
generationConfig: {
|
|
608
|
+
maxOutputTokens,
|
|
609
|
+
temperature,
|
|
610
|
+
topK,
|
|
611
|
+
topP,
|
|
612
|
+
frequencyPenalty,
|
|
613
|
+
presencePenalty,
|
|
614
|
+
stopSequences,
|
|
615
|
+
seed,
|
|
616
|
+
responseMimeType: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? "application/json" : void 0,
|
|
617
|
+
responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && ((_a = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _a : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
|
|
618
|
+
...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && { audioTimestamp: googleOptions.audioTimestamp },
|
|
619
|
+
responseModalities: googleOptions == null ? void 0 : googleOptions.responseModalities,
|
|
620
|
+
thinkingConfig: googleOptions == null ? void 0 : googleOptions.thinkingConfig,
|
|
621
|
+
...(googleOptions == null ? void 0 : googleOptions.mediaResolution) && { mediaResolution: googleOptions.mediaResolution },
|
|
622
|
+
...(googleOptions == null ? void 0 : googleOptions.imageConfig) && { imageConfig: googleOptions.imageConfig }
|
|
623
|
+
},
|
|
624
|
+
contents,
|
|
625
|
+
systemInstruction: isGemmaModel ? void 0 : systemInstruction,
|
|
626
|
+
safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
|
|
627
|
+
tools: googleTools2,
|
|
628
|
+
toolConfig: (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
|
|
629
|
+
...googleToolConfig,
|
|
630
|
+
retrievalConfig: googleOptions.retrievalConfig
|
|
631
|
+
} : googleToolConfig,
|
|
632
|
+
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|
|
633
|
+
labels: googleOptions == null ? void 0 : googleOptions.labels
|
|
634
|
+
},
|
|
635
|
+
warnings: [...warnings, ...toolWarnings],
|
|
636
|
+
providerOptionsName
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
async doGenerate(options) {
|
|
640
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
641
|
+
const { args, warnings, providerOptionsName } = await this.getArgs(options);
|
|
642
|
+
const mergedHeaders = combineHeaders(await resolve(this.config.headers), options.headers);
|
|
643
|
+
const { responseHeaders, value: response, rawValue: rawResponse } = await postJsonToApi({
|
|
644
|
+
url: `${this.config.baseURL}/${getModelPath(this.modelId)}:generateContent`,
|
|
645
|
+
headers: mergedHeaders,
|
|
646
|
+
body: args,
|
|
647
|
+
failedResponseHandler: googleFailedResponseHandler,
|
|
648
|
+
successfulResponseHandler: createJsonResponseHandler(responseSchema),
|
|
649
|
+
abortSignal: options.abortSignal,
|
|
650
|
+
fetch: this.config.fetch
|
|
651
|
+
});
|
|
652
|
+
const candidate = response.candidates[0];
|
|
653
|
+
const content = [];
|
|
654
|
+
const parts = (_b = (_a = candidate.content) == null ? void 0 : _a.parts) != null ? _b : [];
|
|
655
|
+
const usageMetadata = response.usageMetadata;
|
|
656
|
+
let lastCodeExecutionToolCallId;
|
|
657
|
+
for (const part of parts) if ("executableCode" in part && ((_c = part.executableCode) == null ? void 0 : _c.code)) {
|
|
658
|
+
const toolCallId = this.config.generateId();
|
|
659
|
+
lastCodeExecutionToolCallId = toolCallId;
|
|
660
|
+
content.push({
|
|
661
|
+
type: "tool-call",
|
|
662
|
+
toolCallId,
|
|
663
|
+
toolName: "code_execution",
|
|
664
|
+
input: JSON.stringify(part.executableCode),
|
|
665
|
+
providerExecuted: true
|
|
666
|
+
});
|
|
667
|
+
} else if ("codeExecutionResult" in part && part.codeExecutionResult) {
|
|
668
|
+
content.push({
|
|
669
|
+
type: "tool-result",
|
|
670
|
+
toolCallId: lastCodeExecutionToolCallId,
|
|
671
|
+
toolName: "code_execution",
|
|
672
|
+
result: {
|
|
673
|
+
outcome: part.codeExecutionResult.outcome,
|
|
674
|
+
output: (_d = part.codeExecutionResult.output) != null ? _d : ""
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
lastCodeExecutionToolCallId = void 0;
|
|
678
|
+
} else if ("text" in part && part.text != null) {
|
|
679
|
+
const thoughtSignatureMetadata = part.thoughtSignature ? { [providerOptionsName]: { thoughtSignature: part.thoughtSignature } } : void 0;
|
|
680
|
+
if (part.text.length === 0) {
|
|
681
|
+
if (thoughtSignatureMetadata != null && content.length > 0) {
|
|
682
|
+
const lastContent = content[content.length - 1];
|
|
683
|
+
lastContent.providerMetadata = thoughtSignatureMetadata;
|
|
684
|
+
}
|
|
685
|
+
} else content.push({
|
|
686
|
+
type: part.thought === true ? "reasoning" : "text",
|
|
687
|
+
text: part.text,
|
|
688
|
+
providerMetadata: thoughtSignatureMetadata
|
|
689
|
+
});
|
|
690
|
+
} else if ("functionCall" in part) content.push({
|
|
691
|
+
type: "tool-call",
|
|
692
|
+
toolCallId: this.config.generateId(),
|
|
693
|
+
toolName: part.functionCall.name,
|
|
694
|
+
input: JSON.stringify(part.functionCall.args),
|
|
695
|
+
providerMetadata: part.thoughtSignature ? { [providerOptionsName]: { thoughtSignature: part.thoughtSignature } } : void 0
|
|
696
|
+
});
|
|
697
|
+
else if ("inlineData" in part) content.push({
|
|
698
|
+
type: "file",
|
|
699
|
+
data: part.inlineData.data,
|
|
700
|
+
mediaType: part.inlineData.mimeType,
|
|
701
|
+
providerMetadata: part.thoughtSignature ? { [providerOptionsName]: { thoughtSignature: part.thoughtSignature } } : void 0
|
|
702
|
+
});
|
|
703
|
+
const sources = (_e = extractSources({
|
|
704
|
+
groundingMetadata: candidate.groundingMetadata,
|
|
705
|
+
generateId: this.config.generateId
|
|
706
|
+
})) != null ? _e : [];
|
|
707
|
+
for (const source of sources) content.push(source);
|
|
708
|
+
return {
|
|
709
|
+
content,
|
|
710
|
+
finishReason: {
|
|
711
|
+
unified: mapGoogleGenerativeAIFinishReason({
|
|
712
|
+
finishReason: candidate.finishReason,
|
|
713
|
+
hasToolCalls: content.some((part) => part.type === "tool-call" && !part.providerExecuted)
|
|
714
|
+
}),
|
|
715
|
+
raw: (_f = candidate.finishReason) != null ? _f : void 0
|
|
716
|
+
},
|
|
717
|
+
usage: convertGoogleGenerativeAIUsage(usageMetadata),
|
|
718
|
+
warnings,
|
|
719
|
+
providerMetadata: { [providerOptionsName]: {
|
|
720
|
+
promptFeedback: (_g = response.promptFeedback) != null ? _g : null,
|
|
721
|
+
groundingMetadata: (_h = candidate.groundingMetadata) != null ? _h : null,
|
|
722
|
+
urlContextMetadata: (_i = candidate.urlContextMetadata) != null ? _i : null,
|
|
723
|
+
safetyRatings: (_j = candidate.safetyRatings) != null ? _j : null,
|
|
724
|
+
usageMetadata: usageMetadata != null ? usageMetadata : null
|
|
725
|
+
} },
|
|
726
|
+
request: { body: args },
|
|
727
|
+
response: {
|
|
728
|
+
headers: responseHeaders,
|
|
729
|
+
body: rawResponse
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
async doStream(options) {
|
|
734
|
+
const { args, warnings, providerOptionsName } = await this.getArgs(options);
|
|
735
|
+
const headers = combineHeaders(await resolve(this.config.headers), options.headers);
|
|
736
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
737
|
+
url: `${this.config.baseURL}/${getModelPath(this.modelId)}:streamGenerateContent?alt=sse`,
|
|
738
|
+
headers,
|
|
739
|
+
body: args,
|
|
740
|
+
failedResponseHandler: googleFailedResponseHandler,
|
|
741
|
+
successfulResponseHandler: createEventSourceResponseHandler(chunkSchema),
|
|
742
|
+
abortSignal: options.abortSignal,
|
|
743
|
+
fetch: this.config.fetch
|
|
744
|
+
});
|
|
745
|
+
let finishReason = {
|
|
746
|
+
unified: "other",
|
|
747
|
+
raw: void 0
|
|
748
|
+
};
|
|
749
|
+
let usage = void 0;
|
|
750
|
+
let providerMetadata = void 0;
|
|
751
|
+
const generateId3 = this.config.generateId;
|
|
752
|
+
let hasToolCalls = false;
|
|
753
|
+
let currentTextBlockId = null;
|
|
754
|
+
let currentReasoningBlockId = null;
|
|
755
|
+
let blockCounter = 0;
|
|
756
|
+
const emittedSourceUrls = /* @__PURE__ */ new Set();
|
|
757
|
+
let lastCodeExecutionToolCallId;
|
|
758
|
+
return {
|
|
759
|
+
stream: response.pipeThrough(new TransformStream({
|
|
760
|
+
start(controller) {
|
|
761
|
+
controller.enqueue({
|
|
762
|
+
type: "stream-start",
|
|
763
|
+
warnings
|
|
764
|
+
});
|
|
765
|
+
},
|
|
766
|
+
transform(chunk, controller) {
|
|
767
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
768
|
+
if (options.includeRawChunks) controller.enqueue({
|
|
769
|
+
type: "raw",
|
|
770
|
+
rawValue: chunk.rawValue
|
|
771
|
+
});
|
|
772
|
+
if (!chunk.success) {
|
|
773
|
+
controller.enqueue({
|
|
774
|
+
type: "error",
|
|
775
|
+
error: chunk.error
|
|
776
|
+
});
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
const value = chunk.value;
|
|
780
|
+
const usageMetadata = value.usageMetadata;
|
|
781
|
+
if (usageMetadata != null) usage = usageMetadata;
|
|
782
|
+
const candidate = (_a = value.candidates) == null ? void 0 : _a[0];
|
|
783
|
+
if (candidate == null) return;
|
|
784
|
+
const content = candidate.content;
|
|
785
|
+
const sources = extractSources({
|
|
786
|
+
groundingMetadata: candidate.groundingMetadata,
|
|
787
|
+
generateId: generateId3
|
|
788
|
+
});
|
|
789
|
+
if (sources != null) {
|
|
790
|
+
for (const source of sources) if (source.sourceType === "url" && !emittedSourceUrls.has(source.url)) {
|
|
791
|
+
emittedSourceUrls.add(source.url);
|
|
792
|
+
controller.enqueue(source);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
if (content != null) {
|
|
796
|
+
const parts = (_b = content.parts) != null ? _b : [];
|
|
797
|
+
for (const part of parts) if ("executableCode" in part && ((_c = part.executableCode) == null ? void 0 : _c.code)) {
|
|
798
|
+
const toolCallId = generateId3();
|
|
799
|
+
lastCodeExecutionToolCallId = toolCallId;
|
|
800
|
+
controller.enqueue({
|
|
801
|
+
type: "tool-call",
|
|
802
|
+
toolCallId,
|
|
803
|
+
toolName: "code_execution",
|
|
804
|
+
input: JSON.stringify(part.executableCode),
|
|
805
|
+
providerExecuted: true
|
|
806
|
+
});
|
|
807
|
+
} else if ("codeExecutionResult" in part && part.codeExecutionResult) {
|
|
808
|
+
const toolCallId = lastCodeExecutionToolCallId;
|
|
809
|
+
if (toolCallId) {
|
|
810
|
+
controller.enqueue({
|
|
811
|
+
type: "tool-result",
|
|
812
|
+
toolCallId,
|
|
813
|
+
toolName: "code_execution",
|
|
814
|
+
result: {
|
|
815
|
+
outcome: part.codeExecutionResult.outcome,
|
|
816
|
+
output: (_d = part.codeExecutionResult.output) != null ? _d : ""
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
lastCodeExecutionToolCallId = void 0;
|
|
820
|
+
}
|
|
821
|
+
} else if ("text" in part && part.text != null) {
|
|
822
|
+
const thoughtSignatureMetadata = part.thoughtSignature ? { [providerOptionsName]: { thoughtSignature: part.thoughtSignature } } : void 0;
|
|
823
|
+
if (part.text.length === 0) {
|
|
824
|
+
if (thoughtSignatureMetadata != null && currentTextBlockId !== null) controller.enqueue({
|
|
825
|
+
type: "text-delta",
|
|
826
|
+
id: currentTextBlockId,
|
|
827
|
+
delta: "",
|
|
828
|
+
providerMetadata: thoughtSignatureMetadata
|
|
829
|
+
});
|
|
830
|
+
} else if (part.thought === true) {
|
|
831
|
+
if (currentTextBlockId !== null) {
|
|
832
|
+
controller.enqueue({
|
|
833
|
+
type: "text-end",
|
|
834
|
+
id: currentTextBlockId
|
|
835
|
+
});
|
|
836
|
+
currentTextBlockId = null;
|
|
837
|
+
}
|
|
838
|
+
if (currentReasoningBlockId === null) {
|
|
839
|
+
currentReasoningBlockId = String(blockCounter++);
|
|
840
|
+
controller.enqueue({
|
|
841
|
+
type: "reasoning-start",
|
|
842
|
+
id: currentReasoningBlockId,
|
|
843
|
+
providerMetadata: thoughtSignatureMetadata
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
controller.enqueue({
|
|
847
|
+
type: "reasoning-delta",
|
|
848
|
+
id: currentReasoningBlockId,
|
|
849
|
+
delta: part.text,
|
|
850
|
+
providerMetadata: thoughtSignatureMetadata
|
|
851
|
+
});
|
|
852
|
+
} else {
|
|
853
|
+
if (currentReasoningBlockId !== null) {
|
|
854
|
+
controller.enqueue({
|
|
855
|
+
type: "reasoning-end",
|
|
856
|
+
id: currentReasoningBlockId
|
|
857
|
+
});
|
|
858
|
+
currentReasoningBlockId = null;
|
|
859
|
+
}
|
|
860
|
+
if (currentTextBlockId === null) {
|
|
861
|
+
currentTextBlockId = String(blockCounter++);
|
|
862
|
+
controller.enqueue({
|
|
863
|
+
type: "text-start",
|
|
864
|
+
id: currentTextBlockId,
|
|
865
|
+
providerMetadata: thoughtSignatureMetadata
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
controller.enqueue({
|
|
869
|
+
type: "text-delta",
|
|
870
|
+
id: currentTextBlockId,
|
|
871
|
+
delta: part.text,
|
|
872
|
+
providerMetadata: thoughtSignatureMetadata
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
} else if ("inlineData" in part) {
|
|
876
|
+
if (currentTextBlockId !== null) {
|
|
877
|
+
controller.enqueue({
|
|
878
|
+
type: "text-end",
|
|
879
|
+
id: currentTextBlockId
|
|
880
|
+
});
|
|
881
|
+
currentTextBlockId = null;
|
|
882
|
+
}
|
|
883
|
+
if (currentReasoningBlockId !== null) {
|
|
884
|
+
controller.enqueue({
|
|
885
|
+
type: "reasoning-end",
|
|
886
|
+
id: currentReasoningBlockId
|
|
887
|
+
});
|
|
888
|
+
currentReasoningBlockId = null;
|
|
889
|
+
}
|
|
890
|
+
const thoughtSignatureMetadata = part.thoughtSignature ? { [providerOptionsName]: { thoughtSignature: part.thoughtSignature } } : void 0;
|
|
891
|
+
controller.enqueue({
|
|
892
|
+
type: "file",
|
|
893
|
+
mediaType: part.inlineData.mimeType,
|
|
894
|
+
data: part.inlineData.data,
|
|
895
|
+
providerMetadata: thoughtSignatureMetadata
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
const toolCallDeltas = getToolCallsFromParts({
|
|
899
|
+
parts: content.parts,
|
|
900
|
+
generateId: generateId3,
|
|
901
|
+
providerOptionsName
|
|
902
|
+
});
|
|
903
|
+
if (toolCallDeltas != null) for (const toolCall of toolCallDeltas) {
|
|
904
|
+
controller.enqueue({
|
|
905
|
+
type: "tool-input-start",
|
|
906
|
+
id: toolCall.toolCallId,
|
|
907
|
+
toolName: toolCall.toolName,
|
|
908
|
+
providerMetadata: toolCall.providerMetadata
|
|
909
|
+
});
|
|
910
|
+
controller.enqueue({
|
|
911
|
+
type: "tool-input-delta",
|
|
912
|
+
id: toolCall.toolCallId,
|
|
913
|
+
delta: toolCall.args,
|
|
914
|
+
providerMetadata: toolCall.providerMetadata
|
|
915
|
+
});
|
|
916
|
+
controller.enqueue({
|
|
917
|
+
type: "tool-input-end",
|
|
918
|
+
id: toolCall.toolCallId,
|
|
919
|
+
providerMetadata: toolCall.providerMetadata
|
|
920
|
+
});
|
|
921
|
+
controller.enqueue({
|
|
922
|
+
type: "tool-call",
|
|
923
|
+
toolCallId: toolCall.toolCallId,
|
|
924
|
+
toolName: toolCall.toolName,
|
|
925
|
+
input: toolCall.args,
|
|
926
|
+
providerMetadata: toolCall.providerMetadata
|
|
927
|
+
});
|
|
928
|
+
hasToolCalls = true;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
if (candidate.finishReason != null) {
|
|
932
|
+
finishReason = {
|
|
933
|
+
unified: mapGoogleGenerativeAIFinishReason({
|
|
934
|
+
finishReason: candidate.finishReason,
|
|
935
|
+
hasToolCalls
|
|
936
|
+
}),
|
|
937
|
+
raw: candidate.finishReason
|
|
938
|
+
};
|
|
939
|
+
providerMetadata = { [providerOptionsName]: {
|
|
940
|
+
promptFeedback: (_e = value.promptFeedback) != null ? _e : null,
|
|
941
|
+
groundingMetadata: (_f = candidate.groundingMetadata) != null ? _f : null,
|
|
942
|
+
urlContextMetadata: (_g = candidate.urlContextMetadata) != null ? _g : null,
|
|
943
|
+
safetyRatings: (_h = candidate.safetyRatings) != null ? _h : null
|
|
944
|
+
} };
|
|
945
|
+
if (usageMetadata != null) providerMetadata[providerOptionsName].usageMetadata = usageMetadata;
|
|
946
|
+
}
|
|
947
|
+
},
|
|
948
|
+
flush(controller) {
|
|
949
|
+
if (currentTextBlockId !== null) controller.enqueue({
|
|
950
|
+
type: "text-end",
|
|
951
|
+
id: currentTextBlockId
|
|
952
|
+
});
|
|
953
|
+
if (currentReasoningBlockId !== null) controller.enqueue({
|
|
954
|
+
type: "reasoning-end",
|
|
955
|
+
id: currentReasoningBlockId
|
|
956
|
+
});
|
|
957
|
+
controller.enqueue({
|
|
958
|
+
type: "finish",
|
|
959
|
+
finishReason,
|
|
960
|
+
usage: convertGoogleGenerativeAIUsage(usage),
|
|
961
|
+
providerMetadata
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
})),
|
|
965
|
+
response: { headers: responseHeaders },
|
|
966
|
+
request: { body: args }
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
function getToolCallsFromParts({ parts, generateId: generateId3, providerOptionsName }) {
|
|
971
|
+
const functionCallParts = parts == null ? void 0 : parts.filter((part) => "functionCall" in part);
|
|
972
|
+
return functionCallParts == null || functionCallParts.length === 0 ? void 0 : functionCallParts.map((part) => ({
|
|
973
|
+
type: "tool-call",
|
|
974
|
+
toolCallId: generateId3(),
|
|
975
|
+
toolName: part.functionCall.name,
|
|
976
|
+
args: JSON.stringify(part.functionCall.args),
|
|
977
|
+
providerMetadata: part.thoughtSignature ? { [providerOptionsName]: { thoughtSignature: part.thoughtSignature } } : void 0
|
|
978
|
+
}));
|
|
979
|
+
}
|
|
980
|
+
function extractSources({ groundingMetadata, generateId: generateId3 }) {
|
|
981
|
+
var _a, _b, _c, _d, _e, _f;
|
|
982
|
+
if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) return;
|
|
983
|
+
const sources = [];
|
|
984
|
+
for (const chunk of groundingMetadata.groundingChunks) if (chunk.web != null) sources.push({
|
|
985
|
+
type: "source",
|
|
986
|
+
sourceType: "url",
|
|
987
|
+
id: generateId3(),
|
|
988
|
+
url: chunk.web.uri,
|
|
989
|
+
title: (_a = chunk.web.title) != null ? _a : void 0
|
|
990
|
+
});
|
|
991
|
+
else if (chunk.image != null) sources.push({
|
|
992
|
+
type: "source",
|
|
993
|
+
sourceType: "url",
|
|
994
|
+
id: generateId3(),
|
|
995
|
+
url: chunk.image.sourceUri,
|
|
996
|
+
title: (_b = chunk.image.title) != null ? _b : void 0
|
|
997
|
+
});
|
|
998
|
+
else if (chunk.retrievedContext != null) {
|
|
999
|
+
const uri = chunk.retrievedContext.uri;
|
|
1000
|
+
const fileSearchStore = chunk.retrievedContext.fileSearchStore;
|
|
1001
|
+
if (uri && (uri.startsWith("http://") || uri.startsWith("https://"))) sources.push({
|
|
1002
|
+
type: "source",
|
|
1003
|
+
sourceType: "url",
|
|
1004
|
+
id: generateId3(),
|
|
1005
|
+
url: uri,
|
|
1006
|
+
title: (_c = chunk.retrievedContext.title) != null ? _c : void 0
|
|
1007
|
+
});
|
|
1008
|
+
else if (uri) {
|
|
1009
|
+
const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
|
|
1010
|
+
let mediaType = "application/octet-stream";
|
|
1011
|
+
let filename = void 0;
|
|
1012
|
+
if (uri.endsWith(".pdf")) {
|
|
1013
|
+
mediaType = "application/pdf";
|
|
1014
|
+
filename = uri.split("/").pop();
|
|
1015
|
+
} else if (uri.endsWith(".txt")) {
|
|
1016
|
+
mediaType = "text/plain";
|
|
1017
|
+
filename = uri.split("/").pop();
|
|
1018
|
+
} else if (uri.endsWith(".docx")) {
|
|
1019
|
+
mediaType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
1020
|
+
filename = uri.split("/").pop();
|
|
1021
|
+
} else if (uri.endsWith(".doc")) {
|
|
1022
|
+
mediaType = "application/msword";
|
|
1023
|
+
filename = uri.split("/").pop();
|
|
1024
|
+
} else if (uri.match(/\.(md|markdown)$/)) {
|
|
1025
|
+
mediaType = "text/markdown";
|
|
1026
|
+
filename = uri.split("/").pop();
|
|
1027
|
+
} else filename = uri.split("/").pop();
|
|
1028
|
+
sources.push({
|
|
1029
|
+
type: "source",
|
|
1030
|
+
sourceType: "document",
|
|
1031
|
+
id: generateId3(),
|
|
1032
|
+
mediaType,
|
|
1033
|
+
title,
|
|
1034
|
+
filename
|
|
1035
|
+
});
|
|
1036
|
+
} else if (fileSearchStore) {
|
|
1037
|
+
const title = (_e = chunk.retrievedContext.title) != null ? _e : "Unknown Document";
|
|
1038
|
+
sources.push({
|
|
1039
|
+
type: "source",
|
|
1040
|
+
sourceType: "document",
|
|
1041
|
+
id: generateId3(),
|
|
1042
|
+
mediaType: "application/octet-stream",
|
|
1043
|
+
title,
|
|
1044
|
+
filename: fileSearchStore.split("/").pop()
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
} else if (chunk.maps != null) {
|
|
1048
|
+
if (chunk.maps.uri) sources.push({
|
|
1049
|
+
type: "source",
|
|
1050
|
+
sourceType: "url",
|
|
1051
|
+
id: generateId3(),
|
|
1052
|
+
url: chunk.maps.uri,
|
|
1053
|
+
title: (_f = chunk.maps.title) != null ? _f : void 0
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
return sources.length > 0 ? sources : void 0;
|
|
1057
|
+
}
|
|
1058
|
+
var getGroundingMetadataSchema = () => object({
|
|
1059
|
+
webSearchQueries: array(string()).nullish(),
|
|
1060
|
+
imageSearchQueries: array(string()).nullish(),
|
|
1061
|
+
retrievalQueries: array(string()).nullish(),
|
|
1062
|
+
searchEntryPoint: object({ renderedContent: string() }).nullish(),
|
|
1063
|
+
groundingChunks: array(object({
|
|
1064
|
+
web: object({
|
|
1065
|
+
uri: string(),
|
|
1066
|
+
title: string().nullish()
|
|
1067
|
+
}).nullish(),
|
|
1068
|
+
image: object({
|
|
1069
|
+
sourceUri: string(),
|
|
1070
|
+
imageUri: string(),
|
|
1071
|
+
title: string().nullish(),
|
|
1072
|
+
domain: string().nullish()
|
|
1073
|
+
}).nullish(),
|
|
1074
|
+
retrievedContext: object({
|
|
1075
|
+
uri: string().nullish(),
|
|
1076
|
+
title: string().nullish(),
|
|
1077
|
+
text: string().nullish(),
|
|
1078
|
+
fileSearchStore: string().nullish()
|
|
1079
|
+
}).nullish(),
|
|
1080
|
+
maps: object({
|
|
1081
|
+
uri: string().nullish(),
|
|
1082
|
+
title: string().nullish(),
|
|
1083
|
+
text: string().nullish(),
|
|
1084
|
+
placeId: string().nullish()
|
|
1085
|
+
}).nullish()
|
|
1086
|
+
})).nullish(),
|
|
1087
|
+
groundingSupports: array(object({
|
|
1088
|
+
segment: object({
|
|
1089
|
+
startIndex: number().nullish(),
|
|
1090
|
+
endIndex: number().nullish(),
|
|
1091
|
+
text: string().nullish()
|
|
1092
|
+
}).nullish(),
|
|
1093
|
+
segment_text: string().nullish(),
|
|
1094
|
+
groundingChunkIndices: array(number()).nullish(),
|
|
1095
|
+
supportChunkIndices: array(number()).nullish(),
|
|
1096
|
+
confidenceScores: array(number()).nullish(),
|
|
1097
|
+
confidenceScore: array(number()).nullish()
|
|
1098
|
+
})).nullish(),
|
|
1099
|
+
retrievalMetadata: union([object({ webDynamicRetrievalScore: number() }), object({})]).nullish()
|
|
1100
|
+
});
|
|
1101
|
+
var getContentSchema = () => object({ parts: array(union([
|
|
1102
|
+
object({
|
|
1103
|
+
functionCall: object({
|
|
1104
|
+
name: string(),
|
|
1105
|
+
args: unknown()
|
|
1106
|
+
}),
|
|
1107
|
+
thoughtSignature: string().nullish()
|
|
1108
|
+
}),
|
|
1109
|
+
object({
|
|
1110
|
+
inlineData: object({
|
|
1111
|
+
mimeType: string(),
|
|
1112
|
+
data: string()
|
|
1113
|
+
}),
|
|
1114
|
+
thoughtSignature: string().nullish()
|
|
1115
|
+
}),
|
|
1116
|
+
object({
|
|
1117
|
+
executableCode: object({
|
|
1118
|
+
language: string(),
|
|
1119
|
+
code: string()
|
|
1120
|
+
}).nullish(),
|
|
1121
|
+
codeExecutionResult: object({
|
|
1122
|
+
outcome: string(),
|
|
1123
|
+
output: string().nullish()
|
|
1124
|
+
}).nullish(),
|
|
1125
|
+
text: string().nullish(),
|
|
1126
|
+
thought: boolean().nullish(),
|
|
1127
|
+
thoughtSignature: string().nullish()
|
|
1128
|
+
})
|
|
1129
|
+
])).nullish() });
|
|
1130
|
+
var getSafetyRatingSchema = () => object({
|
|
1131
|
+
category: string().nullish(),
|
|
1132
|
+
probability: string().nullish(),
|
|
1133
|
+
probabilityScore: number().nullish(),
|
|
1134
|
+
severity: string().nullish(),
|
|
1135
|
+
severityScore: number().nullish(),
|
|
1136
|
+
blocked: boolean().nullish()
|
|
1137
|
+
});
|
|
1138
|
+
var usageSchema = object({
|
|
1139
|
+
cachedContentTokenCount: number().nullish(),
|
|
1140
|
+
thoughtsTokenCount: number().nullish(),
|
|
1141
|
+
promptTokenCount: number().nullish(),
|
|
1142
|
+
candidatesTokenCount: number().nullish(),
|
|
1143
|
+
totalTokenCount: number().nullish(),
|
|
1144
|
+
trafficType: string().nullish()
|
|
1145
|
+
});
|
|
1146
|
+
var getUrlContextMetadataSchema = () => object({ urlMetadata: array(object({
|
|
1147
|
+
retrievedUrl: string(),
|
|
1148
|
+
urlRetrievalStatus: string()
|
|
1149
|
+
})).nullish() });
|
|
1150
|
+
var responseSchema = lazySchema(() => zodSchema(object({
|
|
1151
|
+
candidates: array(object({
|
|
1152
|
+
content: getContentSchema().nullish().or(object({}).strict()),
|
|
1153
|
+
finishReason: string().nullish(),
|
|
1154
|
+
safetyRatings: array(getSafetyRatingSchema()).nullish(),
|
|
1155
|
+
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
1156
|
+
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
1157
|
+
})),
|
|
1158
|
+
usageMetadata: usageSchema.nullish(),
|
|
1159
|
+
promptFeedback: object({
|
|
1160
|
+
blockReason: string().nullish(),
|
|
1161
|
+
safetyRatings: array(getSafetyRatingSchema()).nullish()
|
|
1162
|
+
}).nullish()
|
|
1163
|
+
})));
|
|
1164
|
+
var chunkSchema = lazySchema(() => zodSchema(object({
|
|
1165
|
+
candidates: array(object({
|
|
1166
|
+
content: getContentSchema().nullish(),
|
|
1167
|
+
finishReason: string().nullish(),
|
|
1168
|
+
safetyRatings: array(getSafetyRatingSchema()).nullish(),
|
|
1169
|
+
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
1170
|
+
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
1171
|
+
})).nullish(),
|
|
1172
|
+
usageMetadata: usageSchema.nullish(),
|
|
1173
|
+
promptFeedback: object({
|
|
1174
|
+
blockReason: string().nullish(),
|
|
1175
|
+
safetyRatings: array(getSafetyRatingSchema()).nullish()
|
|
1176
|
+
}).nullish()
|
|
1177
|
+
})));
|
|
1178
|
+
var codeExecution = createProviderToolFactoryWithOutputSchema({
|
|
1179
|
+
id: "google.code_execution",
|
|
1180
|
+
inputSchema: object({
|
|
1181
|
+
language: string().describe("The programming language of the code."),
|
|
1182
|
+
code: string().describe("The code to be executed.")
|
|
1183
|
+
}),
|
|
1184
|
+
outputSchema: object({
|
|
1185
|
+
outcome: string().describe("The outcome of the execution (e.g., \"OUTCOME_OK\")."),
|
|
1186
|
+
output: string().describe("The output from the code execution.")
|
|
1187
|
+
})
|
|
1188
|
+
});
|
|
1189
|
+
var enterpriseWebSearch = createProviderToolFactory({
|
|
1190
|
+
id: "google.enterprise_web_search",
|
|
1191
|
+
inputSchema: lazySchema(() => zodSchema(object({})))
|
|
1192
|
+
});
|
|
1193
|
+
var fileSearchArgsBaseSchema = object({
|
|
1194
|
+
fileSearchStoreNames: array(string()).describe("The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"),
|
|
1195
|
+
topK: number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
|
|
1196
|
+
metadataFilter: string().describe("Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression.").optional()
|
|
1197
|
+
}).passthrough();
|
|
1198
|
+
var fileSearch = createProviderToolFactory({
|
|
1199
|
+
id: "google.file_search",
|
|
1200
|
+
inputSchema: lazySchema(() => zodSchema(fileSearchArgsBaseSchema))
|
|
1201
|
+
});
|
|
1202
|
+
var googleMaps = createProviderToolFactory({
|
|
1203
|
+
id: "google.google_maps",
|
|
1204
|
+
inputSchema: lazySchema(() => zodSchema(object({})))
|
|
1205
|
+
});
|
|
1206
|
+
var googleSearchToolArgsBaseSchema = object({
|
|
1207
|
+
searchTypes: object({
|
|
1208
|
+
webSearch: object({}).optional(),
|
|
1209
|
+
imageSearch: object({}).optional()
|
|
1210
|
+
}).optional(),
|
|
1211
|
+
timeRangeFilter: object({
|
|
1212
|
+
startTime: string(),
|
|
1213
|
+
endTime: string()
|
|
1214
|
+
}).optional()
|
|
1215
|
+
}).passthrough();
|
|
1216
|
+
var googleTools = {
|
|
1217
|
+
googleSearch: createProviderToolFactory({
|
|
1218
|
+
id: "google.google_search",
|
|
1219
|
+
inputSchema: lazySchema(() => zodSchema(googleSearchToolArgsBaseSchema))
|
|
1220
|
+
}),
|
|
1221
|
+
enterpriseWebSearch,
|
|
1222
|
+
googleMaps,
|
|
1223
|
+
urlContext: createProviderToolFactory({
|
|
1224
|
+
id: "google.url_context",
|
|
1225
|
+
inputSchema: lazySchema(() => zodSchema(object({})))
|
|
1226
|
+
}),
|
|
1227
|
+
fileSearch,
|
|
1228
|
+
codeExecution,
|
|
1229
|
+
vertexRagStore: createProviderToolFactory({
|
|
1230
|
+
id: "google.vertex_rag_store",
|
|
1231
|
+
inputSchema: object({
|
|
1232
|
+
ragCorpus: string(),
|
|
1233
|
+
topK: number().optional()
|
|
1234
|
+
})
|
|
1235
|
+
})
|
|
1236
|
+
};
|
|
1237
|
+
var GoogleGenerativeAIImageModel = class {
|
|
1238
|
+
constructor(modelId, settings, config) {
|
|
1239
|
+
this.modelId = modelId;
|
|
1240
|
+
this.settings = settings;
|
|
1241
|
+
this.config = config;
|
|
1242
|
+
this.specificationVersion = "v3";
|
|
1243
|
+
}
|
|
1244
|
+
get maxImagesPerCall() {
|
|
1245
|
+
if (this.settings.maxImagesPerCall != null) return this.settings.maxImagesPerCall;
|
|
1246
|
+
if (isGeminiModel(this.modelId)) return 10;
|
|
1247
|
+
return 4;
|
|
1248
|
+
}
|
|
1249
|
+
get provider() {
|
|
1250
|
+
return this.config.provider;
|
|
1251
|
+
}
|
|
1252
|
+
async doGenerate(options) {
|
|
1253
|
+
if (isGeminiModel(this.modelId)) return this.doGenerateGemini(options);
|
|
1254
|
+
return this.doGenerateImagen(options);
|
|
1255
|
+
}
|
|
1256
|
+
async doGenerateImagen(options) {
|
|
1257
|
+
var _a, _b, _c;
|
|
1258
|
+
const { prompt, n = 1, size, aspectRatio = "1:1", seed, providerOptions, headers, abortSignal, files, mask } = options;
|
|
1259
|
+
const warnings = [];
|
|
1260
|
+
if (files != null && files.length > 0) throw new Error("Google Generative AI does not support image editing with Imagen models. Use Google Vertex AI (@ai-sdk/google-vertex) for image editing capabilities.");
|
|
1261
|
+
if (mask != null) throw new Error("Google Generative AI does not support image editing with masks. Use Google Vertex AI (@ai-sdk/google-vertex) for image editing capabilities.");
|
|
1262
|
+
if (size != null) warnings.push({
|
|
1263
|
+
type: "unsupported",
|
|
1264
|
+
feature: "size",
|
|
1265
|
+
details: "This model does not support the `size` option. Use `aspectRatio` instead."
|
|
1266
|
+
});
|
|
1267
|
+
if (seed != null) warnings.push({
|
|
1268
|
+
type: "unsupported",
|
|
1269
|
+
feature: "seed",
|
|
1270
|
+
details: "This model does not support the `seed` option through this provider."
|
|
1271
|
+
});
|
|
1272
|
+
const googleOptions = await parseProviderOptions({
|
|
1273
|
+
provider: "google",
|
|
1274
|
+
providerOptions,
|
|
1275
|
+
schema: googleImageModelOptionsSchema
|
|
1276
|
+
});
|
|
1277
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1278
|
+
const parameters = { sampleCount: n };
|
|
1279
|
+
if (aspectRatio != null) parameters.aspectRatio = aspectRatio;
|
|
1280
|
+
if (googleOptions) Object.assign(parameters, googleOptions);
|
|
1281
|
+
const body = {
|
|
1282
|
+
instances: [{ prompt }],
|
|
1283
|
+
parameters
|
|
1284
|
+
};
|
|
1285
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
1286
|
+
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
1287
|
+
headers: combineHeaders(await resolve(this.config.headers), headers),
|
|
1288
|
+
body,
|
|
1289
|
+
failedResponseHandler: googleFailedResponseHandler,
|
|
1290
|
+
successfulResponseHandler: createJsonResponseHandler(googleImageResponseSchema),
|
|
1291
|
+
abortSignal,
|
|
1292
|
+
fetch: this.config.fetch
|
|
1293
|
+
});
|
|
1294
|
+
return {
|
|
1295
|
+
images: response.predictions.map((p) => p.bytesBase64Encoded),
|
|
1296
|
+
warnings,
|
|
1297
|
+
providerMetadata: { google: { images: response.predictions.map(() => ({})) } },
|
|
1298
|
+
response: {
|
|
1299
|
+
timestamp: currentDate,
|
|
1300
|
+
modelId: this.modelId,
|
|
1301
|
+
headers: responseHeaders
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1305
|
+
async doGenerateGemini(options) {
|
|
1306
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1307
|
+
const { prompt, n, size, aspectRatio, seed, providerOptions, headers, abortSignal, files, mask } = options;
|
|
1308
|
+
const warnings = [];
|
|
1309
|
+
if (mask != null) throw new Error("Gemini image models do not support mask-based image editing.");
|
|
1310
|
+
if (n != null && n > 1) throw new Error("Gemini image models do not support generating a set number of images per call. Use n=1 or omit the n parameter.");
|
|
1311
|
+
if (size != null) warnings.push({
|
|
1312
|
+
type: "unsupported",
|
|
1313
|
+
feature: "size",
|
|
1314
|
+
details: "This model does not support the `size` option. Use `aspectRatio` instead."
|
|
1315
|
+
});
|
|
1316
|
+
const userContent = [];
|
|
1317
|
+
if (prompt != null) userContent.push({
|
|
1318
|
+
type: "text",
|
|
1319
|
+
text: prompt
|
|
1320
|
+
});
|
|
1321
|
+
if (files != null && files.length > 0) for (const file of files) if (file.type === "url") userContent.push({
|
|
1322
|
+
type: "file",
|
|
1323
|
+
data: new URL(file.url),
|
|
1324
|
+
mediaType: "image/*"
|
|
1325
|
+
});
|
|
1326
|
+
else userContent.push({
|
|
1327
|
+
type: "file",
|
|
1328
|
+
data: typeof file.data === "string" ? file.data : new Uint8Array(file.data),
|
|
1329
|
+
mediaType: file.mediaType
|
|
1330
|
+
});
|
|
1331
|
+
const languageModelPrompt = [{
|
|
1332
|
+
role: "user",
|
|
1333
|
+
content: userContent
|
|
1334
|
+
}];
|
|
1335
|
+
const result = await new GoogleGenerativeAILanguageModel(this.modelId, {
|
|
1336
|
+
provider: this.config.provider,
|
|
1337
|
+
baseURL: this.config.baseURL,
|
|
1338
|
+
headers: (_a = this.config.headers) != null ? _a : {},
|
|
1339
|
+
fetch: this.config.fetch,
|
|
1340
|
+
generateId: (_b = this.config.generateId) != null ? _b : generateId
|
|
1341
|
+
}).doGenerate({
|
|
1342
|
+
prompt: languageModelPrompt,
|
|
1343
|
+
seed,
|
|
1344
|
+
providerOptions: { google: {
|
|
1345
|
+
responseModalities: ["IMAGE"],
|
|
1346
|
+
imageConfig: aspectRatio ? { aspectRatio } : void 0,
|
|
1347
|
+
...(_c = providerOptions == null ? void 0 : providerOptions.google) != null ? _c : {}
|
|
1348
|
+
} },
|
|
1349
|
+
headers,
|
|
1350
|
+
abortSignal
|
|
1351
|
+
});
|
|
1352
|
+
const currentDate = (_f = (_e = (_d = this.config._internal) == null ? void 0 : _d.currentDate) == null ? void 0 : _e.call(_d)) != null ? _f : /* @__PURE__ */ new Date();
|
|
1353
|
+
const images = [];
|
|
1354
|
+
for (const part of result.content) if (part.type === "file" && part.mediaType.startsWith("image/")) images.push(convertToBase64(part.data));
|
|
1355
|
+
return {
|
|
1356
|
+
images,
|
|
1357
|
+
warnings,
|
|
1358
|
+
providerMetadata: { google: { images: images.map(() => ({})) } },
|
|
1359
|
+
response: {
|
|
1360
|
+
timestamp: currentDate,
|
|
1361
|
+
modelId: this.modelId,
|
|
1362
|
+
headers: (_g = result.response) == null ? void 0 : _g.headers
|
|
1363
|
+
},
|
|
1364
|
+
usage: result.usage ? {
|
|
1365
|
+
inputTokens: result.usage.inputTokens.total,
|
|
1366
|
+
outputTokens: result.usage.outputTokens.total,
|
|
1367
|
+
totalTokens: ((_h = result.usage.inputTokens.total) != null ? _h : 0) + ((_i = result.usage.outputTokens.total) != null ? _i : 0)
|
|
1368
|
+
} : void 0
|
|
1369
|
+
};
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1372
|
+
function isGeminiModel(modelId) {
|
|
1373
|
+
return modelId.startsWith("gemini-");
|
|
1374
|
+
}
|
|
1375
|
+
var googleImageResponseSchema = lazySchema(() => zodSchema(object({ predictions: array(object({ bytesBase64Encoded: string() })).default([]) })));
|
|
1376
|
+
var googleImageModelOptionsSchema = lazySchema(() => zodSchema(object({
|
|
1377
|
+
personGeneration: _enum([
|
|
1378
|
+
"dont_allow",
|
|
1379
|
+
"allow_adult",
|
|
1380
|
+
"allow_all"
|
|
1381
|
+
]).nullish(),
|
|
1382
|
+
aspectRatio: _enum([
|
|
1383
|
+
"1:1",
|
|
1384
|
+
"3:4",
|
|
1385
|
+
"4:3",
|
|
1386
|
+
"9:16",
|
|
1387
|
+
"16:9"
|
|
1388
|
+
]).nullish()
|
|
1389
|
+
})));
|
|
1390
|
+
var GoogleGenerativeAIVideoModel = class {
|
|
1391
|
+
constructor(modelId, config) {
|
|
1392
|
+
this.modelId = modelId;
|
|
1393
|
+
this.config = config;
|
|
1394
|
+
this.specificationVersion = "v3";
|
|
1395
|
+
}
|
|
1396
|
+
get provider() {
|
|
1397
|
+
return this.config.provider;
|
|
1398
|
+
}
|
|
1399
|
+
get maxVideosPerCall() {
|
|
1400
|
+
return 4;
|
|
1401
|
+
}
|
|
1402
|
+
async doGenerate(options) {
|
|
1403
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1404
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1405
|
+
const warnings = [];
|
|
1406
|
+
const googleOptions = await parseProviderOptions({
|
|
1407
|
+
provider: "google",
|
|
1408
|
+
providerOptions: options.providerOptions,
|
|
1409
|
+
schema: googleVideoModelOptionsSchema
|
|
1410
|
+
});
|
|
1411
|
+
const instances = [{}];
|
|
1412
|
+
const instance = instances[0];
|
|
1413
|
+
if (options.prompt != null) instance.prompt = options.prompt;
|
|
1414
|
+
if (options.image != null) if (options.image.type === "url") warnings.push({
|
|
1415
|
+
type: "unsupported",
|
|
1416
|
+
feature: "URL-based image input",
|
|
1417
|
+
details: "Google Generative AI video models require base64-encoded images. URL will be ignored."
|
|
1418
|
+
});
|
|
1419
|
+
else {
|
|
1420
|
+
const base64Data = typeof options.image.data === "string" ? options.image.data : convertUint8ArrayToBase64(options.image.data);
|
|
1421
|
+
instance.image = { inlineData: {
|
|
1422
|
+
mimeType: options.image.mediaType || "image/png",
|
|
1423
|
+
data: base64Data
|
|
1424
|
+
} };
|
|
1425
|
+
}
|
|
1426
|
+
if ((googleOptions == null ? void 0 : googleOptions.referenceImages) != null) instance.referenceImages = googleOptions.referenceImages.map((refImg) => {
|
|
1427
|
+
if (refImg.bytesBase64Encoded) return { inlineData: {
|
|
1428
|
+
mimeType: "image/png",
|
|
1429
|
+
data: refImg.bytesBase64Encoded
|
|
1430
|
+
} };
|
|
1431
|
+
else if (refImg.gcsUri) return { gcsUri: refImg.gcsUri };
|
|
1432
|
+
return refImg;
|
|
1433
|
+
});
|
|
1434
|
+
const parameters = { sampleCount: options.n };
|
|
1435
|
+
if (options.aspectRatio) parameters.aspectRatio = options.aspectRatio;
|
|
1436
|
+
if (options.resolution) parameters.resolution = {
|
|
1437
|
+
"1280x720": "720p",
|
|
1438
|
+
"1920x1080": "1080p",
|
|
1439
|
+
"3840x2160": "4k"
|
|
1440
|
+
}[options.resolution] || options.resolution;
|
|
1441
|
+
if (options.duration) parameters.durationSeconds = options.duration;
|
|
1442
|
+
if (options.seed) parameters.seed = options.seed;
|
|
1443
|
+
if (googleOptions != null) {
|
|
1444
|
+
const opts = googleOptions;
|
|
1445
|
+
if (opts.personGeneration !== void 0 && opts.personGeneration !== null) parameters.personGeneration = opts.personGeneration;
|
|
1446
|
+
if (opts.negativePrompt !== void 0 && opts.negativePrompt !== null) parameters.negativePrompt = opts.negativePrompt;
|
|
1447
|
+
for (const [key, value] of Object.entries(opts)) if (![
|
|
1448
|
+
"pollIntervalMs",
|
|
1449
|
+
"pollTimeoutMs",
|
|
1450
|
+
"personGeneration",
|
|
1451
|
+
"negativePrompt",
|
|
1452
|
+
"referenceImages"
|
|
1453
|
+
].includes(key)) parameters[key] = value;
|
|
1454
|
+
}
|
|
1455
|
+
const { value: operation } = await postJsonToApi({
|
|
1456
|
+
url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
|
|
1457
|
+
headers: combineHeaders(await resolve(this.config.headers), options.headers),
|
|
1458
|
+
body: {
|
|
1459
|
+
instances,
|
|
1460
|
+
parameters
|
|
1461
|
+
},
|
|
1462
|
+
successfulResponseHandler: createJsonResponseHandler(googleOperationSchema),
|
|
1463
|
+
failedResponseHandler: googleFailedResponseHandler,
|
|
1464
|
+
abortSignal: options.abortSignal,
|
|
1465
|
+
fetch: this.config.fetch
|
|
1466
|
+
});
|
|
1467
|
+
const operationName = operation.name;
|
|
1468
|
+
if (!operationName) throw new AISDKError({
|
|
1469
|
+
name: "GOOGLE_VIDEO_GENERATION_ERROR",
|
|
1470
|
+
message: "No operation name returned from API"
|
|
1471
|
+
});
|
|
1472
|
+
const pollIntervalMs = (_d = googleOptions == null ? void 0 : googleOptions.pollIntervalMs) != null ? _d : 1e4;
|
|
1473
|
+
const pollTimeoutMs = (_e = googleOptions == null ? void 0 : googleOptions.pollTimeoutMs) != null ? _e : 6e5;
|
|
1474
|
+
const startTime = Date.now();
|
|
1475
|
+
let finalOperation = operation;
|
|
1476
|
+
let responseHeaders;
|
|
1477
|
+
while (!finalOperation.done) {
|
|
1478
|
+
if (Date.now() - startTime > pollTimeoutMs) throw new AISDKError({
|
|
1479
|
+
name: "GOOGLE_VIDEO_GENERATION_TIMEOUT",
|
|
1480
|
+
message: `Video generation timed out after ${pollTimeoutMs}ms`
|
|
1481
|
+
});
|
|
1482
|
+
await delay(pollIntervalMs);
|
|
1483
|
+
if ((_f = options.abortSignal) == null ? void 0 : _f.aborted) throw new AISDKError({
|
|
1484
|
+
name: "GOOGLE_VIDEO_GENERATION_ABORTED",
|
|
1485
|
+
message: "Video generation request was aborted"
|
|
1486
|
+
});
|
|
1487
|
+
const { value: statusOperation, responseHeaders: pollHeaders } = await getFromApi({
|
|
1488
|
+
url: `${this.config.baseURL}/${operationName}`,
|
|
1489
|
+
headers: combineHeaders(await resolve(this.config.headers), options.headers),
|
|
1490
|
+
successfulResponseHandler: createJsonResponseHandler(googleOperationSchema),
|
|
1491
|
+
failedResponseHandler: googleFailedResponseHandler,
|
|
1492
|
+
abortSignal: options.abortSignal,
|
|
1493
|
+
fetch: this.config.fetch
|
|
1494
|
+
});
|
|
1495
|
+
finalOperation = statusOperation;
|
|
1496
|
+
responseHeaders = pollHeaders;
|
|
1497
|
+
}
|
|
1498
|
+
if (finalOperation.error) throw new AISDKError({
|
|
1499
|
+
name: "GOOGLE_VIDEO_GENERATION_FAILED",
|
|
1500
|
+
message: `Video generation failed: ${finalOperation.error.message}`
|
|
1501
|
+
});
|
|
1502
|
+
const response = finalOperation.response;
|
|
1503
|
+
if (!((_g = response == null ? void 0 : response.generateVideoResponse) == null ? void 0 : _g.generatedSamples) || response.generateVideoResponse.generatedSamples.length === 0) throw new AISDKError({
|
|
1504
|
+
name: "GOOGLE_VIDEO_GENERATION_ERROR",
|
|
1505
|
+
message: `No videos in response. Response: ${JSON.stringify(finalOperation)}`
|
|
1506
|
+
});
|
|
1507
|
+
const videos = [];
|
|
1508
|
+
const videoMetadata = [];
|
|
1509
|
+
const resolvedHeaders = await resolve(this.config.headers);
|
|
1510
|
+
const apiKey = resolvedHeaders == null ? void 0 : resolvedHeaders["x-goog-api-key"];
|
|
1511
|
+
for (const generatedSample of response.generateVideoResponse.generatedSamples) if ((_h = generatedSample.video) == null ? void 0 : _h.uri) {
|
|
1512
|
+
const urlWithAuth = apiKey ? `${generatedSample.video.uri}${generatedSample.video.uri.includes("?") ? "&" : "?"}key=${apiKey}` : generatedSample.video.uri;
|
|
1513
|
+
videos.push({
|
|
1514
|
+
type: "url",
|
|
1515
|
+
url: urlWithAuth,
|
|
1516
|
+
mediaType: "video/mp4"
|
|
1517
|
+
});
|
|
1518
|
+
videoMetadata.push({ uri: generatedSample.video.uri });
|
|
1519
|
+
}
|
|
1520
|
+
if (videos.length === 0) throw new AISDKError({
|
|
1521
|
+
name: "GOOGLE_VIDEO_GENERATION_ERROR",
|
|
1522
|
+
message: "No valid videos in response"
|
|
1523
|
+
});
|
|
1524
|
+
return {
|
|
1525
|
+
videos,
|
|
1526
|
+
warnings,
|
|
1527
|
+
response: {
|
|
1528
|
+
timestamp: currentDate,
|
|
1529
|
+
modelId: this.modelId,
|
|
1530
|
+
headers: responseHeaders
|
|
1531
|
+
},
|
|
1532
|
+
providerMetadata: { google: { videos: videoMetadata } }
|
|
1533
|
+
};
|
|
1534
|
+
}
|
|
1535
|
+
};
|
|
1536
|
+
var googleOperationSchema = object({
|
|
1537
|
+
name: string().nullish(),
|
|
1538
|
+
done: boolean().nullish(),
|
|
1539
|
+
error: object({
|
|
1540
|
+
code: number().nullish(),
|
|
1541
|
+
message: string(),
|
|
1542
|
+
status: string().nullish()
|
|
1543
|
+
}).nullish(),
|
|
1544
|
+
response: object({ generateVideoResponse: object({ generatedSamples: array(object({ video: object({ uri: string().nullish() }).nullish() })).nullish() }).nullish() }).nullish()
|
|
1545
|
+
});
|
|
1546
|
+
var googleVideoModelOptionsSchema = lazySchema(() => zodSchema(object({
|
|
1547
|
+
pollIntervalMs: number().positive().nullish(),
|
|
1548
|
+
pollTimeoutMs: number().positive().nullish(),
|
|
1549
|
+
personGeneration: _enum([
|
|
1550
|
+
"dont_allow",
|
|
1551
|
+
"allow_adult",
|
|
1552
|
+
"allow_all"
|
|
1553
|
+
]).nullish(),
|
|
1554
|
+
negativePrompt: string().nullish(),
|
|
1555
|
+
referenceImages: array(object({
|
|
1556
|
+
bytesBase64Encoded: string().nullish(),
|
|
1557
|
+
gcsUri: string().nullish()
|
|
1558
|
+
})).nullish()
|
|
1559
|
+
}).passthrough()));
|
|
1560
|
+
function createGoogleGenerativeAI(options = {}) {
|
|
1561
|
+
var _a, _b;
|
|
1562
|
+
const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
|
|
1563
|
+
const providerName = (_b = options.name) != null ? _b : "google.generative-ai";
|
|
1564
|
+
const getHeaders = () => withUserAgentSuffix({
|
|
1565
|
+
"x-goog-api-key": loadApiKey({
|
|
1566
|
+
apiKey: options.apiKey,
|
|
1567
|
+
environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
|
|
1568
|
+
description: "Google Generative AI"
|
|
1569
|
+
}),
|
|
1570
|
+
...options.headers
|
|
1571
|
+
}, `ai-sdk/google/${VERSION}`);
|
|
1572
|
+
const createChatModel = (modelId) => {
|
|
1573
|
+
var _a2;
|
|
1574
|
+
return new GoogleGenerativeAILanguageModel(modelId, {
|
|
1575
|
+
provider: providerName,
|
|
1576
|
+
baseURL,
|
|
1577
|
+
headers: getHeaders,
|
|
1578
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : generateId,
|
|
1579
|
+
supportedUrls: () => ({ "*": [
|
|
1580
|
+
new RegExp(`^${baseURL}/files/.*$`),
|
|
1581
|
+
new RegExp(`^https://(?:www\\.)?youtube\\.com/watch\\?v=[\\w-]+(?:&[\\w=&.-]*)?$`),
|
|
1582
|
+
new RegExp(`^https://youtu\\.be/[\\w-]+(?:\\?[\\w=&.-]*)?$`)
|
|
1583
|
+
] }),
|
|
1584
|
+
fetch: options.fetch
|
|
1585
|
+
});
|
|
1586
|
+
};
|
|
1587
|
+
const createEmbeddingModel = (modelId) => new GoogleGenerativeAIEmbeddingModel(modelId, {
|
|
1588
|
+
provider: providerName,
|
|
1589
|
+
baseURL,
|
|
1590
|
+
headers: getHeaders,
|
|
1591
|
+
fetch: options.fetch
|
|
1592
|
+
});
|
|
1593
|
+
const createImageModel = (modelId, settings = {}) => new GoogleGenerativeAIImageModel(modelId, settings, {
|
|
1594
|
+
provider: providerName,
|
|
1595
|
+
baseURL,
|
|
1596
|
+
headers: getHeaders,
|
|
1597
|
+
fetch: options.fetch
|
|
1598
|
+
});
|
|
1599
|
+
const createVideoModel = (modelId) => {
|
|
1600
|
+
var _a2;
|
|
1601
|
+
return new GoogleGenerativeAIVideoModel(modelId, {
|
|
1602
|
+
provider: providerName,
|
|
1603
|
+
baseURL,
|
|
1604
|
+
headers: getHeaders,
|
|
1605
|
+
fetch: options.fetch,
|
|
1606
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : generateId
|
|
1607
|
+
});
|
|
1608
|
+
};
|
|
1609
|
+
const provider = function(modelId) {
|
|
1610
|
+
if (new.target) throw new Error("The Google Generative AI model function cannot be called with the new keyword.");
|
|
1611
|
+
return createChatModel(modelId);
|
|
1612
|
+
};
|
|
1613
|
+
provider.specificationVersion = "v3";
|
|
1614
|
+
provider.languageModel = createChatModel;
|
|
1615
|
+
provider.chat = createChatModel;
|
|
1616
|
+
provider.generativeAI = createChatModel;
|
|
1617
|
+
provider.embedding = createEmbeddingModel;
|
|
1618
|
+
provider.embeddingModel = createEmbeddingModel;
|
|
1619
|
+
provider.textEmbedding = createEmbeddingModel;
|
|
1620
|
+
provider.textEmbeddingModel = createEmbeddingModel;
|
|
1621
|
+
provider.image = createImageModel;
|
|
1622
|
+
provider.imageModel = createImageModel;
|
|
1623
|
+
provider.video = createVideoModel;
|
|
1624
|
+
provider.videoModel = createVideoModel;
|
|
1625
|
+
provider.tools = googleTools;
|
|
1626
|
+
return provider;
|
|
1627
|
+
}
|
|
1628
|
+
createGoogleGenerativeAI();
|
|
1629
|
+
//#endregion
|
|
1630
|
+
export { createGoogleGenerativeAI as t };
|