@mcp-use/inspector 0.24.1 → 0.24.2
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/cdn/inspector.js +8403 -8399
- package/dist/cli.js +17 -3
- package/dist/client/index.js +31 -31
- package/dist/server/{chunk-6QTK3GVK.js → chunk-DABQVQYF.js} +1 -1
- package/dist/server/{chunk-S2MXUMF5.js → chunk-TJIMGJEY.js} +17 -3
- package/dist/server/cli.js +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/middleware.js +2 -2
- package/dist/server/server.js +1 -1
- package/dist/server/shared-static.d.ts +2 -0
- package/dist/server/shared-static.d.ts.map +1 -1
- package/dist/server/shared-static.js +1 -1
- package/dist/web/assets/{1c-CTmWB9cK.js → 1c-BvhFLIxH.js} +1 -1
- package/dist/web/assets/{abnf-DcwzopGW.js → abnf-CX8OJqYN.js} +1 -1
- package/dist/web/assets/{accesslog-DzVBVVmK.js → accesslog-DcgKZXrS.js} +1 -1
- package/dist/web/assets/{actionscript-Ck9A-ZFD.js → actionscript-CItnilsG.js} +1 -1
- package/dist/web/assets/{ada-DgjiBv9g.js → ada-jhrFP_kG.js} +1 -1
- package/dist/web/assets/{angelscript-BDr46Hte.js → angelscript-VAnEYDkE.js} +1 -1
- package/dist/web/assets/{apache-CWaH05Bo.js → apache-Bvpn5SVi.js} +1 -1
- package/dist/web/assets/{applescript-CbrEu4vA.js → applescript-CJW-xKGY.js} +1 -1
- package/dist/web/assets/{arcade-CNzg8Xf3.js → arcade-DOpc8o0T.js} +1 -1
- package/dist/web/assets/{arduino-DhhbEktI.js → arduino-gi6qvS9d.js} +1 -1
- package/dist/web/assets/{armasm-BCaSrF3m.js → armasm-q6MkkUkb.js} +1 -1
- package/dist/web/assets/{asciidoc-BLbKrIgp.js → asciidoc-dqeP70O7.js} +1 -1
- package/dist/web/assets/{aspectj-BX3kQs8w.js → aspectj-pTI1lMoV.js} +1 -1
- package/dist/web/assets/{autohotkey-0ajUjyoh.js → autohotkey-56nVTWRr.js} +1 -1
- package/dist/web/assets/{autoit-BmfyeJUa.js → autoit-CeD--Ts3.js} +1 -1
- package/dist/web/assets/{avrasm-QAU4tTrX.js → avrasm-AXSUKL73.js} +1 -1
- package/dist/web/assets/{awk-DVoqdQ00.js → awk-rtNNAadV.js} +1 -1
- package/dist/web/assets/{axapta-DT108HB-.js → axapta-5CT0vHQJ.js} +1 -1
- package/dist/web/assets/{bash-B01Hmd3Q.js → bash-BQ-JKmsJ.js} +1 -1
- package/dist/web/assets/{basic-oDJPVXUO.js → basic-BeuEF9yi.js} +1 -1
- package/dist/web/assets/{bnf-BXSOJI_P.js → bnf-CBLE-WBe.js} +1 -1
- package/dist/web/assets/{brainfuck-BbAodQC_.js → brainfuck-D2gmEg74.js} +1 -1
- package/dist/web/assets/{c-BefDSsdB.js → c-B8cZ_Jcv.js} +1 -1
- package/dist/web/assets/{c-like-DCjCKFCJ.js → c-like-BUQset2J.js} +1 -1
- package/dist/web/assets/{cal-BpbFbNeJ.js → cal-BfmxNhZ4.js} +1 -1
- package/dist/web/assets/{capnproto-CtxM_thT.js → capnproto-ci7Oy_3w.js} +1 -1
- package/dist/web/assets/{ceylon-BqSL5L8h.js → ceylon-CR7mkBjT.js} +1 -1
- package/dist/web/assets/{clean-CdLPpK2g.js → clean-DDX6TchJ.js} +1 -1
- package/dist/web/assets/{client-F6B46LQA-DDraFY-s.js → client-S57RS52Z-D8i-S3XX.js} +3 -3
- package/dist/web/assets/{clojure-C_WGEe8n.js → clojure-BI_RGTAe.js} +1 -1
- package/dist/web/assets/{clojure-repl-qbapT5OY.js → clojure-repl-DSE_x4C2.js} +1 -1
- package/dist/web/assets/{cmake-BevqC-kl.js → cmake-DO4jOBdV.js} +1 -1
- package/dist/web/assets/{coffeescript-ursREQ6b.js → coffeescript-Dd0Lp6GU.js} +1 -1
- package/dist/web/assets/{coq-Co7GOSrf.js → coq-BVtIgdCz.js} +1 -1
- package/dist/web/assets/{core-DgXQNB16.js → core-DLviWPP3.js} +1 -1
- package/dist/web/assets/{cos-zpbWPiDR.js → cos-BSiT-IT0.js} +1 -1
- package/dist/web/assets/{cpp-H6GqxXJ1.js → cpp-DQ17j1lu.js} +1 -1
- package/dist/web/assets/{crmsh-Bgt1seVb.js → crmsh-BG-_i7Az.js} +1 -1
- package/dist/web/assets/{crystal-DrqAyYeg.js → crystal-CwybcU_c.js} +1 -1
- package/dist/web/assets/{csharp-KZYClq74.js → csharp-C5EW5MWq.js} +1 -1
- package/dist/web/assets/{csp-CTXVpvJP.js → csp-B4avFpGl.js} +1 -1
- package/dist/web/assets/{css-QhVy_OuY.js → css-XwnDlpLG.js} +1 -1
- package/dist/web/assets/{d-C_ASjLws.js → d-BVPgG_Aw.js} +1 -1
- package/dist/web/assets/{dart-GhKZgoJI.js → dart-CuzkdMfW.js} +1 -1
- package/dist/web/assets/{delphi-DogTNtbf.js → delphi-CUWyVIpe.js} +1 -1
- package/dist/web/assets/{diff-BwWxVOi3.js → diff-D3sSlrXe.js} +1 -1
- package/dist/web/assets/{display-A5IEINAP-DKx-Miug.js → display-A5IEINAP-GZCoUyvv.js} +2 -2
- package/dist/web/assets/{django-D7C4VDjD.js → django-D17_zMlX.js} +1 -1
- package/dist/web/assets/{dns-Di8KRr_4.js → dns-C1XxIveT.js} +1 -1
- package/dist/web/assets/{dockerfile-ChqukacU.js → dockerfile-CaGNlKQa.js} +1 -1
- package/dist/web/assets/{dos-it4jZ1tM.js → dos-CGH0X7Qf.js} +1 -1
- package/dist/web/assets/{dsconfig-E1N6hbLc.js → dsconfig-DTVqhcqx.js} +1 -1
- package/dist/web/assets/{dts-Dn8qzKm5.js → dts-BQco_sjz.js} +1 -1
- package/dist/web/assets/{dust-DvViZlL5.js → dust-BqGWXklz.js} +1 -1
- package/dist/web/assets/{ebnf-f4HwQhHN.js → ebnf-BqCwsW4k.js} +1 -1
- package/dist/web/assets/{elixir-DTCHxwkz.js → elixir-WtC_BfcU.js} +1 -1
- package/dist/web/assets/{elm-DzWAIyWp.js → elm-D7xIR2_2.js} +1 -1
- package/dist/web/assets/{embeddings-BjbiOR07.js → embeddings-DD3kbxNt.js} +1 -1
- package/dist/web/assets/{erb-BFf3OdkT.js → erb-DjXRvkR1.js} +1 -1
- package/dist/web/assets/{erlang-C4_U40M_.js → erlang-3Dswo9Kb.js} +1 -1
- package/dist/web/assets/{erlang-repl-qUaAPP6D.js → erlang-repl-DSxDJl2O.js} +1 -1
- package/dist/web/assets/{excel-D5mWHvTA.js → excel-BomM7FtM.js} +1 -1
- package/dist/web/assets/{fix-D7x6sLPo.js → fix-Dk-kBHCz.js} +1 -1
- package/dist/web/assets/{flix-L29ox9mN.js → flix-AdO4r9fm.js} +1 -1
- package/dist/web/assets/{fortran-DoY7JosF.js → fortran-BiFgPRXr.js} +1 -1
- package/dist/web/assets/{fsharp-87IJ0pSi.js → fsharp-CrGX07bo.js} +1 -1
- package/dist/web/assets/{gams-DvxX9CF0.js → gams-t-W8hkrr.js} +1 -1
- package/dist/web/assets/{gauss-u-lnJtmB.js → gauss-aVHF9YQ0.js} +1 -1
- package/dist/web/assets/{gcode-YJ3yAe35.js → gcode-Dirh21Jx.js} +1 -1
- package/dist/web/assets/{gherkin-qQ4C0hz2.js → gherkin-Doinw4Bw.js} +1 -1
- package/dist/web/assets/{glsl-DovCMqDY.js → glsl-BVAd7fQZ.js} +1 -1
- package/dist/web/assets/{gml-BxNKkhiu.js → gml-D3k6P4wF.js} +1 -1
- package/dist/web/assets/{go-CTer_0Vk.js → go-RoXLUpPR.js} +1 -1
- package/dist/web/assets/{golo-B9QF9C__.js → golo-BC3q2vpX.js} +1 -1
- package/dist/web/assets/{gradle-BO2za7tA.js → gradle-DVbLpAp9.js} +1 -1
- package/dist/web/assets/{groovy-Xl6rXTa-.js → groovy-BlpSZ8yL.js} +1 -1
- package/dist/web/assets/{haml-8ZZMx4TH.js → haml-CzCcmI1O.js} +1 -1
- package/dist/web/assets/{handlebars-Bjp8mTwo.js → handlebars-Bw-pBlQu.js} +1 -1
- package/dist/web/assets/{haskell-BO0IcpsW.js → haskell-DhIYpyey.js} +1 -1
- package/dist/web/assets/{haxe-jucBbb_U.js → haxe-CYh7KB7k.js} +1 -1
- package/dist/web/assets/{hsp-fdaKcvyx.js → hsp-r1aLXMhs.js} +1 -1
- package/dist/web/assets/{htmlbars-CvmnNGP0.js → htmlbars-HUpfURpP.js} +1 -1
- package/dist/web/assets/{http-ClTumGs0.js → http-BGFs537-.js} +1 -1
- package/dist/web/assets/{hy-Cnqvk573.js → hy-Dhjbxgrk.js} +1 -1
- package/dist/web/assets/{index-CWVLvgjZ.js → index-BQDf_2QT.js} +55 -55
- package/dist/web/assets/{index-wt2H_Smv.js → index-BaQ4JmMg.js} +1 -1
- package/dist/web/assets/{index-DJKT2JIf.js → index-BniVLnRq.js} +1 -1
- package/dist/web/assets/{index-DQduPDLp.js → index-D6ksAhcX.js} +1 -1
- package/dist/web/assets/{index-D8HwVPnm.js → index-DdfO8wbV.js} +1 -1
- package/dist/web/assets/{index-DMftCgN8.js → index-DhbVcA9F.js} +1 -1
- package/dist/web/assets/{index-D-IOuSz9.js → index-i9rlZ7RP.js} +1 -1
- package/dist/web/assets/{inform7-DU65okL6.js → inform7-B5avNAGg.js} +1 -1
- package/dist/web/assets/{ini-DPydLnkJ.js → ini-5Yf7OApE.js} +1 -1
- package/dist/web/assets/{irpf90-Ci7RR6GO.js → irpf90-9P8GaAT8.js} +1 -1
- package/dist/web/assets/{isbl-BXthN9NL.js → isbl-DBvY8d_e.js} +1 -1
- package/dist/web/assets/{java-0qMtqeaC.js → java-BYAicyox.js} +1 -1
- package/dist/web/assets/{javascript-C_4y9Xev.js → javascript-BsZ6ruUt.js} +1 -1
- package/dist/web/assets/{jboss-cli-DnOZEump.js → jboss-cli-BEvNpqj4.js} +1 -1
- package/dist/web/assets/{json-COqubvgv.js → json-YkjXrxXX.js} +1 -1
- package/dist/web/assets/{julia-CKTigX7j.js → julia-CIaQJLVA.js} +1 -1
- package/dist/web/assets/{julia-repl-D2X5MoL5.js → julia-repl-neu8z3rS.js} +1 -1
- package/dist/web/assets/{kotlin-DE6v_olT.js → kotlin-B_3Gv_Wa.js} +1 -1
- package/dist/web/assets/{langfuse-U2OEF7K7-tIq5i7J3.js → langfuse-U2OEF7K7-BS7yds-5.js} +3 -3
- package/dist/web/assets/{lasso-DDtPlFVD.js → lasso-BcxCyLbb.js} +1 -1
- package/dist/web/assets/{latex-Ba_YIzTx.js → latex-DBLSyLoB.js} +1 -1
- package/dist/web/assets/{ldif-DdK4S7lt.js → ldif-zLAu6Yaq.js} +1 -1
- package/dist/web/assets/{leaf-BJGKime_.js → leaf-C8g3QwRa.js} +1 -1
- package/dist/web/assets/{less-Dp9tzVdw.js → less-BiZdkKrA.js} +1 -1
- package/dist/web/assets/{lisp-WiJFSxPk.js → lisp-SZa_n4Ha.js} +1 -1
- package/dist/web/assets/{livecodeserver-BbM8H2YJ.js → livecodeserver-DbqsVDXq.js} +1 -1
- package/dist/web/assets/{livescript-DTx-s9n7.js → livescript-CKn9aHzH.js} +1 -1
- package/dist/web/assets/{llms-DmX_6p6K.js → llms-iELWWhGP.js} +1 -1
- package/dist/web/assets/{llvm-CBgnc17r.js → llvm-B2i8wLJj.js} +1 -1
- package/dist/web/assets/{lsl-uuSAdMyc.js → lsl-Cm2mEXVA.js} +1 -1
- package/dist/web/assets/{lua-Dft3BjDM.js → lua-BEDlAaf-.js} +1 -1
- package/dist/web/assets/{makefile-x5-muOWX.js → makefile-CjFs_qe4.js} +1 -1
- package/dist/web/assets/{markdown-7ur18VlQ.js → markdown-isjfrR4I.js} +1 -1
- package/dist/web/assets/{mathematica-BHmDla9L.js → mathematica-_UeFOFBA.js} +1 -1
- package/dist/web/assets/{matlab-o4Sf0Vyx.js → matlab-Bn6pdsuY.js} +1 -1
- package/dist/web/assets/{maxima-1Qi4vqEK.js → maxima-CzA538N9.js} +1 -1
- package/dist/web/assets/{mel-Bm7OmB-d.js → mel-BkIKTvwA.js} +1 -1
- package/dist/web/assets/{mercury-oYuC8GeI.js → mercury-BW46IsU1.js} +1 -1
- package/dist/web/assets/{mipsasm-DyA98-RK.js → mipsasm-xk8xikSW.js} +1 -1
- package/dist/web/assets/{mizar-D8AkzT1W.js → mizar-CydR6mll.js} +1 -1
- package/dist/web/assets/{mojolicious-DoYIupN-.js → mojolicious-DPEf75yc.js} +1 -1
- package/dist/web/assets/{monkey-BS6WeG8G.js → monkey-C3GGTuc2.js} +1 -1
- package/dist/web/assets/{moonscript-Capd9T7Y.js → moonscript-BWCm7GA4.js} +1 -1
- package/dist/web/assets/{n1ql-Db3nfUxR.js → n1ql-KUcEBJ5e.js} +1 -1
- package/dist/web/assets/{nginx-BIxU1lxo.js → nginx-B5n_99-T.js} +1 -1
- package/dist/web/assets/{nim-Co9B9r8M.js → nim-Cj2kL1F7.js} +1 -1
- package/dist/web/assets/{nix-BmaVssIW.js → nix-DU3svOEi.js} +1 -1
- package/dist/web/assets/{node-repl-BEa2E2Ut.js → node-repl-CVjFZCg8.js} +1 -1
- package/dist/web/assets/{nsis-Dm9lIXG7.js → nsis-ec6JIFaq.js} +1 -1
- package/dist/web/assets/{objectivec-Dykoktgt.js → objectivec-35jFh8_n.js} +1 -1
- package/dist/web/assets/{ocaml-BFoqC3jt.js → ocaml-DSvpPQQA.js} +1 -1
- package/dist/web/assets/{openscad-B-Z7cRIs.js → openscad-BtR0N549.js} +1 -1
- package/dist/web/assets/{oxygene-CcfnJtsl.js → oxygene-DHhgzdSe.js} +1 -1
- package/dist/web/assets/{parser3-RGpUpzqB.js → parser3-DBNAvQ81.js} +1 -1
- package/dist/web/assets/{perl-BGfvmCgU.js → perl-aQ2z2IY0.js} +1 -1
- package/dist/web/assets/{pf-DE7lRmO9.js → pf-NcRyIsiR.js} +1 -1
- package/dist/web/assets/{pgsql-D1K7RXHH.js → pgsql-C6IelojA.js} +1 -1
- package/dist/web/assets/{php-CDcB8K22.js → php-DXFb1z3E.js} +1 -1
- package/dist/web/assets/{php-template-C6Ze9zM3.js → php-template-noIzpFwi.js} +1 -1
- package/dist/web/assets/{plaintext-VaxG0XKn.js → plaintext-CuMZI4wJ.js} +1 -1
- package/dist/web/assets/{pony-Dk4oe_9z.js → pony-DKNUP03S.js} +1 -1
- package/dist/web/assets/{powershell-BaX5GCVe.js → powershell-DK5QFD1P.js} +1 -1
- package/dist/web/assets/{processing-fAZf8_bL.js → processing-Bd0YwPX-.js} +1 -1
- package/dist/web/assets/{profile-CDhmTkCS.js → profile-BUJvtaZj.js} +1 -1
- package/dist/web/assets/{prolog-BmoLSmTY.js → prolog-C8MmbuJy.js} +1 -1
- package/dist/web/assets/{properties-DJCBGQNY.js → properties-BQiZSAsl.js} +1 -1
- package/dist/web/assets/{protobuf-CzYqa9zw.js → protobuf-BIM_UAt8.js} +1 -1
- package/dist/web/assets/{puppet-DVc1q4ce.js → puppet-BuXb1lDA.js} +1 -1
- package/dist/web/assets/{purebasic-BiMnj4-V.js → purebasic-BI2OGD7g.js} +1 -1
- package/dist/web/assets/{python-EQDVImf4.js → python-MrZFTqbt.js} +1 -1
- package/dist/web/assets/{python-repl-f1U2J_qV.js → python-repl-BgSuB0OR.js} +1 -1
- package/dist/web/assets/{q-D6s7BXPa.js → q-CHprrWyV.js} +1 -1
- package/dist/web/assets/{qml-BO8q5aWM.js → qml-BnHfbLpq.js} +1 -1
- package/dist/web/assets/{r-CloG_Zdr.js → r-BaO6b_Bk.js} +1 -1
- package/dist/web/assets/{reasonml-Q-1LUqwg.js → reasonml-DSmR8Ung.js} +1 -1
- package/dist/web/assets/{rib-C5Brg8EZ.js → rib-Dm3ubKSd.js} +1 -1
- package/dist/web/assets/{roboconf-Do05VEUh.js → roboconf-BLDc3VXQ.js} +1 -1
- package/dist/web/assets/{routeros-D0vYkkU7.js → routeros-BE3GmAwJ.js} +1 -1
- package/dist/web/assets/{rsl-D5sHPGhK.js → rsl-BJNhDId6.js} +1 -1
- package/dist/web/assets/{ruby-C1RUeSqz.js → ruby-CQ10tkxO.js} +1 -1
- package/dist/web/assets/{ruleslanguage-BsoPWgc2.js → ruleslanguage-DFnSuCn9.js} +1 -1
- package/dist/web/assets/{rust-CtaZBZ4i.js → rust-wEY88oU7.js} +1 -1
- package/dist/web/assets/{sas-CnfjRlE5.js → sas-gbrzG7lJ.js} +1 -1
- package/dist/web/assets/{scala-q_x6mzS5.js → scala-CumsYZ1V.js} +1 -1
- package/dist/web/assets/{scheme-D6sVctSi.js → scheme-DO8wf0St.js} +1 -1
- package/dist/web/assets/{scilab-SYiHdlW6.js → scilab-BeQqjCZH.js} +1 -1
- package/dist/web/assets/{scss-Db4_7V_0.js → scss-Bndud_G4.js} +1 -1
- package/dist/web/assets/{shell-CcdzrrgX.js → shell-Ui33dEFX.js} +1 -1
- package/dist/web/assets/{smali-DORKQgQq.js → smali-MAEUsdX_.js} +1 -1
- package/dist/web/assets/{smalltalk-CpQEvroj.js → smalltalk-hIj_nQ9T.js} +1 -1
- package/dist/web/assets/{sml-SatPISWr.js → sml-CDrYQEBb.js} +1 -1
- package/dist/web/assets/{sqf-cVJuwTv0.js → sqf-BfLxcAGD.js} +1 -1
- package/dist/web/assets/{sql-DdLii_lq.js → sql-DANvBdmv.js} +1 -1
- package/dist/web/assets/{sql_more-CCtqK7TS.js → sql_more-C0QRwHnL.js} +1 -1
- package/dist/web/assets/{stan-C7i5U7Tu.js → stan-Cj8NJPGd.js} +1 -1
- package/dist/web/assets/{stata-BgTOEq36.js → stata-DHZ8Glmp.js} +1 -1
- package/dist/web/assets/{stdio-VW2BGJTO-BWf4fkd0.js → stdio-XAHYUHLM-Ci3DPFXU.js} +1 -1
- package/dist/web/assets/{step21-4wF-EYaY.js → step21-DYbMWMLq.js} +1 -1
- package/dist/web/assets/{stylus-CudOUVbX.js → stylus-HTTDZjuT.js} +1 -1
- package/dist/web/assets/{subunit-FzxEcGnA.js → subunit-VIqybOs4.js} +1 -1
- package/dist/web/assets/{swift-AkuIHMma.js → swift-BR9ynvuv.js} +1 -1
- package/dist/web/assets/{taggerscript-zQnQHjds.js → taggerscript-BBIZMwyL.js} +1 -1
- package/dist/web/assets/{tap-D_u25MR4.js → tap-DgYlHFwQ.js} +1 -1
- package/dist/web/assets/{tcl-BmBEXBlk.js → tcl-BOVb5he3.js} +1 -1
- package/dist/web/assets/{thrift-DWC0li1Q.js → thrift-DnYrJP2I.js} +1 -1
- package/dist/web/assets/{tp-CEq959sY.js → tp-CKMrYpFB.js} +1 -1
- package/dist/web/assets/{twig-C5Wb7ck9.js → twig-C8yRQ_si.js} +1 -1
- package/dist/web/assets/{typescript-WdBZkgaL.js → typescript-Bp8GRFbQ.js} +1 -1
- package/dist/web/assets/{vala-eCM8DSFy.js → vala-Bv7tX-YP.js} +1 -1
- package/dist/web/assets/{vbnet-zpULNywC.js → vbnet-B-xyxnsY.js} +1 -1
- package/dist/web/assets/{vbscript-B03M3MbK.js → vbscript-DCSS0QgU.js} +1 -1
- package/dist/web/assets/{vbscript-html-g1Gm8Ll9.js → vbscript-html-DkK5mhXa.js} +1 -1
- package/dist/web/assets/{verilog-TtrPSIop.js → verilog-CaWRJI65.js} +1 -1
- package/dist/web/assets/{vhdl-it3lcJPz.js → vhdl-UJHisrmd.js} +1 -1
- package/dist/web/assets/{vim-C2d-HZcP.js → vim-CTdBAd8A.js} +1 -1
- package/dist/web/assets/{x86asm-C7xtdQmL.js → x86asm-DipJ34Qb.js} +1 -1
- package/dist/web/assets/{xl-C1gdeZPe.js → xl-DfcCv_5D.js} +1 -1
- package/dist/web/assets/{xml-NLr-LcF5.js → xml-Ds8sXZ7Q.js} +1 -1
- package/dist/web/assets/{xquery-oLMw5fck.js → xquery-BofP9fWJ.js} +1 -1
- package/dist/web/assets/{yaml-C8U6fnu_.js → yaml-CsOQPuOU.js} +1 -1
- package/dist/web/assets/{zephir-CgFtZG3z.js → zephir-CU7UAhpm.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +3 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a7 as Ue,a8 as je,a9 as J,aa as ae,b as Ae,ab as H,Q as le,n as U,ac as kt,ad as xt,ae as Mt,af as Pt,ag as Rt,ah as Ft,ai as Lt,aj as Dt,ak as Bt,al as Ut,i as jt,am as Vt,an as zt,ao as Gt,d as Zt,ap as $t,aq as Ht,ar as Wt,as as Jt,at as Xt,x as Yt,au as Kt,c as He,av as qt,aw as We,ax as Qt,ay as ea,az as ta,aA as Se,aB as aa,aC as sa,aD as na,r as ra,w as Je,aE as re,e as oe,aF as Xe,aG as Ye,D as ce,C as _e,aH as Ve,B as ia,aI as ze,R as Ge,S as X,y as oa,aJ as Ie,W as ca,a2 as Ke,aK as ua,aL as la,aM as ha,a1 as pa,U as qe,aN as ie,p as G,aO as Qe,aP as ga,aQ as et,aR as ma,a as fa,m as da,aS as ba,aT as _a,aU as ya,aV as Ta,aW as va,aX as Ea,aY as wa,aZ as Ca,V as Ze,a_ as Aa,G as Sa,a$ as Ia,o as tt,s as at,b0 as Oa,b1 as ve,z as Na}from"./index-CWVLvgjZ.js";function st(e,a,n,r,i){if(a!==e){typeof a.toJSON=="function"&&(a=a.toJSON());for(var c=Ue(a),h=Ue(e),l=!1,b=h.length-1;b>=0;b--){var f=h[b],T=e[f];if(je(a,f)&&!(a[f]===void 0&&T!==void 0&&Array.isArray(a)===!1)){var y=a[f];typeof T=="object"&&T!=null&&typeof y=="object"&&y!=null&&Array.isArray(T)===Array.isArray(y)?st(T,y,n,r+"/"+J(f),i):T!==y&&(i&&n.push({op:"test",path:r+"/"+J(f),value:ae(T)}),n.push({op:"replace",path:r+"/"+J(f),value:ae(y)}))}else Array.isArray(e)===Array.isArray(a)?(i&&n.push({op:"test",path:r+"/"+J(f),value:ae(T)}),n.push({op:"remove",path:r+"/"+J(f)}),l=!0):(i&&n.push({op:"test",path:r,value:e}),n.push({op:"replace",path:r,value:a}))}if(!(!l&&c.length==h.length))for(var b=0;b<c.length;b++){var f=c[b];!je(e,f)&&a[f]!==void 0&&n.push({op:"add",path:r+"/"+J(f),value:ae(a[f])})}}}function Oe(e,a,n=!1){var r=[];return st(e,a,r,"",n),r}function nt(e){return e!==void 0&&Array.isArray(e.lc_namespace)}function rt(e){return e!==void 0&&H.isRunnable(e)&&"lc_name"in e.constructor&&typeof e.constructor.lc_name=="function"&&e.constructor.lc_name()==="RunnableToolLike"}function it(e){return!!e&&typeof e=="object"&&"name"in e&&"schema"in e&&(Ae(e.schema)||e.schema!=null&&typeof e.schema=="object"&&"type"in e.schema&&typeof e.schema.type=="string"&&["null","boolean","object","array","number","string"].includes(e.schema.type))}function ot(e){return it(e)||rt(e)||nt(e)}var ka={};U(ka,{convertToOpenAIFunction:()=>ct,convertToOpenAITool:()=>xa,isLangChainTool:()=>ot,isRunnableToolLike:()=>rt,isStructuredTool:()=>nt,isStructuredToolParams:()=>it});function ct(e,a){const n=typeof a=="number"?void 0:a;return{name:e.name,description:e.description,parameters:le(e.schema),...n?.strict!==void 0?{strict:n.strict}:{}}}function xa(e,a){const n=typeof a=="number"?void 0:a;let r;return ot(e)?r={type:"function",function:ct(e)}:r=e,n?.strict!==void 0&&(r.function.strict=n.strict),r}var Ma={};U(Ma,{extendInteropZodObject:()=>ta,getInteropZodDefaultGetter:()=>ea,getInteropZodObjectShape:()=>Qt,getSchemaDescription:()=>We,interopParse:()=>qt,interopParseAsync:()=>He,interopSafeParse:()=>Kt,interopSafeParseAsync:()=>Yt,interopZodObjectMakeFieldsOptional:()=>Xt,interopZodObjectPartial:()=>Jt,interopZodObjectPassthrough:()=>Wt,interopZodObjectStrict:()=>Ht,interopZodTransformInputSchema:()=>$t,isInteropZodError:()=>Zt,isInteropZodLiteral:()=>Gt,isInteropZodObject:()=>zt,isInteropZodSchema:()=>Ae,isShapelessZodSchema:()=>Vt,isSimpleStringZodSchema:()=>jt,isZodArrayV4:()=>Ut,isZodLiteralV3:()=>Bt,isZodLiteralV4:()=>Dt,isZodNullableV4:()=>Lt,isZodObjectV3:()=>Ft,isZodObjectV4:()=>Rt,isZodOptionalV4:()=>Pt,isZodSchema:()=>Mt,isZodSchemaV3:()=>xt,isZodSchemaV4:()=>kt});var Pa={};U(Pa,{BasePromptValue:()=>he,ChatPromptValue:()=>lt,ImagePromptValue:()=>Ra,StringPromptValue:()=>ut});var he=class extends sa{},ut=class extends he{static lc_name(){return"StringPromptValue"}lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;value;constructor(e){super({value:e}),this.value=e}toString(){return this.value}toChatMessages(){return[new Se(this.value)]}},lt=class extends he{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ChatPromptValue"}messages;constructor(e){Array.isArray(e)&&(e={messages:e}),super(e),this.messages=e.messages}toString(){return aa(this.messages)}toChatMessages(){return this.messages}},Ra=class extends he{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ImagePromptValue"}imageUrl;value;constructor(e){"imageUrl"in e||(e={imageUrl:e}),super(e),this.imageUrl=e.imageUrl}toString(){return this.imageUrl.url}toChatMessages(){return[new Se({content:[{type:"image_url",image_url:{detail:this.imageUrl.detail,url:this.imageUrl.url}}]})]}},_="0123456789abcdef".split(""),Fa=[-2147483648,8388608,32768,128],D=[24,16,8,0],se=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],P=[];function B(e,a){a?(P[0]=P[16]=P[1]=P[2]=P[3]=P[4]=P[5]=P[6]=P[7]=P[8]=P[9]=P[10]=P[11]=P[12]=P[13]=P[14]=P[15]=0,this.blocks=P):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=e}B.prototype.update=function(e){if(!this.finalized){var a,n=typeof e;if(n!=="string"){if(n==="object"){if(e===null)throw new Error(ERROR);if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(e)))throw new Error(ERROR)}else throw new Error(ERROR);a=!0}for(var r,i=0,c,h=e.length,l=this.blocks;i<h;){if(this.hashed&&(this.hashed=!1,l[0]=this.block,this.block=l[16]=l[1]=l[2]=l[3]=l[4]=l[5]=l[6]=l[7]=l[8]=l[9]=l[10]=l[11]=l[12]=l[13]=l[14]=l[15]=0),a)for(c=this.start;i<h&&c<64;++i)l[c>>>2]|=e[i]<<D[c++&3];else for(c=this.start;i<h&&c<64;++i)r=e.charCodeAt(i),r<128?l[c>>>2]|=r<<D[c++&3]:r<2048?(l[c>>>2]|=(192|r>>>6)<<D[c++&3],l[c>>>2]|=(128|r&63)<<D[c++&3]):r<55296||r>=57344?(l[c>>>2]|=(224|r>>>12)<<D[c++&3],l[c>>>2]|=(128|r>>>6&63)<<D[c++&3],l[c>>>2]|=(128|r&63)<<D[c++&3]):(r=65536+((r&1023)<<10|e.charCodeAt(++i)&1023),l[c>>>2]|=(240|r>>>18)<<D[c++&3],l[c>>>2]|=(128|r>>>12&63)<<D[c++&3],l[c>>>2]|=(128|r>>>6&63)<<D[c++&3],l[c>>>2]|=(128|r&63)<<D[c++&3]);this.lastByteIndex=c,this.bytes+=c-this.start,c>=64?(this.block=l[16],this.start=c-64,this.hash(),this.hashed=!0):this.start=c}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};B.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,a=this.lastByteIndex;e[16]=this.block,e[a>>>2]|=Fa[a&3],this.block=e[16],a>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}};B.prototype.hash=function(){var e=this.h0,a=this.h1,n=this.h2,r=this.h3,i=this.h4,c=this.h5,h=this.h6,l=this.h7,b=this.blocks,f,T,y,E,g,d,m,v,w,A,C;for(f=16;f<64;++f)g=b[f-15],T=(g>>>7|g<<25)^(g>>>18|g<<14)^g>>>3,g=b[f-2],y=(g>>>17|g<<15)^(g>>>19|g<<13)^g>>>10,b[f]=b[f-16]+T+b[f-7]+y<<0;for(C=a&n,f=0;f<64;f+=4)this.first?(this.is224?(v=300032,g=b[0]-1413257819,l=g-150054599<<0,r=g+24177077<<0):(v=704751109,g=b[0]-210244248,l=g-1521486534<<0,r=g+143694565<<0),this.first=!1):(T=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),y=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),v=e&a,E=v^e&n^C,m=i&c^~i&h,g=l+y+m+se[f]+b[f],d=T+E,l=r+g<<0,r=g+d<<0),T=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),y=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7),w=r&e,E=w^r&a^v,m=h&l^~h&i,g=c+y+m+se[f+1]+b[f+1],d=T+E,h=n+g<<0,n=g+d<<0,T=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),y=(h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7),A=n&r,E=A^n&e^w,m=c&h^~c&l,g=i+y+m+se[f+2]+b[f+2],d=T+E,c=a+g<<0,a=g+d<<0,T=(a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10),y=(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7),C=a&n,E=C^a&r^A,m=c&h^~c&l,g=i+y+m+se[f+3]+b[f+3],d=T+E,i=e+g<<0,e=g+d<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+e<<0,this.h1=this.h1+a<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+i<<0,this.h5=this.h5+c<<0,this.h6=this.h6+h<<0,this.h7=this.h7+l<<0};B.prototype.hex=function(){this.finalize();var e=this.h0,a=this.h1,n=this.h2,r=this.h3,i=this.h4,c=this.h5,h=this.h6,l=this.h7,b=_[e>>>28&15]+_[e>>>24&15]+_[e>>>20&15]+_[e>>>16&15]+_[e>>>12&15]+_[e>>>8&15]+_[e>>>4&15]+_[e&15]+_[a>>>28&15]+_[a>>>24&15]+_[a>>>20&15]+_[a>>>16&15]+_[a>>>12&15]+_[a>>>8&15]+_[a>>>4&15]+_[a&15]+_[n>>>28&15]+_[n>>>24&15]+_[n>>>20&15]+_[n>>>16&15]+_[n>>>12&15]+_[n>>>8&15]+_[n>>>4&15]+_[n&15]+_[r>>>28&15]+_[r>>>24&15]+_[r>>>20&15]+_[r>>>16&15]+_[r>>>12&15]+_[r>>>8&15]+_[r>>>4&15]+_[r&15]+_[i>>>28&15]+_[i>>>24&15]+_[i>>>20&15]+_[i>>>16&15]+_[i>>>12&15]+_[i>>>8&15]+_[i>>>4&15]+_[i&15]+_[c>>>28&15]+_[c>>>24&15]+_[c>>>20&15]+_[c>>>16&15]+_[c>>>12&15]+_[c>>>8&15]+_[c>>>4&15]+_[c&15]+_[h>>>28&15]+_[h>>>24&15]+_[h>>>20&15]+_[h>>>16&15]+_[h>>>12&15]+_[h>>>8&15]+_[h>>>4&15]+_[h&15];return this.is224||(b+=_[l>>>28&15]+_[l>>>24&15]+_[l>>>20&15]+_[l>>>16&15]+_[l>>>12&15]+_[l>>>8&15]+_[l>>>4&15]+_[l&15]),b};B.prototype.toString=B.prototype.hex;B.prototype.digest=function(){this.finalize();var e=this.h0,a=this.h1,n=this.h2,r=this.h3,i=this.h4,c=this.h5,h=this.h6,l=this.h7,b=[e>>>24&255,e>>>16&255,e>>>8&255,e&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,n>>>24&255,n>>>16&255,n>>>8&255,n&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255,i>>>24&255,i>>>16&255,i>>>8&255,i&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255];return this.is224||b.push(l>>>24&255,l>>>16&255,l>>>8&255,l&255),b};B.prototype.array=B.prototype.digest;B.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),a=new DataView(e);return a.setUint32(0,this.h0),a.setUint32(4,this.h1),a.setUint32(8,this.h2),a.setUint32(12,this.h3),a.setUint32(16,this.h4),a.setUint32(20,this.h5),a.setUint32(24,this.h6),this.is224||a.setUint32(28,this.h7),e};const ht=(...e)=>new B(!1,!0).update(e.join("")).hex();var La={};U(La,{sha256:()=>ht});var Da={};U(Da,{BaseCache:()=>gt,InMemoryCache:()=>mt,defaultHashKeyEncoder:()=>pt,deserializeStoredGeneration:()=>Ba,serializeGeneration:()=>Ua});const pt=(...e)=>ht(e.join("_"));function Ba(e){return e.message!==void 0?{text:e.text,message:na(e.message)}:{text:e.text}}function Ua(e){const a={text:e.text};return e.message!==void 0&&(a.message=e.message.toDict()),a}var gt=class{keyEncoder=pt;makeDefaultKeyEncoder(e){this.keyEncoder=e}};const ja=new Map;var mt=class ft extends gt{cache;constructor(a){super(),this.cache=a??new Map}lookup(a,n){return Promise.resolve(this.cache.get(this.keyEncoder(a,n))??null)}async update(a,n,r){this.cache.set(this.keyEncoder(a,n),r)}static global(){return new ft(ja)}},q={},$e;function Va(){if($e)return q;$e=1,q.byteLength=l,q.toByteArray=f,q.fromByteArray=E;for(var e=[],a=[],n=typeof Uint8Array<"u"?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,c=r.length;i<c;++i)e[i]=r[i],a[r.charCodeAt(i)]=i;a[45]=62,a[95]=63;function h(g){var d=g.length;if(d%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var m=g.indexOf("=");m===-1&&(m=d);var v=m===d?0:4-m%4;return[m,v]}function l(g){var d=h(g),m=d[0],v=d[1];return(m+v)*3/4-v}function b(g,d,m){return(d+m)*3/4-m}function f(g){var d,m=h(g),v=m[0],w=m[1],A=new n(b(g,v,w)),C=0,M=w>0?v-4:v,O;for(O=0;O<M;O+=4)d=a[g.charCodeAt(O)]<<18|a[g.charCodeAt(O+1)]<<12|a[g.charCodeAt(O+2)]<<6|a[g.charCodeAt(O+3)],A[C++]=d>>16&255,A[C++]=d>>8&255,A[C++]=d&255;return w===2&&(d=a[g.charCodeAt(O)]<<2|a[g.charCodeAt(O+1)]>>4,A[C++]=d&255),w===1&&(d=a[g.charCodeAt(O)]<<10|a[g.charCodeAt(O+1)]<<4|a[g.charCodeAt(O+2)]>>2,A[C++]=d>>8&255,A[C++]=d&255),A}function T(g){return e[g>>18&63]+e[g>>12&63]+e[g>>6&63]+e[g&63]}function y(g,d,m){for(var v,w=[],A=d;A<m;A+=3)v=(g[A]<<16&16711680)+(g[A+1]<<8&65280)+(g[A+2]&255),w.push(T(v));return w.join("")}function E(g){for(var d,m=g.length,v=m%3,w=[],A=16383,C=0,M=m-v;C<M;C+=A)w.push(y(g,C,C+A>M?M:C+A));return v===1?(d=g[m-1],w.push(e[d>>2]+e[d<<4&63]+"==")):v===2&&(d=(g[m-2]<<8)+g[m-1],w.push(e[d>>10]+e[d>>4&63]+e[d<<2&63]+"=")),w.join("")}return q}var za=Va();const Ga=ra(za);var Za=Object.defineProperty,$a=(e,a,n)=>a in e?Za(e,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[a]=n,Ha=(e,a,n)=>($a(e,a+"",n),n);function Wa(e,a){let n=Array.from({length:e.length},(r,i)=>({start:i,end:i+1}));for(;n.length>1;){let r=null;for(let i=0;i<n.length-1;i++){const c=e.slice(n[i].start,n[i+1].end),h=a.get(c.join(","));h!=null&&(r==null||h<r[0])&&(r=[h,i])}if(r!=null){const i=r[1];n[i]={start:n[i].start,end:n[i+1].end},n.splice(i+1,1)}else break}return n}function Ja(e,a){return e.length===1?[a.get(e.join(","))]:Wa(e,a).map(n=>a.get(e.slice(n.start,n.end).join(","))).filter(n=>n!=null)}function Xa(e){return e.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}var Ee=class{specialTokens;inverseSpecialTokens;patStr;textEncoder=new TextEncoder;textDecoder=new TextDecoder("utf-8");rankMap=new Map;textMap=new Map;constructor(e,a){this.patStr=e.pat_str;const n=e.bpe_ranks.split(`
|
|
1
|
+
import{a7 as Ue,a8 as je,a9 as J,aa as ae,b as Ae,ab as H,Q as le,n as U,ac as kt,ad as xt,ae as Mt,af as Pt,ag as Rt,ah as Ft,ai as Lt,aj as Dt,ak as Bt,al as Ut,i as jt,am as Vt,an as zt,ao as Gt,d as Zt,ap as $t,aq as Ht,ar as Wt,as as Jt,at as Xt,x as Yt,au as Kt,c as He,av as qt,aw as We,ax as Qt,ay as ea,az as ta,aA as Se,aB as aa,aC as sa,aD as na,r as ra,w as Je,aE as re,e as oe,aF as Xe,aG as Ye,D as ce,C as _e,aH as Ve,B as ia,aI as ze,R as Ge,S as X,y as oa,aJ as Ie,W as ca,a2 as Ke,aK as ua,aL as la,aM as ha,a1 as pa,U as qe,aN as ie,p as G,aO as Qe,aP as ga,aQ as et,aR as ma,a as fa,m as da,aS as ba,aT as _a,aU as ya,aV as Ta,aW as va,aX as Ea,aY as wa,aZ as Ca,V as Ze,a_ as Aa,G as Sa,a$ as Ia,o as tt,s as at,b0 as Oa,b1 as ve,z as Na}from"./index-BQDf_2QT.js";function st(e,a,n,r,i){if(a!==e){typeof a.toJSON=="function"&&(a=a.toJSON());for(var c=Ue(a),h=Ue(e),l=!1,b=h.length-1;b>=0;b--){var f=h[b],T=e[f];if(je(a,f)&&!(a[f]===void 0&&T!==void 0&&Array.isArray(a)===!1)){var y=a[f];typeof T=="object"&&T!=null&&typeof y=="object"&&y!=null&&Array.isArray(T)===Array.isArray(y)?st(T,y,n,r+"/"+J(f),i):T!==y&&(i&&n.push({op:"test",path:r+"/"+J(f),value:ae(T)}),n.push({op:"replace",path:r+"/"+J(f),value:ae(y)}))}else Array.isArray(e)===Array.isArray(a)?(i&&n.push({op:"test",path:r+"/"+J(f),value:ae(T)}),n.push({op:"remove",path:r+"/"+J(f)}),l=!0):(i&&n.push({op:"test",path:r,value:e}),n.push({op:"replace",path:r,value:a}))}if(!(!l&&c.length==h.length))for(var b=0;b<c.length;b++){var f=c[b];!je(e,f)&&a[f]!==void 0&&n.push({op:"add",path:r+"/"+J(f),value:ae(a[f])})}}}function Oe(e,a,n=!1){var r=[];return st(e,a,r,"",n),r}function nt(e){return e!==void 0&&Array.isArray(e.lc_namespace)}function rt(e){return e!==void 0&&H.isRunnable(e)&&"lc_name"in e.constructor&&typeof e.constructor.lc_name=="function"&&e.constructor.lc_name()==="RunnableToolLike"}function it(e){return!!e&&typeof e=="object"&&"name"in e&&"schema"in e&&(Ae(e.schema)||e.schema!=null&&typeof e.schema=="object"&&"type"in e.schema&&typeof e.schema.type=="string"&&["null","boolean","object","array","number","string"].includes(e.schema.type))}function ot(e){return it(e)||rt(e)||nt(e)}var ka={};U(ka,{convertToOpenAIFunction:()=>ct,convertToOpenAITool:()=>xa,isLangChainTool:()=>ot,isRunnableToolLike:()=>rt,isStructuredTool:()=>nt,isStructuredToolParams:()=>it});function ct(e,a){const n=typeof a=="number"?void 0:a;return{name:e.name,description:e.description,parameters:le(e.schema),...n?.strict!==void 0?{strict:n.strict}:{}}}function xa(e,a){const n=typeof a=="number"?void 0:a;let r;return ot(e)?r={type:"function",function:ct(e)}:r=e,n?.strict!==void 0&&(r.function.strict=n.strict),r}var Ma={};U(Ma,{extendInteropZodObject:()=>ta,getInteropZodDefaultGetter:()=>ea,getInteropZodObjectShape:()=>Qt,getSchemaDescription:()=>We,interopParse:()=>qt,interopParseAsync:()=>He,interopSafeParse:()=>Kt,interopSafeParseAsync:()=>Yt,interopZodObjectMakeFieldsOptional:()=>Xt,interopZodObjectPartial:()=>Jt,interopZodObjectPassthrough:()=>Wt,interopZodObjectStrict:()=>Ht,interopZodTransformInputSchema:()=>$t,isInteropZodError:()=>Zt,isInteropZodLiteral:()=>Gt,isInteropZodObject:()=>zt,isInteropZodSchema:()=>Ae,isShapelessZodSchema:()=>Vt,isSimpleStringZodSchema:()=>jt,isZodArrayV4:()=>Ut,isZodLiteralV3:()=>Bt,isZodLiteralV4:()=>Dt,isZodNullableV4:()=>Lt,isZodObjectV3:()=>Ft,isZodObjectV4:()=>Rt,isZodOptionalV4:()=>Pt,isZodSchema:()=>Mt,isZodSchemaV3:()=>xt,isZodSchemaV4:()=>kt});var Pa={};U(Pa,{BasePromptValue:()=>he,ChatPromptValue:()=>lt,ImagePromptValue:()=>Ra,StringPromptValue:()=>ut});var he=class extends sa{},ut=class extends he{static lc_name(){return"StringPromptValue"}lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;value;constructor(e){super({value:e}),this.value=e}toString(){return this.value}toChatMessages(){return[new Se(this.value)]}},lt=class extends he{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ChatPromptValue"}messages;constructor(e){Array.isArray(e)&&(e={messages:e}),super(e),this.messages=e.messages}toString(){return aa(this.messages)}toChatMessages(){return this.messages}},Ra=class extends he{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ImagePromptValue"}imageUrl;value;constructor(e){"imageUrl"in e||(e={imageUrl:e}),super(e),this.imageUrl=e.imageUrl}toString(){return this.imageUrl.url}toChatMessages(){return[new Se({content:[{type:"image_url",image_url:{detail:this.imageUrl.detail,url:this.imageUrl.url}}]})]}},_="0123456789abcdef".split(""),Fa=[-2147483648,8388608,32768,128],D=[24,16,8,0],se=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],P=[];function B(e,a){a?(P[0]=P[16]=P[1]=P[2]=P[3]=P[4]=P[5]=P[6]=P[7]=P[8]=P[9]=P[10]=P[11]=P[12]=P[13]=P[14]=P[15]=0,this.blocks=P):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=e}B.prototype.update=function(e){if(!this.finalized){var a,n=typeof e;if(n!=="string"){if(n==="object"){if(e===null)throw new Error(ERROR);if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(e)))throw new Error(ERROR)}else throw new Error(ERROR);a=!0}for(var r,i=0,c,h=e.length,l=this.blocks;i<h;){if(this.hashed&&(this.hashed=!1,l[0]=this.block,this.block=l[16]=l[1]=l[2]=l[3]=l[4]=l[5]=l[6]=l[7]=l[8]=l[9]=l[10]=l[11]=l[12]=l[13]=l[14]=l[15]=0),a)for(c=this.start;i<h&&c<64;++i)l[c>>>2]|=e[i]<<D[c++&3];else for(c=this.start;i<h&&c<64;++i)r=e.charCodeAt(i),r<128?l[c>>>2]|=r<<D[c++&3]:r<2048?(l[c>>>2]|=(192|r>>>6)<<D[c++&3],l[c>>>2]|=(128|r&63)<<D[c++&3]):r<55296||r>=57344?(l[c>>>2]|=(224|r>>>12)<<D[c++&3],l[c>>>2]|=(128|r>>>6&63)<<D[c++&3],l[c>>>2]|=(128|r&63)<<D[c++&3]):(r=65536+((r&1023)<<10|e.charCodeAt(++i)&1023),l[c>>>2]|=(240|r>>>18)<<D[c++&3],l[c>>>2]|=(128|r>>>12&63)<<D[c++&3],l[c>>>2]|=(128|r>>>6&63)<<D[c++&3],l[c>>>2]|=(128|r&63)<<D[c++&3]);this.lastByteIndex=c,this.bytes+=c-this.start,c>=64?(this.block=l[16],this.start=c-64,this.hash(),this.hashed=!0):this.start=c}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};B.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,a=this.lastByteIndex;e[16]=this.block,e[a>>>2]|=Fa[a&3],this.block=e[16],a>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}};B.prototype.hash=function(){var e=this.h0,a=this.h1,n=this.h2,r=this.h3,i=this.h4,c=this.h5,h=this.h6,l=this.h7,b=this.blocks,f,T,y,E,g,d,m,v,w,A,C;for(f=16;f<64;++f)g=b[f-15],T=(g>>>7|g<<25)^(g>>>18|g<<14)^g>>>3,g=b[f-2],y=(g>>>17|g<<15)^(g>>>19|g<<13)^g>>>10,b[f]=b[f-16]+T+b[f-7]+y<<0;for(C=a&n,f=0;f<64;f+=4)this.first?(this.is224?(v=300032,g=b[0]-1413257819,l=g-150054599<<0,r=g+24177077<<0):(v=704751109,g=b[0]-210244248,l=g-1521486534<<0,r=g+143694565<<0),this.first=!1):(T=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),y=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),v=e&a,E=v^e&n^C,m=i&c^~i&h,g=l+y+m+se[f]+b[f],d=T+E,l=r+g<<0,r=g+d<<0),T=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),y=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7),w=r&e,E=w^r&a^v,m=h&l^~h&i,g=c+y+m+se[f+1]+b[f+1],d=T+E,h=n+g<<0,n=g+d<<0,T=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),y=(h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7),A=n&r,E=A^n&e^w,m=c&h^~c&l,g=i+y+m+se[f+2]+b[f+2],d=T+E,c=a+g<<0,a=g+d<<0,T=(a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10),y=(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7),C=a&n,E=C^a&r^A,m=c&h^~c&l,g=i+y+m+se[f+3]+b[f+3],d=T+E,i=e+g<<0,e=g+d<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+e<<0,this.h1=this.h1+a<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+i<<0,this.h5=this.h5+c<<0,this.h6=this.h6+h<<0,this.h7=this.h7+l<<0};B.prototype.hex=function(){this.finalize();var e=this.h0,a=this.h1,n=this.h2,r=this.h3,i=this.h4,c=this.h5,h=this.h6,l=this.h7,b=_[e>>>28&15]+_[e>>>24&15]+_[e>>>20&15]+_[e>>>16&15]+_[e>>>12&15]+_[e>>>8&15]+_[e>>>4&15]+_[e&15]+_[a>>>28&15]+_[a>>>24&15]+_[a>>>20&15]+_[a>>>16&15]+_[a>>>12&15]+_[a>>>8&15]+_[a>>>4&15]+_[a&15]+_[n>>>28&15]+_[n>>>24&15]+_[n>>>20&15]+_[n>>>16&15]+_[n>>>12&15]+_[n>>>8&15]+_[n>>>4&15]+_[n&15]+_[r>>>28&15]+_[r>>>24&15]+_[r>>>20&15]+_[r>>>16&15]+_[r>>>12&15]+_[r>>>8&15]+_[r>>>4&15]+_[r&15]+_[i>>>28&15]+_[i>>>24&15]+_[i>>>20&15]+_[i>>>16&15]+_[i>>>12&15]+_[i>>>8&15]+_[i>>>4&15]+_[i&15]+_[c>>>28&15]+_[c>>>24&15]+_[c>>>20&15]+_[c>>>16&15]+_[c>>>12&15]+_[c>>>8&15]+_[c>>>4&15]+_[c&15]+_[h>>>28&15]+_[h>>>24&15]+_[h>>>20&15]+_[h>>>16&15]+_[h>>>12&15]+_[h>>>8&15]+_[h>>>4&15]+_[h&15];return this.is224||(b+=_[l>>>28&15]+_[l>>>24&15]+_[l>>>20&15]+_[l>>>16&15]+_[l>>>12&15]+_[l>>>8&15]+_[l>>>4&15]+_[l&15]),b};B.prototype.toString=B.prototype.hex;B.prototype.digest=function(){this.finalize();var e=this.h0,a=this.h1,n=this.h2,r=this.h3,i=this.h4,c=this.h5,h=this.h6,l=this.h7,b=[e>>>24&255,e>>>16&255,e>>>8&255,e&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,n>>>24&255,n>>>16&255,n>>>8&255,n&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255,i>>>24&255,i>>>16&255,i>>>8&255,i&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255];return this.is224||b.push(l>>>24&255,l>>>16&255,l>>>8&255,l&255),b};B.prototype.array=B.prototype.digest;B.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),a=new DataView(e);return a.setUint32(0,this.h0),a.setUint32(4,this.h1),a.setUint32(8,this.h2),a.setUint32(12,this.h3),a.setUint32(16,this.h4),a.setUint32(20,this.h5),a.setUint32(24,this.h6),this.is224||a.setUint32(28,this.h7),e};const ht=(...e)=>new B(!1,!0).update(e.join("")).hex();var La={};U(La,{sha256:()=>ht});var Da={};U(Da,{BaseCache:()=>gt,InMemoryCache:()=>mt,defaultHashKeyEncoder:()=>pt,deserializeStoredGeneration:()=>Ba,serializeGeneration:()=>Ua});const pt=(...e)=>ht(e.join("_"));function Ba(e){return e.message!==void 0?{text:e.text,message:na(e.message)}:{text:e.text}}function Ua(e){const a={text:e.text};return e.message!==void 0&&(a.message=e.message.toDict()),a}var gt=class{keyEncoder=pt;makeDefaultKeyEncoder(e){this.keyEncoder=e}};const ja=new Map;var mt=class ft extends gt{cache;constructor(a){super(),this.cache=a??new Map}lookup(a,n){return Promise.resolve(this.cache.get(this.keyEncoder(a,n))??null)}async update(a,n,r){this.cache.set(this.keyEncoder(a,n),r)}static global(){return new ft(ja)}},q={},$e;function Va(){if($e)return q;$e=1,q.byteLength=l,q.toByteArray=f,q.fromByteArray=E;for(var e=[],a=[],n=typeof Uint8Array<"u"?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,c=r.length;i<c;++i)e[i]=r[i],a[r.charCodeAt(i)]=i;a[45]=62,a[95]=63;function h(g){var d=g.length;if(d%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var m=g.indexOf("=");m===-1&&(m=d);var v=m===d?0:4-m%4;return[m,v]}function l(g){var d=h(g),m=d[0],v=d[1];return(m+v)*3/4-v}function b(g,d,m){return(d+m)*3/4-m}function f(g){var d,m=h(g),v=m[0],w=m[1],A=new n(b(g,v,w)),C=0,M=w>0?v-4:v,O;for(O=0;O<M;O+=4)d=a[g.charCodeAt(O)]<<18|a[g.charCodeAt(O+1)]<<12|a[g.charCodeAt(O+2)]<<6|a[g.charCodeAt(O+3)],A[C++]=d>>16&255,A[C++]=d>>8&255,A[C++]=d&255;return w===2&&(d=a[g.charCodeAt(O)]<<2|a[g.charCodeAt(O+1)]>>4,A[C++]=d&255),w===1&&(d=a[g.charCodeAt(O)]<<10|a[g.charCodeAt(O+1)]<<4|a[g.charCodeAt(O+2)]>>2,A[C++]=d>>8&255,A[C++]=d&255),A}function T(g){return e[g>>18&63]+e[g>>12&63]+e[g>>6&63]+e[g&63]}function y(g,d,m){for(var v,w=[],A=d;A<m;A+=3)v=(g[A]<<16&16711680)+(g[A+1]<<8&65280)+(g[A+2]&255),w.push(T(v));return w.join("")}function E(g){for(var d,m=g.length,v=m%3,w=[],A=16383,C=0,M=m-v;C<M;C+=A)w.push(y(g,C,C+A>M?M:C+A));return v===1?(d=g[m-1],w.push(e[d>>2]+e[d<<4&63]+"==")):v===2&&(d=(g[m-2]<<8)+g[m-1],w.push(e[d>>10]+e[d>>4&63]+e[d<<2&63]+"=")),w.join("")}return q}var za=Va();const Ga=ra(za);var Za=Object.defineProperty,$a=(e,a,n)=>a in e?Za(e,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[a]=n,Ha=(e,a,n)=>($a(e,a+"",n),n);function Wa(e,a){let n=Array.from({length:e.length},(r,i)=>({start:i,end:i+1}));for(;n.length>1;){let r=null;for(let i=0;i<n.length-1;i++){const c=e.slice(n[i].start,n[i+1].end),h=a.get(c.join(","));h!=null&&(r==null||h<r[0])&&(r=[h,i])}if(r!=null){const i=r[1];n[i]={start:n[i].start,end:n[i+1].end},n.splice(i+1,1)}else break}return n}function Ja(e,a){return e.length===1?[a.get(e.join(","))]:Wa(e,a).map(n=>a.get(e.slice(n.start,n.end).join(","))).filter(n=>n!=null)}function Xa(e){return e.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}var Ee=class{specialTokens;inverseSpecialTokens;patStr;textEncoder=new TextEncoder;textDecoder=new TextDecoder("utf-8");rankMap=new Map;textMap=new Map;constructor(e,a){this.patStr=e.pat_str;const n=e.bpe_ranks.split(`
|
|
2
2
|
`).filter(Boolean).reduce((r,i)=>{const[c,h,...l]=i.split(" "),b=Number.parseInt(h,10);return l.forEach((f,T)=>r[f]=b+T),r},{});for(const[r,i]of Object.entries(n)){const c=Ga.toByteArray(r);this.rankMap.set(c.join(","),i),this.textMap.set(i,c)}this.specialTokens={...e.special_tokens,...a},this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((r,[i,c])=>(r[c]=this.textEncoder.encode(i),r),{})}encode(e,a=[],n="all"){const r=new RegExp(this.patStr,"ug"),i=Ee.specialTokenRegex(Object.keys(this.specialTokens)),c=[],h=new Set(a==="all"?Object.keys(this.specialTokens):a),l=new Set(n==="all"?Object.keys(this.specialTokens).filter(f=>!h.has(f)):n);if(l.size>0){const f=Ee.specialTokenRegex([...l]),T=e.match(f);if(T!=null)throw new Error(`The text contains a special token that is not allowed: ${T[0]}`)}let b=0;for(;;){let f=null,T=b;for(;i.lastIndex=T,f=i.exec(e),!(f==null||h.has(f[0]));)T=f.index+1;const y=f?.index??e.length;for(const g of e.substring(b,y).matchAll(r)){const d=this.textEncoder.encode(g[0]),m=this.rankMap.get(d.join(","));if(m!=null){c.push(m);continue}c.push(...Ja(d,this.rankMap))}if(f==null)break;let E=this.specialTokens[f[0]];c.push(E),b=f.index+f[0].length}return c}decode(e){const a=[];let n=0;for(let c=0;c<e.length;++c){const h=e[c],l=this.textMap.get(h)??this.inverseSpecialTokens[h];l!=null&&(a.push(l),n+=l.length)}const r=new Uint8Array(n);let i=0;for(const c of a)r.set(c,i),i+=c.length;return this.textDecoder.decode(r)}},dt=Ee;Ha(dt,"specialTokenRegex",e=>new RegExp(e.map(a=>Xa(a)).join("|"),"g"));function Ya(e){switch(e){case"gpt2":return"gpt2";case"code-cushman-001":case"code-cushman-002":case"code-davinci-001":case"code-davinci-002":case"cushman-codex":case"davinci-codex":case"davinci-002":case"text-davinci-002":case"text-davinci-003":return"p50k_base";case"code-davinci-edit-001":case"text-davinci-edit-001":return"p50k_edit";case"ada":case"babbage":case"babbage-002":case"code-search-ada-code-001":case"code-search-babbage-code-001":case"curie":case"davinci":case"text-ada-001":case"text-babbage-001":case"text-curie-001":case"text-davinci-001":case"text-search-ada-doc-001":case"text-search-babbage-doc-001":case"text-search-curie-doc-001":case"text-search-davinci-doc-001":case"text-similarity-ada-001":case"text-similarity-babbage-001":case"text-similarity-curie-001":case"text-similarity-davinci-001":return"r50k_base";case"gpt-3.5-turbo-instruct-0914":case"gpt-3.5-turbo-instruct":case"gpt-3.5-turbo-16k-0613":case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo":case"gpt-4-32k-0613":case"gpt-4-32k-0314":case"gpt-4-32k":case"gpt-4-0613":case"gpt-4-0314":case"gpt-4":case"gpt-3.5-turbo-1106":case"gpt-35-turbo":case"gpt-4-1106-preview":case"gpt-4-vision-preview":case"gpt-3.5-turbo-0125":case"gpt-4-turbo":case"gpt-4-turbo-2024-04-09":case"gpt-4-turbo-preview":case"gpt-4-0125-preview":case"text-embedding-ada-002":case"text-embedding-3-small":case"text-embedding-3-large":return"cl100k_base";case"gpt-4o":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":case"gpt-4o-2024-11-20":case"gpt-4o-mini-2024-07-18":case"gpt-4o-mini":case"gpt-4o-search-preview":case"gpt-4o-search-preview-2025-03-11":case"gpt-4o-mini-search-preview":case"gpt-4o-mini-search-preview-2025-03-11":case"gpt-4o-audio-preview":case"gpt-4o-audio-preview-2024-12-17":case"gpt-4o-audio-preview-2024-10-01":case"gpt-4o-mini-audio-preview":case"gpt-4o-mini-audio-preview-2024-12-17":case"o1":case"o1-2024-12-17":case"o1-mini":case"o1-mini-2024-09-12":case"o1-preview":case"o1-preview-2024-09-12":case"o1-pro":case"o1-pro-2025-03-19":case"o3":case"o3-2025-04-16":case"o3-mini":case"o3-mini-2025-01-31":case"o4-mini":case"o4-mini-2025-04-16":case"chatgpt-4o-latest":case"gpt-4o-realtime":case"gpt-4o-realtime-preview-2024-10-01":case"gpt-4o-realtime-preview-2024-12-17":case"gpt-4o-mini-realtime-preview":case"gpt-4o-mini-realtime-preview-2024-12-17":case"gpt-4.1":case"gpt-4.1-2025-04-14":case"gpt-4.1-mini":case"gpt-4.1-mini-2025-04-14":case"gpt-4.1-nano":case"gpt-4.1-nano-2025-04-14":case"gpt-4.5-preview":case"gpt-4.5-preview-2025-02-27":case"gpt-5":case"gpt-5-2025-08-07":case"gpt-5-nano":case"gpt-5-nano-2025-08-07":case"gpt-5-mini":case"gpt-5-mini-2025-08-07":case"gpt-5-chat-latest":return"o200k_base";default:throw new Error("Unknown model")}}var Ka={};U(Ka,{encodingForModel:()=>Ne,getEncoding:()=>bt});const ne={},qa=new Je({});async function bt(e){return e in ne||(ne[e]=qa.fetch(`https://tiktoken.pages.dev/js/${e}.json`).then(a=>a.json()).then(a=>new dt(a)).catch(a=>{throw delete ne[e],a})),await ne[e]}async function Ne(e){return bt(Ya(e))}var Qa={};U(Qa,{BaseLangChain:()=>yt,BaseLanguageModel:()=>Tt,calculateMaxTokens:()=>as,getEmbeddingContextSize:()=>es,getModelContextSize:()=>_t,getModelNameForTiktoken:()=>pe,isOpenAITool:()=>ts});const pe=e=>e.startsWith("gpt-5")?"gpt-5":e.startsWith("gpt-3.5-turbo-16k")?"gpt-3.5-turbo-16k":e.startsWith("gpt-3.5-turbo-")?"gpt-3.5-turbo":e.startsWith("gpt-4-32k")?"gpt-4-32k":e.startsWith("gpt-4-")?"gpt-4":e.startsWith("gpt-4o")?"gpt-4o":e,es=e=>{switch(e){case"text-embedding-ada-002":return 8191;default:return 2046}},_t=e=>{switch(pe(e)){case"gpt-5":case"gpt-5-turbo":case"gpt-5-turbo-preview":return 4e5;case"gpt-4o":case"gpt-4o-mini":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":return 128e3;case"gpt-4-turbo":case"gpt-4-turbo-preview":case"gpt-4-turbo-2024-04-09":case"gpt-4-0125-preview":case"gpt-4-1106-preview":return 128e3;case"gpt-4-32k":case"gpt-4-32k-0314":case"gpt-4-32k-0613":return 32768;case"gpt-4":case"gpt-4-0314":case"gpt-4-0613":return 8192;case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-16k-0613":return 16384;case"gpt-3.5-turbo":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-1106":case"gpt-3.5-turbo-0125":return 4096;case"text-davinci-003":case"text-davinci-002":return 4097;case"text-davinci-001":return 2049;case"text-curie-001":case"text-babbage-001":case"text-ada-001":return 2048;case"code-davinci-002":case"code-davinci-001":return 8e3;case"code-cushman-001":return 2048;case"claude-3-5-sonnet-20241022":case"claude-3-5-sonnet-20240620":case"claude-3-opus-20240229":case"claude-3-sonnet-20240229":case"claude-3-haiku-20240307":case"claude-2.1":return 2e5;case"claude-2.0":case"claude-instant-1.2":return 1e5;case"gemini-1.5-pro":case"gemini-1.5-pro-latest":case"gemini-1.5-flash":case"gemini-1.5-flash-latest":return 1e6;case"gemini-pro":case"gemini-pro-vision":return 32768;default:return 4097}};function ts(e){return typeof e!="object"||!e?!1:!!("type"in e&&e.type==="function"&&"function"in e&&typeof e.function=="object"&&e.function&&"name"in e.function&&"parameters"in e.function)}const as=async({prompt:e,modelName:a})=>{let n;try{n=(await Ne(pe(a))).encode(e).length}catch{console.warn("Failed to calculate number of tokens, falling back to approximate count"),n=Math.ceil(e.length/4)}return _t(a)-n},ss=()=>!1;var yt=class extends H{verbose;callbacks;tags;metadata;get lc_attributes(){return{callbacks:void 0,verbose:void 0}}constructor(e){super(e),this.verbose=e.verbose??ss(),this.callbacks=e.callbacks,this.tags=e.tags??[],this.metadata=e.metadata??{}}},Tt=class extends yt{get callKeys(){return["stop","timeout","signal","tags","metadata","callbacks"]}caller;cache;constructor({callbacks:e,callbackManager:a,...n}){const{cache:r,...i}=n;super({callbacks:e??a,...i}),typeof r=="object"?this.cache=r:r?this.cache=mt.global():this.cache=void 0,this.caller=new Je(n??{})}_encoding;async getNumTokens(e){let a;typeof e=="string"?a=e:a=e.map(r=>typeof r=="string"?r:r.type==="text"&&"text"in r?r.text:"").join("");let n=Math.ceil(a.length/4);if(!this._encoding)try{this._encoding=await Ne("modelName"in this?pe(this.modelName):"gpt2")}catch(r){console.warn("Failed to calculate number of tokens, falling back to approximate count",r)}if(this._encoding)try{n=this._encoding.encode(a).length}catch(r){console.warn("Failed to calculate number of tokens, falling back to approximate count",r)}return n}static _convertInputToPromptValue(e){return typeof e=="string"?new ut(e):Array.isArray(e)?new lt(e.map(re)):e}_identifyingParams(){return{}}_getSerializedCacheKeyParametersForCall({config:e,...a}){const n={...this._identifyingParams(),...a,_type:this._llmType(),_model:this._modelType()};return Object.entries(n).filter(([c,h])=>h!==void 0).map(([c,h])=>`${c}:${JSON.stringify(h)}`).sort().join(",")}serialize(){return{...this._identifyingParams(),_type:this._llmType(),_model:this._modelType()}}static async deserialize(e){throw new Error("Use .toJSON() instead")}get profile(){return{}}},ue=class extends H{static lc_name(){return"RunnablePassthrough"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;func;constructor(e){super(e),e&&(this.func=e.func)}async invoke(e,a){const n=oe(a);return this.func&&await this.func(e,n),this._callWithConfig(r=>Promise.resolve(r),e,n)}async*transform(e,a){const n=oe(a);let r,i=!0;for await(const c of this._transformStreamWithConfig(e,h=>h,n))if(yield c,i)if(r===void 0)r=c;else try{r=ce(r,c)}catch{r=void 0,i=!1}this.func&&r!==void 0&&await this.func(r,n)}static assign(e){return new Xe(new Ye({steps:e}))}};const ns=e=>e();function ye(e){const a=e.constructor;return new a({...e,content:e.contentBlocks,response_metadata:{...e.response_metadata,output_version:"v1"}})}var rs={};U(rs,{BaseChatModel:()=>vt,SimpleChatModel:()=>is});function Te(e){const a=[];for(const n of e){let r=n;if(Array.isArray(n.content))for(let i=0;i<n.content.length;i++){const c=n.content[i];(ua(c)||la(c))&&r===n&&(r=new n.constructor({...r,content:[...n.content.slice(0,i),ha(c),...n.content.slice(i+1)]}))}a.push(r)}return a}var vt=class Z extends Tt{lc_namespace=["langchain","chat_models",this._llmType()];disableStreaming=!1;outputVersion;get callKeys(){return[...super.callKeys,"outputVersion"]}constructor(a){super(a),this.outputVersion=ns(()=>{const n=a.outputVersion??pa("LC_OUTPUT_VERSION");return n&&["v0","v1"].includes(n)?n:"v0"})}_separateRunnableConfigFromCallOptionsCompat(a){const[n,r]=super._separateRunnableConfigFromCallOptions(a);return r.signal=n.signal,[n,r]}async invoke(a,n){const r=Z._convertInputToPromptValue(a);return(await this.generatePrompt([r],n,n?.callbacks)).generations[0][0].message}async*_streamResponseChunks(a,n,r){throw new Error("Not implemented.")}async*_streamIterator(a,n){if(this._streamResponseChunks===Z.prototype._streamResponseChunks||this.disableStreaming)yield this.invoke(a,n);else{const i=Z._convertInputToPromptValue(a).toChatMessages(),[c,h]=this._separateRunnableConfigFromCallOptionsCompat(n),l={...c.metadata,...this.getLsParams(h)},b=await _e.configure(c.callbacks,this.callbacks,c.tags,this.tags,l,this.metadata,{verbose:this.verbose}),f={options:h,invocation_params:this?.invocationParams(h),batch_size:1},T=h.outputVersion??this.outputVersion,y=await b?.handleChatModelStart(this.toJSON(),[Te(i)],c.runId,void 0,f,void 0,void 0,c.runName);let E,g;try{for await(const d of this._streamResponseChunks(i,h,y?.[0])){if(h.signal?.throwIfAborted(),d.message.id==null){const m=y?.at(0)?.runId;m!=null&&d.message._updateId(`run-${m}`)}d.message.response_metadata={...d.generationInfo,...d.message.response_metadata},T==="v1"?yield ye(d.message):yield d.message,E?E=E.concat(d):E=d,Ve(d.message)&&d.message.usage_metadata!==void 0&&(g={tokenUsage:{promptTokens:d.message.usage_metadata.input_tokens,completionTokens:d.message.usage_metadata.output_tokens,totalTokens:d.message.usage_metadata.total_tokens}})}h.signal?.throwIfAborted()}catch(d){throw await Promise.all((y??[]).map(m=>m?.handleLLMError(d))),d}await Promise.all((y??[]).map(d=>d?.handleLLMEnd({generations:[[E]],llmOutput:g})))}}getLsParams(a){const n=this.getName().startsWith("Chat")?this.getName().replace("Chat",""):this.getName();return{ls_model_type:"chat",ls_stop:a.stop,ls_provider:n}}async _generateUncached(a,n,r,i){const c=a.map(E=>E.map(re));let h;if(i!==void 0&&i.length===c.length)h=i;else{const E={...r.metadata,...this.getLsParams(n)},g=await _e.configure(r.callbacks,this.callbacks,r.tags,this.tags,E,this.metadata,{verbose:this.verbose}),d={options:n,invocation_params:this?.invocationParams(n),batch_size:1};h=await g?.handleChatModelStart(this.toJSON(),c.map(Te),r.runId,void 0,d,void 0,void 0,r.runName)}const l=n.outputVersion??this.outputVersion,b=[],f=[];if(!!h?.[0].handlers.find(ia)&&!this.disableStreaming&&c.length===1&&this._streamResponseChunks!==Z.prototype._streamResponseChunks)try{const E=await this._streamResponseChunks(c[0],n,h?.[0]);let g,d;for await(const m of E){if(n.signal?.aborted){const v=g?.message;throw new ze("Model invocation was aborted.",v)}if(m.message.id==null){const v=h?.at(0)?.runId;v!=null&&m.message._updateId(`run-${v}`)}g===void 0?g=m:g=ce(g,m),Ve(m.message)&&m.message.usage_metadata!==void 0&&(d={tokenUsage:{promptTokens:m.message.usage_metadata.input_tokens,completionTokens:m.message.usage_metadata.output_tokens,totalTokens:m.message.usage_metadata.total_tokens}})}if(n.signal?.aborted){const m=g?.message;throw new ze("Model invocation was aborted.",m)}if(g===void 0)throw new Error("Received empty response from chat model call.");b.push([g]),await h?.[0].handleLLMEnd({generations:b,llmOutput:d})}catch(E){throw await h?.[0].handleLLMError(E),E}else{const E=await Promise.allSettled(c.map(async(g,d)=>{const m=await this._generate(g,{...n,promptIndex:d},h?.[d]);if(l==="v1")for(const v of m.generations)v.message=ye(v.message);return m}));await Promise.all(E.map(async(g,d)=>{if(g.status==="fulfilled"){const m=g.value;for(const v of m.generations){if(v.message.id==null){const w=h?.at(0)?.runId;w!=null&&v.message._updateId(`run-${w}`)}v.message.response_metadata={...v.generationInfo,...v.message.response_metadata}}return m.generations.length===1&&(m.generations[0].message.response_metadata={...m.llmOutput,...m.generations[0].message.response_metadata}),b[d]=m.generations,f[d]=m.llmOutput,h?.[d]?.handleLLMEnd({generations:[m.generations],llmOutput:m.llmOutput})}else return await h?.[d]?.handleLLMError(g.reason),Promise.reject(g.reason)}))}const y={generations:b,llmOutput:f.length?this._combineLLMOutput?.(...f):void 0};return Object.defineProperty(y,Ge,{value:h?{runIds:h?.map(E=>E.runId)}:void 0,configurable:!0}),y}async _generateCached({messages:a,cache:n,llmStringKey:r,parsedOptions:i,handledOptions:c}){const h=a.map(w=>w.map(re)),l={...c.metadata,...this.getLsParams(i)},b=await _e.configure(c.callbacks,this.callbacks,c.tags,this.tags,l,this.metadata,{verbose:this.verbose}),f={options:i,invocation_params:this?.invocationParams(i),batch_size:1},T=await b?.handleChatModelStart(this.toJSON(),h.map(Te),c.runId,void 0,f,void 0,void 0,c.runName),y=[],g=(await Promise.allSettled(h.map(async(w,A)=>{const C=Z._convertInputToPromptValue(w).toString(),M=await n.lookup(C,r);return M==null&&y.push(A),M}))).map((w,A)=>({result:w,runManager:T?.[A]})).filter(({result:w})=>w.status==="fulfilled"&&w.value!=null||w.status==="rejected"),d=i.outputVersion??this.outputVersion,m=[];await Promise.all(g.map(async({result:w,runManager:A},C)=>{if(w.status==="fulfilled"){const M=w.value;return m[C]=M.map(O=>("message"in O&&X(O.message)&&oa(O.message)&&(O.message.usage_metadata={input_tokens:0,output_tokens:0,total_tokens:0},d==="v1"&&(O.message=ye(O.message))),O.generationInfo={...O.generationInfo,tokenUsage:{}},O)),M.length&&await A?.handleLLMNewToken(M[0].text),A?.handleLLMEnd({generations:[M]},void 0,void 0,void 0,{cached:!0})}else return await A?.handleLLMError(w.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(w.reason)}));const v={generations:m,missingPromptIndices:y,startedRunManagers:T};return Object.defineProperty(v,Ge,{value:T?{runIds:T?.map(w=>w.runId)}:void 0,configurable:!0}),v}async generate(a,n,r){let i;Array.isArray(n)?i={stop:n}:i=n;const c=a.map(d=>d.map(re)),[h,l]=this._separateRunnableConfigFromCallOptionsCompat(i);if(h.callbacks=h.callbacks??r,!this.cache)return this._generateUncached(c,l,h);const{cache:b}=this,f=this._getSerializedCacheKeyParametersForCall(l),{generations:T,missingPromptIndices:y,startedRunManagers:E}=await this._generateCached({messages:c,cache:b,llmStringKey:f,parsedOptions:l,handledOptions:h});let g={};if(y.length>0){const d=await this._generateUncached(y.map(m=>c[m]),l,h,E!==void 0?y.map(m=>E?.[m]):void 0);await Promise.all(d.generations.map(async(m,v)=>{const w=y[v];T[w]=m;const A=Z._convertInputToPromptValue(c[w]).toString();return b.update(A,f,m)})),g=d.llmOutput??{}}return{generations:T,llmOutput:g}}invocationParams(a){return{}}_modelType(){return"base_chat_model"}async generatePrompt(a,n,r){const i=a.map(c=>c.toChatMessages());return this.generate(i,n,r)}withStructuredOutput(a,n){if(typeof this.bindTools!="function")throw new Error('Chat model must implement ".bindTools()" to use withStructuredOutput.');if(n?.strict)throw new Error('"strict" mode is not supported for this model by default.');const r=a,i=n?.name,c=We(r)??"A function available to call.",h=n?.method,l=n?.includeRaw;if(h==="jsonMode")throw new Error('Base withStructuredOutput implementation only supports "functionCalling" as a method.');let b=i??"extract",f;Ae(r)?f=[{type:"function",function:{name:b,description:c,parameters:le(r)}}]:("name"in r&&(b=r.name),f=[{type:"function",function:{name:b,description:c,parameters:r}}]);const T=this.bindTools(f),y=Ie.from(m=>{if(!ca.isInstance(m))throw new Error("Input is not an AIMessageChunk.");if(!m.tool_calls||m.tool_calls.length===0)throw new Error("No tool calls found in the response.");const v=m.tool_calls.find(w=>w.name===b);if(!v)throw new Error(`No tool call found with name ${b}.`);return v.args});if(!l)return T.pipe(y).withConfig({runName:"StructuredOutput"});const E=ue.assign({parsed:(m,v)=>y.invoke(m.raw,v)}),g=ue.assign({parsed:()=>null}),d=E.withFallbacks({fallbacks:[g]});return Ke.from([{raw:T},d]).withConfig({runName:"StructuredOutputRunnable"})}},is=class extends vt{async _generate(e,a,n){const r=await this._call(e,a,n),i=new qe(r);if(typeof i.content!="string")throw new Error("Cannot generate with a simple chat model when output is not a string.");return{generations:[{text:i.content,message:i}]}}},os=class extends H{static lc_name(){return"RouterRunnable"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;runnables;constructor(e){super(e),this.runnables=e.runnables}async invoke(e,a){const{key:n,input:r}=e,i=this.runnables[n];if(i===void 0)throw new Error(`No runnable associated with key "${n}".`);return i.invoke(r,oe(a))}async batch(e,a,n){const r=e.map(y=>y.key),i=e.map(y=>y.input);if(r.find(y=>this.runnables[y]===void 0)!==void 0)throw new Error("One or more keys do not have a corresponding runnable.");const h=r.map(y=>this.runnables[y]),l=this._getOptionsList(a??{},e.length),b=l[0]?.maxConcurrency??n?.maxConcurrency,f=b&&b>0?b:e.length,T=[];for(let y=0;y<i.length;y+=f){const E=i.slice(y,y+f).map((d,m)=>h[m].invoke(d,l[m])),g=await Promise.all(E);T.push(g)}return T.flat()}async stream(e,a){const{key:n,input:r}=e,i=this.runnables[n];if(i===void 0)throw new Error(`No runnable associated with key "${n}".`);return i.stream(r,a)}},cs=class extends H{static lc_name(){return"RunnableBranch"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;default;branches;constructor(e){super(e),this.branches=e.branches,this.default=e.default}static from(e){if(e.length<1)throw new Error("RunnableBranch requires at least one branch");const n=e.slice(0,-1).map(([i,c])=>[ie(i),ie(c)]),r=ie(e[e.length-1]);return new this({branches:n,default:r})}async _invoke(e,a,n){let r;for(let i=0;i<this.branches.length;i+=1){const[c,h]=this.branches[i];if(await c.invoke(e,G(a,{callbacks:n?.getChild(`condition:${i+1}`)}))){r=await h.invoke(e,G(a,{callbacks:n?.getChild(`branch:${i+1}`)}));break}}return r||(r=await this.default.invoke(e,G(a,{callbacks:n?.getChild("branch:default")}))),r}async invoke(e,a={}){return this._callWithConfig(this._invoke,e,a)}async*_streamIterator(e,a){const r=await(await Qe(a))?.handleChainStart(this.toJSON(),ga(e,"input"),a?.runId,void 0,void 0,void 0,a?.runName);let i,c=!0,h;try{for(let l=0;l<this.branches.length;l+=1){const[b,f]=this.branches[l];if(await b.invoke(e,G(a,{callbacks:r?.getChild(`condition:${l+1}`)}))){h=await f.stream(e,G(a,{callbacks:r?.getChild(`branch:${l+1}`)}));for await(const y of h)if(yield y,c)if(i===void 0)i=y;else try{i=ce(i,y)}catch{i=void 0,c=!1}break}}if(h===void 0){h=await this.default.stream(e,G(a,{callbacks:r?.getChild("branch:default")}));for await(const l of h)if(yield l,c)if(i===void 0)i=l;else try{i=ce(i,l)}catch{i=void 0,c=!1}}}catch(l){throw await r?.handleChainError(l),l}await r?.handleChainEnd(i??{})}},us=class extends et{runnable;inputMessagesKey;outputMessagesKey;historyMessagesKey;getMessageHistory;constructor(e){let a=Ie.from((c,h)=>this._enterHistory(c,h??{})).withConfig({runName:"loadHistory"});const n=e.historyMessagesKey??e.inputMessagesKey;n&&(a=ue.assign({[n]:a}).withConfig({runName:"insertHistory"}));const r=a.pipe(e.runnable.withListeners({onEnd:(c,h)=>this._exitHistory(c,h??{})})).withConfig({runName:"RunnableWithMessageHistory"}),i=e.config??{};super({...e,config:i,bound:r}),this.runnable=e.runnable,this.getMessageHistory=e.getMessageHistory,this.inputMessagesKey=e.inputMessagesKey,this.outputMessagesKey=e.outputMessagesKey,this.historyMessagesKey=e.historyMessagesKey}_getInputMessages(e){let a;if(typeof e=="object"&&!Array.isArray(e)&&!X(e)){let n;this.inputMessagesKey?n=this.inputMessagesKey:Object.keys(e).length===1?n=Object.keys(e)[0]:n="input",Array.isArray(e[n])&&Array.isArray(e[n][0])?a=e[n][0]:a=e[n]}else a=e;if(typeof a=="string")return[new Se(a)];if(Array.isArray(a))return a;if(X(a))return[a];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages.
|
|
3
3
|
Got ${JSON.stringify(a,null,2)}`)}_getOutputMessages(e){let a;if(!Array.isArray(e)&&!X(e)&&typeof e!="string"){let n;this.outputMessagesKey!==void 0?n=this.outputMessagesKey:Object.keys(e).length===1?n=Object.keys(e)[0]:n="output",e.generations!==void 0?a=e.generations[0][0].message:a=e[n]}else a=e;if(typeof a=="string")return[new qe(a)];if(Array.isArray(a))return a;if(X(a))return[a];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages. Received: ${JSON.stringify(a,null,2)}`)}async _enterHistory(e,a){const r=await(a?.configurable?.messageHistory).getMessages();return this.historyMessagesKey===void 0?r.concat(this._getInputMessages(e)):r}async _exitHistory(e,a){const n=a.configurable?.messageHistory;let r;Array.isArray(e.inputs)&&Array.isArray(e.inputs[0])?r=e.inputs[0]:r=e.inputs;let i=this._getInputMessages(r);if(this.historyMessagesKey===void 0){const l=await n.getMessages();i=i.slice(l.length)}const c=e.outputs;if(!c)throw new Error(`Output values from 'Run' undefined. Run: ${JSON.stringify(e,null,2)}`);const h=this._getOutputMessages(c);await n.addMessages([...i,...h])}async _mergeConfig(...e){const a=await super._mergeConfig(...e);if(!a.configurable||!a.configurable.sessionId){const r={[this.inputMessagesKey??"input"]:"foo"},i={configurable:{sessionId:"123"}};throw new Error(`sessionId is required. Pass it in as part of the config argument to .invoke() or .stream()
|
|
4
4
|
eg. chain.invoke(${JSON.stringify(r)}, ${JSON.stringify(i)})`)}const{sessionId:n}=a.configurable;return a.configurable.messageHistory=await this.getMessageHistory(n),a}},ls={};U(ls,{RouterRunnable:()=>os,Runnable:()=>H,RunnableAssign:()=>Xe,RunnableBinding:()=>et,RunnableBranch:()=>cs,RunnableEach:()=>Ea,RunnableLambda:()=>Ie,RunnableMap:()=>Ye,RunnableParallel:()=>va,RunnablePassthrough:()=>ue,RunnablePick:()=>Ta,RunnableRetry:()=>ya,RunnableSequence:()=>Ke,RunnableToolLike:()=>_a,RunnableWithFallbacks:()=>ba,RunnableWithMessageHistory:()=>us,_coerceToRunnable:()=>ie,ensureConfig:()=>oe,getCallbackManagerForConfig:()=>Qe,mergeConfigs:()=>da,patchConfig:()=>G,pickRunnableConfigKeys:()=>fa,raceWithSignal:()=>ma});var Et=class extends H{parseResultWithPrompt(e,a,n){return this.parseResult(e,n)}_baseMessageToString(e){return typeof e.content=="string"?e.content:this._baseMessageContentToString(e.content)}_baseMessageContentToString(e){return JSON.stringify(e)}async invoke(e,a){return typeof e=="string"?this._callWithConfig(async(n,r)=>this.parseResult([{text:n}],r?.callbacks),e,{...a,runType:"parser"}):this._callWithConfig(async(n,r)=>this.parseResult([{message:n,text:this._baseMessageToString(n)}],r?.callbacks),e,{...a,runType:"parser"})}},ge=class extends Et{parseResult(e,a){return this.parse(e[0].text,a)}async parseWithPrompt(e,a,n){return this.parse(e,n)}_type(){throw new Error("_type not implemented")}},$=class extends Error{llmOutput;observation;sendToLLM;constructor(e,a,n,r=!1){if(super(e),this.llmOutput=a,this.observation=n,this.sendToLLM=r,r&&(n===void 0||a===void 0))throw new Error("Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true");wa(this,"OUTPUT_PARSING_FAILURE")}},Q=class extends ge{async*_transform(e){for await(const a of e)typeof a=="string"?yield this.parseResult([{text:a}]):yield this.parseResult([{message:a,text:this._baseMessageToString(a)}])}async*transform(e,a){yield*this._transformStreamWithConfig(e,this._transform.bind(this),{...a,runType:"parser"})}},ke=class extends Q{diff=!1;constructor(e){super(e),this.diff=e?.diff??this.diff}async*_transform(e){let a,n;for await(const r of e){if(typeof r!="string"&&typeof r.content!="string")throw new Error("Cannot handle non-string output.");let i;if(Ca(r)){if(typeof r.content!="string")throw new Error("Cannot handle non-string message output.");i=new Ze({message:r,text:r.content})}else if(X(r)){if(typeof r.content!="string")throw new Error("Cannot handle non-string message output.");i=new Ze({message:Aa(r),text:r.content})}else i=new Sa({text:r});n===void 0?n=i:n=n.concat(i);const c=await this.parsePartialResult([n]);c!=null&&!Ia(c,a)&&(this.diff?yield this._diff(a,c):yield c,a=c)}}getFormatInstructions(){return""}},hs=class extends Q{static lc_name(){return"BytesOutputParser"}lc_namespace=["langchain_core","output_parsers","bytes"];lc_serializable=!0;textEncoder=new TextEncoder;parse(e){return Promise.resolve(this.textEncoder.encode(e))}getFormatInstructions(){return""}},ee=class extends Q{re;async*_transform(e){let a="";for await(const n of e)if(typeof n=="string"?a+=n:a+=n.content,this.re){const r=[...a.matchAll(this.re)];if(r.length>1){let i=0;for(const c of r.slice(0,-1))yield[c[1]],i+=(c.index??0)+c[0].length;a=a.slice(i)}}else{const r=await this.parse(a);if(r.length>1){for(const i of r.slice(0,-1))yield[i];a=r[r.length-1]}}for(const n of await this.parse(a))yield[n]}},ps=class extends ee{static lc_name(){return"CommaSeparatedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;async parse(e){try{return e.trim().split(",").map(a=>a.trim())}catch{throw new $(`Could not parse output: ${e}`,e)}}getFormatInstructions(){return"Your response should be a list of comma separated values, eg: `foo, bar, baz`"}},gs=class extends ee{lc_namespace=["langchain_core","output_parsers","list"];length;separator;constructor({length:e,separator:a}){super(...arguments),this.length=e,this.separator=a||","}async parse(e){try{const a=e.trim().split(this.separator).map(n=>n.trim());if(this.length!==void 0&&a.length!==this.length)throw new $(`Incorrect number of items. Expected ${this.length}, got ${a.length}.`);return a}catch(a){throw Object.getPrototypeOf(a)===$.prototype?a:new $(`Could not parse output: ${e}`)}}getFormatInstructions(){return`Your response should be a list of ${this.length===void 0?"":`${this.length} `}items separated by "${this.separator}" (eg: \`foo${this.separator} bar${this.separator} baz\`)`}},ms=class extends ee{static lc_name(){return"NumberedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;getFormatInstructions(){return`Your response should be a numbered list with each item on a new line. For example:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as at,f as rt,g as Ct,O as Ot,h as yt,J as It,R as U}from"./index-DMftCgN8.js";import{b as ut,Q as vt,S as _t,U as Et,V as Tt,W as wt,X as St,Y as At,y as lt,Z as Rt,$ as xt,a0 as k,x as kt,a1 as ct,a2 as bt}from"./index-CWVLvgjZ.js";import{E as Nt,c as Mt}from"./embeddings-BjbiOR07.js";function I(t){if(typeof t=="object"&&t!==null){const e={...t};"additionalProperties"in e&&delete e.additionalProperties,"$schema"in e&&delete e.$schema,"strict"in e&&delete e.strict;for(const n in e)n in e&&(Array.isArray(e[n])?e[n]=e[n].map(I):typeof e[n]=="object"&&e[n]!==null&&(e[n]=I(e[n])));return e}return t}function N(t){const{$schema:e,...n}=I(ut(t)?vt(t):t);return n}function Dt(t){const{$schema:e,...n}=I(t);return n}function E(t,e,n=[]){if(t==null||typeof t!="object")return;const s=t;if(Array.isArray(s.enum)&&s.enum.some(i=>i==="")){const i=n.length?` at path "${n.join(".")}"`:"",o=e?` in tool "${e}"`:"";throw new Error(`Invalid enum: empty string not allowed${o}${i}. Gemini API rejects empty strings in enums.`)}if(s.type==="object"&&s.properties&&typeof s.properties=="object")for(const[i,o]of Object.entries(s.properties))E(o,e,[...n,i]);s.items&&E(s.items,e,[...n,"[]"]);for(const i of["anyOf","oneOf","allOf"]){const o=s[i];Array.isArray(o)&&o.forEach((a,u)=>E(a,e,[...n,`${i}[${u}]`]))}s.additionalProperties&&typeof s.additionalProperties=="object"&&E(s.additionalProperties,e,[...n,"additionalProperties"])}const h=[];for(let t=0;t<256;++t)h.push((t+256).toString(16).slice(1));function Gt(t,e=0){return(h[t[e+0]]+h[t[e+1]]+h[t[e+2]]+h[t[e+3]]+"-"+h[t[e+4]]+h[t[e+5]]+"-"+h[t[e+6]]+h[t[e+7]]+"-"+h[t[e+8]]+h[t[e+9]]+"-"+h[t[e+10]]+h[t[e+11]]+h[t[e+12]]+h[t[e+13]]+h[t[e+14]]+h[t[e+15]]).toLowerCase()}let b;const Ut=new Uint8Array(16);function Lt(){if(!b){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");b=crypto.getRandomValues.bind(crypto)}return b(Ut)}const Pt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),L={randomUUID:Pt};function dt(t,e,n){if(L.randomUUID&&!t)return L.randomUUID();t=t||{};const s=t.random??t.rng?.()??Lt();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Gt(s)}const D="__gemini_function_call_thought_signatures__",jt="ErYCCrMCAdHtim9kOoOkrPiCNVsmlpMIKd7ZMxgiFbVQOkgp7nlLcDMzVsZwIzvuT7nQROivoXA72ccC2lSDvR0Gh7dkWaGuj7ctv6t7ZceHnecx0QYa+ix8tYpRfjhyWozQ49lWiws6+YGjCt10KRTyWsZ2h6O7iHTYJwKIRwGUHRKy/qK/6kFxJm5ML00gLq4D8s5Z6DBpp2ZlR+uF4G8jJgeWQgyHWVdx2wGYElaceVAc66tZdPQRdOHpWtgYSI1YdaXgVI8KHY3/EfNc2YqqMIulvkDBAnuMhkAjV9xmBa54Tq+ih3Im4+r3DzqhGqYdsSkhS0kZMwte4Hjs65dZzCw9lANxIqYi1DJ639WNPYihp/DCJCos7o+/EeSPJaio5sgWDyUnMGkY1atsJZ+m7pj7DD5tvQ==",Kt=t=>t();function Ft(t){return St.isInstance(t)?t.role:t.type}function Ht(t){switch(t){case"supervisor":case"ai":case"model":return"model";case"system":return"system";case"human":return"user";case"tool":case"function":return"function";default:throw new Error(`Unknown / unsupported author: ${t}`)}}function $t(t){if("mimeType"in t&&"data"in t)return{inlineData:{mimeType:t.mimeType,data:t.data}};if("mimeType"in t&&"fileUri"in t)return{fileData:{mimeType:t.mimeType,fileUri:t.fileUri}};throw new Error("Invalid media content")}function Yt(t,e){return e.map(n=>lt(n)?n.tool_calls??[]:[]).flat().find(n=>n.id===t.tool_call_id)?.name}function Bt(t){return{providerName:"Google Gemini",fromStandardTextBlock(e){return{text:e.text}},fromStandardImageBlock(e){if(!t)throw new Error("This model does not support images");if(e.source_type==="url"){const n=k({dataUrl:e.url});return n?{inlineData:{mimeType:n.mime_type,data:n.data}}:{fileData:{mimeType:e.mime_type??"",fileUri:e.url}}}if(e.source_type==="base64")return{inlineData:{mimeType:e.mime_type??"",data:e.data}};throw new Error(`Unsupported source type: ${e.source_type}`)},fromStandardAudioBlock(e){if(!t)throw new Error("This model does not support audio");if(e.source_type==="url"){const n=k({dataUrl:e.url});return n?{inlineData:{mimeType:n.mime_type,data:n.data}}:{fileData:{mimeType:e.mime_type??"",fileUri:e.url}}}if(e.source_type==="base64")return{inlineData:{mimeType:e.mime_type??"",data:e.data}};throw new Error(`Unsupported source type: ${e.source_type}`)},fromStandardFileBlock(e){if(!t)throw new Error("This model does not support files");if(e.source_type==="text")return{text:e.text};if(e.source_type==="url"){const n=k({dataUrl:e.url});return n?{inlineData:{mimeType:n.mime_type,data:n.data}}:{fileData:{mimeType:e.mime_type??"",fileUri:e.url}}}if(e.source_type==="base64")return{inlineData:{mimeType:e.mime_type??"",data:e.data}};throw new Error(`Unsupported source type: ${e.source_type}`)}}}function P(t,e){if(Rt(t))return xt(t,Bt(e));if(t.type==="text")return{text:t.text};if(t.type==="executableCode")return{executableCode:t.executableCode};if(t.type==="codeExecutionResult")return{codeExecutionResult:t.codeExecutionResult};if(t.type==="image_url"){if(!e)throw new Error("This model does not support images");let n;if(typeof t.image_url=="string")n=t.image_url;else if(typeof t.image_url=="object"&&"url"in t.image_url)n=t.image_url.url;else throw new Error("Please provide image as base64 encoded data URL");const[s,i]=n.split(",");if(!s.startsWith("data:"))throw new Error("Please provide image as base64 encoded data URL");const[o,a]=s.replace(/^data:/,"").split(";");if(a!=="base64")throw new Error("Please provide image as base64 encoded data URL");return{inlineData:{data:i,mimeType:o}}}else{if(t.type==="media")return $t(t);if(t.type==="tool_use")return{functionCall:{name:t.name,args:t.input}};if(t.type==="tool_call")return{functionCall:{name:t.name,args:t.args}};if(t.type?.includes("/")&&t.type.split("/").length===2&&"data"in t&&typeof t.data=="string")return{inlineData:{mimeType:t.type,data:t.data}};if("functionCall"in t)return;throw"type"in t?new Error(`Unknown content type ${t.type}`):new Error(`Unknown content ${JSON.stringify(t)}`)}}function qt(t,e,n,s){if(At(t)){const u=t.name??Yt(t,n);if(u===void 0)throw new Error(`Google requires a tool name for each tool call response, and we could not infer a called tool name for ToolMessage "${t.id}" from your passed messages. Please populate a "name" field on that ToolMessage explicitly.`);const d=Array.isArray(t.content)?t.content.map(p=>P(p,e)).filter(p=>p!==void 0):t.content;return t.status==="error"?[{functionResponse:{name:u,response:{error:{details:d}}}}]:[{functionResponse:{name:u,response:{result:d}}}]}let i=[];const o=[];typeof t.content=="string"&&t.content&&o.push({text:t.content}),Array.isArray(t.content)&&o.push(...t.content.map(u=>P(u,e)).filter(u=>u!==void 0));const a=t.additional_kwargs?.[D];return lt(t)&&t.tool_calls?.length&&(i=t.tool_calls.map(u=>{const d=Kt(()=>{if(u.id){const p=a?.[u.id];if(p)return p}return s?.includes("gemini-3")?jt:""});return{functionCall:{name:u.name,args:u.args},...d?{thoughtSignature:d}:{}}})),[...o,...i]}function j(t,e,n=!1,s){return t.reduce((i,o,a)=>{if(!_t(o))throw new Error("Unsupported message input");const u=Ft(o);if(u==="system"&&a!==0)throw new Error("System message should be the first one");const d=Ht(u),p=i.content[i.content.length];if(!i.mergeWithPreviousContent&&p&&p.role===d)throw new Error("Google Generative AI requires alternate messages between authors");const l=qt(o,e,t.slice(0,a),s);if(i.mergeWithPreviousContent){const f=i.content[i.content.length-1];if(!f)throw new Error("There was a problem parsing your system message. Please try a prompt without one.");return f.parts.push(...l),{mergeWithPreviousContent:!1,content:i.content}}let r=d;(r==="function"||r==="system"&&!n)&&(r="user");const c={role:r,parts:l};return{mergeWithPreviousContent:u==="system"&&!n,content:[...i.content,c]}},{content:[],mergeWithPreviousContent:!1}).content}function Vt(t,e){if(!t.candidates||t.candidates.length===0||!t.candidates[0])return{generations:[],llmOutput:{filters:t.promptFeedback}};const[n]=t.candidates,{content:s,...i}=n,o=s.parts?.reduce((l,r)=>("functionCall"in r&&r.functionCall&&l.push({...r,id:"id"in r.functionCall&&typeof r.functionCall.id=="string"?r.functionCall.id:dt()}),l),[]);let a;const u=s?.parts;Array.isArray(u)&&u.length===1&&"text"in u[0]&&u[0].text&&!u[0].thought?a=u[0].text:Array.isArray(u)&&u.length>0?a=u.map(l=>l.thought&&"text"in l&&l.text?{type:"thinking",thinking:l.text,...l.thoughtSignature?{signature:l.thoughtSignature}:{}}:"text"in l?{type:"text",text:l.text}:"inlineData"in l?{type:"inlineData",inlineData:l.inlineData}:"functionCall"in l?{type:"functionCall",functionCall:l.functionCall}:"functionResponse"in l?{type:"functionResponse",functionResponse:l.functionResponse}:"fileData"in l?{type:"fileData",fileData:l.fileData}:"executableCode"in l?{type:"executableCode",executableCode:l.executableCode}:"codeExecutionResult"in l?{type:"codeExecutionResult",codeExecutionResult:l.codeExecutionResult}:l):a=[];const d=o?.reduce((l,r)=>("thoughtSignature"in r&&typeof r.thoughtSignature=="string"&&(l[r.id]=r.thoughtSignature),l),{});let p="";return typeof a=="string"?p=a:Array.isArray(a)&&a.length>0&&(p=a.find(l=>"text"in l)?.text??p),{generations:[{text:p,message:new Et({content:a??"",tool_calls:o?.map(l=>({type:"tool_call",id:l.id,name:l.functionCall.name,args:l.functionCall.args})),additional_kwargs:{...i,[D]:d},usage_metadata:e?.usageMetadata}),generationInfo:i}],llmOutput:{tokenUsage:{promptTokens:e?.usageMetadata?.input_tokens,completionTokens:e?.usageMetadata?.output_tokens,totalTokens:e?.usageMetadata?.total_tokens}}}}function Wt(t,e){if(!t.candidates||t.candidates.length===0)return null;const[n]=t.candidates,{content:s,...i}=n,o=s.parts?.reduce((r,c)=>("functionCall"in c&&c.functionCall&&r.push({...c,id:"id"in c.functionCall&&typeof c.functionCall.id=="string"?c.functionCall.id:dt()}),r),[]);let a;const u=s?.parts;Array.isArray(u)&&u.every(r=>"text"in r&&!r.thought)?a=u.map(r=>r.text).join(""):Array.isArray(u)?a=u.map(r=>r.thought&&"text"in r&&r.text?{type:"thinking",thinking:r.text,...r.thoughtSignature?{signature:r.thoughtSignature}:{}}:"text"in r?{type:"text",text:r.text}:"inlineData"in r?{type:"inlineData",inlineData:r.inlineData}:"functionCall"in r?{type:"functionCall",functionCall:r.functionCall}:"functionResponse"in r?{type:"functionResponse",functionResponse:r.functionResponse}:"fileData"in r?{type:"fileData",fileData:r.fileData}:"executableCode"in r?{type:"executableCode",executableCode:r.executableCode}:"codeExecutionResult"in r?{type:"codeExecutionResult",codeExecutionResult:r.codeExecutionResult}:r):a=[];let d="";a&&typeof a=="string"?d=a:Array.isArray(a)&&(d=a.find(r=>"text"in r)?.text??"");const p=[];o&&p.push(...o.map(r=>({type:"tool_call_chunk",id:r.id,name:r.functionCall.name,args:JSON.stringify(r.functionCall.args)})));const l=o?.reduce((r,c)=>("thoughtSignature"in c&&typeof c.thoughtSignature=="string"&&(r[c.id]=c.thoughtSignature),r),{});return new Tt({text:d,message:new wt({content:a||"",name:s?s.role:void 0,tool_call_chunks:p,additional_kwargs:{[D]:l},response_metadata:{model_provider:"google-genai"},usage_metadata:e.usageMetadata}),generationInfo:i})}function Jt(t){return t.every(e=>"functionDeclarations"in e&&Array.isArray(e.functionDeclarations))?t:[{functionDeclarations:t.map(e=>{if(at(e)){const n=N(e.schema);return n.type==="object"&&"properties"in n&&Object.keys(n.properties).length===0?{name:e.name,description:e.description}:(E(n,e.name),{name:e.name,description:e.description,parameters:n})}if(rt(e)){const n=Dt(e.function.parameters);return E(n,e.function.name),{name:e.function.name,description:e.function.description??"A function available to call.",parameters:n}}return e})}]}function K(t,e){const n={input_tokens:t?.promptTokenCount??0,output_tokens:t?.candidatesTokenCount??0,total_tokens:t?.totalTokenCount??0};if(t?.cachedContentTokenCount&&(n.input_token_details??={},n.input_token_details.cache_read=t.cachedContentTokenCount),e==="gemini-3-pro-preview"){const s=Math.max(0,t?.promptTokenCount??-2e5),i=Math.max(0,t?.cachedContentTokenCount??-2e5);s&&(n.input_token_details={...n.input_token_details,over_200k:s}),i&&(n.input_token_details={...n.input_token_details,cache_read_over_200k:i})}return n}var F=class extends Ct{static lc_name(){return"GoogleGenerativeAIToolsOutputParser"}lc_namespace=["langchain","google_genai","output_parsers"];returnId=!1;keyName;returnSingle=!1;zodSchema;constructor(t){super(t),this.keyName=t.keyName,this.returnSingle=t.returnSingle??this.returnSingle,this.zodSchema=t.zodSchema}async _validateResult(t){if(this.zodSchema===void 0)return t;const e=await kt(this.zodSchema,t);if(e.success)return e.data;throw new Ot(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(e.error.issues)}`,JSON.stringify(t,null,2))}async parseResult(t){const e=t.flatMap(s=>{const{message:i}=s;return!("tool_calls"in i)||!Array.isArray(i.tool_calls)?[]:i.tool_calls});if(e[0]===void 0)throw new Error("No parseable tool calls provided to GoogleGenerativeAIToolsOutputParser.");const[n]=e;return await this._validateResult(n.args)}},H;(function(t){t.STRING="string",t.NUMBER="number",t.INTEGER="integer",t.BOOLEAN="boolean",t.ARRAY="array",t.OBJECT="object"})(H||(H={}));var $;(function(t){t.LANGUAGE_UNSPECIFIED="language_unspecified",t.PYTHON="python"})($||($={}));var Y;(function(t){t.OUTCOME_UNSPECIFIED="outcome_unspecified",t.OUTCOME_OK="outcome_ok",t.OUTCOME_FAILED="outcome_failed",t.OUTCOME_DEADLINE_EXCEEDED="outcome_deadline_exceeded"})(Y||(Y={}));const B=["user","model","function","system"];var q;(function(t){t.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",t.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",t.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",t.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",t.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",t.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY"})(q||(q={}));var V;(function(t){t.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",t.BLOCK_NONE="BLOCK_NONE"})(V||(V={}));var W;(function(t){t.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",t.NEGLIGIBLE="NEGLIGIBLE",t.LOW="LOW",t.MEDIUM="MEDIUM",t.HIGH="HIGH"})(W||(W={}));var J;(function(t){t.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",t.SAFETY="SAFETY",t.OTHER="OTHER"})(J||(J={}));var w;(function(t){t.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",t.STOP="STOP",t.MAX_TOKENS="MAX_TOKENS",t.SAFETY="SAFETY",t.RECITATION="RECITATION",t.LANGUAGE="LANGUAGE",t.BLOCKLIST="BLOCKLIST",t.PROHIBITED_CONTENT="PROHIBITED_CONTENT",t.SPII="SPII",t.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",t.OTHER="OTHER"})(w||(w={}));var z;(function(t){t.TASK_TYPE_UNSPECIFIED="TASK_TYPE_UNSPECIFIED",t.RETRIEVAL_QUERY="RETRIEVAL_QUERY",t.RETRIEVAL_DOCUMENT="RETRIEVAL_DOCUMENT",t.SEMANTIC_SIMILARITY="SEMANTIC_SIMILARITY",t.CLASSIFICATION="CLASSIFICATION",t.CLUSTERING="CLUSTERING"})(z||(z={}));var T;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.AUTO="AUTO",t.ANY="ANY",t.NONE="NONE"})(T||(T={}));var Q;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.MODE_DYNAMIC="MODE_DYNAMIC"})(Q||(Q={}));class m extends Error{constructor(e){super(`[GoogleGenerativeAI Error]: ${e}`)}}class _ extends m{constructor(e,n){super(e),this.response=n}}class ft extends m{constructor(e,n,s,i){super(e),this.status=n,this.statusText=s,this.errorDetails=i}}class y extends m{}class pt extends m{}const zt="https://generativelanguage.googleapis.com",Qt="v1beta",Zt="0.24.1",Xt="genai-js";var v;(function(t){t.GENERATE_CONTENT="generateContent",t.STREAM_GENERATE_CONTENT="streamGenerateContent",t.COUNT_TOKENS="countTokens",t.EMBED_CONTENT="embedContent",t.BATCH_EMBED_CONTENTS="batchEmbedContents"})(v||(v={}));class te{constructor(e,n,s,i,o){this.model=e,this.task=n,this.apiKey=s,this.stream=i,this.requestOptions=o}toString(){var e,n;const s=((e=this.requestOptions)===null||e===void 0?void 0:e.apiVersion)||Qt;let o=`${((n=this.requestOptions)===null||n===void 0?void 0:n.baseUrl)||zt}/${s}/${this.model}:${this.task}`;return this.stream&&(o+="?alt=sse"),o}}function ee(t){const e=[];return t?.apiClient&&e.push(t.apiClient),e.push(`${Xt}/${Zt}`),e.join(" ")}async function ne(t){var e;const n=new Headers;n.append("Content-Type","application/json"),n.append("x-goog-api-client",ee(t.requestOptions)),n.append("x-goog-api-key",t.apiKey);let s=(e=t.requestOptions)===null||e===void 0?void 0:e.customHeaders;if(s){if(!(s instanceof Headers))try{s=new Headers(s)}catch(i){throw new y(`unable to convert customHeaders value ${JSON.stringify(s)} to Headers: ${i.message}`)}for(const[i,o]of s.entries()){if(i==="x-goog-api-key")throw new y(`Cannot set reserved header name ${i}`);if(i==="x-goog-api-client")throw new y(`Header name ${i} can only be set using the apiClient field`);n.append(i,o)}}return n}async function se(t,e,n,s,i,o){const a=new te(t,e,n,s,o);return{url:a.toString(),fetchOptions:Object.assign(Object.assign({},re(o)),{method:"POST",headers:await ne(a),body:i})}}async function R(t,e,n,s,i,o={},a=fetch){const{url:u,fetchOptions:d}=await se(t,e,n,s,i,o);return ie(u,d,a)}async function ie(t,e,n=fetch){let s;try{s=await n(t,e)}catch(i){oe(i,t)}return s.ok||await ae(s,t),s}function oe(t,e){let n=t;throw n.name==="AbortError"?(n=new pt(`Request aborted when fetching ${e.toString()}: ${t.message}`),n.stack=t.stack):t instanceof ft||t instanceof y||(n=new m(`Error fetching from ${e.toString()}: ${t.message}`),n.stack=t.stack),n}async function ae(t,e){let n="",s;try{const i=await t.json();n=i.error.message,i.error.details&&(n+=` ${JSON.stringify(i.error.details)}`,s=i.error.details)}catch{}throw new ft(`Error fetching from ${e.toString()}: [${t.status} ${t.statusText}] ${n}`,t.status,t.statusText,s)}function re(t){const e={};if(t?.signal!==void 0||t?.timeout>=0){const n=new AbortController;t?.timeout>=0&&setTimeout(()=>n.abort(),t.timeout),t?.signal&&t.signal.addEventListener("abort",()=>{n.abort()}),e.signal=n.signal}return e}function G(t){return t.text=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.`),x(t.candidates[0]))throw new _(`${O(t)}`,t);return ue(t)}else if(t.promptFeedback)throw new _(`Text not available. ${O(t)}`,t);return""},t.functionCall=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),x(t.candidates[0]))throw new _(`${O(t)}`,t);return console.warn("response.functionCall() is deprecated. Use response.functionCalls() instead."),Z(t)[0]}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t.functionCalls=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),x(t.candidates[0]))throw new _(`${O(t)}`,t);return Z(t)}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t}function ue(t){var e,n,s,i;const o=[];if(!((n=(e=t.candidates)===null||e===void 0?void 0:e[0].content)===null||n===void 0)&&n.parts)for(const a of(i=(s=t.candidates)===null||s===void 0?void 0:s[0].content)===null||i===void 0?void 0:i.parts)a.text&&o.push(a.text),a.executableCode&&o.push("\n```"+a.executableCode.language+`
|
|
1
|
+
import{c as at,f as rt,g as Ct,O as Ot,h as yt,J as It,R as U}from"./index-DhbVcA9F.js";import{b as ut,Q as vt,S as _t,U as Et,V as Tt,W as wt,X as St,Y as At,y as lt,Z as Rt,$ as xt,a0 as k,x as kt,a1 as ct,a2 as bt}from"./index-BQDf_2QT.js";import{E as Nt,c as Mt}from"./embeddings-DD3kbxNt.js";function I(t){if(typeof t=="object"&&t!==null){const e={...t};"additionalProperties"in e&&delete e.additionalProperties,"$schema"in e&&delete e.$schema,"strict"in e&&delete e.strict;for(const n in e)n in e&&(Array.isArray(e[n])?e[n]=e[n].map(I):typeof e[n]=="object"&&e[n]!==null&&(e[n]=I(e[n])));return e}return t}function N(t){const{$schema:e,...n}=I(ut(t)?vt(t):t);return n}function Dt(t){const{$schema:e,...n}=I(t);return n}function E(t,e,n=[]){if(t==null||typeof t!="object")return;const s=t;if(Array.isArray(s.enum)&&s.enum.some(i=>i==="")){const i=n.length?` at path "${n.join(".")}"`:"",o=e?` in tool "${e}"`:"";throw new Error(`Invalid enum: empty string not allowed${o}${i}. Gemini API rejects empty strings in enums.`)}if(s.type==="object"&&s.properties&&typeof s.properties=="object")for(const[i,o]of Object.entries(s.properties))E(o,e,[...n,i]);s.items&&E(s.items,e,[...n,"[]"]);for(const i of["anyOf","oneOf","allOf"]){const o=s[i];Array.isArray(o)&&o.forEach((a,u)=>E(a,e,[...n,`${i}[${u}]`]))}s.additionalProperties&&typeof s.additionalProperties=="object"&&E(s.additionalProperties,e,[...n,"additionalProperties"])}const h=[];for(let t=0;t<256;++t)h.push((t+256).toString(16).slice(1));function Gt(t,e=0){return(h[t[e+0]]+h[t[e+1]]+h[t[e+2]]+h[t[e+3]]+"-"+h[t[e+4]]+h[t[e+5]]+"-"+h[t[e+6]]+h[t[e+7]]+"-"+h[t[e+8]]+h[t[e+9]]+"-"+h[t[e+10]]+h[t[e+11]]+h[t[e+12]]+h[t[e+13]]+h[t[e+14]]+h[t[e+15]]).toLowerCase()}let b;const Ut=new Uint8Array(16);function Lt(){if(!b){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");b=crypto.getRandomValues.bind(crypto)}return b(Ut)}const Pt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),L={randomUUID:Pt};function dt(t,e,n){if(L.randomUUID&&!t)return L.randomUUID();t=t||{};const s=t.random??t.rng?.()??Lt();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Gt(s)}const D="__gemini_function_call_thought_signatures__",jt="ErYCCrMCAdHtim9kOoOkrPiCNVsmlpMIKd7ZMxgiFbVQOkgp7nlLcDMzVsZwIzvuT7nQROivoXA72ccC2lSDvR0Gh7dkWaGuj7ctv6t7ZceHnecx0QYa+ix8tYpRfjhyWozQ49lWiws6+YGjCt10KRTyWsZ2h6O7iHTYJwKIRwGUHRKy/qK/6kFxJm5ML00gLq4D8s5Z6DBpp2ZlR+uF4G8jJgeWQgyHWVdx2wGYElaceVAc66tZdPQRdOHpWtgYSI1YdaXgVI8KHY3/EfNc2YqqMIulvkDBAnuMhkAjV9xmBa54Tq+ih3Im4+r3DzqhGqYdsSkhS0kZMwte4Hjs65dZzCw9lANxIqYi1DJ639WNPYihp/DCJCos7o+/EeSPJaio5sgWDyUnMGkY1atsJZ+m7pj7DD5tvQ==",Kt=t=>t();function Ft(t){return St.isInstance(t)?t.role:t.type}function Ht(t){switch(t){case"supervisor":case"ai":case"model":return"model";case"system":return"system";case"human":return"user";case"tool":case"function":return"function";default:throw new Error(`Unknown / unsupported author: ${t}`)}}function $t(t){if("mimeType"in t&&"data"in t)return{inlineData:{mimeType:t.mimeType,data:t.data}};if("mimeType"in t&&"fileUri"in t)return{fileData:{mimeType:t.mimeType,fileUri:t.fileUri}};throw new Error("Invalid media content")}function Yt(t,e){return e.map(n=>lt(n)?n.tool_calls??[]:[]).flat().find(n=>n.id===t.tool_call_id)?.name}function Bt(t){return{providerName:"Google Gemini",fromStandardTextBlock(e){return{text:e.text}},fromStandardImageBlock(e){if(!t)throw new Error("This model does not support images");if(e.source_type==="url"){const n=k({dataUrl:e.url});return n?{inlineData:{mimeType:n.mime_type,data:n.data}}:{fileData:{mimeType:e.mime_type??"",fileUri:e.url}}}if(e.source_type==="base64")return{inlineData:{mimeType:e.mime_type??"",data:e.data}};throw new Error(`Unsupported source type: ${e.source_type}`)},fromStandardAudioBlock(e){if(!t)throw new Error("This model does not support audio");if(e.source_type==="url"){const n=k({dataUrl:e.url});return n?{inlineData:{mimeType:n.mime_type,data:n.data}}:{fileData:{mimeType:e.mime_type??"",fileUri:e.url}}}if(e.source_type==="base64")return{inlineData:{mimeType:e.mime_type??"",data:e.data}};throw new Error(`Unsupported source type: ${e.source_type}`)},fromStandardFileBlock(e){if(!t)throw new Error("This model does not support files");if(e.source_type==="text")return{text:e.text};if(e.source_type==="url"){const n=k({dataUrl:e.url});return n?{inlineData:{mimeType:n.mime_type,data:n.data}}:{fileData:{mimeType:e.mime_type??"",fileUri:e.url}}}if(e.source_type==="base64")return{inlineData:{mimeType:e.mime_type??"",data:e.data}};throw new Error(`Unsupported source type: ${e.source_type}`)}}}function P(t,e){if(Rt(t))return xt(t,Bt(e));if(t.type==="text")return{text:t.text};if(t.type==="executableCode")return{executableCode:t.executableCode};if(t.type==="codeExecutionResult")return{codeExecutionResult:t.codeExecutionResult};if(t.type==="image_url"){if(!e)throw new Error("This model does not support images");let n;if(typeof t.image_url=="string")n=t.image_url;else if(typeof t.image_url=="object"&&"url"in t.image_url)n=t.image_url.url;else throw new Error("Please provide image as base64 encoded data URL");const[s,i]=n.split(",");if(!s.startsWith("data:"))throw new Error("Please provide image as base64 encoded data URL");const[o,a]=s.replace(/^data:/,"").split(";");if(a!=="base64")throw new Error("Please provide image as base64 encoded data URL");return{inlineData:{data:i,mimeType:o}}}else{if(t.type==="media")return $t(t);if(t.type==="tool_use")return{functionCall:{name:t.name,args:t.input}};if(t.type==="tool_call")return{functionCall:{name:t.name,args:t.args}};if(t.type?.includes("/")&&t.type.split("/").length===2&&"data"in t&&typeof t.data=="string")return{inlineData:{mimeType:t.type,data:t.data}};if("functionCall"in t)return;throw"type"in t?new Error(`Unknown content type ${t.type}`):new Error(`Unknown content ${JSON.stringify(t)}`)}}function qt(t,e,n,s){if(At(t)){const u=t.name??Yt(t,n);if(u===void 0)throw new Error(`Google requires a tool name for each tool call response, and we could not infer a called tool name for ToolMessage "${t.id}" from your passed messages. Please populate a "name" field on that ToolMessage explicitly.`);const d=Array.isArray(t.content)?t.content.map(p=>P(p,e)).filter(p=>p!==void 0):t.content;return t.status==="error"?[{functionResponse:{name:u,response:{error:{details:d}}}}]:[{functionResponse:{name:u,response:{result:d}}}]}let i=[];const o=[];typeof t.content=="string"&&t.content&&o.push({text:t.content}),Array.isArray(t.content)&&o.push(...t.content.map(u=>P(u,e)).filter(u=>u!==void 0));const a=t.additional_kwargs?.[D];return lt(t)&&t.tool_calls?.length&&(i=t.tool_calls.map(u=>{const d=Kt(()=>{if(u.id){const p=a?.[u.id];if(p)return p}return s?.includes("gemini-3")?jt:""});return{functionCall:{name:u.name,args:u.args},...d?{thoughtSignature:d}:{}}})),[...o,...i]}function j(t,e,n=!1,s){return t.reduce((i,o,a)=>{if(!_t(o))throw new Error("Unsupported message input");const u=Ft(o);if(u==="system"&&a!==0)throw new Error("System message should be the first one");const d=Ht(u),p=i.content[i.content.length];if(!i.mergeWithPreviousContent&&p&&p.role===d)throw new Error("Google Generative AI requires alternate messages between authors");const l=qt(o,e,t.slice(0,a),s);if(i.mergeWithPreviousContent){const f=i.content[i.content.length-1];if(!f)throw new Error("There was a problem parsing your system message. Please try a prompt without one.");return f.parts.push(...l),{mergeWithPreviousContent:!1,content:i.content}}let r=d;(r==="function"||r==="system"&&!n)&&(r="user");const c={role:r,parts:l};return{mergeWithPreviousContent:u==="system"&&!n,content:[...i.content,c]}},{content:[],mergeWithPreviousContent:!1}).content}function Vt(t,e){if(!t.candidates||t.candidates.length===0||!t.candidates[0])return{generations:[],llmOutput:{filters:t.promptFeedback}};const[n]=t.candidates,{content:s,...i}=n,o=s.parts?.reduce((l,r)=>("functionCall"in r&&r.functionCall&&l.push({...r,id:"id"in r.functionCall&&typeof r.functionCall.id=="string"?r.functionCall.id:dt()}),l),[]);let a;const u=s?.parts;Array.isArray(u)&&u.length===1&&"text"in u[0]&&u[0].text&&!u[0].thought?a=u[0].text:Array.isArray(u)&&u.length>0?a=u.map(l=>l.thought&&"text"in l&&l.text?{type:"thinking",thinking:l.text,...l.thoughtSignature?{signature:l.thoughtSignature}:{}}:"text"in l?{type:"text",text:l.text}:"inlineData"in l?{type:"inlineData",inlineData:l.inlineData}:"functionCall"in l?{type:"functionCall",functionCall:l.functionCall}:"functionResponse"in l?{type:"functionResponse",functionResponse:l.functionResponse}:"fileData"in l?{type:"fileData",fileData:l.fileData}:"executableCode"in l?{type:"executableCode",executableCode:l.executableCode}:"codeExecutionResult"in l?{type:"codeExecutionResult",codeExecutionResult:l.codeExecutionResult}:l):a=[];const d=o?.reduce((l,r)=>("thoughtSignature"in r&&typeof r.thoughtSignature=="string"&&(l[r.id]=r.thoughtSignature),l),{});let p="";return typeof a=="string"?p=a:Array.isArray(a)&&a.length>0&&(p=a.find(l=>"text"in l)?.text??p),{generations:[{text:p,message:new Et({content:a??"",tool_calls:o?.map(l=>({type:"tool_call",id:l.id,name:l.functionCall.name,args:l.functionCall.args})),additional_kwargs:{...i,[D]:d},usage_metadata:e?.usageMetadata}),generationInfo:i}],llmOutput:{tokenUsage:{promptTokens:e?.usageMetadata?.input_tokens,completionTokens:e?.usageMetadata?.output_tokens,totalTokens:e?.usageMetadata?.total_tokens}}}}function Wt(t,e){if(!t.candidates||t.candidates.length===0)return null;const[n]=t.candidates,{content:s,...i}=n,o=s.parts?.reduce((r,c)=>("functionCall"in c&&c.functionCall&&r.push({...c,id:"id"in c.functionCall&&typeof c.functionCall.id=="string"?c.functionCall.id:dt()}),r),[]);let a;const u=s?.parts;Array.isArray(u)&&u.every(r=>"text"in r&&!r.thought)?a=u.map(r=>r.text).join(""):Array.isArray(u)?a=u.map(r=>r.thought&&"text"in r&&r.text?{type:"thinking",thinking:r.text,...r.thoughtSignature?{signature:r.thoughtSignature}:{}}:"text"in r?{type:"text",text:r.text}:"inlineData"in r?{type:"inlineData",inlineData:r.inlineData}:"functionCall"in r?{type:"functionCall",functionCall:r.functionCall}:"functionResponse"in r?{type:"functionResponse",functionResponse:r.functionResponse}:"fileData"in r?{type:"fileData",fileData:r.fileData}:"executableCode"in r?{type:"executableCode",executableCode:r.executableCode}:"codeExecutionResult"in r?{type:"codeExecutionResult",codeExecutionResult:r.codeExecutionResult}:r):a=[];let d="";a&&typeof a=="string"?d=a:Array.isArray(a)&&(d=a.find(r=>"text"in r)?.text??"");const p=[];o&&p.push(...o.map(r=>({type:"tool_call_chunk",id:r.id,name:r.functionCall.name,args:JSON.stringify(r.functionCall.args)})));const l=o?.reduce((r,c)=>("thoughtSignature"in c&&typeof c.thoughtSignature=="string"&&(r[c.id]=c.thoughtSignature),r),{});return new Tt({text:d,message:new wt({content:a||"",name:s?s.role:void 0,tool_call_chunks:p,additional_kwargs:{[D]:l},response_metadata:{model_provider:"google-genai"},usage_metadata:e.usageMetadata}),generationInfo:i})}function Jt(t){return t.every(e=>"functionDeclarations"in e&&Array.isArray(e.functionDeclarations))?t:[{functionDeclarations:t.map(e=>{if(at(e)){const n=N(e.schema);return n.type==="object"&&"properties"in n&&Object.keys(n.properties).length===0?{name:e.name,description:e.description}:(E(n,e.name),{name:e.name,description:e.description,parameters:n})}if(rt(e)){const n=Dt(e.function.parameters);return E(n,e.function.name),{name:e.function.name,description:e.function.description??"A function available to call.",parameters:n}}return e})}]}function K(t,e){const n={input_tokens:t?.promptTokenCount??0,output_tokens:t?.candidatesTokenCount??0,total_tokens:t?.totalTokenCount??0};if(t?.cachedContentTokenCount&&(n.input_token_details??={},n.input_token_details.cache_read=t.cachedContentTokenCount),e==="gemini-3-pro-preview"){const s=Math.max(0,t?.promptTokenCount??-2e5),i=Math.max(0,t?.cachedContentTokenCount??-2e5);s&&(n.input_token_details={...n.input_token_details,over_200k:s}),i&&(n.input_token_details={...n.input_token_details,cache_read_over_200k:i})}return n}var F=class extends Ct{static lc_name(){return"GoogleGenerativeAIToolsOutputParser"}lc_namespace=["langchain","google_genai","output_parsers"];returnId=!1;keyName;returnSingle=!1;zodSchema;constructor(t){super(t),this.keyName=t.keyName,this.returnSingle=t.returnSingle??this.returnSingle,this.zodSchema=t.zodSchema}async _validateResult(t){if(this.zodSchema===void 0)return t;const e=await kt(this.zodSchema,t);if(e.success)return e.data;throw new Ot(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(e.error.issues)}`,JSON.stringify(t,null,2))}async parseResult(t){const e=t.flatMap(s=>{const{message:i}=s;return!("tool_calls"in i)||!Array.isArray(i.tool_calls)?[]:i.tool_calls});if(e[0]===void 0)throw new Error("No parseable tool calls provided to GoogleGenerativeAIToolsOutputParser.");const[n]=e;return await this._validateResult(n.args)}},H;(function(t){t.STRING="string",t.NUMBER="number",t.INTEGER="integer",t.BOOLEAN="boolean",t.ARRAY="array",t.OBJECT="object"})(H||(H={}));var $;(function(t){t.LANGUAGE_UNSPECIFIED="language_unspecified",t.PYTHON="python"})($||($={}));var Y;(function(t){t.OUTCOME_UNSPECIFIED="outcome_unspecified",t.OUTCOME_OK="outcome_ok",t.OUTCOME_FAILED="outcome_failed",t.OUTCOME_DEADLINE_EXCEEDED="outcome_deadline_exceeded"})(Y||(Y={}));const B=["user","model","function","system"];var q;(function(t){t.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",t.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",t.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",t.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",t.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",t.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY"})(q||(q={}));var V;(function(t){t.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",t.BLOCK_NONE="BLOCK_NONE"})(V||(V={}));var W;(function(t){t.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",t.NEGLIGIBLE="NEGLIGIBLE",t.LOW="LOW",t.MEDIUM="MEDIUM",t.HIGH="HIGH"})(W||(W={}));var J;(function(t){t.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",t.SAFETY="SAFETY",t.OTHER="OTHER"})(J||(J={}));var w;(function(t){t.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",t.STOP="STOP",t.MAX_TOKENS="MAX_TOKENS",t.SAFETY="SAFETY",t.RECITATION="RECITATION",t.LANGUAGE="LANGUAGE",t.BLOCKLIST="BLOCKLIST",t.PROHIBITED_CONTENT="PROHIBITED_CONTENT",t.SPII="SPII",t.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",t.OTHER="OTHER"})(w||(w={}));var z;(function(t){t.TASK_TYPE_UNSPECIFIED="TASK_TYPE_UNSPECIFIED",t.RETRIEVAL_QUERY="RETRIEVAL_QUERY",t.RETRIEVAL_DOCUMENT="RETRIEVAL_DOCUMENT",t.SEMANTIC_SIMILARITY="SEMANTIC_SIMILARITY",t.CLASSIFICATION="CLASSIFICATION",t.CLUSTERING="CLUSTERING"})(z||(z={}));var T;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.AUTO="AUTO",t.ANY="ANY",t.NONE="NONE"})(T||(T={}));var Q;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.MODE_DYNAMIC="MODE_DYNAMIC"})(Q||(Q={}));class m extends Error{constructor(e){super(`[GoogleGenerativeAI Error]: ${e}`)}}class _ extends m{constructor(e,n){super(e),this.response=n}}class ft extends m{constructor(e,n,s,i){super(e),this.status=n,this.statusText=s,this.errorDetails=i}}class y extends m{}class pt extends m{}const zt="https://generativelanguage.googleapis.com",Qt="v1beta",Zt="0.24.1",Xt="genai-js";var v;(function(t){t.GENERATE_CONTENT="generateContent",t.STREAM_GENERATE_CONTENT="streamGenerateContent",t.COUNT_TOKENS="countTokens",t.EMBED_CONTENT="embedContent",t.BATCH_EMBED_CONTENTS="batchEmbedContents"})(v||(v={}));class te{constructor(e,n,s,i,o){this.model=e,this.task=n,this.apiKey=s,this.stream=i,this.requestOptions=o}toString(){var e,n;const s=((e=this.requestOptions)===null||e===void 0?void 0:e.apiVersion)||Qt;let o=`${((n=this.requestOptions)===null||n===void 0?void 0:n.baseUrl)||zt}/${s}/${this.model}:${this.task}`;return this.stream&&(o+="?alt=sse"),o}}function ee(t){const e=[];return t?.apiClient&&e.push(t.apiClient),e.push(`${Xt}/${Zt}`),e.join(" ")}async function ne(t){var e;const n=new Headers;n.append("Content-Type","application/json"),n.append("x-goog-api-client",ee(t.requestOptions)),n.append("x-goog-api-key",t.apiKey);let s=(e=t.requestOptions)===null||e===void 0?void 0:e.customHeaders;if(s){if(!(s instanceof Headers))try{s=new Headers(s)}catch(i){throw new y(`unable to convert customHeaders value ${JSON.stringify(s)} to Headers: ${i.message}`)}for(const[i,o]of s.entries()){if(i==="x-goog-api-key")throw new y(`Cannot set reserved header name ${i}`);if(i==="x-goog-api-client")throw new y(`Header name ${i} can only be set using the apiClient field`);n.append(i,o)}}return n}async function se(t,e,n,s,i,o){const a=new te(t,e,n,s,o);return{url:a.toString(),fetchOptions:Object.assign(Object.assign({},re(o)),{method:"POST",headers:await ne(a),body:i})}}async function R(t,e,n,s,i,o={},a=fetch){const{url:u,fetchOptions:d}=await se(t,e,n,s,i,o);return ie(u,d,a)}async function ie(t,e,n=fetch){let s;try{s=await n(t,e)}catch(i){oe(i,t)}return s.ok||await ae(s,t),s}function oe(t,e){let n=t;throw n.name==="AbortError"?(n=new pt(`Request aborted when fetching ${e.toString()}: ${t.message}`),n.stack=t.stack):t instanceof ft||t instanceof y||(n=new m(`Error fetching from ${e.toString()}: ${t.message}`),n.stack=t.stack),n}async function ae(t,e){let n="",s;try{const i=await t.json();n=i.error.message,i.error.details&&(n+=` ${JSON.stringify(i.error.details)}`,s=i.error.details)}catch{}throw new ft(`Error fetching from ${e.toString()}: [${t.status} ${t.statusText}] ${n}`,t.status,t.statusText,s)}function re(t){const e={};if(t?.signal!==void 0||t?.timeout>=0){const n=new AbortController;t?.timeout>=0&&setTimeout(()=>n.abort(),t.timeout),t?.signal&&t.signal.addEventListener("abort",()=>{n.abort()}),e.signal=n.signal}return e}function G(t){return t.text=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.`),x(t.candidates[0]))throw new _(`${O(t)}`,t);return ue(t)}else if(t.promptFeedback)throw new _(`Text not available. ${O(t)}`,t);return""},t.functionCall=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),x(t.candidates[0]))throw new _(`${O(t)}`,t);return console.warn("response.functionCall() is deprecated. Use response.functionCalls() instead."),Z(t)[0]}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t.functionCalls=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),x(t.candidates[0]))throw new _(`${O(t)}`,t);return Z(t)}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t}function ue(t){var e,n,s,i;const o=[];if(!((n=(e=t.candidates)===null||e===void 0?void 0:e[0].content)===null||n===void 0)&&n.parts)for(const a of(i=(s=t.candidates)===null||s===void 0?void 0:s[0].content)===null||i===void 0?void 0:i.parts)a.text&&o.push(a.text),a.executableCode&&o.push("\n```"+a.executableCode.language+`
|
|
2
2
|
`+a.executableCode.code+"\n```\n"),a.codeExecutionResult&&o.push("\n```\n"+a.codeExecutionResult.output+"\n```\n");return o.length>0?o.join(""):""}function Z(t){var e,n,s,i;const o=[];if(!((n=(e=t.candidates)===null||e===void 0?void 0:e[0].content)===null||n===void 0)&&n.parts)for(const a of(i=(s=t.candidates)===null||s===void 0?void 0:s[0].content)===null||i===void 0?void 0:i.parts)a.functionCall&&o.push(a.functionCall);if(o.length>0)return o}const le=[w.RECITATION,w.SAFETY,w.LANGUAGE];function x(t){return!!t.finishReason&&le.includes(t.finishReason)}function O(t){var e,n,s;let i="";if((!t.candidates||t.candidates.length===0)&&t.promptFeedback)i+="Response was blocked",!((e=t.promptFeedback)===null||e===void 0)&&e.blockReason&&(i+=` due to ${t.promptFeedback.blockReason}`),!((n=t.promptFeedback)===null||n===void 0)&&n.blockReasonMessage&&(i+=`: ${t.promptFeedback.blockReasonMessage}`);else if(!((s=t.candidates)===null||s===void 0)&&s[0]){const o=t.candidates[0];x(o)&&(i+=`Candidate was blocked due to ${o.finishReason}`,o.finishMessage&&(i+=`: ${o.finishMessage}`))}return i}function S(t){return this instanceof S?(this.v=t,this):new S(t)}function ce(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=n.apply(t,e||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(c){s[c]&&(i[c]=function(f){return new Promise(function(g,C){o.push([c,f,g,C])>1||u(c,f)})})}function u(c,f){try{d(s[c](f))}catch(g){r(o[0][3],g)}}function d(c){c.value instanceof S?Promise.resolve(c.value.v).then(p,l):r(o[0][2],c)}function p(c){u("next",c)}function l(c){u("throw",c)}function r(c,f){c(f),o.shift(),o.length&&u(o[0][0],o[0][1])}}const X=/^data\: (.*)(?:\n\n|\r\r|\r\n\r\n)/;function de(t){const e=t.body.pipeThrough(new TextDecoderStream("utf8",{fatal:!0})),n=ge(e),[s,i]=n.tee();return{stream:pe(s),response:fe(i)}}async function fe(t){const e=[],n=t.getReader();for(;;){const{done:s,value:i}=await n.read();if(s)return G(he(e));e.push(i)}}function pe(t){return ce(this,arguments,function*(){const n=t.getReader();for(;;){const{value:s,done:i}=yield S(n.read());if(i)break;yield yield S(G(s))}})}function ge(t){const e=t.getReader();return new ReadableStream({start(s){let i="";return o();function o(){return e.read().then(({value:a,done:u})=>{if(u){if(i.trim()){s.error(new m("Failed to parse stream"));return}s.close();return}i+=a;let d=i.match(X),p;for(;d;){try{p=JSON.parse(d[1])}catch{s.error(new m(`Error parsing JSON response: "${d[1]}"`));return}s.enqueue(p),i=i.substring(d[0].length),d=i.match(X)}return o()}).catch(a=>{let u=a;throw u.stack=a.stack,u.name==="AbortError"?u=new pt("Request aborted when reading from the stream"):u=new m("Error reading from the stream"),u})}}})}function he(t){const e=t[t.length-1],n={promptFeedback:e?.promptFeedback};for(const s of t){if(s.candidates){let i=0;for(const o of s.candidates)if(n.candidates||(n.candidates=[]),n.candidates[i]||(n.candidates[i]={index:i}),n.candidates[i].citationMetadata=o.citationMetadata,n.candidates[i].groundingMetadata=o.groundingMetadata,n.candidates[i].finishReason=o.finishReason,n.candidates[i].finishMessage=o.finishMessage,n.candidates[i].safetyRatings=o.safetyRatings,o.content&&o.content.parts){n.candidates[i].content||(n.candidates[i].content={role:o.content.role||"user",parts:[]});const a={};for(const u of o.content.parts)u.text&&(a.text=u.text),u.functionCall&&(a.functionCall=u.functionCall),u.executableCode&&(a.executableCode=u.executableCode),u.codeExecutionResult&&(a.codeExecutionResult=u.codeExecutionResult),Object.keys(a).length===0&&(a.text=""),n.candidates[i].content.parts.push(a)}i++}s.usageMetadata&&(n.usageMetadata=s.usageMetadata)}return n}async function gt(t,e,n,s){const i=await R(e,v.STREAM_GENERATE_CONTENT,t,!0,JSON.stringify(n),s);return de(i)}async function ht(t,e,n,s){const o=await(await R(e,v.GENERATE_CONTENT,t,!1,JSON.stringify(n),s)).json();return{response:G(o)}}function mt(t){if(t!=null){if(typeof t=="string")return{role:"system",parts:[{text:t}]};if(t.text)return{role:"system",parts:[t]};if(t.parts)return t.role?t:{role:"system",parts:t.parts}}}function A(t){let e=[];if(typeof t=="string")e=[{text:t}];else for(const n of t)typeof n=="string"?e.push({text:n}):e.push(n);return me(e)}function me(t){const e={role:"user",parts:[]},n={role:"function",parts:[]};let s=!1,i=!1;for(const o of t)"functionResponse"in o?(n.parts.push(o),i=!0):(e.parts.push(o),s=!0);if(s&&i)throw new m("Within a single message, FunctionResponse cannot be mixed with other type of part in the request for sending chat message.");if(!s&&!i)throw new m("No content is provided for sending chat message.");return s?e:n}function Ce(t,e){var n;let s={model:e?.model,generationConfig:e?.generationConfig,safetySettings:e?.safetySettings,tools:e?.tools,toolConfig:e?.toolConfig,systemInstruction:e?.systemInstruction,cachedContent:(n=e?.cachedContent)===null||n===void 0?void 0:n.name,contents:[]};const i=t.generateContentRequest!=null;if(t.contents){if(i)throw new y("CountTokensRequest must have one of contents or generateContentRequest, not both.");s.contents=t.contents}else if(i)s=Object.assign(Object.assign({},s),t.generateContentRequest);else{const o=A(t);s.contents=[o]}return{generateContentRequest:s}}function tt(t){let e;return t.contents?e=t:e={contents:[A(t)]},t.systemInstruction&&(e.systemInstruction=mt(t.systemInstruction)),e}function Oe(t){return typeof t=="string"||Array.isArray(t)?{content:A(t)}:t}const et=["text","inlineData","functionCall","functionResponse","executableCode","codeExecutionResult"],ye={user:["text","inlineData"],function:["functionResponse"],model:["text","functionCall","executableCode","codeExecutionResult"],system:["text"]};function Ie(t){let e=!1;for(const n of t){const{role:s,parts:i}=n;if(!e&&s!=="user")throw new m(`First content should be with role 'user', got ${s}`);if(!B.includes(s))throw new m(`Each item should include role field. Got ${s} but valid roles are: ${JSON.stringify(B)}`);if(!Array.isArray(i))throw new m("Content should have 'parts' property with an array of Parts");if(i.length===0)throw new m("Each Content should have at least one part");const o={text:0,inlineData:0,functionCall:0,functionResponse:0,fileData:0,executableCode:0,codeExecutionResult:0};for(const u of i)for(const d of et)d in u&&(o[d]+=1);const a=ye[s];for(const u of et)if(!a.includes(u)&&o[u]>0)throw new m(`Content with role '${s}' can't contain '${u}' part`);e=!0}}function nt(t){var e;if(t.candidates===void 0||t.candidates.length===0)return!1;const n=(e=t.candidates[0])===null||e===void 0?void 0:e.content;if(n===void 0||n.parts===void 0||n.parts.length===0)return!1;for(const s of n.parts)if(s===void 0||Object.keys(s).length===0||s.text!==void 0&&s.text==="")return!1;return!0}const st="SILENT_ERROR";class ve{constructor(e,n,s,i={}){this.model=n,this.params=s,this._requestOptions=i,this._history=[],this._sendPromise=Promise.resolve(),this._apiKey=e,s?.history&&(Ie(s.history),this._history=s.history)}async getHistory(){return await this._sendPromise,this._history}async sendMessage(e,n={}){var s,i,o,a,u,d;await this._sendPromise;const p=A(e),l={safetySettings:(s=this.params)===null||s===void 0?void 0:s.safetySettings,generationConfig:(i=this.params)===null||i===void 0?void 0:i.generationConfig,tools:(o=this.params)===null||o===void 0?void 0:o.tools,toolConfig:(a=this.params)===null||a===void 0?void 0:a.toolConfig,systemInstruction:(u=this.params)===null||u===void 0?void 0:u.systemInstruction,cachedContent:(d=this.params)===null||d===void 0?void 0:d.cachedContent,contents:[...this._history,p]},r=Object.assign(Object.assign({},this._requestOptions),n);let c;return this._sendPromise=this._sendPromise.then(()=>ht(this._apiKey,this.model,l,r)).then(f=>{var g;if(nt(f.response)){this._history.push(p);const C=Object.assign({parts:[],role:"model"},(g=f.response.candidates)===null||g===void 0?void 0:g[0].content);this._history.push(C)}else{const C=O(f.response);C&&console.warn(`sendMessage() was unsuccessful. ${C}. Inspect response object for details.`)}c=f}).catch(f=>{throw this._sendPromise=Promise.resolve(),f}),await this._sendPromise,c}async sendMessageStream(e,n={}){var s,i,o,a,u,d;await this._sendPromise;const p=A(e),l={safetySettings:(s=this.params)===null||s===void 0?void 0:s.safetySettings,generationConfig:(i=this.params)===null||i===void 0?void 0:i.generationConfig,tools:(o=this.params)===null||o===void 0?void 0:o.tools,toolConfig:(a=this.params)===null||a===void 0?void 0:a.toolConfig,systemInstruction:(u=this.params)===null||u===void 0?void 0:u.systemInstruction,cachedContent:(d=this.params)===null||d===void 0?void 0:d.cachedContent,contents:[...this._history,p]},r=Object.assign(Object.assign({},this._requestOptions),n),c=gt(this._apiKey,this.model,l,r);return this._sendPromise=this._sendPromise.then(()=>c).catch(f=>{throw new Error(st)}).then(f=>f.response).then(f=>{if(nt(f)){this._history.push(p);const g=Object.assign({},f.candidates[0].content);g.role||(g.role="model"),this._history.push(g)}else{const g=O(f);g&&console.warn(`sendMessageStream() was unsuccessful. ${g}. Inspect response object for details.`)}}).catch(f=>{f.message!==st&&console.error(f)}),c}}async function _e(t,e,n,s){return(await R(e,v.COUNT_TOKENS,t,!1,JSON.stringify(n),s)).json()}async function Ee(t,e,n,s){return(await R(e,v.EMBED_CONTENT,t,!1,JSON.stringify(n),s)).json()}async function Te(t,e,n,s){const i=n.requests.map(a=>Object.assign(Object.assign({},a),{model:e}));return(await R(e,v.BATCH_EMBED_CONTENTS,t,!1,JSON.stringify({requests:i}),s)).json()}class it{constructor(e,n,s={}){this.apiKey=e,this._requestOptions=s,n.model.includes("/")?this.model=n.model:this.model=`models/${n.model}`,this.generationConfig=n.generationConfig||{},this.safetySettings=n.safetySettings||[],this.tools=n.tools,this.toolConfig=n.toolConfig,this.systemInstruction=mt(n.systemInstruction),this.cachedContent=n.cachedContent}async generateContent(e,n={}){var s;const i=tt(e),o=Object.assign(Object.assign({},this._requestOptions),n);return ht(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(s=this.cachedContent)===null||s===void 0?void 0:s.name},i),o)}async generateContentStream(e,n={}){var s;const i=tt(e),o=Object.assign(Object.assign({},this._requestOptions),n);return gt(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(s=this.cachedContent)===null||s===void 0?void 0:s.name},i),o)}startChat(e){var n;return new ve(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(n=this.cachedContent)===null||n===void 0?void 0:n.name},e),this._requestOptions)}async countTokens(e,n={}){const s=Ce(e,{model:this.model,generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:this.cachedContent}),i=Object.assign(Object.assign({},this._requestOptions),n);return _e(this.apiKey,this.model,s,i)}async embedContent(e,n={}){const s=Oe(e),i=Object.assign(Object.assign({},this._requestOptions),n);return Ee(this.apiKey,this.model,s,i)}async batchEmbedContents(e,n={}){const s=Object.assign(Object.assign({},this._requestOptions),n);return Te(this.apiKey,this.model,e,s)}}class M{constructor(e){this.apiKey=e}getGenerativeModel(e,n){if(!e.model)throw new m("Must provide a model name. Example: genai.getGenerativeModel({ model: 'my-model-name' })");return new it(this.apiKey,e,n)}getGenerativeModelFromCachedContent(e,n,s){if(!e.name)throw new y("Cached content must contain a `name` field.");if(!e.model)throw new y("Cached content must contain a `model` field.");const i=["model","systemInstruction"];for(const a of i)if(n?.[a]&&e[a]&&n?.[a]!==e[a]){if(a==="model"){const u=n.model.startsWith("models/")?n.model.replace("models/",""):n.model,d=e.model.startsWith("models/")?e.model.replace("models/",""):e.model;if(u===d)continue}throw new y(`Different value for "${a}" specified in modelParams (${n[a]}) and cachedContent (${e[a]})`)}const o=Object.assign(Object.assign({},n),{model:e.model,tools:e.tools,toolConfig:e.toolConfig,systemInstruction:e.systemInstruction,cachedContent:e});return new it(this.apiKey,o,s)}}function ot(t,e){const n=we(t);return{tools:n,toolConfig:Ae(n,e)}}function we(t){let e=[];const n=[];return t.forEach(s=>{if(at(s)){const[i]=Jt([s]);i.functionDeclarations&&e.push(...i.functionDeclarations)}else if(rt(s)){const{functionDeclarations:i}=Se(s);if(i)e.push(...i);else throw new Error("Failed to convert OpenAI structured tool to GenerativeAI tool")}else n.push(s)}),n.find(s=>"functionDeclarations"in s)?n.map(s=>{if(e?.length>0&&"functionDeclarations"in s){const i={functionDeclarations:[...s.functionDeclarations||[],...e]};return e=[],i}return s}):[...n,...e.length>0?[{functionDeclarations:e}]:[]]}function Se(t){return{functionDeclarations:[{name:t.function.name,description:t.function.description,parameters:I(t.function.parameters)}]}}function Ae(t,e){if(!t.length||!e)return;const{toolChoice:n,allowedFunctionNames:s}=e,i={any:T.ANY,auto:T.AUTO,none:T.NONE};if(n&&["any","auto","none"].includes(n))return{functionCallingConfig:{mode:i[n]??"MODE_UNSPECIFIED",allowedFunctionNames:s}};if(typeof n=="string"||s)return{functionCallingConfig:{mode:T.ANY,allowedFunctionNames:[...s??[],...n&&typeof n=="string"?[n]:[]]}}}const Re={"gemini-embedding-001":{maxInputTokens:2048,imageInputs:!1,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:3072,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.5-flash-lite-preview-09-2025":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-pro-preview-06-05":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash-preview-04-17":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.5-flash-preview-09-2025":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-pro-preview-05-06":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash-preview-05-20":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-live-2.5-flash":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-3-flash-preview":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-live-2.5-flash-preview-native-audio":{maxInputTokens:131072,imageInputs:!1,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.5-flash-lite":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash-preview-tts":{maxInputTokens:8e3,imageInputs:!1,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:16e3,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-flash-latest":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash-lite-preview-06-17":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.5-flash-image":{maxInputTokens:32768,imageInputs:!0,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:32768,reasoningOutput:!0,imageOutputs:!0,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.5-pro-preview-tts":{maxInputTokens:8e3,imageInputs:!1,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:16e3,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.5-flash-image-preview":{maxInputTokens:32768,imageInputs:!0,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:32768,reasoningOutput:!0,imageOutputs:!0,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-1.5-flash-8b":{maxInputTokens:1e6,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-3-pro-preview":{maxInputTokens:1e6,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:64e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.0-flash-lite":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-1.5-flash":{maxInputTokens:1e6,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-flash-lite-latest":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-pro":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.0-flash":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-1.5-pro":{maxInputTokens:1e6,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1}};var Ne=class extends yt{static lc_name(){return"ChatGoogleGenerativeAI"}lc_serializable=!0;get lc_secrets(){return{apiKey:"GOOGLE_API_KEY"}}lc_namespace=["langchain","chat_models","google_genai"];get lc_aliases(){return{apiKey:"google_api_key"}}model;temperature;maxOutputTokens;topP;topK;stopSequences=[];safetySettings;apiKey;streaming=!1;json;streamUsage=!0;convertSystemMessageToHumanContent;thinkingConfig;client;get _isMultimodalModel(){return this.model.includes("vision")||this.model.startsWith("gemini-1.5")||this.model.startsWith("gemini-2")||this.model.startsWith("gemma-3-")&&!this.model.startsWith("gemma-3-1b")||this.model.startsWith("gemini-3")}constructor(t){if(super(t),this.model=t.model.replace(/^models\//,""),this.maxOutputTokens=t.maxOutputTokens??this.maxOutputTokens,this.maxOutputTokens&&this.maxOutputTokens<0)throw new Error("`maxOutputTokens` must be a positive integer");if(this.temperature=t.temperature??this.temperature,this.temperature&&(this.temperature<0||this.temperature>2))throw new Error("`temperature` must be in the range of [0.0,2.0]");if(this.topP=t.topP??this.topP,this.topP&&this.topP<0)throw new Error("`topP` must be a positive integer");if(this.topP&&this.topP>1)throw new Error("`topP` must be below 1.");if(this.topK=t.topK??this.topK,this.topK&&this.topK<0)throw new Error("`topK` must be a positive integer");if(this.stopSequences=t.stopSequences??this.stopSequences,this.apiKey=t.apiKey??ct("GOOGLE_API_KEY"),!this.apiKey)throw new Error("Please set an API key for Google GenerativeAI in the environment variable GOOGLE_API_KEY or in the `apiKey` field of the ChatGoogleGenerativeAI constructor");if(this.safetySettings=t.safetySettings??this.safetySettings,this.safetySettings&&this.safetySettings.length>0&&new Set(this.safetySettings.map(e=>e.category)).size!==this.safetySettings.length)throw new Error("The categories in `safetySettings` array must be unique");this.streaming=t.streaming??this.streaming,this.json=t.json,this.thinkingConfig=t.thinkingConfig??this.thinkingConfig,this.client=new M(this.apiKey).getGenerativeModel({model:this.model,safetySettings:this.safetySettings,generationConfig:{stopSequences:this.stopSequences,maxOutputTokens:this.maxOutputTokens,temperature:this.temperature,topP:this.topP,topK:this.topK,...this.json?{responseMimeType:"application/json"}:{},...this.thinkingConfig?{thinkingConfig:this.thinkingConfig}:{}}},{apiVersion:t.apiVersion,baseUrl:t.baseUrl,customHeaders:t.customHeaders}),this.streamUsage=t.streamUsage??this.streamUsage}useCachedContent(t,e,n){this.apiKey&&(this.client=new M(this.apiKey).getGenerativeModelFromCachedContent(t,e,n))}get useSystemInstruction(){return typeof this.convertSystemMessageToHumanContent=="boolean"?!this.convertSystemMessageToHumanContent:this.computeUseSystemInstruction}get computeUseSystemInstruction(){return this.model==="gemini-1.0-pro-001"||this.model.startsWith("gemini-pro-vision")||this.model.startsWith("gemini-1.0-pro-vision")?!1:this.model!=="gemini-pro"}getLsParams(t){return{ls_provider:"google_genai",ls_model_name:this.model,ls_model_type:"chat",ls_temperature:this.client.generationConfig.temperature,ls_max_tokens:this.client.generationConfig.maxOutputTokens,ls_stop:t.stop}}_combineLLMOutput(){return[]}_llmType(){return"googlegenerativeai"}bindTools(t,e){return this.withConfig({tools:ot(t)?.tools,...e})}invocationParams(t){const e=t?.tools?.length?ot(t.tools,{toolChoice:t.tool_choice,allowedFunctionNames:t.allowedFunctionNames}):void 0;return t?.responseSchema?(this.client.generationConfig.responseSchema=t.responseSchema,this.client.generationConfig.responseMimeType="application/json"):(this.client.generationConfig.responseSchema=void 0,this.client.generationConfig.responseMimeType=this.json?"application/json":void 0),{...e?.tools?{tools:e.tools}:{},...e?.toolConfig?{toolConfig:e.toolConfig}:{}}}async _generate(t,e,n){e.signal?.throwIfAborted();const s=j(t,this._isMultimodalModel,this.useSystemInstruction,this.model);let i=s;if(s[0].role==="system"){const[p]=s;this.client.systemInstruction=p,i=s.slice(1)}const o=this.invocationParams(e);if(this.streaming){const p={},l=this._streamResponseChunks(t,e,n),r=[];for await(const c of l){const f=c.generationInfo?.completion??0;r[f]===void 0?r[f]=c:r[f]=r[f].concat(c)}return{generations:r.filter(c=>c!==void 0),llmOutput:{estimatedTokenUsage:p}}}const a=await this.completionWithRetry({...o,contents:i});let u;"usageMetadata"in a.response&&(u=K(a.response.usageMetadata,this.model));const d=Vt(a.response,{usageMetadata:u});return d.generations?.length>0&&await n?.handleLLMNewToken(d.generations[0]?.text??""),d}async*_streamResponseChunks(t,e,n){const s=j(t,this._isMultimodalModel,this.useSystemInstruction,this.model);let i=s;if(s[0].role==="system"){const[r]=s;this.client.systemInstruction=r,i=s.slice(1)}const o={...this.invocationParams(e),contents:i},a=await this.caller.callWithOptions({signal:e?.signal},async()=>{const{stream:r}=await this.client.generateContentStream(o,{signal:e?.signal});return r});let u,d=0,p=0,l=0;for await(const r of a){if(e.signal?.aborted)return;if("usageMetadata"in r&&r.usageMetadata!==void 0&&this.streamUsage!==!1&&e.streamUsage!==!1){u=K(r.usageMetadata,this.model);const f=r.usageMetadata.promptTokenCount??0;u.input_tokens=Math.max(0,f-d),d=f;const g=r.usageMetadata.candidatesTokenCount??0;u.output_tokens=Math.max(0,g-p),p=g;const C=r.usageMetadata.totalTokenCount??0;u.total_tokens=Math.max(0,C-l),l=C}const c=Wt(r,{usageMetadata:u});c&&(yield c,await n?.handleLLMNewToken(c.text??""))}}async completionWithRetry(t,e){return this.caller.callWithOptions({signal:e?.signal},async()=>{try{return await this.client.generateContent(t,{signal:e?.signal})}catch(n){throw n.message?.includes("400 Bad Request")&&(n.status=400),n}})}get profile(){return Re[this.model]??{}}withStructuredOutput(t,e){const n=t,s=e?.name,i=e?.method,o=e?.includeRaw;if(i==="jsonMode")throw new Error('ChatGoogleGenerativeAI only supports "jsonSchema" or "functionCalling" as a method.');let a,u;if(i==="functionCalling"){let r=s??"extract",c;if(ut(n)){const f=N(n);c=[{functionDeclarations:[{name:r,description:f.description??"A function available to call.",parameters:f}]}],u=new F({returnSingle:!0,keyName:r,zodSchema:n})}else{let f;typeof n.name=="string"&&typeof n.parameters=="object"&&n.parameters!=null?(f=n,f.parameters=I(n.parameters),r=n.name):f={name:r,description:n.description??"",parameters:I(n)},c=[{functionDeclarations:[f]}],u=new F({returnSingle:!0,keyName:r})}a=this.bindTools(c).withConfig({allowedFunctionNames:[r]})}else{const r=N(n);a=this.withConfig({responseSchema:r}),u=new It}if(!o)return a.pipe(u).withConfig({runName:"ChatGoogleGenerativeAIStructuredOutput"});const d=U.assign({parsed:(r,c)=>u.invoke(r.raw,c)}),p=U.assign({parsed:()=>null}),l=d.withFallbacks({fallbacks:[p]});return bt.from([{raw:a},l]).withConfig({runName:"StructuredOutputRunnable"})}},Me=class extends Nt{apiKey;modelName="embedding-001";model="embedding-001";taskType;title;stripNewLines=!0;maxBatchSize=100;client;constructor(t){if(super(t??{}),this.modelName=t?.model?.replace(/^models\//,"")??t?.modelName?.replace(/^models\//,"")??this.modelName,this.model=this.modelName,this.taskType=t?.taskType??this.taskType,this.title=t?.title??this.title,this.title&&this.taskType!=="RETRIEVAL_DOCUMENT")throw new Error("title can only be sepcified with TaskType.RETRIEVAL_DOCUMENT");if(this.apiKey=t?.apiKey??ct("GOOGLE_API_KEY"),!this.apiKey)throw new Error("Please set an API key for Google GenerativeAI in the environmentb variable GOOGLE_API_KEY or in the `apiKey` field of the GoogleGenerativeAIEmbeddings constructor");this.client=new M(this.apiKey).getGenerativeModel({model:this.model},{baseUrl:t?.baseUrl})}_convertToContent(t){return{content:{role:"user",parts:[{text:this.stripNewLines?t.replace(/\n/g," "):t}]},taskType:this.taskType,title:this.title}}async _embedQueryContent(t){const e=this._convertToContent(t);return(await this.client.embedContent(e)).embedding.values??[]}async _embedDocumentsContent(t){const e=Mt(t,this.maxBatchSize),n=e.map(s=>({requests:s.map(i=>this._convertToContent(i))}));return(await Promise.allSettled(n.map(s=>this.client.batchEmbedContents(s)))).flatMap((s,i)=>s.status==="fulfilled"?s.value.embeddings.map(o=>o.values||[]):Array(e[i].length).fill([]))}embedQuery(t){return this.caller.call(this._embedQueryContent.bind(this),t)}embedDocuments(t){return this.caller.call(this._embedDocumentsContent.bind(this),t)}};export{Ne as ChatGoogleGenerativeAI,Me as GoogleGenerativeAIEmbeddings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a}from"./index-
|
|
1
|
+
import{r as a}from"./index-BQDf_2QT.js";import{r as s}from"./inform7-CKh91FfW.js";function c(t,f){for(var o=0;o<f.length;o++){const r=f[o];if(typeof r!="string"&&!Array.isArray(r)){for(const e in r)if(e!=="default"&&!(e in t)){const n=Object.getOwnPropertyDescriptor(r,e);n&&Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>r[e]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var i=s();const m=a(i),l=c({__proto__:null,default:m},[i]);export{l as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as f}from"./index-
|
|
1
|
+
import{r as f}from"./index-BQDf_2QT.js";import{r as s}from"./ini-CUN5Fz6a.js";function c(t,n){for(var o=0;o<n.length;o++){const e=n[o];if(typeof e!="string"&&!Array.isArray(e)){for(const r in e)if(r!=="default"&&!(r in t)){const i=Object.getOwnPropertyDescriptor(e,r);i&&Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var a=s();const p=f(a),g=c({__proto__:null,default:p},[a]);export{g as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p}from"./index-
|
|
1
|
+
import{r as p}from"./index-BQDf_2QT.js";import{r as a}from"./irpf90-BGwK5upn.js";function s(t,i){for(var o=0;o<i.length;o++){const r=i[o];if(typeof r!="string"&&!Array.isArray(r)){for(const e in r)if(e!=="default"&&!(e in t)){const f=Object.getOwnPropertyDescriptor(r,e);f&&Object.defineProperty(t,e,f.get?f:{enumerable:!0,get:()=>r[e]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var n=a();const c=p(n),g=s({__proto__:null,default:c},[n]);export{g as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a}from"./index-
|
|
1
|
+
import{r as a}from"./index-BQDf_2QT.js";import{r as f}from"./isbl-BW2-1xqY.js";function l(t,i){for(var o=0;o<i.length;o++){const e=i[o];if(typeof e!="string"&&!Array.isArray(e)){for(const r in e)if(r!=="default"&&!(r in t)){const s=Object.getOwnPropertyDescriptor(e,r);s&&Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:()=>e[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var n=f();const c=a(n),b=l({__proto__:null,default:c},[n]);export{b as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s}from"./index-
|
|
1
|
+
import{r as s}from"./index-BQDf_2QT.js";import{r as i}from"./java-BopHZ59q.js";function c(t,n){for(var o=0;o<n.length;o++){const e=n[o];if(typeof e!="string"&&!Array.isArray(e)){for(const r in e)if(r!=="default"&&!(r in t)){const a=Object.getOwnPropertyDescriptor(e,r);a&&Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var f=i();const p=s(f),g=c({__proto__:null,default:p},[f]);export{g as j};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c}from"./index-
|
|
1
|
+
import{r as c}from"./index-BQDf_2QT.js";import{r as n}from"./javascript-Bcajz3YC.js";function p(t,s){for(var o=0;o<s.length;o++){const r=s[o];if(typeof r!="string"&&!Array.isArray(r)){for(const e in r)if(e!=="default"&&!(e in t)){const a=Object.getOwnPropertyDescriptor(r,e);a&&Object.defineProperty(t,e,a.get?a:{enumerable:!0,get:()=>r[e]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var i=n();const f=c(i),g=p({__proto__:null,default:f},[i]);export{g as j};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a}from"./index-
|
|
1
|
+
import{r as a}from"./index-BQDf_2QT.js";import{r as f}from"./jboss-cli-7Bb2wtKY.js";function l(t,i){for(var o=0;o<i.length;o++){const e=i[o];if(typeof e!="string"&&!Array.isArray(e)){for(const r in e)if(r!=="default"&&!(r in t)){const s=Object.getOwnPropertyDescriptor(e,r);s&&Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:()=>e[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var n=f();const c=a(n),b=l({__proto__:null,default:c},[n]);export{b as j};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as f}from"./index-
|
|
1
|
+
import{r as f}from"./index-BQDf_2QT.js";import{r as i}from"./json-_cGKMkqV.js";function c(t,s){for(var o=0;o<s.length;o++){const e=s[o];if(typeof e!="string"&&!Array.isArray(e)){for(const r in e)if(r!=="default"&&!(r in t)){const n=Object.getOwnPropertyDescriptor(e,r);n&&Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var a=i();const p=f(a),g=c({__proto__:null,default:p},[a]);export{g as j};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as f}from"./index-
|
|
1
|
+
import{r as f}from"./index-BQDf_2QT.js";import{r as s}from"./julia-CflsGA1_.js";function u(t,i){for(var o=0;o<i.length;o++){const e=i[o];if(typeof e!="string"&&!Array.isArray(e)){for(const r in e)if(r!=="default"&&!(r in t)){const a=Object.getOwnPropertyDescriptor(e,r);a&&Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var n=s();const l=f(n),g=u({__proto__:null,default:l},[n]);export{g as j};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n}from"./index-
|
|
1
|
+
import{r as n}from"./index-BQDf_2QT.js";import{r as p}from"./julia-repl-DTkCRO_Z.js";function f(t,l){for(var o=0;o<l.length;o++){const e=l[o];if(typeof e!="string"&&!Array.isArray(e)){for(const r in e)if(r!=="default"&&!(r in t)){const a=Object.getOwnPropertyDescriptor(e,r);a&&Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var i=p();const s=n(i),g=f({__proto__:null,default:s},[i]);export{g as j};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as f}from"./index-
|
|
1
|
+
import{r as f}from"./index-BQDf_2QT.js";import{r as s}from"./kotlin-DSmpQSGN.js";function l(r,i){for(var o=0;o<i.length;o++){const e=i[o];if(typeof e!="string"&&!Array.isArray(e)){for(const t in e)if(t!=="default"&&!(t in r)){const n=Object.getOwnPropertyDescriptor(e,t);n&&Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}var a=s();const c=f(a),g=l({__proto__:null,default:c},[a]);export{g as k};
|