drizzle-cube 0.4.29 → 0.4.30
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/adapters/anthropic-BIva8k1r.cjs +1 -0
- package/dist/adapters/anthropic-B_rg0BhK.js +140 -0
- package/dist/adapters/dist-Boc63-1q.cjs +2 -0
- package/dist/adapters/dist-De5fzUEM.js +581 -0
- package/dist/adapters/express/index.cjs +2 -10
- package/dist/adapters/express/index.js +232 -342
- package/dist/adapters/fastify/index.cjs +2 -10
- package/dist/adapters/fastify/index.js +275 -424
- package/dist/adapters/google-CT4kgmBf.js +154 -0
- package/dist/adapters/google-Dgo9-Kb5.cjs +2 -0
- package/dist/adapters/handler-B8vuFQYP.cjs +25 -0
- package/dist/adapters/handler-D-2-6uLM.js +2951 -0
- package/dist/adapters/hono/index.cjs +2 -10
- package/dist/adapters/hono/index.js +307 -402
- package/dist/adapters/mcp-prompts-BAutSQYA.js +344 -0
- package/dist/adapters/mcp-prompts-DsAkafVn.cjs +5 -0
- package/dist/adapters/mcp-transport-CuugoG8t.js +7821 -0
- package/dist/adapters/mcp-transport-Dpp6hdZe.cjs +253 -0
- package/dist/adapters/nextjs/index.cjs +1 -9
- package/dist/adapters/nextjs/index.js +377 -600
- package/dist/adapters/openai-CjBvA6mK.js +4114 -0
- package/dist/adapters/openai-DhLE0A9Z.cjs +1 -0
- package/dist/adapters/openai-Zjw4Zo4R.js +153 -0
- package/dist/adapters/openai-eJBw3LfQ.cjs +16 -0
- package/dist/adapters/types.cjs +0 -1
- package/dist/adapters/types.js +0 -1
- package/dist/adapters/utils-ChhNGUOF.js +5396 -0
- package/dist/adapters/utils-CwJplXR5.cjs +15 -0
- package/dist/adapters/utils.cjs +1 -19
- package/dist/adapters/utils.js +2 -21333
- package/dist/client/charts.js +15 -186
- package/dist/client/chunks/DashboardEditModal-C076pscL.js +6678 -0
- package/dist/client/chunks/DashboardEditModal-C076pscL.js.map +1 -0
- package/dist/client/chunks/FieldSearchModal-C0DjSWk3.js +2631 -0
- package/dist/client/chunks/FieldSearchModal-C0DjSWk3.js.map +1 -0
- package/dist/client/chunks/RetentionCombinedChart-DuGXc-AP.js +270 -0
- package/dist/client/chunks/RetentionCombinedChart-DuGXc-AP.js.map +1 -0
- package/dist/client/chunks/RetentionCombinedChart.config-DprbXd1N.js +56 -0
- package/dist/client/chunks/RetentionCombinedChart.config-DprbXd1N.js.map +1 -0
- package/dist/client/chunks/RetentionHeatmap-BoGY6mlZ.js +193 -0
- package/dist/client/chunks/RetentionHeatmap-BoGY6mlZ.js.map +1 -0
- package/dist/client/chunks/RetentionHeatmap.config-cbaNExVy.js +25 -0
- package/dist/client/chunks/RetentionHeatmap.config-cbaNExVy.js.map +1 -0
- package/dist/client/chunks/analysis-builder-DF0XntqC.js +6111 -0
- package/dist/client/chunks/analysis-builder-DF0XntqC.js.map +1 -0
- package/dist/client/chunks/analysis-builder-shared-2QhKYbs6.js +3114 -0
- package/dist/client/chunks/analysis-builder-shared-2QhKYbs6.js.map +1 -0
- package/dist/client/chunks/chart-activity-grid-CNES9VBk.js +803 -0
- package/dist/client/chunks/chart-activity-grid-CNES9VBk.js.map +1 -0
- package/dist/client/chunks/chart-area-CRJc3KOu.js +449 -0
- package/dist/client/chunks/chart-area-CRJc3KOu.js.map +1 -0
- package/dist/client/chunks/chart-bar-DD2PjJ5n.js +270 -0
- package/dist/client/chunks/chart-bar-DD2PjJ5n.js.map +1 -0
- package/dist/client/chunks/chart-box-plot-BcqleldJ.js +377 -0
- package/dist/client/chunks/chart-box-plot-BcqleldJ.js.map +1 -0
- package/dist/client/chunks/chart-bubble-BmQkVk4K.js +273 -0
- package/dist/client/chunks/chart-bubble-BmQkVk4K.js.map +1 -0
- package/dist/client/chunks/chart-candlestick-C3Rep469.js +306 -0
- package/dist/client/chunks/chart-candlestick-C3Rep469.js.map +1 -0
- package/dist/client/chunks/chart-config-activity-grid-USo7JrPh.js +51 -0
- package/dist/client/chunks/chart-config-activity-grid-USo7JrPh.js.map +1 -0
- package/dist/client/chunks/chart-config-area-D_ZufYzg.js +93 -0
- package/dist/client/chunks/chart-config-area-D_ZufYzg.js.map +1 -0
- package/dist/client/chunks/chart-config-bar-BCi2Wmd6.js +87 -0
- package/dist/client/chunks/chart-config-bar-BCi2Wmd6.js.map +1 -0
- package/dist/client/chunks/chart-config-box-plot-afKLzJSp.js +35 -0
- package/dist/client/chunks/chart-config-box-plot-afKLzJSp.js.map +1 -0
- package/dist/client/chunks/chart-config-bubble-CgbBjPv8.js +82 -0
- package/dist/client/chunks/chart-config-bubble-CgbBjPv8.js.map +1 -0
- package/dist/client/chunks/chart-config-candlestick-7boGjZ-A.js +72 -0
- package/dist/client/chunks/chart-config-candlestick-7boGjZ-A.js.map +1 -0
- package/dist/client/chunks/chart-config-data-table-Cl7sBasW.js +30 -0
- package/dist/client/chunks/chart-config-data-table-Cl7sBasW.js.map +1 -0
- package/dist/client/chunks/chart-config-funnel-CXPYQtTl.js +93 -0
- package/dist/client/chunks/chart-config-funnel-CXPYQtTl.js.map +1 -0
- package/dist/client/chunks/chart-config-gauge-DUNEUCvh.js +64 -0
- package/dist/client/chunks/chart-config-gauge-DUNEUCvh.js.map +1 -0
- package/dist/client/chunks/chart-config-heat-map-BFf1tO11.js +91 -0
- package/dist/client/chunks/chart-config-heat-map-BFf1tO11.js.map +1 -0
- package/dist/client/chunks/chart-config-kpi-delta-C5k2waIJ.js +94 -0
- package/dist/client/chunks/chart-config-kpi-delta-C5k2waIJ.js.map +1 -0
- package/dist/client/chunks/chart-config-kpi-number-DptOyhk0.js +75 -0
- package/dist/client/chunks/chart-config-kpi-number-DptOyhk0.js.map +1 -0
- package/dist/client/chunks/chart-config-kpi-text-D9DdVWqd.js +47 -0
- package/dist/client/chunks/chart-config-kpi-text-D9DdVWqd.js.map +1 -0
- package/dist/client/chunks/chart-config-line-B3NgLF7K.js +104 -0
- package/dist/client/chunks/chart-config-line-B3NgLF7K.js.map +1 -0
- package/dist/client/chunks/chart-config-markdown-tlfivQTt.js +117 -0
- package/dist/client/chunks/chart-config-markdown-tlfivQTt.js.map +1 -0
- package/dist/client/chunks/chart-config-measure-profile-D7XDwrU2.js +82 -0
- package/dist/client/chunks/chart-config-measure-profile-D7XDwrU2.js.map +1 -0
- package/dist/client/chunks/chart-config-pie-wY0B52PC.js +68 -0
- package/dist/client/chunks/chart-config-pie-wY0B52PC.js.map +1 -0
- package/dist/client/chunks/chart-config-radar-DRpJBy1M.js +49 -0
- package/dist/client/chunks/chart-config-radar-DRpJBy1M.js.map +1 -0
- package/dist/client/chunks/chart-config-radial-bar-DCUpXv9G.js +38 -0
- package/dist/client/chunks/chart-config-radial-bar-DCUpXv9G.js.map +1 -0
- package/dist/client/chunks/chart-config-sankey-CdOhlm4h.js +66 -0
- package/dist/client/chunks/chart-config-sankey-CdOhlm4h.js.map +1 -0
- package/dist/client/chunks/chart-config-scatter-B2su_x8f.js +61 -0
- package/dist/client/chunks/chart-config-scatter-B2su_x8f.js.map +1 -0
- package/dist/client/chunks/chart-config-sunburst-BPdjbk18.js +45 -0
- package/dist/client/chunks/chart-config-sunburst-BPdjbk18.js.map +1 -0
- package/dist/client/chunks/chart-config-tree-map-Cbsh2fe2.js +51 -0
- package/dist/client/chunks/chart-config-tree-map-Cbsh2fe2.js.map +1 -0
- package/dist/client/chunks/chart-config-waterfall-DGmuZfQF.js +59 -0
- package/dist/client/chunks/chart-config-waterfall-DGmuZfQF.js.map +1 -0
- package/dist/client/chunks/chart-data-table-DehW1C1G.js +4088 -0
- package/dist/client/chunks/chart-data-table-DehW1C1G.js.map +1 -0
- package/dist/client/chunks/chart-funnel-BjkpnG5g.js +447 -0
- package/dist/client/chunks/chart-funnel-BjkpnG5g.js.map +1 -0
- package/dist/client/chunks/chart-gauge-BWW_HEfg.js +424 -0
- package/dist/client/chunks/chart-gauge-BWW_HEfg.js.map +1 -0
- package/dist/client/chunks/chart-heat-map-BWuOuDcm.js +236 -0
- package/dist/client/chunks/chart-heat-map-BWuOuDcm.js.map +1 -0
- package/dist/client/chunks/chart-kpi-delta-D5OHtDJx.js +343 -0
- package/dist/client/chunks/chart-kpi-delta-D5OHtDJx.js.map +1 -0
- package/dist/client/chunks/chart-kpi-number-C9zH-aKC.js +326 -0
- package/dist/client/chunks/chart-kpi-number-C9zH-aKC.js.map +1 -0
- package/dist/client/chunks/chart-kpi-text-ChVn3S7j.js +149 -0
- package/dist/client/chunks/chart-kpi-text-ChVn3S7j.js.map +1 -0
- package/dist/client/chunks/chart-line-DOIMkP0b.js +431 -0
- package/dist/client/chunks/chart-line-DOIMkP0b.js.map +1 -0
- package/dist/client/chunks/chart-markdown-DXxc43w1.js +3457 -0
- package/dist/client/chunks/chart-markdown-DXxc43w1.js.map +1 -0
- package/dist/client/chunks/chart-measure-profile-C6wrr9il.js +179 -0
- package/dist/client/chunks/chart-measure-profile-C6wrr9il.js.map +1 -0
- package/dist/client/chunks/chart-pie-BU_FgwDc.js +172 -0
- package/dist/client/chunks/chart-pie-BU_FgwDc.js.map +1 -0
- package/dist/client/chunks/chart-radar-DlufwnAX.js +154 -0
- package/dist/client/chunks/chart-radar-DlufwnAX.js.map +1 -0
- package/dist/client/chunks/chart-radial-bar-B5vS_Aw5.js +148 -0
- package/dist/client/chunks/chart-radial-bar-B5vS_Aw5.js.map +1 -0
- package/dist/client/chunks/chart-sankey-FChb26UX.js +222 -0
- package/dist/client/chunks/chart-sankey-FChb26UX.js.map +1 -0
- package/dist/client/chunks/chart-scatter-DW0cAZ2H.js +255 -0
- package/dist/client/chunks/chart-scatter-DW0cAZ2H.js.map +1 -0
- package/dist/client/chunks/chart-sunburst-Clf-6WxW.js +221 -0
- package/dist/client/chunks/chart-sunburst-Clf-6WxW.js.map +1 -0
- package/dist/client/chunks/chart-tree-map-p_VwUJPF.js +298 -0
- package/dist/client/chunks/chart-tree-map-p_VwUJPF.js.map +1 -0
- package/dist/client/chunks/chart-waterfall-jt44IQ-w.js +237 -0
- package/dist/client/chunks/chart-waterfall-jt44IQ-w.js.map +1 -0
- package/dist/client/chunks/charts-core-CUVzf4cV.js +215 -0
- package/dist/client/chunks/charts-core-CUVzf4cV.js.map +1 -0
- package/dist/client/chunks/charts-loader-AGpph8_I.js +259 -0
- package/dist/client/chunks/charts-loader-AGpph8_I.js.map +1 -0
- package/dist/client/chunks/core-D1TOj17W.js +845 -0
- package/dist/client/chunks/core-D1TOj17W.js.map +1 -0
- package/dist/client/chunks/dist-DDBeV_JI.js +847 -0
- package/dist/client/chunks/dist-DDBeV_JI.js.map +1 -0
- package/dist/client/chunks/javascript-BBwTSo6e.js +438 -0
- package/dist/client/chunks/javascript-BBwTSo6e.js.map +1 -0
- package/dist/client/chunks/json-BpTrLZSh.js +38 -0
- package/dist/client/chunks/json-BpTrLZSh.js.map +1 -0
- package/dist/client/chunks/lazyChartConfigRegistry-BjhxDaSf.js +149 -0
- package/dist/client/chunks/lazyChartConfigRegistry-BjhxDaSf.js.map +1 -0
- package/dist/client/chunks/providers-DX3Vw5kc.js +7 -0
- package/dist/client/chunks/providers-DX3Vw5kc.js.map +1 -0
- package/dist/client/chunks/retention-UEXlSdZ-.js +132 -0
- package/dist/client/chunks/retention-UEXlSdZ-.js.map +1 -0
- package/dist/client/chunks/rolldown-runtime-lc2dmIiU.js +20 -0
- package/dist/client/chunks/schema-visualization-ZugB4Io9.js +1073 -0
- package/dist/client/chunks/schema-visualization-ZugB4Io9.js.map +1 -0
- package/dist/client/chunks/sql-B0chxcEK.js +120 -0
- package/dist/client/chunks/sql-B0chxcEK.js.map +1 -0
- package/dist/client/chunks/syntaxHighlighting-87bOwTxj.js +30 -0
- package/dist/client/chunks/syntaxHighlighting-87bOwTxj.js.map +1 -0
- package/dist/client/chunks/useDebounce-BQjNWndQ.js +1394 -0
- package/dist/client/chunks/useDebounce-BQjNWndQ.js.map +1 -0
- package/dist/client/chunks/useDirtyStateTracking-CgKZWkel.js +66 -0
- package/dist/client/chunks/useDirtyStateTracking-CgKZWkel.js.map +1 -0
- package/dist/client/chunks/useExplainAI-c_bHxZe5.js +203 -0
- package/dist/client/chunks/useExplainAI-c_bHxZe5.js.map +1 -0
- package/dist/client/chunks/useNotebookLayout-BFZ_33Kb.js +37 -0
- package/dist/client/chunks/useNotebookLayout-BFZ_33Kb.js.map +1 -0
- package/dist/client/chunks/utils-A54Ny29G.js +128 -0
- package/dist/client/chunks/utils-A54Ny29G.js.map +1 -0
- package/dist/client/chunks/vendor-CoPBRumI.js +828 -0
- package/dist/client/chunks/vendor-CoPBRumI.js.map +1 -0
- package/dist/client/components.js +4 -18
- package/dist/client/hooks.js +6 -58
- package/dist/client/icons.js +2 -15
- package/dist/client/index.js +1061 -1295
- package/dist/client/index.js.map +1 -1
- package/dist/client/providers.js +3 -9
- package/dist/client/styles.css +2 -1
- package/dist/client/types.d.ts +1 -0
- package/dist/client/utils.js +7 -74
- package/dist/client-bundle-stats.html +1 -1
- package/dist/server/anthropic-BsNspi1r.js +140 -0
- package/dist/server/anthropic-DsCEX6Fm.cjs +1 -0
- package/dist/server/dist-CMWZC51B.js +581 -0
- package/dist/server/dist-DxegvyZF.cjs +2 -0
- package/dist/server/google-BXwMolCu.js +154 -0
- package/dist/server/google-DzQWXFwF.cjs +2 -0
- package/dist/server/index.cjs +109 -129
- package/dist/server/index.js +15089 -34394
- package/dist/server/openai-BPhmb8mi.js +4114 -0
- package/dist/server/openai-CLsoLaue.cjs +1 -0
- package/dist/server/openai-D1kZ5sdM.js +153 -0
- package/dist/server/openai-DkOKbVLC.cjs +16 -0
- package/package.json +5 -5
- package/dist/adapters/anthropic-BTkjgFpT.cjs +0 -1
- package/dist/adapters/anthropic-CTu9E801.js +0 -126
- package/dist/adapters/google-BAK9pnQf.cjs +0 -2
- package/dist/adapters/google-DficVAsJ.js +0 -146
- package/dist/adapters/handler-BHguLZOY.js +0 -2713
- package/dist/adapters/handler-DOIyiFPg.cjs +0 -39
- package/dist/adapters/index-BgCeQBuN.cjs +0 -2
- package/dist/adapters/index-C3PskWTr.js +0 -5353
- package/dist/adapters/index-C45_meK_.js +0 -719
- package/dist/adapters/index-ht4NPca9.cjs +0 -23
- package/dist/adapters/mcp-transport-CWGqDQSI.cjs +0 -259
- package/dist/adapters/mcp-transport-CyeHMDPl.js +0 -11055
- package/dist/adapters/openai-BvA6eLs8.cjs +0 -1
- package/dist/adapters/openai-mcE24du8.js +0 -131
- package/dist/client/charts.js.map +0 -1
- package/dist/client/chunks/RetentionCombinedChart--SnU4Y_I.js +0 -256
- package/dist/client/chunks/RetentionCombinedChart--SnU4Y_I.js.map +0 -1
- package/dist/client/chunks/RetentionCombinedChart.config-Bbp2ghim.js +0 -48
- package/dist/client/chunks/RetentionCombinedChart.config-Bbp2ghim.js.map +0 -1
- package/dist/client/chunks/RetentionHeatmap-BHYU8MXY.js +0 -178
- package/dist/client/chunks/RetentionHeatmap-BHYU8MXY.js.map +0 -1
- package/dist/client/chunks/RetentionHeatmap.config-BWf_-vdj.js +0 -29
- package/dist/client/chunks/RetentionHeatmap.config-BWf_-vdj.js.map +0 -1
- package/dist/client/chunks/analysis-builder-DMFoAkjT.js +0 -6203
- package/dist/client/chunks/analysis-builder-DMFoAkjT.js.map +0 -1
- package/dist/client/chunks/analysis-builder-shared-CunrT3gi.js +0 -3140
- package/dist/client/chunks/analysis-builder-shared-CunrT3gi.js.map +0 -1
- package/dist/client/chunks/chart-activity-grid-DCznpK6N.js +0 -347
- package/dist/client/chunks/chart-activity-grid-DCznpK6N.js.map +0 -1
- package/dist/client/chunks/chart-area-CqKRIUpj.js +0 -234
- package/dist/client/chunks/chart-area-CqKRIUpj.js.map +0 -1
- package/dist/client/chunks/chart-bar-Bl5jvrU_.js +0 -267
- package/dist/client/chunks/chart-bar-Bl5jvrU_.js.map +0 -1
- package/dist/client/chunks/chart-box-plot-CzMb00z_.js +0 -322
- package/dist/client/chunks/chart-box-plot-CzMb00z_.js.map +0 -1
- package/dist/client/chunks/chart-bubble-BF8Z52eW.js +0 -249
- package/dist/client/chunks/chart-bubble-BF8Z52eW.js.map +0 -1
- package/dist/client/chunks/chart-candlestick-ByWS945g.js +0 -269
- package/dist/client/chunks/chart-candlestick-ByWS945g.js.map +0 -1
- package/dist/client/chunks/chart-config-activity-grid-CmOqDuOT.js +0 -50
- package/dist/client/chunks/chart-config-activity-grid-CmOqDuOT.js.map +0 -1
- package/dist/client/chunks/chart-config-area-CK_GVApT.js +0 -77
- package/dist/client/chunks/chart-config-area-CK_GVApT.js.map +0 -1
- package/dist/client/chunks/chart-config-bar-C8uzktxl.js +0 -71
- package/dist/client/chunks/chart-config-bar-C8uzktxl.js.map +0 -1
- package/dist/client/chunks/chart-config-box-plot-D_E_SSc2.js +0 -38
- package/dist/client/chunks/chart-config-box-plot-D_E_SSc2.js.map +0 -1
- package/dist/client/chunks/chart-config-bubble-q3DoQX5F.js +0 -71
- package/dist/client/chunks/chart-config-bubble-q3DoQX5F.js.map +0 -1
- package/dist/client/chunks/chart-config-candlestick-CRCpD43-.js +0 -70
- package/dist/client/chunks/chart-config-candlestick-CRCpD43-.js.map +0 -1
- package/dist/client/chunks/chart-config-data-table-B20Y5JCm.js +0 -28
- package/dist/client/chunks/chart-config-data-table-B20Y5JCm.js.map +0 -1
- package/dist/client/chunks/chart-config-funnel-3eYnGg8M.js +0 -92
- package/dist/client/chunks/chart-config-funnel-3eYnGg8M.js.map +0 -1
- package/dist/client/chunks/chart-config-gauge-CQx9w3d4.js +0 -64
- package/dist/client/chunks/chart-config-gauge-CQx9w3d4.js.map +0 -1
- package/dist/client/chunks/chart-config-heat-map-_wEnTnRA.js +0 -77
- package/dist/client/chunks/chart-config-heat-map-_wEnTnRA.js.map +0 -1
- package/dist/client/chunks/chart-config-kpi-delta-DLGZ2A3X.js +0 -97
- package/dist/client/chunks/chart-config-kpi-delta-DLGZ2A3X.js.map +0 -1
- package/dist/client/chunks/chart-config-kpi-number-K-wzviXF.js +0 -75
- package/dist/client/chunks/chart-config-kpi-number-K-wzviXF.js.map +0 -1
- package/dist/client/chunks/chart-config-kpi-text-BjYqwqaJ.js +0 -47
- package/dist/client/chunks/chart-config-kpi-text-BjYqwqaJ.js.map +0 -1
- package/dist/client/chunks/chart-config-line-JNagi9tf.js +0 -88
- package/dist/client/chunks/chart-config-line-JNagi9tf.js.map +0 -1
- package/dist/client/chunks/chart-config-markdown-BWQSjJpy.js +0 -97
- package/dist/client/chunks/chart-config-markdown-BWQSjJpy.js.map +0 -1
- package/dist/client/chunks/chart-config-measure-profile-ZYaMrtws.js +0 -70
- package/dist/client/chunks/chart-config-measure-profile-ZYaMrtws.js.map +0 -1
- package/dist/client/chunks/chart-config-pie-CNLXb-fr.js +0 -39
- package/dist/client/chunks/chart-config-pie-CNLXb-fr.js.map +0 -1
- package/dist/client/chunks/chart-config-radar-oxHfRAa3.js +0 -44
- package/dist/client/chunks/chart-config-radar-oxHfRAa3.js.map +0 -1
- package/dist/client/chunks/chart-config-radial-bar-_Aw3jAEm.js +0 -37
- package/dist/client/chunks/chart-config-radial-bar-_Aw3jAEm.js.map +0 -1
- package/dist/client/chunks/chart-config-sankey-C8FX9hGF.js +0 -61
- package/dist/client/chunks/chart-config-sankey-C8FX9hGF.js.map +0 -1
- package/dist/client/chunks/chart-config-scatter-DFKM80eO.js +0 -53
- package/dist/client/chunks/chart-config-scatter-DFKM80eO.js.map +0 -1
- package/dist/client/chunks/chart-config-sunburst-BmC0NLTU.js +0 -50
- package/dist/client/chunks/chart-config-sunburst-BmC0NLTU.js.map +0 -1
- package/dist/client/chunks/chart-config-tree-map-DGMbNTaa.js +0 -47
- package/dist/client/chunks/chart-config-tree-map-DGMbNTaa.js.map +0 -1
- package/dist/client/chunks/chart-config-waterfall-DTyXV_fo.js +0 -60
- package/dist/client/chunks/chart-config-waterfall-DTyXV_fo.js.map +0 -1
- package/dist/client/chunks/chart-data-table-HwfF-Ujv.js +0 -293
- package/dist/client/chunks/chart-data-table-HwfF-Ujv.js.map +0 -1
- package/dist/client/chunks/chart-funnel-WmuoWlCq.js +0 -259
- package/dist/client/chunks/chart-funnel-WmuoWlCq.js.map +0 -1
- package/dist/client/chunks/chart-gauge-Cot4By-w.js +0 -374
- package/dist/client/chunks/chart-gauge-Cot4By-w.js.map +0 -1
- package/dist/client/chunks/chart-heat-map-bGNtsZMr.js +0 -231
- package/dist/client/chunks/chart-heat-map-bGNtsZMr.js.map +0 -1
- package/dist/client/chunks/chart-kpi-delta-DeyKMxgq.js +0 -351
- package/dist/client/chunks/chart-kpi-delta-DeyKMxgq.js.map +0 -1
- package/dist/client/chunks/chart-kpi-number-D1z1gxXO.js +0 -476
- package/dist/client/chunks/chart-kpi-number-D1z1gxXO.js.map +0 -1
- package/dist/client/chunks/chart-kpi-text-b7q6KWc0.js +0 -165
- package/dist/client/chunks/chart-kpi-text-b7q6KWc0.js.map +0 -1
- package/dist/client/chunks/chart-line-3Nf-EPqJ.js +0 -450
- package/dist/client/chunks/chart-line-3Nf-EPqJ.js.map +0 -1
- package/dist/client/chunks/chart-markdown-BT_-MBq1.js +0 -2721
- package/dist/client/chunks/chart-markdown-BT_-MBq1.js.map +0 -1
- package/dist/client/chunks/chart-measure-profile-BVjUonqU.js +0 -114
- package/dist/client/chunks/chart-measure-profile-BVjUonqU.js.map +0 -1
- package/dist/client/chunks/chart-pie-DblG6w7g.js +0 -137
- package/dist/client/chunks/chart-pie-DblG6w7g.js.map +0 -1
- package/dist/client/chunks/chart-radar-BHZbeeTg.js +0 -129
- package/dist/client/chunks/chart-radar-BHZbeeTg.js.map +0 -1
- package/dist/client/chunks/chart-radial-bar-AlEJC1Jo.js +0 -119
- package/dist/client/chunks/chart-radial-bar-AlEJC1Jo.js.map +0 -1
- package/dist/client/chunks/chart-sankey-E8vYKjQF.js +0 -189
- package/dist/client/chunks/chart-sankey-E8vYKjQF.js.map +0 -1
- package/dist/client/chunks/chart-scatter-Bbxqi0iw.js +0 -202
- package/dist/client/chunks/chart-scatter-Bbxqi0iw.js.map +0 -1
- package/dist/client/chunks/chart-sunburst-BgnTKolT.js +0 -188
- package/dist/client/chunks/chart-sunburst-BgnTKolT.js.map +0 -1
- package/dist/client/chunks/chart-tree-map-i9LGCLwl.js +0 -284
- package/dist/client/chunks/chart-tree-map-i9LGCLwl.js.map +0 -1
- package/dist/client/chunks/chart-waterfall-BeIhCm83.js +0 -191
- package/dist/client/chunks/chart-waterfall-BeIhCm83.js.map +0 -1
- package/dist/client/chunks/charts-core-BUUO36OM.js +0 -692
- package/dist/client/chunks/charts-core-BUUO36OM.js.map +0 -1
- package/dist/client/chunks/charts-loader-goTYnavu.js +0 -258
- package/dist/client/chunks/charts-loader-goTYnavu.js.map +0 -1
- package/dist/client/chunks/components-BFgYvFq6.js +0 -10066
- package/dist/client/chunks/components-BFgYvFq6.js.map +0 -1
- package/dist/client/chunks/core-Y9e-sNfb.js +0 -1068
- package/dist/client/chunks/core-Y9e-sNfb.js.map +0 -1
- package/dist/client/chunks/flow-utils-CjQZG5qq.js +0 -16
- package/dist/client/chunks/flow-utils-CjQZG5qq.js.map +0 -1
- package/dist/client/chunks/funnel-utils-CyonoNeC.js +0 -135
- package/dist/client/chunks/funnel-utils-CyonoNeC.js.map +0 -1
- package/dist/client/chunks/icons-CwvgmdIP.js +0 -1636
- package/dist/client/chunks/icons-CwvgmdIP.js.map +0 -1
- package/dist/client/chunks/index-CApFCBF9.js +0 -81
- package/dist/client/chunks/index-CApFCBF9.js.map +0 -1
- package/dist/client/chunks/index-_2PSgbkC.js +0 -1046
- package/dist/client/chunks/index-_2PSgbkC.js.map +0 -1
- package/dist/client/chunks/javascript-DII1YQGr.js +0 -659
- package/dist/client/chunks/javascript-DII1YQGr.js.map +0 -1
- package/dist/client/chunks/json-C_6Prymp.js +0 -39
- package/dist/client/chunks/json-C_6Prymp.js.map +0 -1
- package/dist/client/chunks/providers-Ds7DRmnO.js +0 -554
- package/dist/client/chunks/providers-Ds7DRmnO.js.map +0 -1
- package/dist/client/chunks/retention-CzCo8262.js +0 -120
- package/dist/client/chunks/retention-CzCo8262.js.map +0 -1
- package/dist/client/chunks/schema-visualization-B97a1Ybu.js +0 -772
- package/dist/client/chunks/schema-visualization-B97a1Ybu.js.map +0 -1
- package/dist/client/chunks/sql-IeKX8fQ8.js +0 -616
- package/dist/client/chunks/sql-IeKX8fQ8.js.map +0 -1
- package/dist/client/chunks/syntaxHighlighting-DAMSW_A6.js +0 -34
- package/dist/client/chunks/syntaxHighlighting-DAMSW_A6.js.map +0 -1
- package/dist/client/chunks/theme-Dp3hFed1.js +0 -112
- package/dist/client/chunks/theme-Dp3hFed1.js.map +0 -1
- package/dist/client/chunks/useDirtyStateTracking-CyAXd07d.js +0 -1231
- package/dist/client/chunks/useDirtyStateTracking-CyAXd07d.js.map +0 -1
- package/dist/client/chunks/useExplainAI-CfQ_JmF1.js +0 -182
- package/dist/client/chunks/useExplainAI-CfQ_JmF1.js.map +0 -1
- package/dist/client/chunks/vendor-B2EH3V58.js +0 -2892
- package/dist/client/chunks/vendor-B2EH3V58.js.map +0 -1
- package/dist/client/components.js.map +0 -1
- package/dist/client/hooks.js.map +0 -1
- package/dist/client/icons.js.map +0 -1
- package/dist/client/providers.js.map +0 -1
- package/dist/client/utils.js.map +0 -1
- package/dist/server/anthropic-BTkjgFpT.cjs +0 -1
- package/dist/server/anthropic-CTu9E801.js +0 -126
- package/dist/server/google-BAK9pnQf.cjs +0 -2
- package/dist/server/google-DficVAsJ.js +0 -146
- package/dist/server/index-BgCeQBuN.cjs +0 -2
- package/dist/server/index-C3PskWTr.js +0 -5353
- package/dist/server/index-C45_meK_.js +0 -719
- package/dist/server/index-ht4NPca9.cjs +0 -23
- package/dist/server/openai-BvA6eLs8.cjs +0 -1
- package/dist/server/openai-mcE24du8.js +0 -131
|
@@ -0,0 +1,4114 @@
|
|
|
1
|
+
//#region node_modules/openai/internal/tslib.mjs
|
|
2
|
+
function e(e, t, n, r, i) {
|
|
3
|
+
if (r === "m") throw TypeError("Private method is not writable");
|
|
4
|
+
if (r === "a" && !i) throw TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof t == "function" ? e !== t || !i : !t.has(e)) throw TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return r === "a" ? i.call(e, n) : i ? i.value = n : t.set(e, n), n;
|
|
7
|
+
}
|
|
8
|
+
function t(e, t, n, r) {
|
|
9
|
+
if (n === "a" && !r) throw TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof t == "function" ? e !== t || !r : !t.has(e)) throw TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return n === "m" ? r : n === "a" ? r.call(e) : r ? r.value : t.get(e);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region node_modules/openai/internal/utils/uuid.mjs
|
|
15
|
+
var n = function() {
|
|
16
|
+
let { crypto: e } = globalThis;
|
|
17
|
+
if (e?.randomUUID) return n = e.randomUUID.bind(e), e.randomUUID();
|
|
18
|
+
let t = new Uint8Array(1), r = e ? () => e.getRandomValues(t)[0] : () => Math.random() * 255 & 255;
|
|
19
|
+
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (e) => (e ^ r() & 15 >> e / 4).toString(16));
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region node_modules/openai/internal/errors.mjs
|
|
23
|
+
function r(e) {
|
|
24
|
+
return typeof e == "object" && !!e && ("name" in e && e.name === "AbortError" || "message" in e && String(e.message).includes("FetchRequestCanceledException"));
|
|
25
|
+
}
|
|
26
|
+
var i = (e) => {
|
|
27
|
+
if (e instanceof Error) return e;
|
|
28
|
+
if (typeof e == "object" && e) {
|
|
29
|
+
try {
|
|
30
|
+
if (Object.prototype.toString.call(e) === "[object Error]") {
|
|
31
|
+
let t = Error(e.message, e.cause ? { cause: e.cause } : {});
|
|
32
|
+
return e.stack && (t.stack = e.stack), e.cause && !t.cause && (t.cause = e.cause), e.name && (t.name = e.name), t;
|
|
33
|
+
}
|
|
34
|
+
} catch {}
|
|
35
|
+
try {
|
|
36
|
+
return Error(JSON.stringify(e));
|
|
37
|
+
} catch {}
|
|
38
|
+
}
|
|
39
|
+
return Error(e);
|
|
40
|
+
}, a = class extends Error {}, o = class e extends a {
|
|
41
|
+
constructor(t, n, r, i) {
|
|
42
|
+
super(`${e.makeMessage(t, n, r)}`), this.status = t, this.headers = i, this.requestID = i?.get("x-request-id"), this.error = n;
|
|
43
|
+
let a = n;
|
|
44
|
+
this.code = a?.code, this.param = a?.param, this.type = a?.type;
|
|
45
|
+
}
|
|
46
|
+
static makeMessage(e, t, n) {
|
|
47
|
+
let r = t?.message ? typeof t.message == "string" ? t.message : JSON.stringify(t.message) : t ? JSON.stringify(t) : n;
|
|
48
|
+
return e && r ? `${e} ${r}` : e ? `${e} status code (no body)` : r || "(no status code or body)";
|
|
49
|
+
}
|
|
50
|
+
static generate(t, n, r, a) {
|
|
51
|
+
if (!t || !a) return new c({
|
|
52
|
+
message: r,
|
|
53
|
+
cause: i(n)
|
|
54
|
+
});
|
|
55
|
+
let o = n?.error;
|
|
56
|
+
return t === 400 ? new u(t, o, r, a) : t === 401 ? new d(t, o, r, a) : t === 403 ? new f(t, o, r, a) : t === 404 ? new p(t, o, r, a) : t === 409 ? new m(t, o, r, a) : t === 422 ? new h(t, o, r, a) : t === 429 ? new g(t, o, r, a) : t >= 500 ? new _(t, o, r, a) : new e(t, o, r, a);
|
|
57
|
+
}
|
|
58
|
+
}, s = class extends o {
|
|
59
|
+
constructor({ message: e } = {}) {
|
|
60
|
+
super(void 0, void 0, e || "Request was aborted.", void 0);
|
|
61
|
+
}
|
|
62
|
+
}, c = class extends o {
|
|
63
|
+
constructor({ message: e, cause: t }) {
|
|
64
|
+
super(void 0, void 0, e || "Connection error.", void 0), t && (this.cause = t);
|
|
65
|
+
}
|
|
66
|
+
}, l = class extends c {
|
|
67
|
+
constructor({ message: e } = {}) {
|
|
68
|
+
super({ message: e ?? "Request timed out." });
|
|
69
|
+
}
|
|
70
|
+
}, u = class extends o {}, d = class extends o {}, f = class extends o {}, p = class extends o {}, m = class extends o {}, h = class extends o {}, g = class extends o {}, _ = class extends o {}, v = class extends a {
|
|
71
|
+
constructor() {
|
|
72
|
+
super("Could not parse response content as the length limit was reached");
|
|
73
|
+
}
|
|
74
|
+
}, y = class extends a {
|
|
75
|
+
constructor() {
|
|
76
|
+
super("Could not parse response content as the request was rejected by the content filter");
|
|
77
|
+
}
|
|
78
|
+
}, b = class extends Error {
|
|
79
|
+
constructor(e) {
|
|
80
|
+
super(e);
|
|
81
|
+
}
|
|
82
|
+
}, ee = /^[a-z][a-z0-9+.-]*:/i, te = (e) => ee.test(e), x = (e) => (x = Array.isArray, x(e)), S = x;
|
|
83
|
+
function C(e) {
|
|
84
|
+
return typeof e == "object" ? e ?? {} : {};
|
|
85
|
+
}
|
|
86
|
+
function ne(e) {
|
|
87
|
+
if (!e) return !0;
|
|
88
|
+
for (let t in e) return !1;
|
|
89
|
+
return !0;
|
|
90
|
+
}
|
|
91
|
+
function re(e, t) {
|
|
92
|
+
return Object.prototype.hasOwnProperty.call(e, t);
|
|
93
|
+
}
|
|
94
|
+
function ie(e) {
|
|
95
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
96
|
+
}
|
|
97
|
+
var ae = (e, t) => {
|
|
98
|
+
if (typeof t != "number" || !Number.isInteger(t)) throw new a(`${e} must be an integer`);
|
|
99
|
+
if (t < 0) throw new a(`${e} must be a positive integer`);
|
|
100
|
+
return t;
|
|
101
|
+
}, oe = (e) => {
|
|
102
|
+
try {
|
|
103
|
+
return JSON.parse(e);
|
|
104
|
+
} catch {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
}, se = (e) => new Promise((t) => setTimeout(t, e)), w = "6.27.0", ce = () => typeof window < "u" && window.document !== void 0 && typeof navigator < "u";
|
|
108
|
+
function le() {
|
|
109
|
+
return typeof Deno < "u" && Deno.build != null ? "deno" : typeof EdgeRuntime < "u" ? "edge" : Object.prototype.toString.call(globalThis.process === void 0 ? 0 : globalThis.process) === "[object process]" ? "node" : "unknown";
|
|
110
|
+
}
|
|
111
|
+
var ue = () => {
|
|
112
|
+
let e = le();
|
|
113
|
+
if (e === "deno") return {
|
|
114
|
+
"X-Stainless-Lang": "js",
|
|
115
|
+
"X-Stainless-Package-Version": w,
|
|
116
|
+
"X-Stainless-OS": pe(Deno.build.os),
|
|
117
|
+
"X-Stainless-Arch": fe(Deno.build.arch),
|
|
118
|
+
"X-Stainless-Runtime": "deno",
|
|
119
|
+
"X-Stainless-Runtime-Version": typeof Deno.version == "string" ? Deno.version : Deno.version?.deno ?? "unknown"
|
|
120
|
+
};
|
|
121
|
+
if (typeof EdgeRuntime < "u") return {
|
|
122
|
+
"X-Stainless-Lang": "js",
|
|
123
|
+
"X-Stainless-Package-Version": w,
|
|
124
|
+
"X-Stainless-OS": "Unknown",
|
|
125
|
+
"X-Stainless-Arch": `other:${EdgeRuntime}`,
|
|
126
|
+
"X-Stainless-Runtime": "edge",
|
|
127
|
+
"X-Stainless-Runtime-Version": globalThis.process.version
|
|
128
|
+
};
|
|
129
|
+
if (e === "node") return {
|
|
130
|
+
"X-Stainless-Lang": "js",
|
|
131
|
+
"X-Stainless-Package-Version": w,
|
|
132
|
+
"X-Stainless-OS": pe(globalThis.process.platform ?? "unknown"),
|
|
133
|
+
"X-Stainless-Arch": fe(globalThis.process.arch ?? "unknown"),
|
|
134
|
+
"X-Stainless-Runtime": "node",
|
|
135
|
+
"X-Stainless-Runtime-Version": globalThis.process.version ?? "unknown"
|
|
136
|
+
};
|
|
137
|
+
let t = de();
|
|
138
|
+
return t ? {
|
|
139
|
+
"X-Stainless-Lang": "js",
|
|
140
|
+
"X-Stainless-Package-Version": w,
|
|
141
|
+
"X-Stainless-OS": "Unknown",
|
|
142
|
+
"X-Stainless-Arch": "unknown",
|
|
143
|
+
"X-Stainless-Runtime": `browser:${t.browser}`,
|
|
144
|
+
"X-Stainless-Runtime-Version": t.version
|
|
145
|
+
} : {
|
|
146
|
+
"X-Stainless-Lang": "js",
|
|
147
|
+
"X-Stainless-Package-Version": w,
|
|
148
|
+
"X-Stainless-OS": "Unknown",
|
|
149
|
+
"X-Stainless-Arch": "unknown",
|
|
150
|
+
"X-Stainless-Runtime": "unknown",
|
|
151
|
+
"X-Stainless-Runtime-Version": "unknown"
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
function de() {
|
|
155
|
+
if (typeof navigator > "u" || !navigator) return null;
|
|
156
|
+
for (let { key: e, pattern: t } of [
|
|
157
|
+
{
|
|
158
|
+
key: "edge",
|
|
159
|
+
pattern: /Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
key: "ie",
|
|
163
|
+
pattern: /MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
key: "ie",
|
|
167
|
+
pattern: /Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
key: "chrome",
|
|
171
|
+
pattern: /Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
key: "firefox",
|
|
175
|
+
pattern: /Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
key: "safari",
|
|
179
|
+
pattern: /(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/
|
|
180
|
+
}
|
|
181
|
+
]) {
|
|
182
|
+
let n = t.exec(navigator.userAgent);
|
|
183
|
+
if (n) return {
|
|
184
|
+
browser: e,
|
|
185
|
+
version: `${n[1] || 0}.${n[2] || 0}.${n[3] || 0}`
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
var fe = (e) => e === "x32" ? "x32" : e === "x86_64" || e === "x64" ? "x64" : e === "arm" ? "arm" : e === "aarch64" || e === "arm64" ? "arm64" : e ? `other:${e}` : "unknown", pe = (e) => (e = e.toLowerCase(), e.includes("ios") ? "iOS" : e === "android" ? "Android" : e === "darwin" ? "MacOS" : e === "win32" ? "Windows" : e === "freebsd" ? "FreeBSD" : e === "openbsd" ? "OpenBSD" : e === "linux" ? "Linux" : e ? `Other:${e}` : "Unknown"), me, he = () => me ??= ue();
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region node_modules/openai/internal/shims.mjs
|
|
193
|
+
function ge() {
|
|
194
|
+
if (typeof fetch < "u") return fetch;
|
|
195
|
+
throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`");
|
|
196
|
+
}
|
|
197
|
+
function _e(...e) {
|
|
198
|
+
let t = globalThis.ReadableStream;
|
|
199
|
+
if (t === void 0) throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");
|
|
200
|
+
return new t(...e);
|
|
201
|
+
}
|
|
202
|
+
function ve(e) {
|
|
203
|
+
let t = Symbol.asyncIterator in e ? e[Symbol.asyncIterator]() : e[Symbol.iterator]();
|
|
204
|
+
return _e({
|
|
205
|
+
start() {},
|
|
206
|
+
async pull(e) {
|
|
207
|
+
let { done: n, value: r } = await t.next();
|
|
208
|
+
n ? e.close() : e.enqueue(r);
|
|
209
|
+
},
|
|
210
|
+
async cancel() {
|
|
211
|
+
await t.return?.();
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
function ye(e) {
|
|
216
|
+
if (e[Symbol.asyncIterator]) return e;
|
|
217
|
+
let t = e.getReader();
|
|
218
|
+
return {
|
|
219
|
+
async next() {
|
|
220
|
+
try {
|
|
221
|
+
let e = await t.read();
|
|
222
|
+
return e?.done && t.releaseLock(), e;
|
|
223
|
+
} catch (e) {
|
|
224
|
+
throw t.releaseLock(), e;
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
async return() {
|
|
228
|
+
let e = t.cancel();
|
|
229
|
+
return t.releaseLock(), await e, {
|
|
230
|
+
done: !0,
|
|
231
|
+
value: void 0
|
|
232
|
+
};
|
|
233
|
+
},
|
|
234
|
+
[Symbol.asyncIterator]() {
|
|
235
|
+
return this;
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
async function be(e) {
|
|
240
|
+
if (typeof e != "object" || !e) return;
|
|
241
|
+
if (e[Symbol.asyncIterator]) {
|
|
242
|
+
await e[Symbol.asyncIterator]().return?.();
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
let t = e.getReader(), n = t.cancel();
|
|
246
|
+
t.releaseLock(), await n;
|
|
247
|
+
}
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region node_modules/openai/internal/request-options.mjs
|
|
250
|
+
var xe = ({ headers: e, body: t }) => ({
|
|
251
|
+
bodyHeaders: { "content-type": "application/json" },
|
|
252
|
+
body: JSON.stringify(t)
|
|
253
|
+
}), Se = "RFC3986", Ce = (e) => String(e), we = {
|
|
254
|
+
RFC1738: (e) => String(e).replace(/%20/g, "+"),
|
|
255
|
+
RFC3986: Ce
|
|
256
|
+
}, Te = (e, t) => (Te = Object.hasOwn ?? Function.prototype.call.bind(Object.prototype.hasOwnProperty), Te(e, t)), T = /* @__PURE__ */ (() => {
|
|
257
|
+
let e = [];
|
|
258
|
+
for (let t = 0; t < 256; ++t) e.push("%" + ((t < 16 ? "0" : "") + t.toString(16)).toUpperCase());
|
|
259
|
+
return e;
|
|
260
|
+
})(), Ee = 1024, De = (e, t, n, r, i) => {
|
|
261
|
+
if (e.length === 0) return e;
|
|
262
|
+
let a = e;
|
|
263
|
+
if (typeof e == "symbol" ? a = Symbol.prototype.toString.call(e) : typeof e != "string" && (a = String(e)), n === "iso-8859-1") return escape(a).replace(/%u[0-9a-f]{4}/gi, function(e) {
|
|
264
|
+
return "%26%23" + parseInt(e.slice(2), 16) + "%3B";
|
|
265
|
+
});
|
|
266
|
+
let o = "";
|
|
267
|
+
for (let e = 0; e < a.length; e += Ee) {
|
|
268
|
+
let t = a.length >= Ee ? a.slice(e, e + Ee) : a, n = [];
|
|
269
|
+
for (let e = 0; e < t.length; ++e) {
|
|
270
|
+
let r = t.charCodeAt(e);
|
|
271
|
+
if (r === 45 || r === 46 || r === 95 || r === 126 || r >= 48 && r <= 57 || r >= 65 && r <= 90 || r >= 97 && r <= 122 || i === "RFC1738" && (r === 40 || r === 41)) {
|
|
272
|
+
n[n.length] = t.charAt(e);
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
if (r < 128) {
|
|
276
|
+
n[n.length] = T[r];
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
if (r < 2048) {
|
|
280
|
+
n[n.length] = T[192 | r >> 6] + T[128 | r & 63];
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
if (r < 55296 || r >= 57344) {
|
|
284
|
+
n[n.length] = T[224 | r >> 12] + T[128 | r >> 6 & 63] + T[128 | r & 63];
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
e += 1, r = 65536 + ((r & 1023) << 10 | t.charCodeAt(e) & 1023), n[n.length] = T[240 | r >> 18] + T[128 | r >> 12 & 63] + T[128 | r >> 6 & 63] + T[128 | r & 63];
|
|
288
|
+
}
|
|
289
|
+
o += n.join("");
|
|
290
|
+
}
|
|
291
|
+
return o;
|
|
292
|
+
};
|
|
293
|
+
function Oe(e) {
|
|
294
|
+
return !e || typeof e != "object" ? !1 : !!(e.constructor && e.constructor.isBuffer && e.constructor.isBuffer(e));
|
|
295
|
+
}
|
|
296
|
+
function ke(e, t) {
|
|
297
|
+
if (x(e)) {
|
|
298
|
+
let n = [];
|
|
299
|
+
for (let r = 0; r < e.length; r += 1) n.push(t(e[r]));
|
|
300
|
+
return n;
|
|
301
|
+
}
|
|
302
|
+
return t(e);
|
|
303
|
+
}
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region node_modules/openai/internal/qs/stringify.mjs
|
|
306
|
+
var Ae = {
|
|
307
|
+
brackets(e) {
|
|
308
|
+
return String(e) + "[]";
|
|
309
|
+
},
|
|
310
|
+
comma: "comma",
|
|
311
|
+
indices(e, t) {
|
|
312
|
+
return String(e) + "[" + t + "]";
|
|
313
|
+
},
|
|
314
|
+
repeat(e) {
|
|
315
|
+
return String(e);
|
|
316
|
+
}
|
|
317
|
+
}, je = function(e, t) {
|
|
318
|
+
Array.prototype.push.apply(e, x(t) ? t : [t]);
|
|
319
|
+
}, Me, E = {
|
|
320
|
+
addQueryPrefix: !1,
|
|
321
|
+
allowDots: !1,
|
|
322
|
+
allowEmptyArrays: !1,
|
|
323
|
+
arrayFormat: "indices",
|
|
324
|
+
charset: "utf-8",
|
|
325
|
+
charsetSentinel: !1,
|
|
326
|
+
delimiter: "&",
|
|
327
|
+
encode: !0,
|
|
328
|
+
encodeDotInKeys: !1,
|
|
329
|
+
encoder: De,
|
|
330
|
+
encodeValuesOnly: !1,
|
|
331
|
+
format: Se,
|
|
332
|
+
formatter: Ce,
|
|
333
|
+
indices: !1,
|
|
334
|
+
serializeDate(e) {
|
|
335
|
+
return (Me ??= Function.prototype.call.bind(Date.prototype.toISOString))(e);
|
|
336
|
+
},
|
|
337
|
+
skipNulls: !1,
|
|
338
|
+
strictNullHandling: !1
|
|
339
|
+
};
|
|
340
|
+
function Ne(e) {
|
|
341
|
+
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "symbol" || typeof e == "bigint";
|
|
342
|
+
}
|
|
343
|
+
var Pe = {};
|
|
344
|
+
function Fe(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g, _) {
|
|
345
|
+
let v = e, y = _, b = 0, ee = !1;
|
|
346
|
+
for (; (y = y.get(Pe)) !== void 0 && !ee;) {
|
|
347
|
+
let t = y.get(e);
|
|
348
|
+
if (b += 1, t !== void 0) {
|
|
349
|
+
if (t === b) throw RangeError("Cyclic object value");
|
|
350
|
+
ee = !0;
|
|
351
|
+
}
|
|
352
|
+
y.get(Pe) === void 0 && (b = 0);
|
|
353
|
+
}
|
|
354
|
+
if (typeof l == "function" ? v = l(t, v) : v instanceof Date ? v = f?.(v) : n === "comma" && x(v) && (v = ke(v, function(e) {
|
|
355
|
+
return e instanceof Date ? f?.(e) : e;
|
|
356
|
+
})), v === null) {
|
|
357
|
+
if (a) return c && !h ? c(t, E.encoder, g, "key", p) : t;
|
|
358
|
+
v = "";
|
|
359
|
+
}
|
|
360
|
+
if (Ne(v) || Oe(v)) {
|
|
361
|
+
if (c) {
|
|
362
|
+
let e = h ? t : c(t, E.encoder, g, "key", p);
|
|
363
|
+
return [m?.(e) + "=" + m?.(c(v, E.encoder, g, "value", p))];
|
|
364
|
+
}
|
|
365
|
+
return [m?.(t) + "=" + m?.(String(v))];
|
|
366
|
+
}
|
|
367
|
+
let te = [];
|
|
368
|
+
if (v === void 0) return te;
|
|
369
|
+
let S;
|
|
370
|
+
if (n === "comma" && x(v)) h && c && (v = ke(v, c)), S = [{ value: v.length > 0 ? v.join(",") || null : void 0 }];
|
|
371
|
+
else if (x(l)) S = l;
|
|
372
|
+
else {
|
|
373
|
+
let e = Object.keys(v);
|
|
374
|
+
S = u ? e.sort(u) : e;
|
|
375
|
+
}
|
|
376
|
+
let C = s ? String(t).replace(/\./g, "%2E") : String(t), ne = r && x(v) && v.length === 1 ? C + "[]" : C;
|
|
377
|
+
if (i && x(v) && v.length === 0) return ne + "[]";
|
|
378
|
+
for (let t = 0; t < S.length; ++t) {
|
|
379
|
+
let y = S[t], ee = typeof y == "object" && y.value !== void 0 ? y.value : v[y];
|
|
380
|
+
if (o && ee === null) continue;
|
|
381
|
+
let C = d && s ? y.replace(/\./g, "%2E") : y, re = x(v) ? typeof n == "function" ? n(ne, C) : ne : ne + (d ? "." + C : "[" + C + "]");
|
|
382
|
+
_.set(e, b);
|
|
383
|
+
let ie = /* @__PURE__ */ new WeakMap();
|
|
384
|
+
ie.set(Pe, _), je(te, Fe(ee, re, n, r, i, a, o, s, n === "comma" && h && x(v) ? null : c, l, u, d, f, p, m, h, g, ie));
|
|
385
|
+
}
|
|
386
|
+
return te;
|
|
387
|
+
}
|
|
388
|
+
function Ie(e = E) {
|
|
389
|
+
if (e.allowEmptyArrays !== void 0 && typeof e.allowEmptyArrays != "boolean") throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");
|
|
390
|
+
if (e.encodeDotInKeys !== void 0 && typeof e.encodeDotInKeys != "boolean") throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");
|
|
391
|
+
if (e.encoder !== null && e.encoder !== void 0 && typeof e.encoder != "function") throw TypeError("Encoder has to be a function.");
|
|
392
|
+
let t = e.charset || E.charset;
|
|
393
|
+
if (e.charset !== void 0 && e.charset !== "utf-8" && e.charset !== "iso-8859-1") throw TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");
|
|
394
|
+
let n = Se;
|
|
395
|
+
if (e.format !== void 0) {
|
|
396
|
+
if (!Te(we, e.format)) throw TypeError("Unknown format option provided.");
|
|
397
|
+
n = e.format;
|
|
398
|
+
}
|
|
399
|
+
let r = we[n], i = E.filter;
|
|
400
|
+
(typeof e.filter == "function" || x(e.filter)) && (i = e.filter);
|
|
401
|
+
let a;
|
|
402
|
+
if (a = e.arrayFormat && e.arrayFormat in Ae ? e.arrayFormat : "indices" in e ? e.indices ? "indices" : "repeat" : E.arrayFormat, "commaRoundTrip" in e && typeof e.commaRoundTrip != "boolean") throw TypeError("`commaRoundTrip` must be a boolean, or absent");
|
|
403
|
+
let o = e.allowDots === void 0 ? e.encodeDotInKeys ? !0 : E.allowDots : !!e.allowDots;
|
|
404
|
+
return {
|
|
405
|
+
addQueryPrefix: typeof e.addQueryPrefix == "boolean" ? e.addQueryPrefix : E.addQueryPrefix,
|
|
406
|
+
allowDots: o,
|
|
407
|
+
allowEmptyArrays: typeof e.allowEmptyArrays == "boolean" ? !!e.allowEmptyArrays : E.allowEmptyArrays,
|
|
408
|
+
arrayFormat: a,
|
|
409
|
+
charset: t,
|
|
410
|
+
charsetSentinel: typeof e.charsetSentinel == "boolean" ? e.charsetSentinel : E.charsetSentinel,
|
|
411
|
+
commaRoundTrip: !!e.commaRoundTrip,
|
|
412
|
+
delimiter: e.delimiter === void 0 ? E.delimiter : e.delimiter,
|
|
413
|
+
encode: typeof e.encode == "boolean" ? e.encode : E.encode,
|
|
414
|
+
encodeDotInKeys: typeof e.encodeDotInKeys == "boolean" ? e.encodeDotInKeys : E.encodeDotInKeys,
|
|
415
|
+
encoder: typeof e.encoder == "function" ? e.encoder : E.encoder,
|
|
416
|
+
encodeValuesOnly: typeof e.encodeValuesOnly == "boolean" ? e.encodeValuesOnly : E.encodeValuesOnly,
|
|
417
|
+
filter: i,
|
|
418
|
+
format: n,
|
|
419
|
+
formatter: r,
|
|
420
|
+
serializeDate: typeof e.serializeDate == "function" ? e.serializeDate : E.serializeDate,
|
|
421
|
+
skipNulls: typeof e.skipNulls == "boolean" ? e.skipNulls : E.skipNulls,
|
|
422
|
+
sort: typeof e.sort == "function" ? e.sort : null,
|
|
423
|
+
strictNullHandling: typeof e.strictNullHandling == "boolean" ? e.strictNullHandling : E.strictNullHandling
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
function Le(e, t = {}) {
|
|
427
|
+
let n = e, r = Ie(t), i, a;
|
|
428
|
+
typeof r.filter == "function" ? (a = r.filter, n = a("", n)) : x(r.filter) && (a = r.filter, i = a);
|
|
429
|
+
let o = [];
|
|
430
|
+
if (typeof n != "object" || !n) return "";
|
|
431
|
+
let s = Ae[r.arrayFormat], c = s === "comma" && r.commaRoundTrip;
|
|
432
|
+
i ||= Object.keys(n), r.sort && i.sort(r.sort);
|
|
433
|
+
let l = /* @__PURE__ */ new WeakMap();
|
|
434
|
+
for (let e = 0; e < i.length; ++e) {
|
|
435
|
+
let t = i[e];
|
|
436
|
+
r.skipNulls && n[t] === null || je(o, Fe(n[t], t, s, c, r.allowEmptyArrays, r.strictNullHandling, r.skipNulls, r.encodeDotInKeys, r.encode ? r.encoder : null, r.filter, r.sort, r.allowDots, r.serializeDate, r.format, r.formatter, r.encodeValuesOnly, r.charset, l));
|
|
437
|
+
}
|
|
438
|
+
let u = o.join(r.delimiter), d = r.addQueryPrefix === !0 ? "?" : "";
|
|
439
|
+
return r.charsetSentinel && (r.charset === "iso-8859-1" ? d += "utf8=%26%2310003%3B&" : d += "utf8=%E2%9C%93&"), u.length > 0 ? d + u : "";
|
|
440
|
+
}
|
|
441
|
+
//#endregion
|
|
442
|
+
//#region node_modules/openai/internal/utils/query.mjs
|
|
443
|
+
function Re(e) {
|
|
444
|
+
return Le(e, { arrayFormat: "brackets" });
|
|
445
|
+
}
|
|
446
|
+
//#endregion
|
|
447
|
+
//#region node_modules/openai/internal/utils/bytes.mjs
|
|
448
|
+
function ze(e) {
|
|
449
|
+
let t = 0;
|
|
450
|
+
for (let n of e) t += n.length;
|
|
451
|
+
let n = new Uint8Array(t), r = 0;
|
|
452
|
+
for (let t of e) n.set(t, r), r += t.length;
|
|
453
|
+
return n;
|
|
454
|
+
}
|
|
455
|
+
var Be;
|
|
456
|
+
function Ve(e) {
|
|
457
|
+
let t;
|
|
458
|
+
return (Be ??= (t = new globalThis.TextEncoder(), t.encode.bind(t)))(e);
|
|
459
|
+
}
|
|
460
|
+
var He;
|
|
461
|
+
function Ue(e) {
|
|
462
|
+
let t;
|
|
463
|
+
return (He ??= (t = new globalThis.TextDecoder(), t.decode.bind(t)))(e);
|
|
464
|
+
}
|
|
465
|
+
//#endregion
|
|
466
|
+
//#region node_modules/openai/internal/decoders/line.mjs
|
|
467
|
+
var D, O, We = class {
|
|
468
|
+
constructor() {
|
|
469
|
+
D.set(this, void 0), O.set(this, void 0), e(this, D, new Uint8Array(), "f"), e(this, O, null, "f");
|
|
470
|
+
}
|
|
471
|
+
decode(n) {
|
|
472
|
+
if (n == null) return [];
|
|
473
|
+
let r = n instanceof ArrayBuffer ? new Uint8Array(n) : typeof n == "string" ? Ve(n) : n;
|
|
474
|
+
e(this, D, ze([t(this, D, "f"), r]), "f");
|
|
475
|
+
let i = [], a;
|
|
476
|
+
for (; (a = Ge(t(this, D, "f"), t(this, O, "f"))) != null;) {
|
|
477
|
+
if (a.carriage && t(this, O, "f") == null) {
|
|
478
|
+
e(this, O, a.index, "f");
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
if (t(this, O, "f") != null && (a.index !== t(this, O, "f") + 1 || a.carriage)) {
|
|
482
|
+
i.push(Ue(t(this, D, "f").subarray(0, t(this, O, "f") - 1))), e(this, D, t(this, D, "f").subarray(t(this, O, "f")), "f"), e(this, O, null, "f");
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
let n = t(this, O, "f") === null ? a.preceding : a.preceding - 1, r = Ue(t(this, D, "f").subarray(0, n));
|
|
486
|
+
i.push(r), e(this, D, t(this, D, "f").subarray(a.index), "f"), e(this, O, null, "f");
|
|
487
|
+
}
|
|
488
|
+
return i;
|
|
489
|
+
}
|
|
490
|
+
flush() {
|
|
491
|
+
return t(this, D, "f").length ? this.decode("\n") : [];
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
D = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), We.NEWLINE_CHARS = new Set(["\n", "\r"]), We.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
|
|
495
|
+
function Ge(e, t) {
|
|
496
|
+
for (let n = t ?? 0; n < e.length; n++) {
|
|
497
|
+
if (e[n] === 10) return {
|
|
498
|
+
preceding: n,
|
|
499
|
+
index: n + 1,
|
|
500
|
+
carriage: !1
|
|
501
|
+
};
|
|
502
|
+
if (e[n] === 13) return {
|
|
503
|
+
preceding: n,
|
|
504
|
+
index: n + 1,
|
|
505
|
+
carriage: !0
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
return null;
|
|
509
|
+
}
|
|
510
|
+
function Ke(e) {
|
|
511
|
+
for (let t = 0; t < e.length - 1; t++) {
|
|
512
|
+
if (e[t] === 10 && e[t + 1] === 10 || e[t] === 13 && e[t + 1] === 13) return t + 2;
|
|
513
|
+
if (e[t] === 13 && e[t + 1] === 10 && t + 3 < e.length && e[t + 2] === 13 && e[t + 3] === 10) return t + 4;
|
|
514
|
+
}
|
|
515
|
+
return -1;
|
|
516
|
+
}
|
|
517
|
+
//#endregion
|
|
518
|
+
//#region node_modules/openai/internal/utils/log.mjs
|
|
519
|
+
var qe = {
|
|
520
|
+
off: 0,
|
|
521
|
+
error: 200,
|
|
522
|
+
warn: 300,
|
|
523
|
+
info: 400,
|
|
524
|
+
debug: 500
|
|
525
|
+
}, Je = (e, t, n) => {
|
|
526
|
+
if (e) {
|
|
527
|
+
if (re(qe, e)) return e;
|
|
528
|
+
k(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(qe))}`);
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
function Ye() {}
|
|
532
|
+
function Xe(e, t, n) {
|
|
533
|
+
return !t || qe[e] > qe[n] ? Ye : t[e].bind(t);
|
|
534
|
+
}
|
|
535
|
+
var Ze = {
|
|
536
|
+
error: Ye,
|
|
537
|
+
warn: Ye,
|
|
538
|
+
info: Ye,
|
|
539
|
+
debug: Ye
|
|
540
|
+
}, Qe = /* @__PURE__ */ new WeakMap();
|
|
541
|
+
function k(e) {
|
|
542
|
+
let t = e.logger, n = e.logLevel ?? "off";
|
|
543
|
+
if (!t) return Ze;
|
|
544
|
+
let r = Qe.get(t);
|
|
545
|
+
if (r && r[0] === n) return r[1];
|
|
546
|
+
let i = {
|
|
547
|
+
error: Xe("error", t, n),
|
|
548
|
+
warn: Xe("warn", t, n),
|
|
549
|
+
info: Xe("info", t, n),
|
|
550
|
+
debug: Xe("debug", t, n)
|
|
551
|
+
};
|
|
552
|
+
return Qe.set(t, [n, i]), i;
|
|
553
|
+
}
|
|
554
|
+
var A = (e) => (e.options && (e.options = { ...e.options }, delete e.options.headers), e.headers &&= Object.fromEntries((e.headers instanceof Headers ? [...e.headers] : Object.entries(e.headers)).map(([e, t]) => [e, e.toLowerCase() === "authorization" || e.toLowerCase() === "cookie" || e.toLowerCase() === "set-cookie" ? "***" : t])), "retryOfRequestLogID" in e && (e.retryOfRequestLogID && (e.retryOf = e.retryOfRequestLogID), delete e.retryOfRequestLogID), e), $e, et = class n {
|
|
555
|
+
constructor(t, n, r) {
|
|
556
|
+
this.iterator = t, $e.set(this, void 0), this.controller = n, e(this, $e, r, "f");
|
|
557
|
+
}
|
|
558
|
+
static fromSSEResponse(e, t, i, s) {
|
|
559
|
+
let c = !1, l = i ? k(i) : console;
|
|
560
|
+
async function* u() {
|
|
561
|
+
if (c) throw new a("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
|
|
562
|
+
c = !0;
|
|
563
|
+
let n = !1;
|
|
564
|
+
try {
|
|
565
|
+
for await (let r of tt(e, t)) if (!n) {
|
|
566
|
+
if (r.data.startsWith("[DONE]")) {
|
|
567
|
+
n = !0;
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
if (r.event === null || !r.event.startsWith("thread.")) {
|
|
571
|
+
let t;
|
|
572
|
+
try {
|
|
573
|
+
t = JSON.parse(r.data);
|
|
574
|
+
} catch (e) {
|
|
575
|
+
throw l.error("Could not parse message into JSON:", r.data), l.error("From chunk:", r.raw), e;
|
|
576
|
+
}
|
|
577
|
+
if (t && t.error) throw new o(void 0, t.error, void 0, e.headers);
|
|
578
|
+
yield s ? {
|
|
579
|
+
event: r.event,
|
|
580
|
+
data: t
|
|
581
|
+
} : t;
|
|
582
|
+
} else {
|
|
583
|
+
let e;
|
|
584
|
+
try {
|
|
585
|
+
e = JSON.parse(r.data);
|
|
586
|
+
} catch (e) {
|
|
587
|
+
throw console.error("Could not parse message into JSON:", r.data), console.error("From chunk:", r.raw), e;
|
|
588
|
+
}
|
|
589
|
+
if (r.event == "error") throw new o(void 0, e.error, e.message, void 0);
|
|
590
|
+
yield {
|
|
591
|
+
event: r.event,
|
|
592
|
+
data: e
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
n = !0;
|
|
597
|
+
} catch (e) {
|
|
598
|
+
if (r(e)) return;
|
|
599
|
+
throw e;
|
|
600
|
+
} finally {
|
|
601
|
+
n || t.abort();
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
return new n(u, t, i);
|
|
605
|
+
}
|
|
606
|
+
static fromReadableStream(e, t, i) {
|
|
607
|
+
let o = !1;
|
|
608
|
+
async function* s() {
|
|
609
|
+
let t = new We(), n = ye(e);
|
|
610
|
+
for await (let e of n) for (let n of t.decode(e)) yield n;
|
|
611
|
+
for (let e of t.flush()) yield e;
|
|
612
|
+
}
|
|
613
|
+
async function* c() {
|
|
614
|
+
if (o) throw new a("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
|
|
615
|
+
o = !0;
|
|
616
|
+
let e = !1;
|
|
617
|
+
try {
|
|
618
|
+
for await (let t of s()) e || t && (yield JSON.parse(t));
|
|
619
|
+
e = !0;
|
|
620
|
+
} catch (e) {
|
|
621
|
+
if (r(e)) return;
|
|
622
|
+
throw e;
|
|
623
|
+
} finally {
|
|
624
|
+
e || t.abort();
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
return new n(c, t, i);
|
|
628
|
+
}
|
|
629
|
+
[($e = /* @__PURE__ */ new WeakMap(), Symbol.asyncIterator)]() {
|
|
630
|
+
return this.iterator();
|
|
631
|
+
}
|
|
632
|
+
tee() {
|
|
633
|
+
let e = [], r = [], i = this.iterator(), a = (t) => ({ next: () => {
|
|
634
|
+
if (t.length === 0) {
|
|
635
|
+
let t = i.next();
|
|
636
|
+
e.push(t), r.push(t);
|
|
637
|
+
}
|
|
638
|
+
return t.shift();
|
|
639
|
+
} });
|
|
640
|
+
return [new n(() => a(e), this.controller, t(this, $e, "f")), new n(() => a(r), this.controller, t(this, $e, "f"))];
|
|
641
|
+
}
|
|
642
|
+
toReadableStream() {
|
|
643
|
+
let e = this, t;
|
|
644
|
+
return _e({
|
|
645
|
+
async start() {
|
|
646
|
+
t = e[Symbol.asyncIterator]();
|
|
647
|
+
},
|
|
648
|
+
async pull(e) {
|
|
649
|
+
try {
|
|
650
|
+
let { value: n, done: r } = await t.next();
|
|
651
|
+
if (r) return e.close();
|
|
652
|
+
let i = Ve(JSON.stringify(n) + "\n");
|
|
653
|
+
e.enqueue(i);
|
|
654
|
+
} catch (t) {
|
|
655
|
+
e.error(t);
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
async cancel() {
|
|
659
|
+
await t.return?.();
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
async function* tt(e, t) {
|
|
665
|
+
if (!e.body) throw t.abort(), globalThis.navigator !== void 0 && globalThis.navigator.product === "ReactNative" ? new a("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api") : new a("Attempted to iterate over a response with no body");
|
|
666
|
+
let n = new rt(), r = new We(), i = ye(e.body);
|
|
667
|
+
for await (let e of nt(i)) for (let t of r.decode(e)) {
|
|
668
|
+
let e = n.decode(t);
|
|
669
|
+
e && (yield e);
|
|
670
|
+
}
|
|
671
|
+
for (let e of r.flush()) {
|
|
672
|
+
let t = n.decode(e);
|
|
673
|
+
t && (yield t);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
async function* nt(e) {
|
|
677
|
+
let t = new Uint8Array();
|
|
678
|
+
for await (let n of e) {
|
|
679
|
+
if (n == null) continue;
|
|
680
|
+
let e = n instanceof ArrayBuffer ? new Uint8Array(n) : typeof n == "string" ? Ve(n) : n, r = new Uint8Array(t.length + e.length);
|
|
681
|
+
r.set(t), r.set(e, t.length), t = r;
|
|
682
|
+
let i;
|
|
683
|
+
for (; (i = Ke(t)) !== -1;) yield t.slice(0, i), t = t.slice(i);
|
|
684
|
+
}
|
|
685
|
+
t.length > 0 && (yield t);
|
|
686
|
+
}
|
|
687
|
+
var rt = class {
|
|
688
|
+
constructor() {
|
|
689
|
+
this.event = null, this.data = [], this.chunks = [];
|
|
690
|
+
}
|
|
691
|
+
decode(e) {
|
|
692
|
+
if (e.endsWith("\r") && (e = e.substring(0, e.length - 1)), !e) {
|
|
693
|
+
if (!this.event && !this.data.length) return null;
|
|
694
|
+
let e = {
|
|
695
|
+
event: this.event,
|
|
696
|
+
data: this.data.join("\n"),
|
|
697
|
+
raw: this.chunks
|
|
698
|
+
};
|
|
699
|
+
return this.event = null, this.data = [], this.chunks = [], e;
|
|
700
|
+
}
|
|
701
|
+
if (this.chunks.push(e), e.startsWith(":")) return null;
|
|
702
|
+
let [t, n, r] = it(e, ":");
|
|
703
|
+
return r.startsWith(" ") && (r = r.substring(1)), t === "event" ? this.event = r : t === "data" && this.data.push(r), null;
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
function it(e, t) {
|
|
707
|
+
let n = e.indexOf(t);
|
|
708
|
+
return n === -1 ? [
|
|
709
|
+
e,
|
|
710
|
+
"",
|
|
711
|
+
""
|
|
712
|
+
] : [
|
|
713
|
+
e.substring(0, n),
|
|
714
|
+
t,
|
|
715
|
+
e.substring(n + t.length)
|
|
716
|
+
];
|
|
717
|
+
}
|
|
718
|
+
//#endregion
|
|
719
|
+
//#region node_modules/openai/internal/parse.mjs
|
|
720
|
+
async function at(e, t) {
|
|
721
|
+
let { response: n, requestLogID: r, retryOfRequestLogID: i, startTime: a } = t, o = await (async () => {
|
|
722
|
+
if (t.options.stream) return k(e).debug("response", n.status, n.url, n.headers, n.body), t.options.__streamClass ? t.options.__streamClass.fromSSEResponse(n, t.controller, e, t.options.__synthesizeEventData) : et.fromSSEResponse(n, t.controller, e, t.options.__synthesizeEventData);
|
|
723
|
+
if (n.status === 204) return null;
|
|
724
|
+
if (t.options.__binaryResponse) return n;
|
|
725
|
+
let r = n.headers.get("content-type")?.split(";")[0]?.trim();
|
|
726
|
+
return r?.includes("application/json") || r?.endsWith("+json") ? n.headers.get("content-length") === "0" ? void 0 : ot(await n.json(), n) : await n.text();
|
|
727
|
+
})();
|
|
728
|
+
return k(e).debug(`[${r}] response parsed`, A({
|
|
729
|
+
retryOfRequestLogID: i,
|
|
730
|
+
url: n.url,
|
|
731
|
+
status: n.status,
|
|
732
|
+
body: o,
|
|
733
|
+
durationMs: Date.now() - a
|
|
734
|
+
})), o;
|
|
735
|
+
}
|
|
736
|
+
function ot(e, t) {
|
|
737
|
+
return !e || typeof e != "object" || Array.isArray(e) ? e : Object.defineProperty(e, "_request_id", {
|
|
738
|
+
value: t.headers.get("x-request-id"),
|
|
739
|
+
enumerable: !1
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
//#endregion
|
|
743
|
+
//#region node_modules/openai/core/api-promise.mjs
|
|
744
|
+
var st, ct = class n extends Promise {
|
|
745
|
+
constructor(t, n, r = at) {
|
|
746
|
+
super((e) => {
|
|
747
|
+
e(null);
|
|
748
|
+
}), this.responsePromise = n, this.parseResponse = r, st.set(this, void 0), e(this, st, t, "f");
|
|
749
|
+
}
|
|
750
|
+
_thenUnwrap(e) {
|
|
751
|
+
return new n(t(this, st, "f"), this.responsePromise, async (t, n) => ot(e(await this.parseResponse(t, n), n), n.response));
|
|
752
|
+
}
|
|
753
|
+
asResponse() {
|
|
754
|
+
return this.responsePromise.then((e) => e.response);
|
|
755
|
+
}
|
|
756
|
+
async withResponse() {
|
|
757
|
+
let [e, t] = await Promise.all([this.parse(), this.asResponse()]);
|
|
758
|
+
return {
|
|
759
|
+
data: e,
|
|
760
|
+
response: t,
|
|
761
|
+
request_id: t.headers.get("x-request-id")
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
parse() {
|
|
765
|
+
return this.parsedPromise ||= this.responsePromise.then((e) => this.parseResponse(t(this, st, "f"), e)), this.parsedPromise;
|
|
766
|
+
}
|
|
767
|
+
then(e, t) {
|
|
768
|
+
return this.parse().then(e, t);
|
|
769
|
+
}
|
|
770
|
+
catch(e) {
|
|
771
|
+
return this.parse().catch(e);
|
|
772
|
+
}
|
|
773
|
+
finally(e) {
|
|
774
|
+
return this.parse().finally(e);
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
st = /* @__PURE__ */ new WeakMap();
|
|
778
|
+
//#endregion
|
|
779
|
+
//#region node_modules/openai/core/pagination.mjs
|
|
780
|
+
var lt, ut = class {
|
|
781
|
+
constructor(t, n, r, i) {
|
|
782
|
+
lt.set(this, void 0), e(this, lt, t, "f"), this.options = i, this.response = n, this.body = r;
|
|
783
|
+
}
|
|
784
|
+
hasNextPage() {
|
|
785
|
+
return this.getPaginatedItems().length ? this.nextPageRequestOptions() != null : !1;
|
|
786
|
+
}
|
|
787
|
+
async getNextPage() {
|
|
788
|
+
let e = this.nextPageRequestOptions();
|
|
789
|
+
if (!e) throw new a("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");
|
|
790
|
+
return await t(this, lt, "f").requestAPIList(this.constructor, e);
|
|
791
|
+
}
|
|
792
|
+
async *iterPages() {
|
|
793
|
+
let e = this;
|
|
794
|
+
for (yield e; e.hasNextPage();) e = await e.getNextPage(), yield e;
|
|
795
|
+
}
|
|
796
|
+
async *[(lt = /* @__PURE__ */ new WeakMap(), Symbol.asyncIterator)]() {
|
|
797
|
+
for await (let e of this.iterPages()) for (let t of e.getPaginatedItems()) yield t;
|
|
798
|
+
}
|
|
799
|
+
}, dt = class extends ct {
|
|
800
|
+
constructor(e, t, n) {
|
|
801
|
+
super(e, t, async (e, t) => new n(e, t.response, await at(e, t), t.options));
|
|
802
|
+
}
|
|
803
|
+
async *[Symbol.asyncIterator]() {
|
|
804
|
+
let e = await this;
|
|
805
|
+
for await (let t of e) yield t;
|
|
806
|
+
}
|
|
807
|
+
}, ft = class extends ut {
|
|
808
|
+
constructor(e, t, n, r) {
|
|
809
|
+
super(e, t, n, r), this.data = n.data || [], this.object = n.object;
|
|
810
|
+
}
|
|
811
|
+
getPaginatedItems() {
|
|
812
|
+
return this.data ?? [];
|
|
813
|
+
}
|
|
814
|
+
nextPageRequestOptions() {
|
|
815
|
+
return null;
|
|
816
|
+
}
|
|
817
|
+
}, j = class extends ut {
|
|
818
|
+
constructor(e, t, n, r) {
|
|
819
|
+
super(e, t, n, r), this.data = n.data || [], this.has_more = n.has_more || !1;
|
|
820
|
+
}
|
|
821
|
+
getPaginatedItems() {
|
|
822
|
+
return this.data ?? [];
|
|
823
|
+
}
|
|
824
|
+
hasNextPage() {
|
|
825
|
+
return this.has_more === !1 ? !1 : super.hasNextPage();
|
|
826
|
+
}
|
|
827
|
+
nextPageRequestOptions() {
|
|
828
|
+
let e = this.getPaginatedItems(), t = e[e.length - 1]?.id;
|
|
829
|
+
return t ? {
|
|
830
|
+
...this.options,
|
|
831
|
+
query: {
|
|
832
|
+
...C(this.options.query),
|
|
833
|
+
after: t
|
|
834
|
+
}
|
|
835
|
+
} : null;
|
|
836
|
+
}
|
|
837
|
+
}, pt = class extends ut {
|
|
838
|
+
constructor(e, t, n, r) {
|
|
839
|
+
super(e, t, n, r), this.data = n.data || [], this.has_more = n.has_more || !1, this.last_id = n.last_id || "";
|
|
840
|
+
}
|
|
841
|
+
getPaginatedItems() {
|
|
842
|
+
return this.data ?? [];
|
|
843
|
+
}
|
|
844
|
+
hasNextPage() {
|
|
845
|
+
return this.has_more === !1 ? !1 : super.hasNextPage();
|
|
846
|
+
}
|
|
847
|
+
nextPageRequestOptions() {
|
|
848
|
+
let e = this.last_id;
|
|
849
|
+
return e ? {
|
|
850
|
+
...this.options,
|
|
851
|
+
query: {
|
|
852
|
+
...C(this.options.query),
|
|
853
|
+
after: e
|
|
854
|
+
}
|
|
855
|
+
} : null;
|
|
856
|
+
}
|
|
857
|
+
}, mt = () => {
|
|
858
|
+
if (typeof File > "u") {
|
|
859
|
+
let { process: e } = globalThis, t = typeof e?.versions?.node == "string" && parseInt(e.versions.node.split(".")) < 20;
|
|
860
|
+
throw Error("`File` is not defined as a global, which is required for file uploads." + (t ? " Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`." : ""));
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
function ht(e, t, n) {
|
|
864
|
+
return mt(), new File(e, t ?? "unknown_file", n);
|
|
865
|
+
}
|
|
866
|
+
function gt(e) {
|
|
867
|
+
return (typeof e == "object" && !!e && ("name" in e && e.name && String(e.name) || "url" in e && e.url && String(e.url) || "filename" in e && e.filename && String(e.filename) || "path" in e && e.path && String(e.path)) || "").split(/[\\/]/).pop() || void 0;
|
|
868
|
+
}
|
|
869
|
+
var _t = (e) => typeof e == "object" && !!e && typeof e[Symbol.asyncIterator] == "function", vt = async (e, t) => wt(e.body) ? {
|
|
870
|
+
...e,
|
|
871
|
+
body: await xt(e.body, t)
|
|
872
|
+
} : e, M = async (e, t) => ({
|
|
873
|
+
...e,
|
|
874
|
+
body: await xt(e.body, t)
|
|
875
|
+
}), yt = /* @__PURE__ */ new WeakMap();
|
|
876
|
+
function bt(e) {
|
|
877
|
+
let t = typeof e == "function" ? e : e.fetch, n = yt.get(t);
|
|
878
|
+
if (n) return n;
|
|
879
|
+
let r = (async () => {
|
|
880
|
+
try {
|
|
881
|
+
let e = "Response" in t ? t.Response : (await t("data:,")).constructor, n = new FormData();
|
|
882
|
+
return n.toString() !== await new e(n).text();
|
|
883
|
+
} catch {
|
|
884
|
+
return !0;
|
|
885
|
+
}
|
|
886
|
+
})();
|
|
887
|
+
return yt.set(t, r), r;
|
|
888
|
+
}
|
|
889
|
+
var xt = async (e, t) => {
|
|
890
|
+
if (!await bt(t)) throw TypeError("The provided fetch function does not support file uploads with the current global FormData class.");
|
|
891
|
+
let n = new FormData();
|
|
892
|
+
return await Promise.all(Object.entries(e || {}).map(([e, t]) => Tt(n, e, t))), n;
|
|
893
|
+
}, St = (e) => e instanceof Blob && "name" in e, Ct = (e) => typeof e == "object" && !!e && (e instanceof Response || _t(e) || St(e)), wt = (e) => {
|
|
894
|
+
if (Ct(e)) return !0;
|
|
895
|
+
if (Array.isArray(e)) return e.some(wt);
|
|
896
|
+
if (e && typeof e == "object") {
|
|
897
|
+
for (let t in e) if (wt(e[t])) return !0;
|
|
898
|
+
}
|
|
899
|
+
return !1;
|
|
900
|
+
}, Tt = async (e, t, n) => {
|
|
901
|
+
if (n !== void 0) {
|
|
902
|
+
if (n == null) throw TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);
|
|
903
|
+
if (typeof n == "string" || typeof n == "number" || typeof n == "boolean") e.append(t, String(n));
|
|
904
|
+
else if (n instanceof Response) e.append(t, ht([await n.blob()], gt(n)));
|
|
905
|
+
else if (_t(n)) e.append(t, ht([await new Response(ve(n)).blob()], gt(n)));
|
|
906
|
+
else if (St(n)) e.append(t, n, gt(n));
|
|
907
|
+
else if (Array.isArray(n)) await Promise.all(n.map((n) => Tt(e, t + "[]", n)));
|
|
908
|
+
else if (typeof n == "object") await Promise.all(Object.entries(n).map(([n, r]) => Tt(e, `${t}[${n}]`, r)));
|
|
909
|
+
else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`);
|
|
910
|
+
}
|
|
911
|
+
}, Et = (e) => typeof e == "object" && !!e && typeof e.size == "number" && typeof e.type == "string" && typeof e.text == "function" && typeof e.slice == "function" && typeof e.arrayBuffer == "function", Dt = (e) => typeof e == "object" && !!e && typeof e.name == "string" && typeof e.lastModified == "number" && Et(e), Ot = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.blob == "function";
|
|
912
|
+
async function kt(e, t, n) {
|
|
913
|
+
if (mt(), e = await e, Dt(e)) return e instanceof File ? e : ht([await e.arrayBuffer()], e.name);
|
|
914
|
+
if (Ot(e)) {
|
|
915
|
+
let r = await e.blob();
|
|
916
|
+
return t ||= new URL(e.url).pathname.split(/[\\/]/).pop(), ht(await At(r), t, n);
|
|
917
|
+
}
|
|
918
|
+
let r = await At(e);
|
|
919
|
+
if (t ||= gt(e), !n?.type) {
|
|
920
|
+
let e = r.find((e) => typeof e == "object" && "type" in e && e.type);
|
|
921
|
+
typeof e == "string" && (n = {
|
|
922
|
+
...n,
|
|
923
|
+
type: e
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
return ht(r, t, n);
|
|
927
|
+
}
|
|
928
|
+
async function At(e) {
|
|
929
|
+
let t = [];
|
|
930
|
+
if (typeof e == "string" || ArrayBuffer.isView(e) || e instanceof ArrayBuffer) t.push(e);
|
|
931
|
+
else if (Et(e)) t.push(e instanceof Blob ? e : await e.arrayBuffer());
|
|
932
|
+
else if (_t(e)) for await (let n of e) t.push(...await At(n));
|
|
933
|
+
else {
|
|
934
|
+
let t = e?.constructor?.name;
|
|
935
|
+
throw Error(`Unexpected data type: ${typeof e}${t ? `; constructor: ${t}` : ""}${jt(e)}`);
|
|
936
|
+
}
|
|
937
|
+
return t;
|
|
938
|
+
}
|
|
939
|
+
function jt(e) {
|
|
940
|
+
return typeof e != "object" || !e ? "" : `; props: [${Object.getOwnPropertyNames(e).map((e) => `"${e}"`).join(", ")}]`;
|
|
941
|
+
}
|
|
942
|
+
//#endregion
|
|
943
|
+
//#region node_modules/openai/core/resource.mjs
|
|
944
|
+
var N = class {
|
|
945
|
+
constructor(e) {
|
|
946
|
+
this._client = e;
|
|
947
|
+
}
|
|
948
|
+
};
|
|
949
|
+
//#endregion
|
|
950
|
+
//#region node_modules/openai/internal/utils/path.mjs
|
|
951
|
+
function Mt(e) {
|
|
952
|
+
return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
|
|
953
|
+
}
|
|
954
|
+
var Nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null)), P = /* @__PURE__ */ ((e = Mt) => function(t, ...n) {
|
|
955
|
+
if (t.length === 1) return t[0];
|
|
956
|
+
let r = !1, i = [], o = t.reduce((t, a, o) => {
|
|
957
|
+
/[?#]/.test(a) && (r = !0);
|
|
958
|
+
let s = n[o], c = (r ? encodeURIComponent : e)("" + s);
|
|
959
|
+
return o !== n.length && (s == null || typeof s == "object" && s.toString === Object.getPrototypeOf(Object.getPrototypeOf(s.hasOwnProperty ?? Nt) ?? Nt)?.toString) && (c = s + "", i.push({
|
|
960
|
+
start: t.length + a.length,
|
|
961
|
+
length: c.length,
|
|
962
|
+
error: `Value of type ${Object.prototype.toString.call(s).slice(8, -1)} is not a valid path parameter`
|
|
963
|
+
})), t + a + (o === n.length ? "" : c);
|
|
964
|
+
}, ""), s = o.split(/[?#]/, 1)[0], c = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi, l;
|
|
965
|
+
for (; (l = c.exec(s)) !== null;) i.push({
|
|
966
|
+
start: l.index,
|
|
967
|
+
length: l[0].length,
|
|
968
|
+
error: `Value "${l[0]}" can\'t be safely passed as a path parameter`
|
|
969
|
+
});
|
|
970
|
+
if (i.sort((e, t) => e.start - t.start), i.length > 0) {
|
|
971
|
+
let e = 0, t = i.reduce((t, n) => {
|
|
972
|
+
let r = " ".repeat(n.start - e), i = "^".repeat(n.length);
|
|
973
|
+
return e = n.start + n.length, t + r + i;
|
|
974
|
+
}, "");
|
|
975
|
+
throw new a(`Path parameters result in path with invalid segments:\n${i.map((e) => e.error).join("\n")}\n${o}\n${t}`);
|
|
976
|
+
}
|
|
977
|
+
return o;
|
|
978
|
+
})(Mt), Pt = class extends N {
|
|
979
|
+
list(e, t = {}, n) {
|
|
980
|
+
return this._client.getAPIList(P`/chat/completions/${e}/messages`, j, {
|
|
981
|
+
query: t,
|
|
982
|
+
...n
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
//#endregion
|
|
987
|
+
//#region node_modules/openai/lib/parser.mjs
|
|
988
|
+
function Ft(e) {
|
|
989
|
+
return e !== void 0 && "function" in e && e.function !== void 0;
|
|
990
|
+
}
|
|
991
|
+
function It(e) {
|
|
992
|
+
return e?.$brand === "auto-parseable-response-format";
|
|
993
|
+
}
|
|
994
|
+
function Lt(e) {
|
|
995
|
+
return e?.$brand === "auto-parseable-tool";
|
|
996
|
+
}
|
|
997
|
+
function Rt(e, t) {
|
|
998
|
+
return !t || !Ut(t) ? {
|
|
999
|
+
...e,
|
|
1000
|
+
choices: e.choices.map((e) => (Wt(e.message.tool_calls), {
|
|
1001
|
+
...e,
|
|
1002
|
+
message: {
|
|
1003
|
+
...e.message,
|
|
1004
|
+
parsed: null,
|
|
1005
|
+
...e.message.tool_calls ? { tool_calls: e.message.tool_calls } : void 0
|
|
1006
|
+
}
|
|
1007
|
+
}))
|
|
1008
|
+
} : zt(e, t);
|
|
1009
|
+
}
|
|
1010
|
+
function zt(e, t) {
|
|
1011
|
+
let n = e.choices.map((e) => {
|
|
1012
|
+
if (e.finish_reason === "length") throw new v();
|
|
1013
|
+
if (e.finish_reason === "content_filter") throw new y();
|
|
1014
|
+
return Wt(e.message.tool_calls), {
|
|
1015
|
+
...e,
|
|
1016
|
+
message: {
|
|
1017
|
+
...e.message,
|
|
1018
|
+
...e.message.tool_calls ? { tool_calls: e.message.tool_calls?.map((e) => Vt(t, e)) ?? void 0 } : void 0,
|
|
1019
|
+
parsed: e.message.content && !e.message.refusal ? Bt(t, e.message.content) : null
|
|
1020
|
+
}
|
|
1021
|
+
};
|
|
1022
|
+
});
|
|
1023
|
+
return {
|
|
1024
|
+
...e,
|
|
1025
|
+
choices: n
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
function Bt(e, t) {
|
|
1029
|
+
return e.response_format?.type === "json_schema" && e.response_format?.type === "json_schema" ? "$parseRaw" in e.response_format ? e.response_format.$parseRaw(t) : JSON.parse(t) : null;
|
|
1030
|
+
}
|
|
1031
|
+
function Vt(e, t) {
|
|
1032
|
+
let n = e.tools?.find((e) => Ft(e) && e.function?.name === t.function.name);
|
|
1033
|
+
return {
|
|
1034
|
+
...t,
|
|
1035
|
+
function: {
|
|
1036
|
+
...t.function,
|
|
1037
|
+
parsed_arguments: Lt(n) ? n.$parseRaw(t.function.arguments) : n?.function.strict ? JSON.parse(t.function.arguments) : null
|
|
1038
|
+
}
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
function Ht(e, t) {
|
|
1042
|
+
if (!e || !("tools" in e) || !e.tools) return !1;
|
|
1043
|
+
let n = e.tools?.find((e) => Ft(e) && e.function?.name === t.function.name);
|
|
1044
|
+
return Ft(n) && (Lt(n) || n?.function.strict || !1);
|
|
1045
|
+
}
|
|
1046
|
+
function Ut(e) {
|
|
1047
|
+
return It(e.response_format) ? !0 : e.tools?.some((e) => Lt(e) || e.type === "function" && e.function.strict === !0) ?? !1;
|
|
1048
|
+
}
|
|
1049
|
+
function Wt(e) {
|
|
1050
|
+
for (let t of e || []) if (t.type !== "function") throw new a(`Currently only \`function\` tool calls are supported; Received \`${t.type}\``);
|
|
1051
|
+
}
|
|
1052
|
+
function Gt(e) {
|
|
1053
|
+
for (let t of e ?? []) {
|
|
1054
|
+
if (t.type !== "function") throw new a(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);
|
|
1055
|
+
if (t.function.strict !== !0) throw new a(`The \`${t.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
//#endregion
|
|
1059
|
+
//#region node_modules/openai/lib/chatCompletionUtils.mjs
|
|
1060
|
+
var Kt = (e) => e?.role === "assistant", qt = (e) => e?.role === "tool", Jt, Yt, Xt, Zt, Qt, $t, en, F, tn, nn, rn, an, on, sn = class {
|
|
1061
|
+
constructor() {
|
|
1062
|
+
Jt.add(this), this.controller = new AbortController(), Yt.set(this, void 0), Xt.set(this, () => {}), Zt.set(this, () => {}), Qt.set(this, void 0), $t.set(this, () => {}), en.set(this, () => {}), F.set(this, {}), tn.set(this, !1), nn.set(this, !1), rn.set(this, !1), an.set(this, !1), e(this, Yt, new Promise((t, n) => {
|
|
1063
|
+
e(this, Xt, t, "f"), e(this, Zt, n, "f");
|
|
1064
|
+
}), "f"), e(this, Qt, new Promise((t, n) => {
|
|
1065
|
+
e(this, $t, t, "f"), e(this, en, n, "f");
|
|
1066
|
+
}), "f"), t(this, Yt, "f").catch(() => {}), t(this, Qt, "f").catch(() => {});
|
|
1067
|
+
}
|
|
1068
|
+
_run(e) {
|
|
1069
|
+
setTimeout(() => {
|
|
1070
|
+
e().then(() => {
|
|
1071
|
+
this._emitFinal(), this._emit("end");
|
|
1072
|
+
}, t(this, Jt, "m", on).bind(this));
|
|
1073
|
+
}, 0);
|
|
1074
|
+
}
|
|
1075
|
+
_connected() {
|
|
1076
|
+
this.ended || (t(this, Xt, "f").call(this), this._emit("connect"));
|
|
1077
|
+
}
|
|
1078
|
+
get ended() {
|
|
1079
|
+
return t(this, tn, "f");
|
|
1080
|
+
}
|
|
1081
|
+
get errored() {
|
|
1082
|
+
return t(this, nn, "f");
|
|
1083
|
+
}
|
|
1084
|
+
get aborted() {
|
|
1085
|
+
return t(this, rn, "f");
|
|
1086
|
+
}
|
|
1087
|
+
abort() {
|
|
1088
|
+
this.controller.abort();
|
|
1089
|
+
}
|
|
1090
|
+
on(e, n) {
|
|
1091
|
+
return (t(this, F, "f")[e] || (t(this, F, "f")[e] = [])).push({ listener: n }), this;
|
|
1092
|
+
}
|
|
1093
|
+
off(e, n) {
|
|
1094
|
+
let r = t(this, F, "f")[e];
|
|
1095
|
+
if (!r) return this;
|
|
1096
|
+
let i = r.findIndex((e) => e.listener === n);
|
|
1097
|
+
return i >= 0 && r.splice(i, 1), this;
|
|
1098
|
+
}
|
|
1099
|
+
once(e, n) {
|
|
1100
|
+
return (t(this, F, "f")[e] || (t(this, F, "f")[e] = [])).push({
|
|
1101
|
+
listener: n,
|
|
1102
|
+
once: !0
|
|
1103
|
+
}), this;
|
|
1104
|
+
}
|
|
1105
|
+
emitted(t) {
|
|
1106
|
+
return new Promise((n, r) => {
|
|
1107
|
+
e(this, an, !0, "f"), t !== "error" && this.once("error", r), this.once(t, n);
|
|
1108
|
+
});
|
|
1109
|
+
}
|
|
1110
|
+
async done() {
|
|
1111
|
+
e(this, an, !0, "f"), await t(this, Qt, "f");
|
|
1112
|
+
}
|
|
1113
|
+
_emit(n, ...r) {
|
|
1114
|
+
if (t(this, tn, "f")) return;
|
|
1115
|
+
n === "end" && (e(this, tn, !0, "f"), t(this, $t, "f").call(this));
|
|
1116
|
+
let i = t(this, F, "f")[n];
|
|
1117
|
+
if (i && (t(this, F, "f")[n] = i.filter((e) => !e.once), i.forEach(({ listener: e }) => e(...r))), n === "abort") {
|
|
1118
|
+
let e = r[0];
|
|
1119
|
+
!t(this, an, "f") && !i?.length && Promise.reject(e), t(this, Zt, "f").call(this, e), t(this, en, "f").call(this, e), this._emit("end");
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1122
|
+
if (n === "error") {
|
|
1123
|
+
let e = r[0];
|
|
1124
|
+
!t(this, an, "f") && !i?.length && Promise.reject(e), t(this, Zt, "f").call(this, e), t(this, en, "f").call(this, e), this._emit("end");
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
_emitFinal() {}
|
|
1128
|
+
};
|
|
1129
|
+
Yt = /* @__PURE__ */ new WeakMap(), Xt = /* @__PURE__ */ new WeakMap(), Zt = /* @__PURE__ */ new WeakMap(), Qt = /* @__PURE__ */ new WeakMap(), $t = /* @__PURE__ */ new WeakMap(), en = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), tn = /* @__PURE__ */ new WeakMap(), nn = /* @__PURE__ */ new WeakMap(), rn = /* @__PURE__ */ new WeakMap(), an = /* @__PURE__ */ new WeakMap(), Jt = /* @__PURE__ */ new WeakSet(), on = function(t) {
|
|
1130
|
+
if (e(this, nn, !0, "f"), t instanceof Error && t.name === "AbortError" && (t = new s()), t instanceof s) return e(this, rn, !0, "f"), this._emit("abort", t);
|
|
1131
|
+
if (t instanceof a) return this._emit("error", t);
|
|
1132
|
+
if (t instanceof Error) {
|
|
1133
|
+
let e = new a(t.message);
|
|
1134
|
+
return e.cause = t, this._emit("error", e);
|
|
1135
|
+
}
|
|
1136
|
+
return this._emit("error", new a(String(t)));
|
|
1137
|
+
};
|
|
1138
|
+
//#endregion
|
|
1139
|
+
//#region node_modules/openai/lib/RunnableFunction.mjs
|
|
1140
|
+
function cn(e) {
|
|
1141
|
+
return typeof e.parse == "function";
|
|
1142
|
+
}
|
|
1143
|
+
//#endregion
|
|
1144
|
+
//#region node_modules/openai/lib/AbstractChatCompletionRunner.mjs
|
|
1145
|
+
var I, ln, un, dn, fn, pn, mn, hn, gn = 10, _n = class extends sn {
|
|
1146
|
+
constructor() {
|
|
1147
|
+
super(...arguments), I.add(this), this._chatCompletions = [], this.messages = [];
|
|
1148
|
+
}
|
|
1149
|
+
_addChatCompletion(e) {
|
|
1150
|
+
this._chatCompletions.push(e), this._emit("chatCompletion", e);
|
|
1151
|
+
let t = e.choices[0]?.message;
|
|
1152
|
+
return t && this._addMessage(t), e;
|
|
1153
|
+
}
|
|
1154
|
+
_addMessage(e, t = !0) {
|
|
1155
|
+
if ("content" in e || (e.content = null), this.messages.push(e), t) {
|
|
1156
|
+
if (this._emit("message", e), qt(e) && e.content) this._emit("functionToolCallResult", e.content);
|
|
1157
|
+
else if (Kt(e) && e.tool_calls) for (let t of e.tool_calls) t.type === "function" && this._emit("functionToolCall", t.function);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
async finalChatCompletion() {
|
|
1161
|
+
await this.done();
|
|
1162
|
+
let e = this._chatCompletions[this._chatCompletions.length - 1];
|
|
1163
|
+
if (!e) throw new a("stream ended without producing a ChatCompletion");
|
|
1164
|
+
return e;
|
|
1165
|
+
}
|
|
1166
|
+
async finalContent() {
|
|
1167
|
+
return await this.done(), t(this, I, "m", ln).call(this);
|
|
1168
|
+
}
|
|
1169
|
+
async finalMessage() {
|
|
1170
|
+
return await this.done(), t(this, I, "m", un).call(this);
|
|
1171
|
+
}
|
|
1172
|
+
async finalFunctionToolCall() {
|
|
1173
|
+
return await this.done(), t(this, I, "m", dn).call(this);
|
|
1174
|
+
}
|
|
1175
|
+
async finalFunctionToolCallResult() {
|
|
1176
|
+
return await this.done(), t(this, I, "m", fn).call(this);
|
|
1177
|
+
}
|
|
1178
|
+
async totalUsage() {
|
|
1179
|
+
return await this.done(), t(this, I, "m", pn).call(this);
|
|
1180
|
+
}
|
|
1181
|
+
allChatCompletions() {
|
|
1182
|
+
return [...this._chatCompletions];
|
|
1183
|
+
}
|
|
1184
|
+
_emitFinal() {
|
|
1185
|
+
let e = this._chatCompletions[this._chatCompletions.length - 1];
|
|
1186
|
+
e && this._emit("finalChatCompletion", e);
|
|
1187
|
+
let n = t(this, I, "m", un).call(this);
|
|
1188
|
+
n && this._emit("finalMessage", n);
|
|
1189
|
+
let r = t(this, I, "m", ln).call(this);
|
|
1190
|
+
r && this._emit("finalContent", r);
|
|
1191
|
+
let i = t(this, I, "m", dn).call(this);
|
|
1192
|
+
i && this._emit("finalFunctionToolCall", i);
|
|
1193
|
+
let a = t(this, I, "m", fn).call(this);
|
|
1194
|
+
a != null && this._emit("finalFunctionToolCallResult", a), this._chatCompletions.some((e) => e.usage) && this._emit("totalUsage", t(this, I, "m", pn).call(this));
|
|
1195
|
+
}
|
|
1196
|
+
async _createChatCompletion(e, n, r) {
|
|
1197
|
+
let i = r?.signal;
|
|
1198
|
+
i && (i.aborted && this.controller.abort(), i.addEventListener("abort", () => this.controller.abort())), t(this, I, "m", mn).call(this, n);
|
|
1199
|
+
let a = await e.chat.completions.create({
|
|
1200
|
+
...n,
|
|
1201
|
+
stream: !1
|
|
1202
|
+
}, {
|
|
1203
|
+
...r,
|
|
1204
|
+
signal: this.controller.signal
|
|
1205
|
+
});
|
|
1206
|
+
return this._connected(), this._addChatCompletion(zt(a, n));
|
|
1207
|
+
}
|
|
1208
|
+
async _runChatCompletion(e, t, n) {
|
|
1209
|
+
for (let e of t.messages) this._addMessage(e, !1);
|
|
1210
|
+
return await this._createChatCompletion(e, t, n);
|
|
1211
|
+
}
|
|
1212
|
+
async _runTools(e, n, r) {
|
|
1213
|
+
let i = "tool", { tool_choice: o = "auto", stream: s, ...c } = n, l = typeof o != "string" && o.type === "function" && o?.function?.name, { maxChatCompletions: u = gn } = r || {}, d = n.tools.map((e) => {
|
|
1214
|
+
if (Lt(e)) {
|
|
1215
|
+
if (!e.$callback) throw new a("Tool given to `.runTools()` that does not have an associated function");
|
|
1216
|
+
return {
|
|
1217
|
+
type: "function",
|
|
1218
|
+
function: {
|
|
1219
|
+
function: e.$callback,
|
|
1220
|
+
name: e.function.name,
|
|
1221
|
+
description: e.function.description || "",
|
|
1222
|
+
parameters: e.function.parameters,
|
|
1223
|
+
parse: e.$parseRaw,
|
|
1224
|
+
strict: !0
|
|
1225
|
+
}
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1228
|
+
return e;
|
|
1229
|
+
}), f = {};
|
|
1230
|
+
for (let e of d) e.type === "function" && (f[e.function.name || e.function.function.name] = e.function);
|
|
1231
|
+
let p = "tools" in n ? d.map((e) => e.type === "function" ? {
|
|
1232
|
+
type: "function",
|
|
1233
|
+
function: {
|
|
1234
|
+
name: e.function.name || e.function.function.name,
|
|
1235
|
+
parameters: e.function.parameters,
|
|
1236
|
+
description: e.function.description,
|
|
1237
|
+
strict: e.function.strict
|
|
1238
|
+
}
|
|
1239
|
+
} : e) : void 0;
|
|
1240
|
+
for (let e of n.messages) this._addMessage(e, !1);
|
|
1241
|
+
for (let n = 0; n < u; ++n) {
|
|
1242
|
+
let n = (await this._createChatCompletion(e, {
|
|
1243
|
+
...c,
|
|
1244
|
+
tool_choice: o,
|
|
1245
|
+
tools: p,
|
|
1246
|
+
messages: [...this.messages]
|
|
1247
|
+
}, r)).choices[0]?.message;
|
|
1248
|
+
if (!n) throw new a("missing message in ChatCompletion response");
|
|
1249
|
+
if (!n.tool_calls?.length) return;
|
|
1250
|
+
for (let e of n.tool_calls) {
|
|
1251
|
+
if (e.type !== "function") continue;
|
|
1252
|
+
let n = e.id, { name: r, arguments: a } = e.function, o = f[r];
|
|
1253
|
+
if (!o) {
|
|
1254
|
+
let e = `Invalid tool_call: ${JSON.stringify(r)}. Available options are: ${Object.keys(f).map((e) => JSON.stringify(e)).join(", ")}. Please try again`;
|
|
1255
|
+
this._addMessage({
|
|
1256
|
+
role: i,
|
|
1257
|
+
tool_call_id: n,
|
|
1258
|
+
content: e
|
|
1259
|
+
});
|
|
1260
|
+
continue;
|
|
1261
|
+
} else if (l && l !== r) {
|
|
1262
|
+
let e = `Invalid tool_call: ${JSON.stringify(r)}. ${JSON.stringify(l)} requested. Please try again`;
|
|
1263
|
+
this._addMessage({
|
|
1264
|
+
role: i,
|
|
1265
|
+
tool_call_id: n,
|
|
1266
|
+
content: e
|
|
1267
|
+
});
|
|
1268
|
+
continue;
|
|
1269
|
+
}
|
|
1270
|
+
let s;
|
|
1271
|
+
try {
|
|
1272
|
+
s = cn(o) ? await o.parse(a) : a;
|
|
1273
|
+
} catch (e) {
|
|
1274
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
1275
|
+
this._addMessage({
|
|
1276
|
+
role: i,
|
|
1277
|
+
tool_call_id: n,
|
|
1278
|
+
content: t
|
|
1279
|
+
});
|
|
1280
|
+
continue;
|
|
1281
|
+
}
|
|
1282
|
+
let c = await o.function(s, this), u = t(this, I, "m", hn).call(this, c);
|
|
1283
|
+
if (this._addMessage({
|
|
1284
|
+
role: i,
|
|
1285
|
+
tool_call_id: n,
|
|
1286
|
+
content: u
|
|
1287
|
+
}), l) return;
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
};
|
|
1292
|
+
I = /* @__PURE__ */ new WeakSet(), ln = function() {
|
|
1293
|
+
return t(this, I, "m", un).call(this).content ?? null;
|
|
1294
|
+
}, un = function() {
|
|
1295
|
+
let e = this.messages.length;
|
|
1296
|
+
for (; e-- > 0;) {
|
|
1297
|
+
let t = this.messages[e];
|
|
1298
|
+
if (Kt(t)) return {
|
|
1299
|
+
...t,
|
|
1300
|
+
content: t.content ?? null,
|
|
1301
|
+
refusal: t.refusal ?? null
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
throw new a("stream ended without producing a ChatCompletionMessage with role=assistant");
|
|
1305
|
+
}, dn = function() {
|
|
1306
|
+
for (let e = this.messages.length - 1; e >= 0; e--) {
|
|
1307
|
+
let t = this.messages[e];
|
|
1308
|
+
if (Kt(t) && t?.tool_calls?.length) return t.tool_calls.filter((e) => e.type === "function").at(-1)?.function;
|
|
1309
|
+
}
|
|
1310
|
+
}, fn = function() {
|
|
1311
|
+
for (let e = this.messages.length - 1; e >= 0; e--) {
|
|
1312
|
+
let t = this.messages[e];
|
|
1313
|
+
if (qt(t) && t.content != null && typeof t.content == "string" && this.messages.some((e) => e.role === "assistant" && e.tool_calls?.some((e) => e.type === "function" && e.id === t.tool_call_id))) return t.content;
|
|
1314
|
+
}
|
|
1315
|
+
}, pn = function() {
|
|
1316
|
+
let e = {
|
|
1317
|
+
completion_tokens: 0,
|
|
1318
|
+
prompt_tokens: 0,
|
|
1319
|
+
total_tokens: 0
|
|
1320
|
+
};
|
|
1321
|
+
for (let { usage: t } of this._chatCompletions) t && (e.completion_tokens += t.completion_tokens, e.prompt_tokens += t.prompt_tokens, e.total_tokens += t.total_tokens);
|
|
1322
|
+
return e;
|
|
1323
|
+
}, mn = function(e) {
|
|
1324
|
+
if (e.n != null && e.n > 1) throw new a("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.");
|
|
1325
|
+
}, hn = function(e) {
|
|
1326
|
+
return typeof e == "string" ? e : e === void 0 ? "undefined" : JSON.stringify(e);
|
|
1327
|
+
};
|
|
1328
|
+
//#endregion
|
|
1329
|
+
//#region node_modules/openai/lib/ChatCompletionRunner.mjs
|
|
1330
|
+
var vn = class e extends _n {
|
|
1331
|
+
static runTools(t, n, r) {
|
|
1332
|
+
let i = new e(), a = {
|
|
1333
|
+
...r,
|
|
1334
|
+
headers: {
|
|
1335
|
+
...r?.headers,
|
|
1336
|
+
"X-Stainless-Helper-Method": "runTools"
|
|
1337
|
+
}
|
|
1338
|
+
};
|
|
1339
|
+
return i._run(() => i._runTools(t, n, a)), i;
|
|
1340
|
+
}
|
|
1341
|
+
_addMessage(e, t = !0) {
|
|
1342
|
+
super._addMessage(e, t), Kt(e) && e.content && this._emit("content", e.content);
|
|
1343
|
+
}
|
|
1344
|
+
}, yn = 1, bn = 2, xn = 4, Sn = 8, Cn = 16, wn = 32, Tn = 64, En = 128, Dn = 256, On = En | Dn, kn = 496, An = bn | 497, jn = xn | Sn, L = {
|
|
1345
|
+
STR: yn,
|
|
1346
|
+
NUM: bn,
|
|
1347
|
+
ARR: xn,
|
|
1348
|
+
OBJ: Sn,
|
|
1349
|
+
NULL: Cn,
|
|
1350
|
+
BOOL: wn,
|
|
1351
|
+
NAN: Tn,
|
|
1352
|
+
INFINITY: En,
|
|
1353
|
+
MINUS_INFINITY: Dn,
|
|
1354
|
+
INF: On,
|
|
1355
|
+
SPECIAL: kn,
|
|
1356
|
+
ATOM: An,
|
|
1357
|
+
COLLECTION: jn,
|
|
1358
|
+
ALL: An | jn
|
|
1359
|
+
}, Mn = class extends Error {}, Nn = class extends Error {};
|
|
1360
|
+
function Pn(e, t = L.ALL) {
|
|
1361
|
+
if (typeof e != "string") throw TypeError(`expecting str, got ${typeof e}`);
|
|
1362
|
+
if (!e.trim()) throw Error(`${e} is empty`);
|
|
1363
|
+
return Fn(e.trim(), t);
|
|
1364
|
+
}
|
|
1365
|
+
var Fn = (e, t) => {
|
|
1366
|
+
let n = e.length, r = 0, i = (e) => {
|
|
1367
|
+
throw new Mn(`${e} at position ${r}`);
|
|
1368
|
+
}, a = (e) => {
|
|
1369
|
+
throw new Nn(`${e} at position ${r}`);
|
|
1370
|
+
}, o = () => (d(), r >= n && i("Unexpected end of input"), e[r] === "\"" ? s() : e[r] === "{" ? c() : e[r] === "[" ? l() : e.substring(r, r + 4) === "null" || L.NULL & t && n - r < 4 && "null".startsWith(e.substring(r)) ? (r += 4, null) : e.substring(r, r + 4) === "true" || L.BOOL & t && n - r < 4 && "true".startsWith(e.substring(r)) ? (r += 4, !0) : e.substring(r, r + 5) === "false" || L.BOOL & t && n - r < 5 && "false".startsWith(e.substring(r)) ? (r += 5, !1) : e.substring(r, r + 8) === "Infinity" || L.INFINITY & t && n - r < 8 && "Infinity".startsWith(e.substring(r)) ? (r += 8, Infinity) : e.substring(r, r + 9) === "-Infinity" || L.MINUS_INFINITY & t && 1 < n - r && n - r < 9 && "-Infinity".startsWith(e.substring(r)) ? (r += 9, -Infinity) : e.substring(r, r + 3) === "NaN" || L.NAN & t && n - r < 3 && "NaN".startsWith(e.substring(r)) ? (r += 3, NaN) : u()), s = () => {
|
|
1371
|
+
let o = r, s = !1;
|
|
1372
|
+
for (r++; r < n && (e[r] !== "\"" || s && e[r - 1] === "\\");) s = e[r] === "\\" ? !s : !1, r++;
|
|
1373
|
+
if (e.charAt(r) == "\"") try {
|
|
1374
|
+
return JSON.parse(e.substring(o, ++r - Number(s)));
|
|
1375
|
+
} catch (e) {
|
|
1376
|
+
a(String(e));
|
|
1377
|
+
}
|
|
1378
|
+
else if (L.STR & t) try {
|
|
1379
|
+
return JSON.parse(e.substring(o, r - Number(s)) + "\"");
|
|
1380
|
+
} catch {
|
|
1381
|
+
return JSON.parse(e.substring(o, e.lastIndexOf("\\")) + "\"");
|
|
1382
|
+
}
|
|
1383
|
+
i("Unterminated string literal");
|
|
1384
|
+
}, c = () => {
|
|
1385
|
+
r++, d();
|
|
1386
|
+
let a = {};
|
|
1387
|
+
try {
|
|
1388
|
+
for (; e[r] !== "}";) {
|
|
1389
|
+
if (d(), r >= n && L.OBJ & t) return a;
|
|
1390
|
+
let i = s();
|
|
1391
|
+
d(), r++;
|
|
1392
|
+
try {
|
|
1393
|
+
let e = o();
|
|
1394
|
+
Object.defineProperty(a, i, {
|
|
1395
|
+
value: e,
|
|
1396
|
+
writable: !0,
|
|
1397
|
+
enumerable: !0,
|
|
1398
|
+
configurable: !0
|
|
1399
|
+
});
|
|
1400
|
+
} catch (e) {
|
|
1401
|
+
if (L.OBJ & t) return a;
|
|
1402
|
+
throw e;
|
|
1403
|
+
}
|
|
1404
|
+
d(), e[r] === "," && r++;
|
|
1405
|
+
}
|
|
1406
|
+
} catch {
|
|
1407
|
+
if (L.OBJ & t) return a;
|
|
1408
|
+
i("Expected '}' at end of object");
|
|
1409
|
+
}
|
|
1410
|
+
return r++, a;
|
|
1411
|
+
}, l = () => {
|
|
1412
|
+
r++;
|
|
1413
|
+
let n = [];
|
|
1414
|
+
try {
|
|
1415
|
+
for (; e[r] !== "]";) n.push(o()), d(), e[r] === "," && r++;
|
|
1416
|
+
} catch {
|
|
1417
|
+
if (L.ARR & t) return n;
|
|
1418
|
+
i("Expected ']' at end of array");
|
|
1419
|
+
}
|
|
1420
|
+
return r++, n;
|
|
1421
|
+
}, u = () => {
|
|
1422
|
+
if (r === 0) {
|
|
1423
|
+
e === "-" && L.NUM & t && i("Not sure what '-' is");
|
|
1424
|
+
try {
|
|
1425
|
+
return JSON.parse(e);
|
|
1426
|
+
} catch (n) {
|
|
1427
|
+
if (L.NUM & t) try {
|
|
1428
|
+
return e[e.length - 1] === "." ? JSON.parse(e.substring(0, e.lastIndexOf("."))) : JSON.parse(e.substring(0, e.lastIndexOf("e")));
|
|
1429
|
+
} catch {}
|
|
1430
|
+
a(String(n));
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
let o = r;
|
|
1434
|
+
for (e[r] === "-" && r++; e[r] && !",]}".includes(e[r]);) r++;
|
|
1435
|
+
r == n && !(L.NUM & t) && i("Unterminated number literal");
|
|
1436
|
+
try {
|
|
1437
|
+
return JSON.parse(e.substring(o, r));
|
|
1438
|
+
} catch {
|
|
1439
|
+
e.substring(o, r) === "-" && L.NUM & t && i("Not sure what '-' is");
|
|
1440
|
+
try {
|
|
1441
|
+
return JSON.parse(e.substring(o, e.lastIndexOf("e")));
|
|
1442
|
+
} catch (e) {
|
|
1443
|
+
a(String(e));
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
}, d = () => {
|
|
1447
|
+
for (; r < n && " \n\r ".includes(e[r]);) r++;
|
|
1448
|
+
};
|
|
1449
|
+
return o();
|
|
1450
|
+
}, In = (e) => Pn(e, L.ALL ^ L.NUM), R, z, B, V, Ln, Rn, zn, Bn, Vn, Hn, Un, Wn, Gn = class n extends _n {
|
|
1451
|
+
constructor(t) {
|
|
1452
|
+
super(), R.add(this), z.set(this, void 0), B.set(this, void 0), V.set(this, void 0), e(this, z, t, "f"), e(this, B, [], "f");
|
|
1453
|
+
}
|
|
1454
|
+
get currentChatCompletionSnapshot() {
|
|
1455
|
+
return t(this, V, "f");
|
|
1456
|
+
}
|
|
1457
|
+
static fromReadableStream(e) {
|
|
1458
|
+
let t = new n(null);
|
|
1459
|
+
return t._run(() => t._fromReadableStream(e)), t;
|
|
1460
|
+
}
|
|
1461
|
+
static createChatCompletion(e, t, r) {
|
|
1462
|
+
let i = new n(t);
|
|
1463
|
+
return i._run(() => i._runChatCompletion(e, {
|
|
1464
|
+
...t,
|
|
1465
|
+
stream: !0
|
|
1466
|
+
}, {
|
|
1467
|
+
...r,
|
|
1468
|
+
headers: {
|
|
1469
|
+
...r?.headers,
|
|
1470
|
+
"X-Stainless-Helper-Method": "stream"
|
|
1471
|
+
}
|
|
1472
|
+
})), i;
|
|
1473
|
+
}
|
|
1474
|
+
async _createChatCompletion(e, n, r) {
|
|
1475
|
+
super._createChatCompletion;
|
|
1476
|
+
let i = r?.signal;
|
|
1477
|
+
i && (i.aborted && this.controller.abort(), i.addEventListener("abort", () => this.controller.abort())), t(this, R, "m", Ln).call(this);
|
|
1478
|
+
let a = await e.chat.completions.create({
|
|
1479
|
+
...n,
|
|
1480
|
+
stream: !0
|
|
1481
|
+
}, {
|
|
1482
|
+
...r,
|
|
1483
|
+
signal: this.controller.signal
|
|
1484
|
+
});
|
|
1485
|
+
this._connected();
|
|
1486
|
+
for await (let e of a) t(this, R, "m", zn).call(this, e);
|
|
1487
|
+
if (a.controller.signal?.aborted) throw new s();
|
|
1488
|
+
return this._addChatCompletion(t(this, R, "m", Hn).call(this));
|
|
1489
|
+
}
|
|
1490
|
+
async _fromReadableStream(e, n) {
|
|
1491
|
+
let r = n?.signal;
|
|
1492
|
+
r && (r.aborted && this.controller.abort(), r.addEventListener("abort", () => this.controller.abort())), t(this, R, "m", Ln).call(this), this._connected();
|
|
1493
|
+
let i = et.fromReadableStream(e, this.controller), a;
|
|
1494
|
+
for await (let e of i) a && a !== e.id && this._addChatCompletion(t(this, R, "m", Hn).call(this)), t(this, R, "m", zn).call(this, e), a = e.id;
|
|
1495
|
+
if (i.controller.signal?.aborted) throw new s();
|
|
1496
|
+
return this._addChatCompletion(t(this, R, "m", Hn).call(this));
|
|
1497
|
+
}
|
|
1498
|
+
[(z = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakMap(), V = /* @__PURE__ */ new WeakMap(), R = /* @__PURE__ */ new WeakSet(), Ln = function() {
|
|
1499
|
+
this.ended || e(this, V, void 0, "f");
|
|
1500
|
+
}, Rn = function(e) {
|
|
1501
|
+
let n = t(this, B, "f")[e.index];
|
|
1502
|
+
return n || (n = {
|
|
1503
|
+
content_done: !1,
|
|
1504
|
+
refusal_done: !1,
|
|
1505
|
+
logprobs_content_done: !1,
|
|
1506
|
+
logprobs_refusal_done: !1,
|
|
1507
|
+
done_tool_calls: /* @__PURE__ */ new Set(),
|
|
1508
|
+
current_tool_call_index: null
|
|
1509
|
+
}, t(this, B, "f")[e.index] = n, n);
|
|
1510
|
+
}, zn = function(e) {
|
|
1511
|
+
if (this.ended) return;
|
|
1512
|
+
let n = t(this, R, "m", Wn).call(this, e);
|
|
1513
|
+
this._emit("chunk", e, n);
|
|
1514
|
+
for (let r of e.choices) {
|
|
1515
|
+
let e = n.choices[r.index];
|
|
1516
|
+
r.delta.content != null && e.message?.role === "assistant" && e.message?.content && (this._emit("content", r.delta.content, e.message.content), this._emit("content.delta", {
|
|
1517
|
+
delta: r.delta.content,
|
|
1518
|
+
snapshot: e.message.content,
|
|
1519
|
+
parsed: e.message.parsed
|
|
1520
|
+
})), r.delta.refusal != null && e.message?.role === "assistant" && e.message?.refusal && this._emit("refusal.delta", {
|
|
1521
|
+
delta: r.delta.refusal,
|
|
1522
|
+
snapshot: e.message.refusal
|
|
1523
|
+
}), r.logprobs?.content != null && e.message?.role === "assistant" && this._emit("logprobs.content.delta", {
|
|
1524
|
+
content: r.logprobs?.content,
|
|
1525
|
+
snapshot: e.logprobs?.content ?? []
|
|
1526
|
+
}), r.logprobs?.refusal != null && e.message?.role === "assistant" && this._emit("logprobs.refusal.delta", {
|
|
1527
|
+
refusal: r.logprobs?.refusal,
|
|
1528
|
+
snapshot: e.logprobs?.refusal ?? []
|
|
1529
|
+
});
|
|
1530
|
+
let i = t(this, R, "m", Rn).call(this, e);
|
|
1531
|
+
e.finish_reason && (t(this, R, "m", Vn).call(this, e), i.current_tool_call_index != null && t(this, R, "m", Bn).call(this, e, i.current_tool_call_index));
|
|
1532
|
+
for (let n of r.delta.tool_calls ?? []) i.current_tool_call_index !== n.index && (t(this, R, "m", Vn).call(this, e), i.current_tool_call_index != null && t(this, R, "m", Bn).call(this, e, i.current_tool_call_index)), i.current_tool_call_index = n.index;
|
|
1533
|
+
for (let t of r.delta.tool_calls ?? []) {
|
|
1534
|
+
let n = e.message.tool_calls?.[t.index];
|
|
1535
|
+
n?.type && (n?.type === "function" ? this._emit("tool_calls.function.arguments.delta", {
|
|
1536
|
+
name: n.function?.name,
|
|
1537
|
+
index: t.index,
|
|
1538
|
+
arguments: n.function.arguments,
|
|
1539
|
+
parsed_arguments: n.function.parsed_arguments,
|
|
1540
|
+
arguments_delta: t.function?.arguments ?? ""
|
|
1541
|
+
}) : n?.type);
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
}, Bn = function(e, n) {
|
|
1545
|
+
if (t(this, R, "m", Rn).call(this, e).done_tool_calls.has(n)) return;
|
|
1546
|
+
let r = e.message.tool_calls?.[n];
|
|
1547
|
+
if (!r) throw Error("no tool call snapshot");
|
|
1548
|
+
if (!r.type) throw Error("tool call snapshot missing `type`");
|
|
1549
|
+
if (r.type === "function") {
|
|
1550
|
+
let e = t(this, z, "f")?.tools?.find((e) => Ft(e) && e.function.name === r.function.name);
|
|
1551
|
+
this._emit("tool_calls.function.arguments.done", {
|
|
1552
|
+
name: r.function.name,
|
|
1553
|
+
index: n,
|
|
1554
|
+
arguments: r.function.arguments,
|
|
1555
|
+
parsed_arguments: Lt(e) ? e.$parseRaw(r.function.arguments) : e?.function.strict ? JSON.parse(r.function.arguments) : null
|
|
1556
|
+
});
|
|
1557
|
+
} else r.type;
|
|
1558
|
+
}, Vn = function(e) {
|
|
1559
|
+
let n = t(this, R, "m", Rn).call(this, e);
|
|
1560
|
+
if (e.message.content && !n.content_done) {
|
|
1561
|
+
n.content_done = !0;
|
|
1562
|
+
let r = t(this, R, "m", Un).call(this);
|
|
1563
|
+
this._emit("content.done", {
|
|
1564
|
+
content: e.message.content,
|
|
1565
|
+
parsed: r ? r.$parseRaw(e.message.content) : null
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
e.message.refusal && !n.refusal_done && (n.refusal_done = !0, this._emit("refusal.done", { refusal: e.message.refusal })), e.logprobs?.content && !n.logprobs_content_done && (n.logprobs_content_done = !0, this._emit("logprobs.content.done", { content: e.logprobs.content })), e.logprobs?.refusal && !n.logprobs_refusal_done && (n.logprobs_refusal_done = !0, this._emit("logprobs.refusal.done", { refusal: e.logprobs.refusal }));
|
|
1569
|
+
}, Hn = function() {
|
|
1570
|
+
if (this.ended) throw new a("stream has ended, this shouldn't happen");
|
|
1571
|
+
let n = t(this, V, "f");
|
|
1572
|
+
if (!n) throw new a("request ended without sending any chunks");
|
|
1573
|
+
return e(this, V, void 0, "f"), e(this, B, [], "f"), Kn(n, t(this, z, "f"));
|
|
1574
|
+
}, Un = function() {
|
|
1575
|
+
let e = t(this, z, "f")?.response_format;
|
|
1576
|
+
return It(e) ? e : null;
|
|
1577
|
+
}, Wn = function(n) {
|
|
1578
|
+
var r, i, a, o;
|
|
1579
|
+
let s = t(this, V, "f"), { choices: c, ...l } = n;
|
|
1580
|
+
s ? Object.assign(s, l) : s = e(this, V, {
|
|
1581
|
+
...l,
|
|
1582
|
+
choices: []
|
|
1583
|
+
}, "f");
|
|
1584
|
+
for (let { delta: e, finish_reason: c, index: l, logprobs: u = null, ...d } of n.choices) {
|
|
1585
|
+
let n = s.choices[l];
|
|
1586
|
+
if (n ||= s.choices[l] = {
|
|
1587
|
+
finish_reason: c,
|
|
1588
|
+
index: l,
|
|
1589
|
+
message: {},
|
|
1590
|
+
logprobs: u,
|
|
1591
|
+
...d
|
|
1592
|
+
}, u) if (!n.logprobs) n.logprobs = Object.assign({}, u);
|
|
1593
|
+
else {
|
|
1594
|
+
let { content: e, refusal: t, ...a } = u;
|
|
1595
|
+
Object.assign(n.logprobs, a), e && ((r = n.logprobs).content ?? (r.content = []), n.logprobs.content.push(...e)), t && ((i = n.logprobs).refusal ?? (i.refusal = []), n.logprobs.refusal.push(...t));
|
|
1596
|
+
}
|
|
1597
|
+
if (c && (n.finish_reason = c, t(this, z, "f") && Ut(t(this, z, "f")))) {
|
|
1598
|
+
if (c === "length") throw new v();
|
|
1599
|
+
if (c === "content_filter") throw new y();
|
|
1600
|
+
}
|
|
1601
|
+
if (Object.assign(n, d), !e) continue;
|
|
1602
|
+
let { content: f, refusal: p, function_call: m, role: h, tool_calls: g, ..._ } = e;
|
|
1603
|
+
if (Object.assign(n.message, _), p && (n.message.refusal = (n.message.refusal || "") + p), h && (n.message.role = h), m && (n.message.function_call ? (m.name && (n.message.function_call.name = m.name), m.arguments && ((a = n.message.function_call).arguments ?? (a.arguments = ""), n.message.function_call.arguments += m.arguments)) : n.message.function_call = m), f && (n.message.content = (n.message.content || "") + f, !n.message.refusal && t(this, R, "m", Un).call(this) && (n.message.parsed = In(n.message.content))), g) {
|
|
1604
|
+
n.message.tool_calls || (n.message.tool_calls = []);
|
|
1605
|
+
for (let { index: e, id: r, type: i, function: a, ...s } of g) {
|
|
1606
|
+
let c = (o = n.message.tool_calls)[e] ?? (o[e] = {});
|
|
1607
|
+
Object.assign(c, s), r && (c.id = r), i && (c.type = i), a && (c.function ??= {
|
|
1608
|
+
name: a.name ?? "",
|
|
1609
|
+
arguments: ""
|
|
1610
|
+
}), a?.name && (c.function.name = a.name), a?.arguments && (c.function.arguments += a.arguments, Ht(t(this, z, "f"), c) && (c.function.parsed_arguments = In(c.function.arguments)));
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
return s;
|
|
1615
|
+
}, Symbol.asyncIterator)]() {
|
|
1616
|
+
let e = [], t = [], n = !1;
|
|
1617
|
+
return this.on("chunk", (n) => {
|
|
1618
|
+
let r = t.shift();
|
|
1619
|
+
r ? r.resolve(n) : e.push(n);
|
|
1620
|
+
}), this.on("end", () => {
|
|
1621
|
+
n = !0;
|
|
1622
|
+
for (let e of t) e.resolve(void 0);
|
|
1623
|
+
t.length = 0;
|
|
1624
|
+
}), this.on("abort", (e) => {
|
|
1625
|
+
n = !0;
|
|
1626
|
+
for (let n of t) n.reject(e);
|
|
1627
|
+
t.length = 0;
|
|
1628
|
+
}), this.on("error", (e) => {
|
|
1629
|
+
n = !0;
|
|
1630
|
+
for (let n of t) n.reject(e);
|
|
1631
|
+
t.length = 0;
|
|
1632
|
+
}), {
|
|
1633
|
+
next: async () => e.length ? {
|
|
1634
|
+
value: e.shift(),
|
|
1635
|
+
done: !1
|
|
1636
|
+
} : n ? {
|
|
1637
|
+
value: void 0,
|
|
1638
|
+
done: !0
|
|
1639
|
+
} : new Promise((e, n) => t.push({
|
|
1640
|
+
resolve: e,
|
|
1641
|
+
reject: n
|
|
1642
|
+
})).then((e) => e ? {
|
|
1643
|
+
value: e,
|
|
1644
|
+
done: !1
|
|
1645
|
+
} : {
|
|
1646
|
+
value: void 0,
|
|
1647
|
+
done: !0
|
|
1648
|
+
}),
|
|
1649
|
+
return: async () => (this.abort(), {
|
|
1650
|
+
value: void 0,
|
|
1651
|
+
done: !0
|
|
1652
|
+
})
|
|
1653
|
+
};
|
|
1654
|
+
}
|
|
1655
|
+
toReadableStream() {
|
|
1656
|
+
return new et(this[Symbol.asyncIterator].bind(this), this.controller).toReadableStream();
|
|
1657
|
+
}
|
|
1658
|
+
};
|
|
1659
|
+
function Kn(e, t) {
|
|
1660
|
+
let { id: n, choices: r, created: i, model: o, system_fingerprint: s, ...c } = e;
|
|
1661
|
+
return Rt({
|
|
1662
|
+
...c,
|
|
1663
|
+
id: n,
|
|
1664
|
+
choices: r.map(({ message: t, finish_reason: n, index: r, logprobs: i, ...o }) => {
|
|
1665
|
+
if (!n) throw new a(`missing finish_reason for choice ${r}`);
|
|
1666
|
+
let { content: s = null, function_call: c, tool_calls: l, ...u } = t, d = t.role;
|
|
1667
|
+
if (!d) throw new a(`missing role for choice ${r}`);
|
|
1668
|
+
if (c) {
|
|
1669
|
+
let { arguments: e, name: l } = c;
|
|
1670
|
+
if (e == null) throw new a(`missing function_call.arguments for choice ${r}`);
|
|
1671
|
+
if (!l) throw new a(`missing function_call.name for choice ${r}`);
|
|
1672
|
+
return {
|
|
1673
|
+
...o,
|
|
1674
|
+
message: {
|
|
1675
|
+
content: s,
|
|
1676
|
+
function_call: {
|
|
1677
|
+
arguments: e,
|
|
1678
|
+
name: l
|
|
1679
|
+
},
|
|
1680
|
+
role: d,
|
|
1681
|
+
refusal: t.refusal ?? null
|
|
1682
|
+
},
|
|
1683
|
+
finish_reason: n,
|
|
1684
|
+
index: r,
|
|
1685
|
+
logprobs: i
|
|
1686
|
+
};
|
|
1687
|
+
}
|
|
1688
|
+
return l ? {
|
|
1689
|
+
...o,
|
|
1690
|
+
index: r,
|
|
1691
|
+
finish_reason: n,
|
|
1692
|
+
logprobs: i,
|
|
1693
|
+
message: {
|
|
1694
|
+
...u,
|
|
1695
|
+
role: d,
|
|
1696
|
+
content: s,
|
|
1697
|
+
refusal: t.refusal ?? null,
|
|
1698
|
+
tool_calls: l.map((t, n) => {
|
|
1699
|
+
let { function: i, type: o, id: s, ...c } = t, { arguments: l, name: u, ...d } = i || {};
|
|
1700
|
+
if (s == null) throw new a(`missing choices[${r}].tool_calls[${n}].id\n${qn(e)}`);
|
|
1701
|
+
if (o == null) throw new a(`missing choices[${r}].tool_calls[${n}].type\n${qn(e)}`);
|
|
1702
|
+
if (u == null) throw new a(`missing choices[${r}].tool_calls[${n}].function.name\n${qn(e)}`);
|
|
1703
|
+
if (l == null) throw new a(`missing choices[${r}].tool_calls[${n}].function.arguments\n${qn(e)}`);
|
|
1704
|
+
return {
|
|
1705
|
+
...c,
|
|
1706
|
+
id: s,
|
|
1707
|
+
type: o,
|
|
1708
|
+
function: {
|
|
1709
|
+
...d,
|
|
1710
|
+
name: u,
|
|
1711
|
+
arguments: l
|
|
1712
|
+
}
|
|
1713
|
+
};
|
|
1714
|
+
})
|
|
1715
|
+
}
|
|
1716
|
+
} : {
|
|
1717
|
+
...o,
|
|
1718
|
+
message: {
|
|
1719
|
+
...u,
|
|
1720
|
+
content: s,
|
|
1721
|
+
role: d,
|
|
1722
|
+
refusal: t.refusal ?? null
|
|
1723
|
+
},
|
|
1724
|
+
finish_reason: n,
|
|
1725
|
+
index: r,
|
|
1726
|
+
logprobs: i
|
|
1727
|
+
};
|
|
1728
|
+
}),
|
|
1729
|
+
created: i,
|
|
1730
|
+
model: o,
|
|
1731
|
+
object: "chat.completion",
|
|
1732
|
+
...s ? { system_fingerprint: s } : {}
|
|
1733
|
+
}, t);
|
|
1734
|
+
}
|
|
1735
|
+
function qn(e) {
|
|
1736
|
+
return JSON.stringify(e);
|
|
1737
|
+
}
|
|
1738
|
+
//#endregion
|
|
1739
|
+
//#region node_modules/openai/lib/ChatCompletionStreamingRunner.mjs
|
|
1740
|
+
var Jn = class e extends Gn {
|
|
1741
|
+
static fromReadableStream(t) {
|
|
1742
|
+
let n = new e(null);
|
|
1743
|
+
return n._run(() => n._fromReadableStream(t)), n;
|
|
1744
|
+
}
|
|
1745
|
+
static runTools(t, n, r) {
|
|
1746
|
+
let i = new e(n), a = {
|
|
1747
|
+
...r,
|
|
1748
|
+
headers: {
|
|
1749
|
+
...r?.headers,
|
|
1750
|
+
"X-Stainless-Helper-Method": "runTools"
|
|
1751
|
+
}
|
|
1752
|
+
};
|
|
1753
|
+
return i._run(() => i._runTools(t, n, a)), i;
|
|
1754
|
+
}
|
|
1755
|
+
}, Yn = class extends N {
|
|
1756
|
+
constructor() {
|
|
1757
|
+
super(...arguments), this.messages = new Pt(this._client);
|
|
1758
|
+
}
|
|
1759
|
+
create(e, t) {
|
|
1760
|
+
return this._client.post("/chat/completions", {
|
|
1761
|
+
body: e,
|
|
1762
|
+
...t,
|
|
1763
|
+
stream: e.stream ?? !1
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
retrieve(e, t) {
|
|
1767
|
+
return this._client.get(P`/chat/completions/${e}`, t);
|
|
1768
|
+
}
|
|
1769
|
+
update(e, t, n) {
|
|
1770
|
+
return this._client.post(P`/chat/completions/${e}`, {
|
|
1771
|
+
body: t,
|
|
1772
|
+
...n
|
|
1773
|
+
});
|
|
1774
|
+
}
|
|
1775
|
+
list(e = {}, t) {
|
|
1776
|
+
return this._client.getAPIList("/chat/completions", j, {
|
|
1777
|
+
query: e,
|
|
1778
|
+
...t
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
delete(e, t) {
|
|
1782
|
+
return this._client.delete(P`/chat/completions/${e}`, t);
|
|
1783
|
+
}
|
|
1784
|
+
parse(e, t) {
|
|
1785
|
+
return Gt(e.tools), this._client.chat.completions.create(e, {
|
|
1786
|
+
...t,
|
|
1787
|
+
headers: {
|
|
1788
|
+
...t?.headers,
|
|
1789
|
+
"X-Stainless-Helper-Method": "chat.completions.parse"
|
|
1790
|
+
}
|
|
1791
|
+
})._thenUnwrap((t) => zt(t, e));
|
|
1792
|
+
}
|
|
1793
|
+
runTools(e, t) {
|
|
1794
|
+
return e.stream ? Jn.runTools(this._client, e, t) : vn.runTools(this._client, e, t);
|
|
1795
|
+
}
|
|
1796
|
+
stream(e, t) {
|
|
1797
|
+
return Gn.createChatCompletion(this._client, e, t);
|
|
1798
|
+
}
|
|
1799
|
+
};
|
|
1800
|
+
Yn.Messages = Pt;
|
|
1801
|
+
//#endregion
|
|
1802
|
+
//#region node_modules/openai/resources/chat/chat.mjs
|
|
1803
|
+
var Xn = class extends N {
|
|
1804
|
+
constructor() {
|
|
1805
|
+
super(...arguments), this.completions = new Yn(this._client);
|
|
1806
|
+
}
|
|
1807
|
+
};
|
|
1808
|
+
Xn.Completions = Yn;
|
|
1809
|
+
//#endregion
|
|
1810
|
+
//#region node_modules/openai/internal/headers.mjs
|
|
1811
|
+
var Zn = /* @__PURE__ */ Symbol("brand.privateNullableHeaders");
|
|
1812
|
+
function* Qn(e) {
|
|
1813
|
+
if (!e) return;
|
|
1814
|
+
if (Zn in e) {
|
|
1815
|
+
let { values: t, nulls: n } = e;
|
|
1816
|
+
yield* t.entries();
|
|
1817
|
+
for (let e of n) yield [e, null];
|
|
1818
|
+
return;
|
|
1819
|
+
}
|
|
1820
|
+
let t = !1, n;
|
|
1821
|
+
e instanceof Headers ? n = e.entries() : S(e) ? n = e : (t = !0, n = Object.entries(e ?? {}));
|
|
1822
|
+
for (let e of n) {
|
|
1823
|
+
let n = e[0];
|
|
1824
|
+
if (typeof n != "string") throw TypeError("expected header name to be a string");
|
|
1825
|
+
let r = S(e[1]) ? e[1] : [e[1]], i = !1;
|
|
1826
|
+
for (let e of r) e !== void 0 && (t && !i && (i = !0, yield [n, null]), yield [n, e]);
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
var H = (e) => {
|
|
1830
|
+
let t = new Headers(), n = /* @__PURE__ */ new Set();
|
|
1831
|
+
for (let r of e) {
|
|
1832
|
+
let e = /* @__PURE__ */ new Set();
|
|
1833
|
+
for (let [i, a] of Qn(r)) {
|
|
1834
|
+
let r = i.toLowerCase();
|
|
1835
|
+
e.has(r) || (t.delete(i), e.add(r)), a === null ? (t.delete(i), n.add(r)) : (t.append(i, a), n.delete(r));
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
return {
|
|
1839
|
+
[Zn]: !0,
|
|
1840
|
+
values: t,
|
|
1841
|
+
nulls: n
|
|
1842
|
+
};
|
|
1843
|
+
}, $n = class extends N {
|
|
1844
|
+
create(e, t) {
|
|
1845
|
+
return this._client.post("/audio/speech", {
|
|
1846
|
+
body: e,
|
|
1847
|
+
...t,
|
|
1848
|
+
headers: H([{ Accept: "application/octet-stream" }, t?.headers]),
|
|
1849
|
+
__binaryResponse: !0
|
|
1850
|
+
});
|
|
1851
|
+
}
|
|
1852
|
+
}, er = class extends N {
|
|
1853
|
+
create(e, t) {
|
|
1854
|
+
return this._client.post("/audio/transcriptions", M({
|
|
1855
|
+
body: e,
|
|
1856
|
+
...t,
|
|
1857
|
+
stream: e.stream ?? !1,
|
|
1858
|
+
__metadata: { model: e.model }
|
|
1859
|
+
}, this._client));
|
|
1860
|
+
}
|
|
1861
|
+
}, tr = class extends N {
|
|
1862
|
+
create(e, t) {
|
|
1863
|
+
return this._client.post("/audio/translations", M({
|
|
1864
|
+
body: e,
|
|
1865
|
+
...t,
|
|
1866
|
+
__metadata: { model: e.model }
|
|
1867
|
+
}, this._client));
|
|
1868
|
+
}
|
|
1869
|
+
}, nr = class extends N {
|
|
1870
|
+
constructor() {
|
|
1871
|
+
super(...arguments), this.transcriptions = new er(this._client), this.translations = new tr(this._client), this.speech = new $n(this._client);
|
|
1872
|
+
}
|
|
1873
|
+
};
|
|
1874
|
+
nr.Transcriptions = er, nr.Translations = tr, nr.Speech = $n;
|
|
1875
|
+
//#endregion
|
|
1876
|
+
//#region node_modules/openai/resources/batches.mjs
|
|
1877
|
+
var rr = class extends N {
|
|
1878
|
+
create(e, t) {
|
|
1879
|
+
return this._client.post("/batches", {
|
|
1880
|
+
body: e,
|
|
1881
|
+
...t
|
|
1882
|
+
});
|
|
1883
|
+
}
|
|
1884
|
+
retrieve(e, t) {
|
|
1885
|
+
return this._client.get(P`/batches/${e}`, t);
|
|
1886
|
+
}
|
|
1887
|
+
list(e = {}, t) {
|
|
1888
|
+
return this._client.getAPIList("/batches", j, {
|
|
1889
|
+
query: e,
|
|
1890
|
+
...t
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1893
|
+
cancel(e, t) {
|
|
1894
|
+
return this._client.post(P`/batches/${e}/cancel`, t);
|
|
1895
|
+
}
|
|
1896
|
+
}, ir = class extends N {
|
|
1897
|
+
create(e, t) {
|
|
1898
|
+
return this._client.post("/assistants", {
|
|
1899
|
+
body: e,
|
|
1900
|
+
...t,
|
|
1901
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
1902
|
+
});
|
|
1903
|
+
}
|
|
1904
|
+
retrieve(e, t) {
|
|
1905
|
+
return this._client.get(P`/assistants/${e}`, {
|
|
1906
|
+
...t,
|
|
1907
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
1908
|
+
});
|
|
1909
|
+
}
|
|
1910
|
+
update(e, t, n) {
|
|
1911
|
+
return this._client.post(P`/assistants/${e}`, {
|
|
1912
|
+
body: t,
|
|
1913
|
+
...n,
|
|
1914
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
1915
|
+
});
|
|
1916
|
+
}
|
|
1917
|
+
list(e = {}, t) {
|
|
1918
|
+
return this._client.getAPIList("/assistants", j, {
|
|
1919
|
+
query: e,
|
|
1920
|
+
...t,
|
|
1921
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
1922
|
+
});
|
|
1923
|
+
}
|
|
1924
|
+
delete(e, t) {
|
|
1925
|
+
return this._client.delete(P`/assistants/${e}`, {
|
|
1926
|
+
...t,
|
|
1927
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
1928
|
+
});
|
|
1929
|
+
}
|
|
1930
|
+
}, ar = class extends N {
|
|
1931
|
+
create(e, t) {
|
|
1932
|
+
return this._client.post("/realtime/sessions", {
|
|
1933
|
+
body: e,
|
|
1934
|
+
...t,
|
|
1935
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
1936
|
+
});
|
|
1937
|
+
}
|
|
1938
|
+
}, or = class extends N {
|
|
1939
|
+
create(e, t) {
|
|
1940
|
+
return this._client.post("/realtime/transcription_sessions", {
|
|
1941
|
+
body: e,
|
|
1942
|
+
...t,
|
|
1943
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
1944
|
+
});
|
|
1945
|
+
}
|
|
1946
|
+
}, sr = class extends N {
|
|
1947
|
+
constructor() {
|
|
1948
|
+
super(...arguments), this.sessions = new ar(this._client), this.transcriptionSessions = new or(this._client);
|
|
1949
|
+
}
|
|
1950
|
+
};
|
|
1951
|
+
sr.Sessions = ar, sr.TranscriptionSessions = or;
|
|
1952
|
+
//#endregion
|
|
1953
|
+
//#region node_modules/openai/resources/beta/chatkit/sessions.mjs
|
|
1954
|
+
var cr = class extends N {
|
|
1955
|
+
create(e, t) {
|
|
1956
|
+
return this._client.post("/chatkit/sessions", {
|
|
1957
|
+
body: e,
|
|
1958
|
+
...t,
|
|
1959
|
+
headers: H([{ "OpenAI-Beta": "chatkit_beta=v1" }, t?.headers])
|
|
1960
|
+
});
|
|
1961
|
+
}
|
|
1962
|
+
cancel(e, t) {
|
|
1963
|
+
return this._client.post(P`/chatkit/sessions/${e}/cancel`, {
|
|
1964
|
+
...t,
|
|
1965
|
+
headers: H([{ "OpenAI-Beta": "chatkit_beta=v1" }, t?.headers])
|
|
1966
|
+
});
|
|
1967
|
+
}
|
|
1968
|
+
}, lr = class extends N {
|
|
1969
|
+
retrieve(e, t) {
|
|
1970
|
+
return this._client.get(P`/chatkit/threads/${e}`, {
|
|
1971
|
+
...t,
|
|
1972
|
+
headers: H([{ "OpenAI-Beta": "chatkit_beta=v1" }, t?.headers])
|
|
1973
|
+
});
|
|
1974
|
+
}
|
|
1975
|
+
list(e = {}, t) {
|
|
1976
|
+
return this._client.getAPIList("/chatkit/threads", pt, {
|
|
1977
|
+
query: e,
|
|
1978
|
+
...t,
|
|
1979
|
+
headers: H([{ "OpenAI-Beta": "chatkit_beta=v1" }, t?.headers])
|
|
1980
|
+
});
|
|
1981
|
+
}
|
|
1982
|
+
delete(e, t) {
|
|
1983
|
+
return this._client.delete(P`/chatkit/threads/${e}`, {
|
|
1984
|
+
...t,
|
|
1985
|
+
headers: H([{ "OpenAI-Beta": "chatkit_beta=v1" }, t?.headers])
|
|
1986
|
+
});
|
|
1987
|
+
}
|
|
1988
|
+
listItems(e, t = {}, n) {
|
|
1989
|
+
return this._client.getAPIList(P`/chatkit/threads/${e}/items`, pt, {
|
|
1990
|
+
query: t,
|
|
1991
|
+
...n,
|
|
1992
|
+
headers: H([{ "OpenAI-Beta": "chatkit_beta=v1" }, n?.headers])
|
|
1993
|
+
});
|
|
1994
|
+
}
|
|
1995
|
+
}, ur = class extends N {
|
|
1996
|
+
constructor() {
|
|
1997
|
+
super(...arguments), this.sessions = new cr(this._client), this.threads = new lr(this._client);
|
|
1998
|
+
}
|
|
1999
|
+
};
|
|
2000
|
+
ur.Sessions = cr, ur.Threads = lr;
|
|
2001
|
+
//#endregion
|
|
2002
|
+
//#region node_modules/openai/resources/beta/threads/messages.mjs
|
|
2003
|
+
var dr = class extends N {
|
|
2004
|
+
create(e, t, n) {
|
|
2005
|
+
return this._client.post(P`/threads/${e}/messages`, {
|
|
2006
|
+
body: t,
|
|
2007
|
+
...n,
|
|
2008
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2009
|
+
});
|
|
2010
|
+
}
|
|
2011
|
+
retrieve(e, t, n) {
|
|
2012
|
+
let { thread_id: r } = t;
|
|
2013
|
+
return this._client.get(P`/threads/${r}/messages/${e}`, {
|
|
2014
|
+
...n,
|
|
2015
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2016
|
+
});
|
|
2017
|
+
}
|
|
2018
|
+
update(e, t, n) {
|
|
2019
|
+
let { thread_id: r, ...i } = t;
|
|
2020
|
+
return this._client.post(P`/threads/${r}/messages/${e}`, {
|
|
2021
|
+
body: i,
|
|
2022
|
+
...n,
|
|
2023
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2024
|
+
});
|
|
2025
|
+
}
|
|
2026
|
+
list(e, t = {}, n) {
|
|
2027
|
+
return this._client.getAPIList(P`/threads/${e}/messages`, j, {
|
|
2028
|
+
query: t,
|
|
2029
|
+
...n,
|
|
2030
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2031
|
+
});
|
|
2032
|
+
}
|
|
2033
|
+
delete(e, t, n) {
|
|
2034
|
+
let { thread_id: r } = t;
|
|
2035
|
+
return this._client.delete(P`/threads/${r}/messages/${e}`, {
|
|
2036
|
+
...n,
|
|
2037
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2038
|
+
});
|
|
2039
|
+
}
|
|
2040
|
+
}, fr = class extends N {
|
|
2041
|
+
retrieve(e, t, n) {
|
|
2042
|
+
let { thread_id: r, run_id: i, ...a } = t;
|
|
2043
|
+
return this._client.get(P`/threads/${r}/runs/${i}/steps/${e}`, {
|
|
2044
|
+
query: a,
|
|
2045
|
+
...n,
|
|
2046
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2047
|
+
});
|
|
2048
|
+
}
|
|
2049
|
+
list(e, t, n) {
|
|
2050
|
+
let { thread_id: r, ...i } = t;
|
|
2051
|
+
return this._client.getAPIList(P`/threads/${r}/runs/${e}/steps`, j, {
|
|
2052
|
+
query: i,
|
|
2053
|
+
...n,
|
|
2054
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2055
|
+
});
|
|
2056
|
+
}
|
|
2057
|
+
}, pr = (e) => {
|
|
2058
|
+
if (typeof Buffer < "u") {
|
|
2059
|
+
let t = Buffer.from(e, "base64");
|
|
2060
|
+
return Array.from(new Float32Array(t.buffer, t.byteOffset, t.length / Float32Array.BYTES_PER_ELEMENT));
|
|
2061
|
+
} else {
|
|
2062
|
+
let t = atob(e), n = t.length, r = new Uint8Array(n);
|
|
2063
|
+
for (let e = 0; e < n; e++) r[e] = t.charCodeAt(e);
|
|
2064
|
+
return Array.from(new Float32Array(r.buffer));
|
|
2065
|
+
}
|
|
2066
|
+
}, U = (e) => {
|
|
2067
|
+
if (globalThis.process !== void 0) return globalThis.process.env?.[e]?.trim() ?? void 0;
|
|
2068
|
+
if (globalThis.Deno !== void 0) return globalThis.Deno.env?.get?.(e)?.trim();
|
|
2069
|
+
}, W, G, mr, K, hr, q, J, gr, Y, _r, X, vr, yr, br, xr, Sr, Cr, wr, Tr, Er, Dr, Or, kr, Ar = class extends sn {
|
|
2070
|
+
constructor() {
|
|
2071
|
+
super(...arguments), W.add(this), mr.set(this, []), K.set(this, {}), hr.set(this, {}), q.set(this, void 0), J.set(this, void 0), gr.set(this, void 0), Y.set(this, void 0), _r.set(this, void 0), X.set(this, void 0), vr.set(this, void 0), yr.set(this, void 0), br.set(this, void 0);
|
|
2072
|
+
}
|
|
2073
|
+
[(mr = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), hr = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new WeakMap(), gr = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new WeakMap(), _r = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakMap(), vr = /* @__PURE__ */ new WeakMap(), yr = /* @__PURE__ */ new WeakMap(), br = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakSet(), Symbol.asyncIterator)]() {
|
|
2074
|
+
let e = [], t = [], n = !1;
|
|
2075
|
+
return this.on("event", (n) => {
|
|
2076
|
+
let r = t.shift();
|
|
2077
|
+
r ? r.resolve(n) : e.push(n);
|
|
2078
|
+
}), this.on("end", () => {
|
|
2079
|
+
n = !0;
|
|
2080
|
+
for (let e of t) e.resolve(void 0);
|
|
2081
|
+
t.length = 0;
|
|
2082
|
+
}), this.on("abort", (e) => {
|
|
2083
|
+
n = !0;
|
|
2084
|
+
for (let n of t) n.reject(e);
|
|
2085
|
+
t.length = 0;
|
|
2086
|
+
}), this.on("error", (e) => {
|
|
2087
|
+
n = !0;
|
|
2088
|
+
for (let n of t) n.reject(e);
|
|
2089
|
+
t.length = 0;
|
|
2090
|
+
}), {
|
|
2091
|
+
next: async () => e.length ? {
|
|
2092
|
+
value: e.shift(),
|
|
2093
|
+
done: !1
|
|
2094
|
+
} : n ? {
|
|
2095
|
+
value: void 0,
|
|
2096
|
+
done: !0
|
|
2097
|
+
} : new Promise((e, n) => t.push({
|
|
2098
|
+
resolve: e,
|
|
2099
|
+
reject: n
|
|
2100
|
+
})).then((e) => e ? {
|
|
2101
|
+
value: e,
|
|
2102
|
+
done: !1
|
|
2103
|
+
} : {
|
|
2104
|
+
value: void 0,
|
|
2105
|
+
done: !0
|
|
2106
|
+
}),
|
|
2107
|
+
return: async () => (this.abort(), {
|
|
2108
|
+
value: void 0,
|
|
2109
|
+
done: !0
|
|
2110
|
+
})
|
|
2111
|
+
};
|
|
2112
|
+
}
|
|
2113
|
+
static fromReadableStream(e) {
|
|
2114
|
+
let t = new G();
|
|
2115
|
+
return t._run(() => t._fromReadableStream(e)), t;
|
|
2116
|
+
}
|
|
2117
|
+
async _fromReadableStream(e, n) {
|
|
2118
|
+
let r = n?.signal;
|
|
2119
|
+
r && (r.aborted && this.controller.abort(), r.addEventListener("abort", () => this.controller.abort())), this._connected();
|
|
2120
|
+
let i = et.fromReadableStream(e, this.controller);
|
|
2121
|
+
for await (let e of i) t(this, W, "m", xr).call(this, e);
|
|
2122
|
+
if (i.controller.signal?.aborted) throw new s();
|
|
2123
|
+
return this._addRun(t(this, W, "m", Sr).call(this));
|
|
2124
|
+
}
|
|
2125
|
+
toReadableStream() {
|
|
2126
|
+
return new et(this[Symbol.asyncIterator].bind(this), this.controller).toReadableStream();
|
|
2127
|
+
}
|
|
2128
|
+
static createToolAssistantStream(e, t, n, r) {
|
|
2129
|
+
let i = new G();
|
|
2130
|
+
return i._run(() => i._runToolAssistantStream(e, t, n, {
|
|
2131
|
+
...r,
|
|
2132
|
+
headers: {
|
|
2133
|
+
...r?.headers,
|
|
2134
|
+
"X-Stainless-Helper-Method": "stream"
|
|
2135
|
+
}
|
|
2136
|
+
})), i;
|
|
2137
|
+
}
|
|
2138
|
+
async _createToolAssistantStream(e, n, r, i) {
|
|
2139
|
+
let a = i?.signal;
|
|
2140
|
+
a && (a.aborted && this.controller.abort(), a.addEventListener("abort", () => this.controller.abort()));
|
|
2141
|
+
let o = {
|
|
2142
|
+
...r,
|
|
2143
|
+
stream: !0
|
|
2144
|
+
}, c = await e.submitToolOutputs(n, o, {
|
|
2145
|
+
...i,
|
|
2146
|
+
signal: this.controller.signal
|
|
2147
|
+
});
|
|
2148
|
+
this._connected();
|
|
2149
|
+
for await (let e of c) t(this, W, "m", xr).call(this, e);
|
|
2150
|
+
if (c.controller.signal?.aborted) throw new s();
|
|
2151
|
+
return this._addRun(t(this, W, "m", Sr).call(this));
|
|
2152
|
+
}
|
|
2153
|
+
static createThreadAssistantStream(e, t, n) {
|
|
2154
|
+
let r = new G();
|
|
2155
|
+
return r._run(() => r._threadAssistantStream(e, t, {
|
|
2156
|
+
...n,
|
|
2157
|
+
headers: {
|
|
2158
|
+
...n?.headers,
|
|
2159
|
+
"X-Stainless-Helper-Method": "stream"
|
|
2160
|
+
}
|
|
2161
|
+
})), r;
|
|
2162
|
+
}
|
|
2163
|
+
static createAssistantStream(e, t, n, r) {
|
|
2164
|
+
let i = new G();
|
|
2165
|
+
return i._run(() => i._runAssistantStream(e, t, n, {
|
|
2166
|
+
...r,
|
|
2167
|
+
headers: {
|
|
2168
|
+
...r?.headers,
|
|
2169
|
+
"X-Stainless-Helper-Method": "stream"
|
|
2170
|
+
}
|
|
2171
|
+
})), i;
|
|
2172
|
+
}
|
|
2173
|
+
currentEvent() {
|
|
2174
|
+
return t(this, vr, "f");
|
|
2175
|
+
}
|
|
2176
|
+
currentRun() {
|
|
2177
|
+
return t(this, yr, "f");
|
|
2178
|
+
}
|
|
2179
|
+
currentMessageSnapshot() {
|
|
2180
|
+
return t(this, q, "f");
|
|
2181
|
+
}
|
|
2182
|
+
currentRunStepSnapshot() {
|
|
2183
|
+
return t(this, br, "f");
|
|
2184
|
+
}
|
|
2185
|
+
async finalRunSteps() {
|
|
2186
|
+
return await this.done(), Object.values(t(this, K, "f"));
|
|
2187
|
+
}
|
|
2188
|
+
async finalMessages() {
|
|
2189
|
+
return await this.done(), Object.values(t(this, hr, "f"));
|
|
2190
|
+
}
|
|
2191
|
+
async finalRun() {
|
|
2192
|
+
if (await this.done(), !t(this, J, "f")) throw Error("Final run was not received.");
|
|
2193
|
+
return t(this, J, "f");
|
|
2194
|
+
}
|
|
2195
|
+
async _createThreadAssistantStream(e, n, r) {
|
|
2196
|
+
let i = r?.signal;
|
|
2197
|
+
i && (i.aborted && this.controller.abort(), i.addEventListener("abort", () => this.controller.abort()));
|
|
2198
|
+
let a = {
|
|
2199
|
+
...n,
|
|
2200
|
+
stream: !0
|
|
2201
|
+
}, o = await e.createAndRun(a, {
|
|
2202
|
+
...r,
|
|
2203
|
+
signal: this.controller.signal
|
|
2204
|
+
});
|
|
2205
|
+
this._connected();
|
|
2206
|
+
for await (let e of o) t(this, W, "m", xr).call(this, e);
|
|
2207
|
+
if (o.controller.signal?.aborted) throw new s();
|
|
2208
|
+
return this._addRun(t(this, W, "m", Sr).call(this));
|
|
2209
|
+
}
|
|
2210
|
+
async _createAssistantStream(e, n, r, i) {
|
|
2211
|
+
let a = i?.signal;
|
|
2212
|
+
a && (a.aborted && this.controller.abort(), a.addEventListener("abort", () => this.controller.abort()));
|
|
2213
|
+
let o = {
|
|
2214
|
+
...r,
|
|
2215
|
+
stream: !0
|
|
2216
|
+
}, c = await e.create(n, o, {
|
|
2217
|
+
...i,
|
|
2218
|
+
signal: this.controller.signal
|
|
2219
|
+
});
|
|
2220
|
+
this._connected();
|
|
2221
|
+
for await (let e of c) t(this, W, "m", xr).call(this, e);
|
|
2222
|
+
if (c.controller.signal?.aborted) throw new s();
|
|
2223
|
+
return this._addRun(t(this, W, "m", Sr).call(this));
|
|
2224
|
+
}
|
|
2225
|
+
static accumulateDelta(e, t) {
|
|
2226
|
+
for (let [n, r] of Object.entries(t)) {
|
|
2227
|
+
if (!e.hasOwnProperty(n)) {
|
|
2228
|
+
e[n] = r;
|
|
2229
|
+
continue;
|
|
2230
|
+
}
|
|
2231
|
+
let t = e[n];
|
|
2232
|
+
if (t == null) {
|
|
2233
|
+
e[n] = r;
|
|
2234
|
+
continue;
|
|
2235
|
+
}
|
|
2236
|
+
if (n === "index" || n === "type") {
|
|
2237
|
+
e[n] = r;
|
|
2238
|
+
continue;
|
|
2239
|
+
}
|
|
2240
|
+
if (typeof t == "string" && typeof r == "string") t += r;
|
|
2241
|
+
else if (typeof t == "number" && typeof r == "number") t += r;
|
|
2242
|
+
else if (ie(t) && ie(r)) t = this.accumulateDelta(t, r);
|
|
2243
|
+
else if (Array.isArray(t) && Array.isArray(r)) {
|
|
2244
|
+
if (t.every((e) => typeof e == "string" || typeof e == "number")) {
|
|
2245
|
+
t.push(...r);
|
|
2246
|
+
continue;
|
|
2247
|
+
}
|
|
2248
|
+
for (let e of r) {
|
|
2249
|
+
if (!ie(e)) throw Error(`Expected array delta entry to be an object but got: ${e}`);
|
|
2250
|
+
let n = e.index;
|
|
2251
|
+
if (n == null) throw console.error(e), Error("Expected array delta entry to have an `index` property");
|
|
2252
|
+
if (typeof n != "number") throw Error(`Expected array delta entry \`index\` property to be a number but got ${n}`);
|
|
2253
|
+
let r = t[n];
|
|
2254
|
+
r == null ? t.push(e) : t[n] = this.accumulateDelta(r, e);
|
|
2255
|
+
}
|
|
2256
|
+
continue;
|
|
2257
|
+
} else throw Error(`Unhandled record type: ${n}, deltaValue: ${r}, accValue: ${t}`);
|
|
2258
|
+
e[n] = t;
|
|
2259
|
+
}
|
|
2260
|
+
return e;
|
|
2261
|
+
}
|
|
2262
|
+
_addRun(e) {
|
|
2263
|
+
return e;
|
|
2264
|
+
}
|
|
2265
|
+
async _threadAssistantStream(e, t, n) {
|
|
2266
|
+
return await this._createThreadAssistantStream(t, e, n);
|
|
2267
|
+
}
|
|
2268
|
+
async _runAssistantStream(e, t, n, r) {
|
|
2269
|
+
return await this._createAssistantStream(t, e, n, r);
|
|
2270
|
+
}
|
|
2271
|
+
async _runToolAssistantStream(e, t, n, r) {
|
|
2272
|
+
return await this._createToolAssistantStream(t, e, n, r);
|
|
2273
|
+
}
|
|
2274
|
+
};
|
|
2275
|
+
G = Ar, xr = function(n) {
|
|
2276
|
+
if (!this.ended) switch (e(this, vr, n, "f"), t(this, W, "m", Tr).call(this, n), n.event) {
|
|
2277
|
+
case "thread.created": break;
|
|
2278
|
+
case "thread.run.created":
|
|
2279
|
+
case "thread.run.queued":
|
|
2280
|
+
case "thread.run.in_progress":
|
|
2281
|
+
case "thread.run.requires_action":
|
|
2282
|
+
case "thread.run.completed":
|
|
2283
|
+
case "thread.run.incomplete":
|
|
2284
|
+
case "thread.run.failed":
|
|
2285
|
+
case "thread.run.cancelling":
|
|
2286
|
+
case "thread.run.cancelled":
|
|
2287
|
+
case "thread.run.expired":
|
|
2288
|
+
t(this, W, "m", kr).call(this, n);
|
|
2289
|
+
break;
|
|
2290
|
+
case "thread.run.step.created":
|
|
2291
|
+
case "thread.run.step.in_progress":
|
|
2292
|
+
case "thread.run.step.delta":
|
|
2293
|
+
case "thread.run.step.completed":
|
|
2294
|
+
case "thread.run.step.failed":
|
|
2295
|
+
case "thread.run.step.cancelled":
|
|
2296
|
+
case "thread.run.step.expired":
|
|
2297
|
+
t(this, W, "m", wr).call(this, n);
|
|
2298
|
+
break;
|
|
2299
|
+
case "thread.message.created":
|
|
2300
|
+
case "thread.message.in_progress":
|
|
2301
|
+
case "thread.message.delta":
|
|
2302
|
+
case "thread.message.completed":
|
|
2303
|
+
case "thread.message.incomplete":
|
|
2304
|
+
t(this, W, "m", Cr).call(this, n);
|
|
2305
|
+
break;
|
|
2306
|
+
case "error": throw Error("Encountered an error event in event processing - errors should be processed earlier");
|
|
2307
|
+
default:
|
|
2308
|
+
}
|
|
2309
|
+
}, Sr = function() {
|
|
2310
|
+
if (this.ended) throw new a("stream has ended, this shouldn't happen");
|
|
2311
|
+
if (!t(this, J, "f")) throw Error("Final run has not been received");
|
|
2312
|
+
return t(this, J, "f");
|
|
2313
|
+
}, Cr = function(n) {
|
|
2314
|
+
let [r, i] = t(this, W, "m", Dr).call(this, n, t(this, q, "f"));
|
|
2315
|
+
e(this, q, r, "f"), t(this, hr, "f")[r.id] = r;
|
|
2316
|
+
for (let e of i) {
|
|
2317
|
+
let t = r.content[e.index];
|
|
2318
|
+
t?.type == "text" && this._emit("textCreated", t.text);
|
|
2319
|
+
}
|
|
2320
|
+
switch (n.event) {
|
|
2321
|
+
case "thread.message.created":
|
|
2322
|
+
this._emit("messageCreated", n.data);
|
|
2323
|
+
break;
|
|
2324
|
+
case "thread.message.in_progress": break;
|
|
2325
|
+
case "thread.message.delta":
|
|
2326
|
+
if (this._emit("messageDelta", n.data.delta, r), n.data.delta.content) for (let i of n.data.delta.content) {
|
|
2327
|
+
if (i.type == "text" && i.text) {
|
|
2328
|
+
let e = i.text, t = r.content[i.index];
|
|
2329
|
+
if (t && t.type == "text") this._emit("textDelta", e, t.text);
|
|
2330
|
+
else throw Error("The snapshot associated with this text delta is not text or missing");
|
|
2331
|
+
}
|
|
2332
|
+
if (i.index != t(this, gr, "f")) {
|
|
2333
|
+
if (t(this, Y, "f")) switch (t(this, Y, "f").type) {
|
|
2334
|
+
case "text":
|
|
2335
|
+
this._emit("textDone", t(this, Y, "f").text, t(this, q, "f"));
|
|
2336
|
+
break;
|
|
2337
|
+
case "image_file":
|
|
2338
|
+
this._emit("imageFileDone", t(this, Y, "f").image_file, t(this, q, "f"));
|
|
2339
|
+
break;
|
|
2340
|
+
}
|
|
2341
|
+
e(this, gr, i.index, "f");
|
|
2342
|
+
}
|
|
2343
|
+
e(this, Y, r.content[i.index], "f");
|
|
2344
|
+
}
|
|
2345
|
+
break;
|
|
2346
|
+
case "thread.message.completed":
|
|
2347
|
+
case "thread.message.incomplete":
|
|
2348
|
+
if (t(this, gr, "f") !== void 0) {
|
|
2349
|
+
let e = n.data.content[t(this, gr, "f")];
|
|
2350
|
+
if (e) switch (e.type) {
|
|
2351
|
+
case "image_file":
|
|
2352
|
+
this._emit("imageFileDone", e.image_file, t(this, q, "f"));
|
|
2353
|
+
break;
|
|
2354
|
+
case "text":
|
|
2355
|
+
this._emit("textDone", e.text, t(this, q, "f"));
|
|
2356
|
+
break;
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
t(this, q, "f") && this._emit("messageDone", n.data), e(this, q, void 0, "f");
|
|
2360
|
+
}
|
|
2361
|
+
}, wr = function(n) {
|
|
2362
|
+
let r = t(this, W, "m", Er).call(this, n);
|
|
2363
|
+
switch (e(this, br, r, "f"), n.event) {
|
|
2364
|
+
case "thread.run.step.created":
|
|
2365
|
+
this._emit("runStepCreated", n.data);
|
|
2366
|
+
break;
|
|
2367
|
+
case "thread.run.step.delta":
|
|
2368
|
+
let i = n.data.delta;
|
|
2369
|
+
if (i.step_details && i.step_details.type == "tool_calls" && i.step_details.tool_calls && r.step_details.type == "tool_calls") for (let n of i.step_details.tool_calls) n.index == t(this, _r, "f") ? this._emit("toolCallDelta", n, r.step_details.tool_calls[n.index]) : (t(this, X, "f") && this._emit("toolCallDone", t(this, X, "f")), e(this, _r, n.index, "f"), e(this, X, r.step_details.tool_calls[n.index], "f"), t(this, X, "f") && this._emit("toolCallCreated", t(this, X, "f")));
|
|
2370
|
+
this._emit("runStepDelta", n.data.delta, r);
|
|
2371
|
+
break;
|
|
2372
|
+
case "thread.run.step.completed":
|
|
2373
|
+
case "thread.run.step.failed":
|
|
2374
|
+
case "thread.run.step.cancelled":
|
|
2375
|
+
case "thread.run.step.expired":
|
|
2376
|
+
e(this, br, void 0, "f"), n.data.step_details.type == "tool_calls" && t(this, X, "f") && (this._emit("toolCallDone", t(this, X, "f")), e(this, X, void 0, "f")), this._emit("runStepDone", n.data, r);
|
|
2377
|
+
break;
|
|
2378
|
+
case "thread.run.step.in_progress": break;
|
|
2379
|
+
}
|
|
2380
|
+
}, Tr = function(e) {
|
|
2381
|
+
t(this, mr, "f").push(e), this._emit("event", e);
|
|
2382
|
+
}, Er = function(e) {
|
|
2383
|
+
switch (e.event) {
|
|
2384
|
+
case "thread.run.step.created": return t(this, K, "f")[e.data.id] = e.data, e.data;
|
|
2385
|
+
case "thread.run.step.delta":
|
|
2386
|
+
let n = t(this, K, "f")[e.data.id];
|
|
2387
|
+
if (!n) throw Error("Received a RunStepDelta before creation of a snapshot");
|
|
2388
|
+
let r = e.data;
|
|
2389
|
+
if (r.delta) {
|
|
2390
|
+
let i = G.accumulateDelta(n, r.delta);
|
|
2391
|
+
t(this, K, "f")[e.data.id] = i;
|
|
2392
|
+
}
|
|
2393
|
+
return t(this, K, "f")[e.data.id];
|
|
2394
|
+
case "thread.run.step.completed":
|
|
2395
|
+
case "thread.run.step.failed":
|
|
2396
|
+
case "thread.run.step.cancelled":
|
|
2397
|
+
case "thread.run.step.expired":
|
|
2398
|
+
case "thread.run.step.in_progress":
|
|
2399
|
+
t(this, K, "f")[e.data.id] = e.data;
|
|
2400
|
+
break;
|
|
2401
|
+
}
|
|
2402
|
+
if (t(this, K, "f")[e.data.id]) return t(this, K, "f")[e.data.id];
|
|
2403
|
+
throw Error("No snapshot available");
|
|
2404
|
+
}, Dr = function(e, n) {
|
|
2405
|
+
let r = [];
|
|
2406
|
+
switch (e.event) {
|
|
2407
|
+
case "thread.message.created": return [e.data, r];
|
|
2408
|
+
case "thread.message.delta":
|
|
2409
|
+
if (!n) throw Error("Received a delta with no existing snapshot (there should be one from message creation)");
|
|
2410
|
+
let i = e.data;
|
|
2411
|
+
if (i.delta.content) for (let e of i.delta.content) if (e.index in n.content) {
|
|
2412
|
+
let r = n.content[e.index];
|
|
2413
|
+
n.content[e.index] = t(this, W, "m", Or).call(this, e, r);
|
|
2414
|
+
} else n.content[e.index] = e, r.push(e);
|
|
2415
|
+
return [n, r];
|
|
2416
|
+
case "thread.message.in_progress":
|
|
2417
|
+
case "thread.message.completed":
|
|
2418
|
+
case "thread.message.incomplete":
|
|
2419
|
+
if (n) return [n, r];
|
|
2420
|
+
throw Error("Received thread message event with no existing snapshot");
|
|
2421
|
+
}
|
|
2422
|
+
throw Error("Tried to accumulate a non-message event");
|
|
2423
|
+
}, Or = function(e, t) {
|
|
2424
|
+
return G.accumulateDelta(t, e);
|
|
2425
|
+
}, kr = function(n) {
|
|
2426
|
+
switch (e(this, yr, n.data, "f"), n.event) {
|
|
2427
|
+
case "thread.run.created": break;
|
|
2428
|
+
case "thread.run.queued": break;
|
|
2429
|
+
case "thread.run.in_progress": break;
|
|
2430
|
+
case "thread.run.requires_action":
|
|
2431
|
+
case "thread.run.cancelled":
|
|
2432
|
+
case "thread.run.failed":
|
|
2433
|
+
case "thread.run.completed":
|
|
2434
|
+
case "thread.run.expired":
|
|
2435
|
+
case "thread.run.incomplete":
|
|
2436
|
+
e(this, J, n.data, "f"), t(this, X, "f") && (this._emit("toolCallDone", t(this, X, "f")), e(this, X, void 0, "f"));
|
|
2437
|
+
break;
|
|
2438
|
+
case "thread.run.cancelling": break;
|
|
2439
|
+
}
|
|
2440
|
+
};
|
|
2441
|
+
//#endregion
|
|
2442
|
+
//#region node_modules/openai/resources/beta/threads/runs/runs.mjs
|
|
2443
|
+
var jr = class extends N {
|
|
2444
|
+
constructor() {
|
|
2445
|
+
super(...arguments), this.steps = new fr(this._client);
|
|
2446
|
+
}
|
|
2447
|
+
create(e, t, n) {
|
|
2448
|
+
let { include: r, ...i } = t;
|
|
2449
|
+
return this._client.post(P`/threads/${e}/runs`, {
|
|
2450
|
+
query: { include: r },
|
|
2451
|
+
body: i,
|
|
2452
|
+
...n,
|
|
2453
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers]),
|
|
2454
|
+
stream: t.stream ?? !1,
|
|
2455
|
+
__synthesizeEventData: !0
|
|
2456
|
+
});
|
|
2457
|
+
}
|
|
2458
|
+
retrieve(e, t, n) {
|
|
2459
|
+
let { thread_id: r } = t;
|
|
2460
|
+
return this._client.get(P`/threads/${r}/runs/${e}`, {
|
|
2461
|
+
...n,
|
|
2462
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2463
|
+
});
|
|
2464
|
+
}
|
|
2465
|
+
update(e, t, n) {
|
|
2466
|
+
let { thread_id: r, ...i } = t;
|
|
2467
|
+
return this._client.post(P`/threads/${r}/runs/${e}`, {
|
|
2468
|
+
body: i,
|
|
2469
|
+
...n,
|
|
2470
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2471
|
+
});
|
|
2472
|
+
}
|
|
2473
|
+
list(e, t = {}, n) {
|
|
2474
|
+
return this._client.getAPIList(P`/threads/${e}/runs`, j, {
|
|
2475
|
+
query: t,
|
|
2476
|
+
...n,
|
|
2477
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2478
|
+
});
|
|
2479
|
+
}
|
|
2480
|
+
cancel(e, t, n) {
|
|
2481
|
+
let { thread_id: r } = t;
|
|
2482
|
+
return this._client.post(P`/threads/${r}/runs/${e}/cancel`, {
|
|
2483
|
+
...n,
|
|
2484
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2485
|
+
});
|
|
2486
|
+
}
|
|
2487
|
+
async createAndPoll(e, t, n) {
|
|
2488
|
+
let r = await this.create(e, t, n);
|
|
2489
|
+
return await this.poll(r.id, { thread_id: e }, n);
|
|
2490
|
+
}
|
|
2491
|
+
createAndStream(e, t, n) {
|
|
2492
|
+
return Ar.createAssistantStream(e, this._client.beta.threads.runs, t, n);
|
|
2493
|
+
}
|
|
2494
|
+
async poll(e, t, n) {
|
|
2495
|
+
let r = H([n?.headers, {
|
|
2496
|
+
"X-Stainless-Poll-Helper": "true",
|
|
2497
|
+
"X-Stainless-Custom-Poll-Interval": n?.pollIntervalMs?.toString() ?? void 0
|
|
2498
|
+
}]);
|
|
2499
|
+
for (;;) {
|
|
2500
|
+
let { data: i, response: a } = await this.retrieve(e, t, {
|
|
2501
|
+
...n,
|
|
2502
|
+
headers: {
|
|
2503
|
+
...n?.headers,
|
|
2504
|
+
...r
|
|
2505
|
+
}
|
|
2506
|
+
}).withResponse();
|
|
2507
|
+
switch (i.status) {
|
|
2508
|
+
case "queued":
|
|
2509
|
+
case "in_progress":
|
|
2510
|
+
case "cancelling":
|
|
2511
|
+
let e = 5e3;
|
|
2512
|
+
if (n?.pollIntervalMs) e = n.pollIntervalMs;
|
|
2513
|
+
else {
|
|
2514
|
+
let t = a.headers.get("openai-poll-after-ms");
|
|
2515
|
+
if (t) {
|
|
2516
|
+
let n = parseInt(t);
|
|
2517
|
+
isNaN(n) || (e = n);
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
await se(e);
|
|
2521
|
+
break;
|
|
2522
|
+
case "requires_action":
|
|
2523
|
+
case "incomplete":
|
|
2524
|
+
case "cancelled":
|
|
2525
|
+
case "completed":
|
|
2526
|
+
case "failed":
|
|
2527
|
+
case "expired": return i;
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
stream(e, t, n) {
|
|
2532
|
+
return Ar.createAssistantStream(e, this._client.beta.threads.runs, t, n);
|
|
2533
|
+
}
|
|
2534
|
+
submitToolOutputs(e, t, n) {
|
|
2535
|
+
let { thread_id: r, ...i } = t;
|
|
2536
|
+
return this._client.post(P`/threads/${r}/runs/${e}/submit_tool_outputs`, {
|
|
2537
|
+
body: i,
|
|
2538
|
+
...n,
|
|
2539
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers]),
|
|
2540
|
+
stream: t.stream ?? !1,
|
|
2541
|
+
__synthesizeEventData: !0
|
|
2542
|
+
});
|
|
2543
|
+
}
|
|
2544
|
+
async submitToolOutputsAndPoll(e, t, n) {
|
|
2545
|
+
let r = await this.submitToolOutputs(e, t, n);
|
|
2546
|
+
return await this.poll(r.id, t, n);
|
|
2547
|
+
}
|
|
2548
|
+
submitToolOutputsStream(e, t, n) {
|
|
2549
|
+
return Ar.createToolAssistantStream(e, this._client.beta.threads.runs, t, n);
|
|
2550
|
+
}
|
|
2551
|
+
};
|
|
2552
|
+
jr.Steps = fr;
|
|
2553
|
+
//#endregion
|
|
2554
|
+
//#region node_modules/openai/resources/beta/threads/threads.mjs
|
|
2555
|
+
var Mr = class extends N {
|
|
2556
|
+
constructor() {
|
|
2557
|
+
super(...arguments), this.runs = new jr(this._client), this.messages = new dr(this._client);
|
|
2558
|
+
}
|
|
2559
|
+
create(e = {}, t) {
|
|
2560
|
+
return this._client.post("/threads", {
|
|
2561
|
+
body: e,
|
|
2562
|
+
...t,
|
|
2563
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
2564
|
+
});
|
|
2565
|
+
}
|
|
2566
|
+
retrieve(e, t) {
|
|
2567
|
+
return this._client.get(P`/threads/${e}`, {
|
|
2568
|
+
...t,
|
|
2569
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
2570
|
+
});
|
|
2571
|
+
}
|
|
2572
|
+
update(e, t, n) {
|
|
2573
|
+
return this._client.post(P`/threads/${e}`, {
|
|
2574
|
+
body: t,
|
|
2575
|
+
...n,
|
|
2576
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2577
|
+
});
|
|
2578
|
+
}
|
|
2579
|
+
delete(e, t) {
|
|
2580
|
+
return this._client.delete(P`/threads/${e}`, {
|
|
2581
|
+
...t,
|
|
2582
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
2583
|
+
});
|
|
2584
|
+
}
|
|
2585
|
+
createAndRun(e, t) {
|
|
2586
|
+
return this._client.post("/threads/runs", {
|
|
2587
|
+
body: e,
|
|
2588
|
+
...t,
|
|
2589
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, t?.headers]),
|
|
2590
|
+
stream: e.stream ?? !1,
|
|
2591
|
+
__synthesizeEventData: !0
|
|
2592
|
+
});
|
|
2593
|
+
}
|
|
2594
|
+
async createAndRunPoll(e, t) {
|
|
2595
|
+
let n = await this.createAndRun(e, t);
|
|
2596
|
+
return await this.runs.poll(n.id, { thread_id: n.thread_id }, t);
|
|
2597
|
+
}
|
|
2598
|
+
createAndRunStream(e, t) {
|
|
2599
|
+
return Ar.createThreadAssistantStream(e, this._client.beta.threads, t);
|
|
2600
|
+
}
|
|
2601
|
+
};
|
|
2602
|
+
Mr.Runs = jr, Mr.Messages = dr;
|
|
2603
|
+
//#endregion
|
|
2604
|
+
//#region node_modules/openai/resources/beta/beta.mjs
|
|
2605
|
+
var Nr = class extends N {
|
|
2606
|
+
constructor() {
|
|
2607
|
+
super(...arguments), this.realtime = new sr(this._client), this.chatkit = new ur(this._client), this.assistants = new ir(this._client), this.threads = new Mr(this._client);
|
|
2608
|
+
}
|
|
2609
|
+
};
|
|
2610
|
+
Nr.Realtime = sr, Nr.ChatKit = ur, Nr.Assistants = ir, Nr.Threads = Mr;
|
|
2611
|
+
//#endregion
|
|
2612
|
+
//#region node_modules/openai/resources/completions.mjs
|
|
2613
|
+
var Pr = class extends N {
|
|
2614
|
+
create(e, t) {
|
|
2615
|
+
return this._client.post("/completions", {
|
|
2616
|
+
body: e,
|
|
2617
|
+
...t,
|
|
2618
|
+
stream: e.stream ?? !1
|
|
2619
|
+
});
|
|
2620
|
+
}
|
|
2621
|
+
}, Fr = class extends N {
|
|
2622
|
+
retrieve(e, t, n) {
|
|
2623
|
+
let { container_id: r } = t;
|
|
2624
|
+
return this._client.get(P`/containers/${r}/files/${e}/content`, {
|
|
2625
|
+
...n,
|
|
2626
|
+
headers: H([{ Accept: "application/binary" }, n?.headers]),
|
|
2627
|
+
__binaryResponse: !0
|
|
2628
|
+
});
|
|
2629
|
+
}
|
|
2630
|
+
}, Ir = class extends N {
|
|
2631
|
+
constructor() {
|
|
2632
|
+
super(...arguments), this.content = new Fr(this._client);
|
|
2633
|
+
}
|
|
2634
|
+
create(e, t, n) {
|
|
2635
|
+
return this._client.post(P`/containers/${e}/files`, vt({
|
|
2636
|
+
body: t,
|
|
2637
|
+
...n
|
|
2638
|
+
}, this._client));
|
|
2639
|
+
}
|
|
2640
|
+
retrieve(e, t, n) {
|
|
2641
|
+
let { container_id: r } = t;
|
|
2642
|
+
return this._client.get(P`/containers/${r}/files/${e}`, n);
|
|
2643
|
+
}
|
|
2644
|
+
list(e, t = {}, n) {
|
|
2645
|
+
return this._client.getAPIList(P`/containers/${e}/files`, j, {
|
|
2646
|
+
query: t,
|
|
2647
|
+
...n
|
|
2648
|
+
});
|
|
2649
|
+
}
|
|
2650
|
+
delete(e, t, n) {
|
|
2651
|
+
let { container_id: r } = t;
|
|
2652
|
+
return this._client.delete(P`/containers/${r}/files/${e}`, {
|
|
2653
|
+
...n,
|
|
2654
|
+
headers: H([{ Accept: "*/*" }, n?.headers])
|
|
2655
|
+
});
|
|
2656
|
+
}
|
|
2657
|
+
};
|
|
2658
|
+
Ir.Content = Fr;
|
|
2659
|
+
//#endregion
|
|
2660
|
+
//#region node_modules/openai/resources/containers/containers.mjs
|
|
2661
|
+
var Lr = class extends N {
|
|
2662
|
+
constructor() {
|
|
2663
|
+
super(...arguments), this.files = new Ir(this._client);
|
|
2664
|
+
}
|
|
2665
|
+
create(e, t) {
|
|
2666
|
+
return this._client.post("/containers", {
|
|
2667
|
+
body: e,
|
|
2668
|
+
...t
|
|
2669
|
+
});
|
|
2670
|
+
}
|
|
2671
|
+
retrieve(e, t) {
|
|
2672
|
+
return this._client.get(P`/containers/${e}`, t);
|
|
2673
|
+
}
|
|
2674
|
+
list(e = {}, t) {
|
|
2675
|
+
return this._client.getAPIList("/containers", j, {
|
|
2676
|
+
query: e,
|
|
2677
|
+
...t
|
|
2678
|
+
});
|
|
2679
|
+
}
|
|
2680
|
+
delete(e, t) {
|
|
2681
|
+
return this._client.delete(P`/containers/${e}`, {
|
|
2682
|
+
...t,
|
|
2683
|
+
headers: H([{ Accept: "*/*" }, t?.headers])
|
|
2684
|
+
});
|
|
2685
|
+
}
|
|
2686
|
+
};
|
|
2687
|
+
Lr.Files = Ir;
|
|
2688
|
+
//#endregion
|
|
2689
|
+
//#region node_modules/openai/resources/conversations/items.mjs
|
|
2690
|
+
var Rr = class extends N {
|
|
2691
|
+
create(e, t, n) {
|
|
2692
|
+
let { include: r, ...i } = t;
|
|
2693
|
+
return this._client.post(P`/conversations/${e}/items`, {
|
|
2694
|
+
query: { include: r },
|
|
2695
|
+
body: i,
|
|
2696
|
+
...n
|
|
2697
|
+
});
|
|
2698
|
+
}
|
|
2699
|
+
retrieve(e, t, n) {
|
|
2700
|
+
let { conversation_id: r, ...i } = t;
|
|
2701
|
+
return this._client.get(P`/conversations/${r}/items/${e}`, {
|
|
2702
|
+
query: i,
|
|
2703
|
+
...n
|
|
2704
|
+
});
|
|
2705
|
+
}
|
|
2706
|
+
list(e, t = {}, n) {
|
|
2707
|
+
return this._client.getAPIList(P`/conversations/${e}/items`, pt, {
|
|
2708
|
+
query: t,
|
|
2709
|
+
...n
|
|
2710
|
+
});
|
|
2711
|
+
}
|
|
2712
|
+
delete(e, t, n) {
|
|
2713
|
+
let { conversation_id: r } = t;
|
|
2714
|
+
return this._client.delete(P`/conversations/${r}/items/${e}`, n);
|
|
2715
|
+
}
|
|
2716
|
+
}, zr = class extends N {
|
|
2717
|
+
constructor() {
|
|
2718
|
+
super(...arguments), this.items = new Rr(this._client);
|
|
2719
|
+
}
|
|
2720
|
+
create(e = {}, t) {
|
|
2721
|
+
return this._client.post("/conversations", {
|
|
2722
|
+
body: e,
|
|
2723
|
+
...t
|
|
2724
|
+
});
|
|
2725
|
+
}
|
|
2726
|
+
retrieve(e, t) {
|
|
2727
|
+
return this._client.get(P`/conversations/${e}`, t);
|
|
2728
|
+
}
|
|
2729
|
+
update(e, t, n) {
|
|
2730
|
+
return this._client.post(P`/conversations/${e}`, {
|
|
2731
|
+
body: t,
|
|
2732
|
+
...n
|
|
2733
|
+
});
|
|
2734
|
+
}
|
|
2735
|
+
delete(e, t) {
|
|
2736
|
+
return this._client.delete(P`/conversations/${e}`, t);
|
|
2737
|
+
}
|
|
2738
|
+
};
|
|
2739
|
+
zr.Items = Rr;
|
|
2740
|
+
//#endregion
|
|
2741
|
+
//#region node_modules/openai/resources/embeddings.mjs
|
|
2742
|
+
var Br = class extends N {
|
|
2743
|
+
create(e, t) {
|
|
2744
|
+
let n = !!e.encoding_format, r = n ? e.encoding_format : "base64";
|
|
2745
|
+
n && k(this._client).debug("embeddings/user defined encoding_format:", e.encoding_format);
|
|
2746
|
+
let i = this._client.post("/embeddings", {
|
|
2747
|
+
body: {
|
|
2748
|
+
...e,
|
|
2749
|
+
encoding_format: r
|
|
2750
|
+
},
|
|
2751
|
+
...t
|
|
2752
|
+
});
|
|
2753
|
+
return n ? i : (k(this._client).debug("embeddings/decoding base64 embeddings from base64"), i._thenUnwrap((e) => (e && e.data && e.data.forEach((e) => {
|
|
2754
|
+
let t = e.embedding;
|
|
2755
|
+
e.embedding = pr(t);
|
|
2756
|
+
}), e)));
|
|
2757
|
+
}
|
|
2758
|
+
}, Vr = class extends N {
|
|
2759
|
+
retrieve(e, t, n) {
|
|
2760
|
+
let { eval_id: r, run_id: i } = t;
|
|
2761
|
+
return this._client.get(P`/evals/${r}/runs/${i}/output_items/${e}`, n);
|
|
2762
|
+
}
|
|
2763
|
+
list(e, t, n) {
|
|
2764
|
+
let { eval_id: r, ...i } = t;
|
|
2765
|
+
return this._client.getAPIList(P`/evals/${r}/runs/${e}/output_items`, j, {
|
|
2766
|
+
query: i,
|
|
2767
|
+
...n
|
|
2768
|
+
});
|
|
2769
|
+
}
|
|
2770
|
+
}, Hr = class extends N {
|
|
2771
|
+
constructor() {
|
|
2772
|
+
super(...arguments), this.outputItems = new Vr(this._client);
|
|
2773
|
+
}
|
|
2774
|
+
create(e, t, n) {
|
|
2775
|
+
return this._client.post(P`/evals/${e}/runs`, {
|
|
2776
|
+
body: t,
|
|
2777
|
+
...n
|
|
2778
|
+
});
|
|
2779
|
+
}
|
|
2780
|
+
retrieve(e, t, n) {
|
|
2781
|
+
let { eval_id: r } = t;
|
|
2782
|
+
return this._client.get(P`/evals/${r}/runs/${e}`, n);
|
|
2783
|
+
}
|
|
2784
|
+
list(e, t = {}, n) {
|
|
2785
|
+
return this._client.getAPIList(P`/evals/${e}/runs`, j, {
|
|
2786
|
+
query: t,
|
|
2787
|
+
...n
|
|
2788
|
+
});
|
|
2789
|
+
}
|
|
2790
|
+
delete(e, t, n) {
|
|
2791
|
+
let { eval_id: r } = t;
|
|
2792
|
+
return this._client.delete(P`/evals/${r}/runs/${e}`, n);
|
|
2793
|
+
}
|
|
2794
|
+
cancel(e, t, n) {
|
|
2795
|
+
let { eval_id: r } = t;
|
|
2796
|
+
return this._client.post(P`/evals/${r}/runs/${e}`, n);
|
|
2797
|
+
}
|
|
2798
|
+
};
|
|
2799
|
+
Hr.OutputItems = Vr;
|
|
2800
|
+
//#endregion
|
|
2801
|
+
//#region node_modules/openai/resources/evals/evals.mjs
|
|
2802
|
+
var Ur = class extends N {
|
|
2803
|
+
constructor() {
|
|
2804
|
+
super(...arguments), this.runs = new Hr(this._client);
|
|
2805
|
+
}
|
|
2806
|
+
create(e, t) {
|
|
2807
|
+
return this._client.post("/evals", {
|
|
2808
|
+
body: e,
|
|
2809
|
+
...t
|
|
2810
|
+
});
|
|
2811
|
+
}
|
|
2812
|
+
retrieve(e, t) {
|
|
2813
|
+
return this._client.get(P`/evals/${e}`, t);
|
|
2814
|
+
}
|
|
2815
|
+
update(e, t, n) {
|
|
2816
|
+
return this._client.post(P`/evals/${e}`, {
|
|
2817
|
+
body: t,
|
|
2818
|
+
...n
|
|
2819
|
+
});
|
|
2820
|
+
}
|
|
2821
|
+
list(e = {}, t) {
|
|
2822
|
+
return this._client.getAPIList("/evals", j, {
|
|
2823
|
+
query: e,
|
|
2824
|
+
...t
|
|
2825
|
+
});
|
|
2826
|
+
}
|
|
2827
|
+
delete(e, t) {
|
|
2828
|
+
return this._client.delete(P`/evals/${e}`, t);
|
|
2829
|
+
}
|
|
2830
|
+
};
|
|
2831
|
+
Ur.Runs = Hr;
|
|
2832
|
+
//#endregion
|
|
2833
|
+
//#region node_modules/openai/resources/files.mjs
|
|
2834
|
+
var Wr = class extends N {
|
|
2835
|
+
create(e, t) {
|
|
2836
|
+
return this._client.post("/files", M({
|
|
2837
|
+
body: e,
|
|
2838
|
+
...t
|
|
2839
|
+
}, this._client));
|
|
2840
|
+
}
|
|
2841
|
+
retrieve(e, t) {
|
|
2842
|
+
return this._client.get(P`/files/${e}`, t);
|
|
2843
|
+
}
|
|
2844
|
+
list(e = {}, t) {
|
|
2845
|
+
return this._client.getAPIList("/files", j, {
|
|
2846
|
+
query: e,
|
|
2847
|
+
...t
|
|
2848
|
+
});
|
|
2849
|
+
}
|
|
2850
|
+
delete(e, t) {
|
|
2851
|
+
return this._client.delete(P`/files/${e}`, t);
|
|
2852
|
+
}
|
|
2853
|
+
content(e, t) {
|
|
2854
|
+
return this._client.get(P`/files/${e}/content`, {
|
|
2855
|
+
...t,
|
|
2856
|
+
headers: H([{ Accept: "application/binary" }, t?.headers]),
|
|
2857
|
+
__binaryResponse: !0
|
|
2858
|
+
});
|
|
2859
|
+
}
|
|
2860
|
+
async waitForProcessing(e, { pollInterval: t = 5e3, maxWait: n = 1800 * 1e3 } = {}) {
|
|
2861
|
+
let r = new Set([
|
|
2862
|
+
"processed",
|
|
2863
|
+
"error",
|
|
2864
|
+
"deleted"
|
|
2865
|
+
]), i = Date.now(), a = await this.retrieve(e);
|
|
2866
|
+
for (; !a.status || !r.has(a.status);) if (await se(t), a = await this.retrieve(e), Date.now() - i > n) throw new l({ message: `Giving up on waiting for file ${e} to finish processing after ${n} milliseconds.` });
|
|
2867
|
+
return a;
|
|
2868
|
+
}
|
|
2869
|
+
}, Gr = class extends N {}, Kr = class extends N {
|
|
2870
|
+
run(e, t) {
|
|
2871
|
+
return this._client.post("/fine_tuning/alpha/graders/run", {
|
|
2872
|
+
body: e,
|
|
2873
|
+
...t
|
|
2874
|
+
});
|
|
2875
|
+
}
|
|
2876
|
+
validate(e, t) {
|
|
2877
|
+
return this._client.post("/fine_tuning/alpha/graders/validate", {
|
|
2878
|
+
body: e,
|
|
2879
|
+
...t
|
|
2880
|
+
});
|
|
2881
|
+
}
|
|
2882
|
+
}, qr = class extends N {
|
|
2883
|
+
constructor() {
|
|
2884
|
+
super(...arguments), this.graders = new Kr(this._client);
|
|
2885
|
+
}
|
|
2886
|
+
};
|
|
2887
|
+
qr.Graders = Kr;
|
|
2888
|
+
//#endregion
|
|
2889
|
+
//#region node_modules/openai/resources/fine-tuning/checkpoints/permissions.mjs
|
|
2890
|
+
var Jr = class extends N {
|
|
2891
|
+
create(e, t, n) {
|
|
2892
|
+
return this._client.getAPIList(P`/fine_tuning/checkpoints/${e}/permissions`, ft, {
|
|
2893
|
+
body: t,
|
|
2894
|
+
method: "post",
|
|
2895
|
+
...n
|
|
2896
|
+
});
|
|
2897
|
+
}
|
|
2898
|
+
retrieve(e, t = {}, n) {
|
|
2899
|
+
return this._client.get(P`/fine_tuning/checkpoints/${e}/permissions`, {
|
|
2900
|
+
query: t,
|
|
2901
|
+
...n
|
|
2902
|
+
});
|
|
2903
|
+
}
|
|
2904
|
+
list(e, t = {}, n) {
|
|
2905
|
+
return this._client.getAPIList(P`/fine_tuning/checkpoints/${e}/permissions`, pt, {
|
|
2906
|
+
query: t,
|
|
2907
|
+
...n
|
|
2908
|
+
});
|
|
2909
|
+
}
|
|
2910
|
+
delete(e, t, n) {
|
|
2911
|
+
let { fine_tuned_model_checkpoint: r } = t;
|
|
2912
|
+
return this._client.delete(P`/fine_tuning/checkpoints/${r}/permissions/${e}`, n);
|
|
2913
|
+
}
|
|
2914
|
+
}, Yr = class extends N {
|
|
2915
|
+
constructor() {
|
|
2916
|
+
super(...arguments), this.permissions = new Jr(this._client);
|
|
2917
|
+
}
|
|
2918
|
+
};
|
|
2919
|
+
Yr.Permissions = Jr;
|
|
2920
|
+
//#endregion
|
|
2921
|
+
//#region node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs
|
|
2922
|
+
var Xr = class extends N {
|
|
2923
|
+
list(e, t = {}, n) {
|
|
2924
|
+
return this._client.getAPIList(P`/fine_tuning/jobs/${e}/checkpoints`, j, {
|
|
2925
|
+
query: t,
|
|
2926
|
+
...n
|
|
2927
|
+
});
|
|
2928
|
+
}
|
|
2929
|
+
}, Zr = class extends N {
|
|
2930
|
+
constructor() {
|
|
2931
|
+
super(...arguments), this.checkpoints = new Xr(this._client);
|
|
2932
|
+
}
|
|
2933
|
+
create(e, t) {
|
|
2934
|
+
return this._client.post("/fine_tuning/jobs", {
|
|
2935
|
+
body: e,
|
|
2936
|
+
...t
|
|
2937
|
+
});
|
|
2938
|
+
}
|
|
2939
|
+
retrieve(e, t) {
|
|
2940
|
+
return this._client.get(P`/fine_tuning/jobs/${e}`, t);
|
|
2941
|
+
}
|
|
2942
|
+
list(e = {}, t) {
|
|
2943
|
+
return this._client.getAPIList("/fine_tuning/jobs", j, {
|
|
2944
|
+
query: e,
|
|
2945
|
+
...t
|
|
2946
|
+
});
|
|
2947
|
+
}
|
|
2948
|
+
cancel(e, t) {
|
|
2949
|
+
return this._client.post(P`/fine_tuning/jobs/${e}/cancel`, t);
|
|
2950
|
+
}
|
|
2951
|
+
listEvents(e, t = {}, n) {
|
|
2952
|
+
return this._client.getAPIList(P`/fine_tuning/jobs/${e}/events`, j, {
|
|
2953
|
+
query: t,
|
|
2954
|
+
...n
|
|
2955
|
+
});
|
|
2956
|
+
}
|
|
2957
|
+
pause(e, t) {
|
|
2958
|
+
return this._client.post(P`/fine_tuning/jobs/${e}/pause`, t);
|
|
2959
|
+
}
|
|
2960
|
+
resume(e, t) {
|
|
2961
|
+
return this._client.post(P`/fine_tuning/jobs/${e}/resume`, t);
|
|
2962
|
+
}
|
|
2963
|
+
};
|
|
2964
|
+
Zr.Checkpoints = Xr;
|
|
2965
|
+
//#endregion
|
|
2966
|
+
//#region node_modules/openai/resources/fine-tuning/fine-tuning.mjs
|
|
2967
|
+
var Z = class extends N {
|
|
2968
|
+
constructor() {
|
|
2969
|
+
super(...arguments), this.methods = new Gr(this._client), this.jobs = new Zr(this._client), this.checkpoints = new Yr(this._client), this.alpha = new qr(this._client);
|
|
2970
|
+
}
|
|
2971
|
+
};
|
|
2972
|
+
Z.Methods = Gr, Z.Jobs = Zr, Z.Checkpoints = Yr, Z.Alpha = qr;
|
|
2973
|
+
//#endregion
|
|
2974
|
+
//#region node_modules/openai/resources/graders/grader-models.mjs
|
|
2975
|
+
var Qr = class extends N {}, $r = class extends N {
|
|
2976
|
+
constructor() {
|
|
2977
|
+
super(...arguments), this.graderModels = new Qr(this._client);
|
|
2978
|
+
}
|
|
2979
|
+
};
|
|
2980
|
+
$r.GraderModels = Qr;
|
|
2981
|
+
//#endregion
|
|
2982
|
+
//#region node_modules/openai/resources/images.mjs
|
|
2983
|
+
var ei = class extends N {
|
|
2984
|
+
createVariation(e, t) {
|
|
2985
|
+
return this._client.post("/images/variations", M({
|
|
2986
|
+
body: e,
|
|
2987
|
+
...t
|
|
2988
|
+
}, this._client));
|
|
2989
|
+
}
|
|
2990
|
+
edit(e, t) {
|
|
2991
|
+
return this._client.post("/images/edits", M({
|
|
2992
|
+
body: e,
|
|
2993
|
+
...t,
|
|
2994
|
+
stream: e.stream ?? !1
|
|
2995
|
+
}, this._client));
|
|
2996
|
+
}
|
|
2997
|
+
generate(e, t) {
|
|
2998
|
+
return this._client.post("/images/generations", {
|
|
2999
|
+
body: e,
|
|
3000
|
+
...t,
|
|
3001
|
+
stream: e.stream ?? !1
|
|
3002
|
+
});
|
|
3003
|
+
}
|
|
3004
|
+
}, ti = class extends N {
|
|
3005
|
+
retrieve(e, t) {
|
|
3006
|
+
return this._client.get(P`/models/${e}`, t);
|
|
3007
|
+
}
|
|
3008
|
+
list(e) {
|
|
3009
|
+
return this._client.getAPIList("/models", ft, e);
|
|
3010
|
+
}
|
|
3011
|
+
delete(e, t) {
|
|
3012
|
+
return this._client.delete(P`/models/${e}`, t);
|
|
3013
|
+
}
|
|
3014
|
+
}, ni = class extends N {
|
|
3015
|
+
create(e, t) {
|
|
3016
|
+
return this._client.post("/moderations", {
|
|
3017
|
+
body: e,
|
|
3018
|
+
...t
|
|
3019
|
+
});
|
|
3020
|
+
}
|
|
3021
|
+
}, ri = class extends N {
|
|
3022
|
+
accept(e, t, n) {
|
|
3023
|
+
return this._client.post(P`/realtime/calls/${e}/accept`, {
|
|
3024
|
+
body: t,
|
|
3025
|
+
...n,
|
|
3026
|
+
headers: H([{ Accept: "*/*" }, n?.headers])
|
|
3027
|
+
});
|
|
3028
|
+
}
|
|
3029
|
+
hangup(e, t) {
|
|
3030
|
+
return this._client.post(P`/realtime/calls/${e}/hangup`, {
|
|
3031
|
+
...t,
|
|
3032
|
+
headers: H([{ Accept: "*/*" }, t?.headers])
|
|
3033
|
+
});
|
|
3034
|
+
}
|
|
3035
|
+
refer(e, t, n) {
|
|
3036
|
+
return this._client.post(P`/realtime/calls/${e}/refer`, {
|
|
3037
|
+
body: t,
|
|
3038
|
+
...n,
|
|
3039
|
+
headers: H([{ Accept: "*/*" }, n?.headers])
|
|
3040
|
+
});
|
|
3041
|
+
}
|
|
3042
|
+
reject(e, t = {}, n) {
|
|
3043
|
+
return this._client.post(P`/realtime/calls/${e}/reject`, {
|
|
3044
|
+
body: t,
|
|
3045
|
+
...n,
|
|
3046
|
+
headers: H([{ Accept: "*/*" }, n?.headers])
|
|
3047
|
+
});
|
|
3048
|
+
}
|
|
3049
|
+
}, ii = class extends N {
|
|
3050
|
+
create(e, t) {
|
|
3051
|
+
return this._client.post("/realtime/client_secrets", {
|
|
3052
|
+
body: e,
|
|
3053
|
+
...t
|
|
3054
|
+
});
|
|
3055
|
+
}
|
|
3056
|
+
}, ai = class extends N {
|
|
3057
|
+
constructor() {
|
|
3058
|
+
super(...arguments), this.clientSecrets = new ii(this._client), this.calls = new ri(this._client);
|
|
3059
|
+
}
|
|
3060
|
+
};
|
|
3061
|
+
ai.ClientSecrets = ii, ai.Calls = ri;
|
|
3062
|
+
//#endregion
|
|
3063
|
+
//#region node_modules/openai/lib/ResponsesParser.mjs
|
|
3064
|
+
function oi(e, t) {
|
|
3065
|
+
return !t || !li(t) ? {
|
|
3066
|
+
...e,
|
|
3067
|
+
output_parsed: null,
|
|
3068
|
+
output: e.output.map((e) => e.type === "function_call" ? {
|
|
3069
|
+
...e,
|
|
3070
|
+
parsed_arguments: null
|
|
3071
|
+
} : e.type === "message" ? {
|
|
3072
|
+
...e,
|
|
3073
|
+
content: e.content.map((e) => ({
|
|
3074
|
+
...e,
|
|
3075
|
+
parsed: null
|
|
3076
|
+
}))
|
|
3077
|
+
} : e)
|
|
3078
|
+
} : si(e, t);
|
|
3079
|
+
}
|
|
3080
|
+
function si(e, t) {
|
|
3081
|
+
let n = e.output.map((e) => {
|
|
3082
|
+
if (e.type === "function_call") return {
|
|
3083
|
+
...e,
|
|
3084
|
+
parsed_arguments: fi(t, e)
|
|
3085
|
+
};
|
|
3086
|
+
if (e.type === "message") {
|
|
3087
|
+
let n = e.content.map((e) => e.type === "output_text" ? {
|
|
3088
|
+
...e,
|
|
3089
|
+
parsed: ci(t, e.text)
|
|
3090
|
+
} : e);
|
|
3091
|
+
return {
|
|
3092
|
+
...e,
|
|
3093
|
+
content: n
|
|
3094
|
+
};
|
|
3095
|
+
}
|
|
3096
|
+
return e;
|
|
3097
|
+
}), r = Object.assign({}, e, { output: n });
|
|
3098
|
+
return Object.getOwnPropertyDescriptor(e, "output_text") || pi(r), Object.defineProperty(r, "output_parsed", {
|
|
3099
|
+
enumerable: !0,
|
|
3100
|
+
get() {
|
|
3101
|
+
for (let e of r.output) if (e.type === "message") {
|
|
3102
|
+
for (let t of e.content) if (t.type === "output_text" && t.parsed !== null) return t.parsed;
|
|
3103
|
+
}
|
|
3104
|
+
return null;
|
|
3105
|
+
}
|
|
3106
|
+
}), r;
|
|
3107
|
+
}
|
|
3108
|
+
function ci(e, t) {
|
|
3109
|
+
return e.text?.format?.type === "json_schema" ? "$parseRaw" in e.text?.format ? (e.text?.format).$parseRaw(t) : JSON.parse(t) : null;
|
|
3110
|
+
}
|
|
3111
|
+
function li(e) {
|
|
3112
|
+
return !!It(e.text?.format);
|
|
3113
|
+
}
|
|
3114
|
+
function ui(e) {
|
|
3115
|
+
return e?.$brand === "auto-parseable-tool";
|
|
3116
|
+
}
|
|
3117
|
+
function di(e, t) {
|
|
3118
|
+
return e.find((e) => e.type === "function" && e.name === t);
|
|
3119
|
+
}
|
|
3120
|
+
function fi(e, t) {
|
|
3121
|
+
let n = di(e.tools ?? [], t.name);
|
|
3122
|
+
return {
|
|
3123
|
+
...t,
|
|
3124
|
+
...t,
|
|
3125
|
+
parsed_arguments: ui(n) ? n.$parseRaw(t.arguments) : n?.strict ? JSON.parse(t.arguments) : null
|
|
3126
|
+
};
|
|
3127
|
+
}
|
|
3128
|
+
function pi(e) {
|
|
3129
|
+
let t = [];
|
|
3130
|
+
for (let n of e.output) if (n.type === "message") for (let e of n.content) e.type === "output_text" && t.push(e.text);
|
|
3131
|
+
e.output_text = t.join("");
|
|
3132
|
+
}
|
|
3133
|
+
//#endregion
|
|
3134
|
+
//#region node_modules/openai/lib/responses/ResponseStream.mjs
|
|
3135
|
+
var mi, hi, Q, gi, _i, vi, yi, bi, xi = class n extends sn {
|
|
3136
|
+
constructor(t) {
|
|
3137
|
+
super(), mi.add(this), hi.set(this, void 0), Q.set(this, void 0), gi.set(this, void 0), e(this, hi, t, "f");
|
|
3138
|
+
}
|
|
3139
|
+
static createResponse(e, t, r) {
|
|
3140
|
+
let i = new n(t);
|
|
3141
|
+
return i._run(() => i._createOrRetrieveResponse(e, t, {
|
|
3142
|
+
...r,
|
|
3143
|
+
headers: {
|
|
3144
|
+
...r?.headers,
|
|
3145
|
+
"X-Stainless-Helper-Method": "stream"
|
|
3146
|
+
}
|
|
3147
|
+
})), i;
|
|
3148
|
+
}
|
|
3149
|
+
async _createOrRetrieveResponse(e, n, r) {
|
|
3150
|
+
let i = r?.signal;
|
|
3151
|
+
i && (i.aborted && this.controller.abort(), i.addEventListener("abort", () => this.controller.abort())), t(this, mi, "m", _i).call(this);
|
|
3152
|
+
let a, o = null;
|
|
3153
|
+
"response_id" in n ? (a = await e.responses.retrieve(n.response_id, { stream: !0 }, {
|
|
3154
|
+
...r,
|
|
3155
|
+
signal: this.controller.signal,
|
|
3156
|
+
stream: !0
|
|
3157
|
+
}), o = n.starting_after ?? null) : a = await e.responses.create({
|
|
3158
|
+
...n,
|
|
3159
|
+
stream: !0
|
|
3160
|
+
}, {
|
|
3161
|
+
...r,
|
|
3162
|
+
signal: this.controller.signal
|
|
3163
|
+
}), this._connected();
|
|
3164
|
+
for await (let e of a) t(this, mi, "m", vi).call(this, e, o);
|
|
3165
|
+
if (a.controller.signal?.aborted) throw new s();
|
|
3166
|
+
return t(this, mi, "m", yi).call(this);
|
|
3167
|
+
}
|
|
3168
|
+
[(hi = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), gi = /* @__PURE__ */ new WeakMap(), mi = /* @__PURE__ */ new WeakSet(), _i = function() {
|
|
3169
|
+
this.ended || e(this, Q, void 0, "f");
|
|
3170
|
+
}, vi = function(e, n) {
|
|
3171
|
+
if (this.ended) return;
|
|
3172
|
+
let r = (e, t) => {
|
|
3173
|
+
(n == null || t.sequence_number > n) && this._emit(e, t);
|
|
3174
|
+
}, i = t(this, mi, "m", bi).call(this, e);
|
|
3175
|
+
switch (r("event", e), e.type) {
|
|
3176
|
+
case "response.output_text.delta": {
|
|
3177
|
+
let t = i.output[e.output_index];
|
|
3178
|
+
if (!t) throw new a(`missing output at index ${e.output_index}`);
|
|
3179
|
+
if (t.type === "message") {
|
|
3180
|
+
let n = t.content[e.content_index];
|
|
3181
|
+
if (!n) throw new a(`missing content at index ${e.content_index}`);
|
|
3182
|
+
if (n.type !== "output_text") throw new a(`expected content to be 'output_text', got ${n.type}`);
|
|
3183
|
+
r("response.output_text.delta", {
|
|
3184
|
+
...e,
|
|
3185
|
+
snapshot: n.text
|
|
3186
|
+
});
|
|
3187
|
+
}
|
|
3188
|
+
break;
|
|
3189
|
+
}
|
|
3190
|
+
case "response.function_call_arguments.delta": {
|
|
3191
|
+
let t = i.output[e.output_index];
|
|
3192
|
+
if (!t) throw new a(`missing output at index ${e.output_index}`);
|
|
3193
|
+
t.type === "function_call" && r("response.function_call_arguments.delta", {
|
|
3194
|
+
...e,
|
|
3195
|
+
snapshot: t.arguments
|
|
3196
|
+
});
|
|
3197
|
+
break;
|
|
3198
|
+
}
|
|
3199
|
+
default:
|
|
3200
|
+
r(e.type, e);
|
|
3201
|
+
break;
|
|
3202
|
+
}
|
|
3203
|
+
}, yi = function() {
|
|
3204
|
+
if (this.ended) throw new a("stream has ended, this shouldn't happen");
|
|
3205
|
+
let n = t(this, Q, "f");
|
|
3206
|
+
if (!n) throw new a("request ended without sending any events");
|
|
3207
|
+
e(this, Q, void 0, "f");
|
|
3208
|
+
let r = Si(n, t(this, hi, "f"));
|
|
3209
|
+
return e(this, gi, r, "f"), r;
|
|
3210
|
+
}, bi = function(n) {
|
|
3211
|
+
let r = t(this, Q, "f");
|
|
3212
|
+
if (!r) {
|
|
3213
|
+
if (n.type !== "response.created") throw new a(`When snapshot hasn't been set yet, expected 'response.created' event, got ${n.type}`);
|
|
3214
|
+
return r = e(this, Q, n.response, "f"), r;
|
|
3215
|
+
}
|
|
3216
|
+
switch (n.type) {
|
|
3217
|
+
case "response.output_item.added":
|
|
3218
|
+
r.output.push(n.item);
|
|
3219
|
+
break;
|
|
3220
|
+
case "response.content_part.added": {
|
|
3221
|
+
let e = r.output[n.output_index];
|
|
3222
|
+
if (!e) throw new a(`missing output at index ${n.output_index}`);
|
|
3223
|
+
let t = e.type, i = n.part;
|
|
3224
|
+
t === "message" && i.type !== "reasoning_text" ? e.content.push(i) : t === "reasoning" && i.type === "reasoning_text" && (e.content ||= [], e.content.push(i));
|
|
3225
|
+
break;
|
|
3226
|
+
}
|
|
3227
|
+
case "response.output_text.delta": {
|
|
3228
|
+
let e = r.output[n.output_index];
|
|
3229
|
+
if (!e) throw new a(`missing output at index ${n.output_index}`);
|
|
3230
|
+
if (e.type === "message") {
|
|
3231
|
+
let t = e.content[n.content_index];
|
|
3232
|
+
if (!t) throw new a(`missing content at index ${n.content_index}`);
|
|
3233
|
+
if (t.type !== "output_text") throw new a(`expected content to be 'output_text', got ${t.type}`);
|
|
3234
|
+
t.text += n.delta;
|
|
3235
|
+
}
|
|
3236
|
+
break;
|
|
3237
|
+
}
|
|
3238
|
+
case "response.function_call_arguments.delta": {
|
|
3239
|
+
let e = r.output[n.output_index];
|
|
3240
|
+
if (!e) throw new a(`missing output at index ${n.output_index}`);
|
|
3241
|
+
e.type === "function_call" && (e.arguments += n.delta);
|
|
3242
|
+
break;
|
|
3243
|
+
}
|
|
3244
|
+
case "response.reasoning_text.delta": {
|
|
3245
|
+
let e = r.output[n.output_index];
|
|
3246
|
+
if (!e) throw new a(`missing output at index ${n.output_index}`);
|
|
3247
|
+
if (e.type === "reasoning") {
|
|
3248
|
+
let t = e.content?.[n.content_index];
|
|
3249
|
+
if (!t) throw new a(`missing content at index ${n.content_index}`);
|
|
3250
|
+
if (t.type !== "reasoning_text") throw new a(`expected content to be 'reasoning_text', got ${t.type}`);
|
|
3251
|
+
t.text += n.delta;
|
|
3252
|
+
}
|
|
3253
|
+
break;
|
|
3254
|
+
}
|
|
3255
|
+
case "response.completed":
|
|
3256
|
+
e(this, Q, n.response, "f");
|
|
3257
|
+
break;
|
|
3258
|
+
}
|
|
3259
|
+
return r;
|
|
3260
|
+
}, Symbol.asyncIterator)]() {
|
|
3261
|
+
let e = [], t = [], n = !1;
|
|
3262
|
+
return this.on("event", (n) => {
|
|
3263
|
+
let r = t.shift();
|
|
3264
|
+
r ? r.resolve(n) : e.push(n);
|
|
3265
|
+
}), this.on("end", () => {
|
|
3266
|
+
n = !0;
|
|
3267
|
+
for (let e of t) e.resolve(void 0);
|
|
3268
|
+
t.length = 0;
|
|
3269
|
+
}), this.on("abort", (e) => {
|
|
3270
|
+
n = !0;
|
|
3271
|
+
for (let n of t) n.reject(e);
|
|
3272
|
+
t.length = 0;
|
|
3273
|
+
}), this.on("error", (e) => {
|
|
3274
|
+
n = !0;
|
|
3275
|
+
for (let n of t) n.reject(e);
|
|
3276
|
+
t.length = 0;
|
|
3277
|
+
}), {
|
|
3278
|
+
next: async () => e.length ? {
|
|
3279
|
+
value: e.shift(),
|
|
3280
|
+
done: !1
|
|
3281
|
+
} : n ? {
|
|
3282
|
+
value: void 0,
|
|
3283
|
+
done: !0
|
|
3284
|
+
} : new Promise((e, n) => t.push({
|
|
3285
|
+
resolve: e,
|
|
3286
|
+
reject: n
|
|
3287
|
+
})).then((e) => e ? {
|
|
3288
|
+
value: e,
|
|
3289
|
+
done: !1
|
|
3290
|
+
} : {
|
|
3291
|
+
value: void 0,
|
|
3292
|
+
done: !0
|
|
3293
|
+
}),
|
|
3294
|
+
return: async () => (this.abort(), {
|
|
3295
|
+
value: void 0,
|
|
3296
|
+
done: !0
|
|
3297
|
+
})
|
|
3298
|
+
};
|
|
3299
|
+
}
|
|
3300
|
+
async finalResponse() {
|
|
3301
|
+
await this.done();
|
|
3302
|
+
let e = t(this, gi, "f");
|
|
3303
|
+
if (!e) throw new a("stream ended without producing a ChatCompletion");
|
|
3304
|
+
return e;
|
|
3305
|
+
}
|
|
3306
|
+
};
|
|
3307
|
+
function Si(e, t) {
|
|
3308
|
+
return oi(e, t);
|
|
3309
|
+
}
|
|
3310
|
+
//#endregion
|
|
3311
|
+
//#region node_modules/openai/resources/responses/input-items.mjs
|
|
3312
|
+
var Ci = class extends N {
|
|
3313
|
+
list(e, t = {}, n) {
|
|
3314
|
+
return this._client.getAPIList(P`/responses/${e}/input_items`, j, {
|
|
3315
|
+
query: t,
|
|
3316
|
+
...n
|
|
3317
|
+
});
|
|
3318
|
+
}
|
|
3319
|
+
}, wi = class extends N {
|
|
3320
|
+
count(e = {}, t) {
|
|
3321
|
+
return this._client.post("/responses/input_tokens", {
|
|
3322
|
+
body: e,
|
|
3323
|
+
...t
|
|
3324
|
+
});
|
|
3325
|
+
}
|
|
3326
|
+
}, Ti = class extends N {
|
|
3327
|
+
constructor() {
|
|
3328
|
+
super(...arguments), this.inputItems = new Ci(this._client), this.inputTokens = new wi(this._client);
|
|
3329
|
+
}
|
|
3330
|
+
create(e, t) {
|
|
3331
|
+
return this._client.post("/responses", {
|
|
3332
|
+
body: e,
|
|
3333
|
+
...t,
|
|
3334
|
+
stream: e.stream ?? !1
|
|
3335
|
+
})._thenUnwrap((e) => ("object" in e && e.object === "response" && pi(e), e));
|
|
3336
|
+
}
|
|
3337
|
+
retrieve(e, t = {}, n) {
|
|
3338
|
+
return this._client.get(P`/responses/${e}`, {
|
|
3339
|
+
query: t,
|
|
3340
|
+
...n,
|
|
3341
|
+
stream: t?.stream ?? !1
|
|
3342
|
+
})._thenUnwrap((e) => ("object" in e && e.object === "response" && pi(e), e));
|
|
3343
|
+
}
|
|
3344
|
+
delete(e, t) {
|
|
3345
|
+
return this._client.delete(P`/responses/${e}`, {
|
|
3346
|
+
...t,
|
|
3347
|
+
headers: H([{ Accept: "*/*" }, t?.headers])
|
|
3348
|
+
});
|
|
3349
|
+
}
|
|
3350
|
+
parse(e, t) {
|
|
3351
|
+
return this._client.responses.create(e, t)._thenUnwrap((t) => si(t, e));
|
|
3352
|
+
}
|
|
3353
|
+
stream(e, t) {
|
|
3354
|
+
return xi.createResponse(this._client, e, t);
|
|
3355
|
+
}
|
|
3356
|
+
cancel(e, t) {
|
|
3357
|
+
return this._client.post(P`/responses/${e}/cancel`, t);
|
|
3358
|
+
}
|
|
3359
|
+
compact(e, t) {
|
|
3360
|
+
return this._client.post("/responses/compact", {
|
|
3361
|
+
body: e,
|
|
3362
|
+
...t
|
|
3363
|
+
});
|
|
3364
|
+
}
|
|
3365
|
+
};
|
|
3366
|
+
Ti.InputItems = Ci, Ti.InputTokens = wi;
|
|
3367
|
+
//#endregion
|
|
3368
|
+
//#region node_modules/openai/resources/skills/content.mjs
|
|
3369
|
+
var Ei = class extends N {
|
|
3370
|
+
retrieve(e, t) {
|
|
3371
|
+
return this._client.get(P`/skills/${e}/content`, {
|
|
3372
|
+
...t,
|
|
3373
|
+
headers: H([{ Accept: "application/binary" }, t?.headers]),
|
|
3374
|
+
__binaryResponse: !0
|
|
3375
|
+
});
|
|
3376
|
+
}
|
|
3377
|
+
}, Di = class extends N {
|
|
3378
|
+
retrieve(e, t, n) {
|
|
3379
|
+
let { skill_id: r } = t;
|
|
3380
|
+
return this._client.get(P`/skills/${r}/versions/${e}/content`, {
|
|
3381
|
+
...n,
|
|
3382
|
+
headers: H([{ Accept: "application/binary" }, n?.headers]),
|
|
3383
|
+
__binaryResponse: !0
|
|
3384
|
+
});
|
|
3385
|
+
}
|
|
3386
|
+
}, Oi = class extends N {
|
|
3387
|
+
constructor() {
|
|
3388
|
+
super(...arguments), this.content = new Di(this._client);
|
|
3389
|
+
}
|
|
3390
|
+
create(e, t = {}, n) {
|
|
3391
|
+
return this._client.post(P`/skills/${e}/versions`, vt({
|
|
3392
|
+
body: t,
|
|
3393
|
+
...n
|
|
3394
|
+
}, this._client));
|
|
3395
|
+
}
|
|
3396
|
+
retrieve(e, t, n) {
|
|
3397
|
+
let { skill_id: r } = t;
|
|
3398
|
+
return this._client.get(P`/skills/${r}/versions/${e}`, n);
|
|
3399
|
+
}
|
|
3400
|
+
list(e, t = {}, n) {
|
|
3401
|
+
return this._client.getAPIList(P`/skills/${e}/versions`, j, {
|
|
3402
|
+
query: t,
|
|
3403
|
+
...n
|
|
3404
|
+
});
|
|
3405
|
+
}
|
|
3406
|
+
delete(e, t, n) {
|
|
3407
|
+
let { skill_id: r } = t;
|
|
3408
|
+
return this._client.delete(P`/skills/${r}/versions/${e}`, n);
|
|
3409
|
+
}
|
|
3410
|
+
};
|
|
3411
|
+
Oi.Content = Di;
|
|
3412
|
+
//#endregion
|
|
3413
|
+
//#region node_modules/openai/resources/skills/skills.mjs
|
|
3414
|
+
var ki = class extends N {
|
|
3415
|
+
constructor() {
|
|
3416
|
+
super(...arguments), this.content = new Ei(this._client), this.versions = new Oi(this._client);
|
|
3417
|
+
}
|
|
3418
|
+
create(e = {}, t) {
|
|
3419
|
+
return this._client.post("/skills", vt({
|
|
3420
|
+
body: e,
|
|
3421
|
+
...t
|
|
3422
|
+
}, this._client));
|
|
3423
|
+
}
|
|
3424
|
+
retrieve(e, t) {
|
|
3425
|
+
return this._client.get(P`/skills/${e}`, t);
|
|
3426
|
+
}
|
|
3427
|
+
update(e, t, n) {
|
|
3428
|
+
return this._client.post(P`/skills/${e}`, {
|
|
3429
|
+
body: t,
|
|
3430
|
+
...n
|
|
3431
|
+
});
|
|
3432
|
+
}
|
|
3433
|
+
list(e = {}, t) {
|
|
3434
|
+
return this._client.getAPIList("/skills", j, {
|
|
3435
|
+
query: e,
|
|
3436
|
+
...t
|
|
3437
|
+
});
|
|
3438
|
+
}
|
|
3439
|
+
delete(e, t) {
|
|
3440
|
+
return this._client.delete(P`/skills/${e}`, t);
|
|
3441
|
+
}
|
|
3442
|
+
};
|
|
3443
|
+
ki.Content = Ei, ki.Versions = Oi;
|
|
3444
|
+
//#endregion
|
|
3445
|
+
//#region node_modules/openai/resources/uploads/parts.mjs
|
|
3446
|
+
var Ai = class extends N {
|
|
3447
|
+
create(e, t, n) {
|
|
3448
|
+
return this._client.post(P`/uploads/${e}/parts`, M({
|
|
3449
|
+
body: t,
|
|
3450
|
+
...n
|
|
3451
|
+
}, this._client));
|
|
3452
|
+
}
|
|
3453
|
+
}, ji = class extends N {
|
|
3454
|
+
constructor() {
|
|
3455
|
+
super(...arguments), this.parts = new Ai(this._client);
|
|
3456
|
+
}
|
|
3457
|
+
create(e, t) {
|
|
3458
|
+
return this._client.post("/uploads", {
|
|
3459
|
+
body: e,
|
|
3460
|
+
...t
|
|
3461
|
+
});
|
|
3462
|
+
}
|
|
3463
|
+
cancel(e, t) {
|
|
3464
|
+
return this._client.post(P`/uploads/${e}/cancel`, t);
|
|
3465
|
+
}
|
|
3466
|
+
complete(e, t, n) {
|
|
3467
|
+
return this._client.post(P`/uploads/${e}/complete`, {
|
|
3468
|
+
body: t,
|
|
3469
|
+
...n
|
|
3470
|
+
});
|
|
3471
|
+
}
|
|
3472
|
+
};
|
|
3473
|
+
ji.Parts = Ai;
|
|
3474
|
+
//#endregion
|
|
3475
|
+
//#region node_modules/openai/lib/Util.mjs
|
|
3476
|
+
var Mi = async (e) => {
|
|
3477
|
+
let t = await Promise.allSettled(e), n = t.filter((e) => e.status === "rejected");
|
|
3478
|
+
if (n.length) {
|
|
3479
|
+
for (let e of n) console.error(e.reason);
|
|
3480
|
+
throw Error(`${n.length} promise(s) failed - see the above errors`);
|
|
3481
|
+
}
|
|
3482
|
+
let r = [];
|
|
3483
|
+
for (let e of t) e.status === "fulfilled" && r.push(e.value);
|
|
3484
|
+
return r;
|
|
3485
|
+
}, Ni = class extends N {
|
|
3486
|
+
create(e, t, n) {
|
|
3487
|
+
return this._client.post(P`/vector_stores/${e}/file_batches`, {
|
|
3488
|
+
body: t,
|
|
3489
|
+
...n,
|
|
3490
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3491
|
+
});
|
|
3492
|
+
}
|
|
3493
|
+
retrieve(e, t, n) {
|
|
3494
|
+
let { vector_store_id: r } = t;
|
|
3495
|
+
return this._client.get(P`/vector_stores/${r}/file_batches/${e}`, {
|
|
3496
|
+
...n,
|
|
3497
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3498
|
+
});
|
|
3499
|
+
}
|
|
3500
|
+
cancel(e, t, n) {
|
|
3501
|
+
let { vector_store_id: r } = t;
|
|
3502
|
+
return this._client.post(P`/vector_stores/${r}/file_batches/${e}/cancel`, {
|
|
3503
|
+
...n,
|
|
3504
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3505
|
+
});
|
|
3506
|
+
}
|
|
3507
|
+
async createAndPoll(e, t, n) {
|
|
3508
|
+
let r = await this.create(e, t);
|
|
3509
|
+
return await this.poll(e, r.id, n);
|
|
3510
|
+
}
|
|
3511
|
+
listFiles(e, t, n) {
|
|
3512
|
+
let { vector_store_id: r, ...i } = t;
|
|
3513
|
+
return this._client.getAPIList(P`/vector_stores/${r}/file_batches/${e}/files`, j, {
|
|
3514
|
+
query: i,
|
|
3515
|
+
...n,
|
|
3516
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3517
|
+
});
|
|
3518
|
+
}
|
|
3519
|
+
async poll(e, t, n) {
|
|
3520
|
+
let r = H([n?.headers, {
|
|
3521
|
+
"X-Stainless-Poll-Helper": "true",
|
|
3522
|
+
"X-Stainless-Custom-Poll-Interval": n?.pollIntervalMs?.toString() ?? void 0
|
|
3523
|
+
}]);
|
|
3524
|
+
for (;;) {
|
|
3525
|
+
let { data: i, response: a } = await this.retrieve(t, { vector_store_id: e }, {
|
|
3526
|
+
...n,
|
|
3527
|
+
headers: r
|
|
3528
|
+
}).withResponse();
|
|
3529
|
+
switch (i.status) {
|
|
3530
|
+
case "in_progress":
|
|
3531
|
+
let e = 5e3;
|
|
3532
|
+
if (n?.pollIntervalMs) e = n.pollIntervalMs;
|
|
3533
|
+
else {
|
|
3534
|
+
let t = a.headers.get("openai-poll-after-ms");
|
|
3535
|
+
if (t) {
|
|
3536
|
+
let n = parseInt(t);
|
|
3537
|
+
isNaN(n) || (e = n);
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3540
|
+
await se(e);
|
|
3541
|
+
break;
|
|
3542
|
+
case "failed":
|
|
3543
|
+
case "cancelled":
|
|
3544
|
+
case "completed": return i;
|
|
3545
|
+
}
|
|
3546
|
+
}
|
|
3547
|
+
}
|
|
3548
|
+
async uploadAndPoll(e, { files: t, fileIds: n = [] }, r) {
|
|
3549
|
+
if (t == null || t.length == 0) throw Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");
|
|
3550
|
+
let i = r?.maxConcurrency ?? 5, a = Math.min(i, t.length), o = this._client, s = t.values(), c = [...n];
|
|
3551
|
+
async function l(e) {
|
|
3552
|
+
for (let t of e) {
|
|
3553
|
+
let e = await o.files.create({
|
|
3554
|
+
file: t,
|
|
3555
|
+
purpose: "assistants"
|
|
3556
|
+
}, r);
|
|
3557
|
+
c.push(e.id);
|
|
3558
|
+
}
|
|
3559
|
+
}
|
|
3560
|
+
return await Mi(Array(a).fill(s).map(l)), await this.createAndPoll(e, { file_ids: c });
|
|
3561
|
+
}
|
|
3562
|
+
}, Pi = class extends N {
|
|
3563
|
+
create(e, t, n) {
|
|
3564
|
+
return this._client.post(P`/vector_stores/${e}/files`, {
|
|
3565
|
+
body: t,
|
|
3566
|
+
...n,
|
|
3567
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3568
|
+
});
|
|
3569
|
+
}
|
|
3570
|
+
retrieve(e, t, n) {
|
|
3571
|
+
let { vector_store_id: r } = t;
|
|
3572
|
+
return this._client.get(P`/vector_stores/${r}/files/${e}`, {
|
|
3573
|
+
...n,
|
|
3574
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3575
|
+
});
|
|
3576
|
+
}
|
|
3577
|
+
update(e, t, n) {
|
|
3578
|
+
let { vector_store_id: r, ...i } = t;
|
|
3579
|
+
return this._client.post(P`/vector_stores/${r}/files/${e}`, {
|
|
3580
|
+
body: i,
|
|
3581
|
+
...n,
|
|
3582
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3583
|
+
});
|
|
3584
|
+
}
|
|
3585
|
+
list(e, t = {}, n) {
|
|
3586
|
+
return this._client.getAPIList(P`/vector_stores/${e}/files`, j, {
|
|
3587
|
+
query: t,
|
|
3588
|
+
...n,
|
|
3589
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3590
|
+
});
|
|
3591
|
+
}
|
|
3592
|
+
delete(e, t, n) {
|
|
3593
|
+
let { vector_store_id: r } = t;
|
|
3594
|
+
return this._client.delete(P`/vector_stores/${r}/files/${e}`, {
|
|
3595
|
+
...n,
|
|
3596
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3597
|
+
});
|
|
3598
|
+
}
|
|
3599
|
+
async createAndPoll(e, t, n) {
|
|
3600
|
+
let r = await this.create(e, t, n);
|
|
3601
|
+
return await this.poll(e, r.id, n);
|
|
3602
|
+
}
|
|
3603
|
+
async poll(e, t, n) {
|
|
3604
|
+
let r = H([n?.headers, {
|
|
3605
|
+
"X-Stainless-Poll-Helper": "true",
|
|
3606
|
+
"X-Stainless-Custom-Poll-Interval": n?.pollIntervalMs?.toString() ?? void 0
|
|
3607
|
+
}]);
|
|
3608
|
+
for (;;) {
|
|
3609
|
+
let i = await this.retrieve(t, { vector_store_id: e }, {
|
|
3610
|
+
...n,
|
|
3611
|
+
headers: r
|
|
3612
|
+
}).withResponse(), a = i.data;
|
|
3613
|
+
switch (a.status) {
|
|
3614
|
+
case "in_progress":
|
|
3615
|
+
let e = 5e3;
|
|
3616
|
+
if (n?.pollIntervalMs) e = n.pollIntervalMs;
|
|
3617
|
+
else {
|
|
3618
|
+
let t = i.response.headers.get("openai-poll-after-ms");
|
|
3619
|
+
if (t) {
|
|
3620
|
+
let n = parseInt(t);
|
|
3621
|
+
isNaN(n) || (e = n);
|
|
3622
|
+
}
|
|
3623
|
+
}
|
|
3624
|
+
await se(e);
|
|
3625
|
+
break;
|
|
3626
|
+
case "failed":
|
|
3627
|
+
case "completed": return a;
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
}
|
|
3631
|
+
async upload(e, t, n) {
|
|
3632
|
+
let r = await this._client.files.create({
|
|
3633
|
+
file: t,
|
|
3634
|
+
purpose: "assistants"
|
|
3635
|
+
}, n);
|
|
3636
|
+
return this.create(e, { file_id: r.id }, n);
|
|
3637
|
+
}
|
|
3638
|
+
async uploadAndPoll(e, t, n) {
|
|
3639
|
+
let r = await this.upload(e, t, n);
|
|
3640
|
+
return await this.poll(e, r.id, n);
|
|
3641
|
+
}
|
|
3642
|
+
content(e, t, n) {
|
|
3643
|
+
let { vector_store_id: r } = t;
|
|
3644
|
+
return this._client.getAPIList(P`/vector_stores/${r}/files/${e}/content`, ft, {
|
|
3645
|
+
...n,
|
|
3646
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3647
|
+
});
|
|
3648
|
+
}
|
|
3649
|
+
}, Fi = class extends N {
|
|
3650
|
+
constructor() {
|
|
3651
|
+
super(...arguments), this.files = new Pi(this._client), this.fileBatches = new Ni(this._client);
|
|
3652
|
+
}
|
|
3653
|
+
create(e, t) {
|
|
3654
|
+
return this._client.post("/vector_stores", {
|
|
3655
|
+
body: e,
|
|
3656
|
+
...t,
|
|
3657
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
3658
|
+
});
|
|
3659
|
+
}
|
|
3660
|
+
retrieve(e, t) {
|
|
3661
|
+
return this._client.get(P`/vector_stores/${e}`, {
|
|
3662
|
+
...t,
|
|
3663
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
3664
|
+
});
|
|
3665
|
+
}
|
|
3666
|
+
update(e, t, n) {
|
|
3667
|
+
return this._client.post(P`/vector_stores/${e}`, {
|
|
3668
|
+
body: t,
|
|
3669
|
+
...n,
|
|
3670
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3671
|
+
});
|
|
3672
|
+
}
|
|
3673
|
+
list(e = {}, t) {
|
|
3674
|
+
return this._client.getAPIList("/vector_stores", j, {
|
|
3675
|
+
query: e,
|
|
3676
|
+
...t,
|
|
3677
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
3678
|
+
});
|
|
3679
|
+
}
|
|
3680
|
+
delete(e, t) {
|
|
3681
|
+
return this._client.delete(P`/vector_stores/${e}`, {
|
|
3682
|
+
...t,
|
|
3683
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
3684
|
+
});
|
|
3685
|
+
}
|
|
3686
|
+
search(e, t, n) {
|
|
3687
|
+
return this._client.getAPIList(P`/vector_stores/${e}/search`, ft, {
|
|
3688
|
+
body: t,
|
|
3689
|
+
method: "post",
|
|
3690
|
+
...n,
|
|
3691
|
+
headers: H([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3692
|
+
});
|
|
3693
|
+
}
|
|
3694
|
+
};
|
|
3695
|
+
Fi.Files = Pi, Fi.FileBatches = Ni;
|
|
3696
|
+
//#endregion
|
|
3697
|
+
//#region node_modules/openai/resources/videos.mjs
|
|
3698
|
+
var Ii = class extends N {
|
|
3699
|
+
create(e, t) {
|
|
3700
|
+
return this._client.post("/videos", vt({
|
|
3701
|
+
body: e,
|
|
3702
|
+
...t
|
|
3703
|
+
}, this._client));
|
|
3704
|
+
}
|
|
3705
|
+
retrieve(e, t) {
|
|
3706
|
+
return this._client.get(P`/videos/${e}`, t);
|
|
3707
|
+
}
|
|
3708
|
+
list(e = {}, t) {
|
|
3709
|
+
return this._client.getAPIList("/videos", pt, {
|
|
3710
|
+
query: e,
|
|
3711
|
+
...t
|
|
3712
|
+
});
|
|
3713
|
+
}
|
|
3714
|
+
delete(e, t) {
|
|
3715
|
+
return this._client.delete(P`/videos/${e}`, t);
|
|
3716
|
+
}
|
|
3717
|
+
downloadContent(e, t = {}, n) {
|
|
3718
|
+
return this._client.get(P`/videos/${e}/content`, {
|
|
3719
|
+
query: t,
|
|
3720
|
+
...n,
|
|
3721
|
+
headers: H([{ Accept: "application/binary" }, n?.headers]),
|
|
3722
|
+
__binaryResponse: !0
|
|
3723
|
+
});
|
|
3724
|
+
}
|
|
3725
|
+
remix(e, t, n) {
|
|
3726
|
+
return this._client.post(P`/videos/${e}/remix`, vt({
|
|
3727
|
+
body: t,
|
|
3728
|
+
...n
|
|
3729
|
+
}, this._client));
|
|
3730
|
+
}
|
|
3731
|
+
}, Li, Ri, zi, Bi = class extends N {
|
|
3732
|
+
constructor() {
|
|
3733
|
+
super(...arguments), Li.add(this);
|
|
3734
|
+
}
|
|
3735
|
+
async unwrap(e, t, n = this._client.webhookSecret, r = 300) {
|
|
3736
|
+
return await this.verifySignature(e, t, n, r), JSON.parse(e);
|
|
3737
|
+
}
|
|
3738
|
+
async verifySignature(e, n, r = this._client.webhookSecret, i = 300) {
|
|
3739
|
+
if (typeof crypto > "u" || typeof crypto.subtle.importKey != "function" || typeof crypto.subtle.verify != "function") throw Error("Webhook signature verification is only supported when the `crypto` global is defined");
|
|
3740
|
+
t(this, Li, "m", Ri).call(this, r);
|
|
3741
|
+
let a = H([n]).values, o = t(this, Li, "m", zi).call(this, a, "webhook-signature"), s = t(this, Li, "m", zi).call(this, a, "webhook-timestamp"), c = t(this, Li, "m", zi).call(this, a, "webhook-id"), l = parseInt(s, 10);
|
|
3742
|
+
if (isNaN(l)) throw new b("Invalid webhook timestamp format");
|
|
3743
|
+
let u = Math.floor(Date.now() / 1e3);
|
|
3744
|
+
if (u - l > i) throw new b("Webhook timestamp is too old");
|
|
3745
|
+
if (l > u + i) throw new b("Webhook timestamp is too new");
|
|
3746
|
+
let d = o.split(" ").map((e) => e.startsWith("v1,") ? e.substring(3) : e), f = r.startsWith("whsec_") ? Buffer.from(r.replace("whsec_", ""), "base64") : Buffer.from(r, "utf-8"), p = c ? `${c}.${s}.${e}` : `${s}.${e}`, m = await crypto.subtle.importKey("raw", f, {
|
|
3747
|
+
name: "HMAC",
|
|
3748
|
+
hash: "SHA-256"
|
|
3749
|
+
}, !1, ["verify"]);
|
|
3750
|
+
for (let e of d) try {
|
|
3751
|
+
let t = Buffer.from(e, "base64");
|
|
3752
|
+
if (await crypto.subtle.verify("HMAC", m, t, new TextEncoder().encode(p))) return;
|
|
3753
|
+
} catch {
|
|
3754
|
+
continue;
|
|
3755
|
+
}
|
|
3756
|
+
throw new b("The given webhook signature does not match the expected signature");
|
|
3757
|
+
}
|
|
3758
|
+
};
|
|
3759
|
+
Li = /* @__PURE__ */ new WeakSet(), Ri = function(e) {
|
|
3760
|
+
if (typeof e != "string" || e.length === 0) throw Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function");
|
|
3761
|
+
}, zi = function(e, t) {
|
|
3762
|
+
if (!e) throw Error("Headers are required");
|
|
3763
|
+
let n = e.get(t);
|
|
3764
|
+
if (n == null) throw Error(`Missing required header: ${t}`);
|
|
3765
|
+
return n;
|
|
3766
|
+
};
|
|
3767
|
+
//#endregion
|
|
3768
|
+
//#region node_modules/openai/client.mjs
|
|
3769
|
+
var Vi, Hi, Ui, Wi, $ = class {
|
|
3770
|
+
constructor({ baseURL: t = U("OPENAI_BASE_URL"), apiKey: n = U("OPENAI_API_KEY"), organization: r = U("OPENAI_ORG_ID") ?? null, project: i = U("OPENAI_PROJECT_ID") ?? null, webhookSecret: o = U("OPENAI_WEBHOOK_SECRET") ?? null, ...s } = {}) {
|
|
3771
|
+
if (Vi.add(this), Ui.set(this, void 0), this.completions = new Pr(this), this.chat = new Xn(this), this.embeddings = new Br(this), this.files = new Wr(this), this.images = new ei(this), this.audio = new nr(this), this.moderations = new ni(this), this.models = new ti(this), this.fineTuning = new Z(this), this.graders = new $r(this), this.vectorStores = new Fi(this), this.webhooks = new Bi(this), this.beta = new Nr(this), this.batches = new rr(this), this.uploads = new ji(this), this.responses = new Ti(this), this.realtime = new ai(this), this.conversations = new zr(this), this.evals = new Ur(this), this.containers = new Lr(this), this.skills = new ki(this), this.videos = new Ii(this), n === void 0) throw new a("Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.");
|
|
3772
|
+
let c = {
|
|
3773
|
+
apiKey: n,
|
|
3774
|
+
organization: r,
|
|
3775
|
+
project: i,
|
|
3776
|
+
webhookSecret: o,
|
|
3777
|
+
...s,
|
|
3778
|
+
baseURL: t || "https://api.openai.com/v1"
|
|
3779
|
+
};
|
|
3780
|
+
if (!c.dangerouslyAllowBrowser && ce()) throw new a("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew OpenAI({ apiKey, dangerouslyAllowBrowser: true });\n\nhttps://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety\n");
|
|
3781
|
+
this.baseURL = c.baseURL, this.timeout = c.timeout ?? Hi.DEFAULT_TIMEOUT, this.logger = c.logger ?? console;
|
|
3782
|
+
let l = "warn";
|
|
3783
|
+
this.logLevel = l, this.logLevel = Je(c.logLevel, "ClientOptions.logLevel", this) ?? Je(U("OPENAI_LOG"), "process.env['OPENAI_LOG']", this) ?? l, this.fetchOptions = c.fetchOptions, this.maxRetries = c.maxRetries ?? 2, this.fetch = c.fetch ?? ge(), e(this, Ui, xe, "f"), this._options = c, this.apiKey = typeof n == "string" ? n : "Missing Key", this.organization = r, this.project = i, this.webhookSecret = o;
|
|
3784
|
+
}
|
|
3785
|
+
withOptions(e) {
|
|
3786
|
+
return new this.constructor({
|
|
3787
|
+
...this._options,
|
|
3788
|
+
baseURL: this.baseURL,
|
|
3789
|
+
maxRetries: this.maxRetries,
|
|
3790
|
+
timeout: this.timeout,
|
|
3791
|
+
logger: this.logger,
|
|
3792
|
+
logLevel: this.logLevel,
|
|
3793
|
+
fetch: this.fetch,
|
|
3794
|
+
fetchOptions: this.fetchOptions,
|
|
3795
|
+
apiKey: this.apiKey,
|
|
3796
|
+
organization: this.organization,
|
|
3797
|
+
project: this.project,
|
|
3798
|
+
webhookSecret: this.webhookSecret,
|
|
3799
|
+
...e
|
|
3800
|
+
});
|
|
3801
|
+
}
|
|
3802
|
+
defaultQuery() {
|
|
3803
|
+
return this._options.defaultQuery;
|
|
3804
|
+
}
|
|
3805
|
+
validateHeaders({ values: e, nulls: t }) {}
|
|
3806
|
+
async authHeaders(e) {
|
|
3807
|
+
return H([{ Authorization: `Bearer ${this.apiKey}` }]);
|
|
3808
|
+
}
|
|
3809
|
+
stringifyQuery(e) {
|
|
3810
|
+
return Re(e);
|
|
3811
|
+
}
|
|
3812
|
+
getUserAgent() {
|
|
3813
|
+
return `${this.constructor.name}/JS ${w}`;
|
|
3814
|
+
}
|
|
3815
|
+
defaultIdempotencyKey() {
|
|
3816
|
+
return `stainless-node-retry-${n()}`;
|
|
3817
|
+
}
|
|
3818
|
+
makeStatusError(e, t, n, r) {
|
|
3819
|
+
return o.generate(e, t, n, r);
|
|
3820
|
+
}
|
|
3821
|
+
async _callApiKey() {
|
|
3822
|
+
let e = this._options.apiKey;
|
|
3823
|
+
if (typeof e != "function") return !1;
|
|
3824
|
+
let t;
|
|
3825
|
+
try {
|
|
3826
|
+
t = await e();
|
|
3827
|
+
} catch (e) {
|
|
3828
|
+
throw e instanceof a ? e : new a(`Failed to get token from 'apiKey' function: ${e.message}`, { cause: e });
|
|
3829
|
+
}
|
|
3830
|
+
if (typeof t != "string" || !t) throw new a(`Expected 'apiKey' function argument to return a string but it returned ${t}`);
|
|
3831
|
+
return this.apiKey = t, !0;
|
|
3832
|
+
}
|
|
3833
|
+
buildURL(e, n, r) {
|
|
3834
|
+
let i = !t(this, Vi, "m", Wi).call(this) && r || this.baseURL, a = te(e) ? new URL(e) : new URL(i + (i.endsWith("/") && e.startsWith("/") ? e.slice(1) : e)), o = this.defaultQuery();
|
|
3835
|
+
return ne(o) || (n = {
|
|
3836
|
+
...o,
|
|
3837
|
+
...n
|
|
3838
|
+
}), typeof n == "object" && n && !Array.isArray(n) && (a.search = this.stringifyQuery(n)), a.toString();
|
|
3839
|
+
}
|
|
3840
|
+
async prepareOptions(e) {
|
|
3841
|
+
await this._callApiKey();
|
|
3842
|
+
}
|
|
3843
|
+
async prepareRequest(e, { url: t, options: n }) {}
|
|
3844
|
+
get(e, t) {
|
|
3845
|
+
return this.methodRequest("get", e, t);
|
|
3846
|
+
}
|
|
3847
|
+
post(e, t) {
|
|
3848
|
+
return this.methodRequest("post", e, t);
|
|
3849
|
+
}
|
|
3850
|
+
patch(e, t) {
|
|
3851
|
+
return this.methodRequest("patch", e, t);
|
|
3852
|
+
}
|
|
3853
|
+
put(e, t) {
|
|
3854
|
+
return this.methodRequest("put", e, t);
|
|
3855
|
+
}
|
|
3856
|
+
delete(e, t) {
|
|
3857
|
+
return this.methodRequest("delete", e, t);
|
|
3858
|
+
}
|
|
3859
|
+
methodRequest(e, t, n) {
|
|
3860
|
+
return this.request(Promise.resolve(n).then((n) => ({
|
|
3861
|
+
method: e,
|
|
3862
|
+
path: t,
|
|
3863
|
+
...n
|
|
3864
|
+
})));
|
|
3865
|
+
}
|
|
3866
|
+
request(e, t = null) {
|
|
3867
|
+
return new ct(this, this.makeRequest(e, t, void 0));
|
|
3868
|
+
}
|
|
3869
|
+
async makeRequest(e, t, n) {
|
|
3870
|
+
let a = await e, o = a.maxRetries ?? this.maxRetries;
|
|
3871
|
+
t ??= o, await this.prepareOptions(a);
|
|
3872
|
+
let { req: u, url: d, timeout: f } = await this.buildRequest(a, { retryCount: o - t });
|
|
3873
|
+
await this.prepareRequest(u, {
|
|
3874
|
+
url: d,
|
|
3875
|
+
options: a
|
|
3876
|
+
});
|
|
3877
|
+
let p = "log_" + (Math.random() * (1 << 24) | 0).toString(16).padStart(6, "0"), m = n === void 0 ? "" : `, retryOf: ${n}`, h = Date.now();
|
|
3878
|
+
if (k(this).debug(`[${p}] sending request`, A({
|
|
3879
|
+
retryOfRequestLogID: n,
|
|
3880
|
+
method: a.method,
|
|
3881
|
+
url: d,
|
|
3882
|
+
options: a,
|
|
3883
|
+
headers: u.headers
|
|
3884
|
+
})), a.signal?.aborted) throw new s();
|
|
3885
|
+
let g = new AbortController(), _ = await this.fetchWithTimeout(d, u, f, g).catch(i), v = Date.now();
|
|
3886
|
+
if (_ instanceof globalThis.Error) {
|
|
3887
|
+
let e = `retrying, ${t} attempts remaining`;
|
|
3888
|
+
if (a.signal?.aborted) throw new s();
|
|
3889
|
+
let i = r(_) || /timed? ?out/i.test(String(_) + ("cause" in _ ? String(_.cause) : ""));
|
|
3890
|
+
if (t) return k(this).info(`[${p}] connection ${i ? "timed out" : "failed"} - ${e}`), k(this).debug(`[${p}] connection ${i ? "timed out" : "failed"} (${e})`, A({
|
|
3891
|
+
retryOfRequestLogID: n,
|
|
3892
|
+
url: d,
|
|
3893
|
+
durationMs: v - h,
|
|
3894
|
+
message: _.message
|
|
3895
|
+
})), this.retryRequest(a, t, n ?? p);
|
|
3896
|
+
throw k(this).info(`[${p}] connection ${i ? "timed out" : "failed"} - error; no more retries left`), k(this).debug(`[${p}] connection ${i ? "timed out" : "failed"} (error; no more retries left)`, A({
|
|
3897
|
+
retryOfRequestLogID: n,
|
|
3898
|
+
url: d,
|
|
3899
|
+
durationMs: v - h,
|
|
3900
|
+
message: _.message
|
|
3901
|
+
})), i ? new l() : new c({ cause: _ });
|
|
3902
|
+
}
|
|
3903
|
+
let y = `[${p}${m}${[..._.headers.entries()].filter(([e]) => e === "x-request-id").map(([e, t]) => ", " + e + ": " + JSON.stringify(t)).join("")}] ${u.method} ${d} ${_.ok ? "succeeded" : "failed"} with status ${_.status} in ${v - h}ms`;
|
|
3904
|
+
if (!_.ok) {
|
|
3905
|
+
let e = await this.shouldRetry(_);
|
|
3906
|
+
if (t && e) {
|
|
3907
|
+
let e = `retrying, ${t} attempts remaining`;
|
|
3908
|
+
return await be(_.body), k(this).info(`${y} - ${e}`), k(this).debug(`[${p}] response error (${e})`, A({
|
|
3909
|
+
retryOfRequestLogID: n,
|
|
3910
|
+
url: _.url,
|
|
3911
|
+
status: _.status,
|
|
3912
|
+
headers: _.headers,
|
|
3913
|
+
durationMs: v - h
|
|
3914
|
+
})), this.retryRequest(a, t, n ?? p, _.headers);
|
|
3915
|
+
}
|
|
3916
|
+
let r = e ? "error; no more retries left" : "error; not retryable";
|
|
3917
|
+
k(this).info(`${y} - ${r}`);
|
|
3918
|
+
let o = await _.text().catch((e) => i(e).message), s = oe(o), c = s ? void 0 : o;
|
|
3919
|
+
throw k(this).debug(`[${p}] response error (${r})`, A({
|
|
3920
|
+
retryOfRequestLogID: n,
|
|
3921
|
+
url: _.url,
|
|
3922
|
+
status: _.status,
|
|
3923
|
+
headers: _.headers,
|
|
3924
|
+
message: c,
|
|
3925
|
+
durationMs: Date.now() - h
|
|
3926
|
+
})), this.makeStatusError(_.status, s, c, _.headers);
|
|
3927
|
+
}
|
|
3928
|
+
return k(this).info(y), k(this).debug(`[${p}] response start`, A({
|
|
3929
|
+
retryOfRequestLogID: n,
|
|
3930
|
+
url: _.url,
|
|
3931
|
+
status: _.status,
|
|
3932
|
+
headers: _.headers,
|
|
3933
|
+
durationMs: v - h
|
|
3934
|
+
})), {
|
|
3935
|
+
response: _,
|
|
3936
|
+
options: a,
|
|
3937
|
+
controller: g,
|
|
3938
|
+
requestLogID: p,
|
|
3939
|
+
retryOfRequestLogID: n,
|
|
3940
|
+
startTime: h
|
|
3941
|
+
};
|
|
3942
|
+
}
|
|
3943
|
+
getAPIList(e, t, n) {
|
|
3944
|
+
return this.requestAPIList(t, n && "then" in n ? n.then((t) => ({
|
|
3945
|
+
method: "get",
|
|
3946
|
+
path: e,
|
|
3947
|
+
...t
|
|
3948
|
+
})) : {
|
|
3949
|
+
method: "get",
|
|
3950
|
+
path: e,
|
|
3951
|
+
...n
|
|
3952
|
+
});
|
|
3953
|
+
}
|
|
3954
|
+
requestAPIList(e, t) {
|
|
3955
|
+
let n = this.makeRequest(t, null, void 0);
|
|
3956
|
+
return new dt(this, n, e);
|
|
3957
|
+
}
|
|
3958
|
+
async fetchWithTimeout(e, t, n, r) {
|
|
3959
|
+
let { signal: i, method: a, ...o } = t || {}, s = this._makeAbort(r);
|
|
3960
|
+
i && i.addEventListener("abort", s, { once: !0 });
|
|
3961
|
+
let c = setTimeout(s, n), l = globalThis.ReadableStream && o.body instanceof globalThis.ReadableStream || typeof o.body == "object" && o.body !== null && Symbol.asyncIterator in o.body, u = {
|
|
3962
|
+
signal: r.signal,
|
|
3963
|
+
...l ? { duplex: "half" } : {},
|
|
3964
|
+
method: "GET",
|
|
3965
|
+
...o
|
|
3966
|
+
};
|
|
3967
|
+
a && (u.method = a.toUpperCase());
|
|
3968
|
+
try {
|
|
3969
|
+
return await this.fetch.call(void 0, e, u);
|
|
3970
|
+
} finally {
|
|
3971
|
+
clearTimeout(c);
|
|
3972
|
+
}
|
|
3973
|
+
}
|
|
3974
|
+
async shouldRetry(e) {
|
|
3975
|
+
let t = e.headers.get("x-should-retry");
|
|
3976
|
+
return t === "true" ? !0 : t === "false" ? !1 : e.status === 408 || e.status === 409 || e.status === 429 || e.status >= 500;
|
|
3977
|
+
}
|
|
3978
|
+
async retryRequest(e, t, n, r) {
|
|
3979
|
+
let i, a = r?.get("retry-after-ms");
|
|
3980
|
+
if (a) {
|
|
3981
|
+
let e = parseFloat(a);
|
|
3982
|
+
Number.isNaN(e) || (i = e);
|
|
3983
|
+
}
|
|
3984
|
+
let o = r?.get("retry-after");
|
|
3985
|
+
if (o && !i) {
|
|
3986
|
+
let e = parseFloat(o);
|
|
3987
|
+
i = Number.isNaN(e) ? Date.parse(o) - Date.now() : e * 1e3;
|
|
3988
|
+
}
|
|
3989
|
+
if (i === void 0) {
|
|
3990
|
+
let n = e.maxRetries ?? this.maxRetries;
|
|
3991
|
+
i = this.calculateDefaultRetryTimeoutMillis(t, n);
|
|
3992
|
+
}
|
|
3993
|
+
return await se(i), this.makeRequest(e, t - 1, n);
|
|
3994
|
+
}
|
|
3995
|
+
calculateDefaultRetryTimeoutMillis(e, t) {
|
|
3996
|
+
let n = t - e;
|
|
3997
|
+
return Math.min(.5 * 2 ** n, 8) * (1 - Math.random() * .25) * 1e3;
|
|
3998
|
+
}
|
|
3999
|
+
async buildRequest(e, { retryCount: t = 0 } = {}) {
|
|
4000
|
+
let n = { ...e }, { method: r, path: i, query: a, defaultBaseURL: o } = n, s = this.buildURL(i, a, o);
|
|
4001
|
+
"timeout" in n && ae("timeout", n.timeout), n.timeout = n.timeout ?? this.timeout;
|
|
4002
|
+
let { bodyHeaders: c, body: l } = this.buildBody({ options: n });
|
|
4003
|
+
return {
|
|
4004
|
+
req: {
|
|
4005
|
+
method: r,
|
|
4006
|
+
headers: await this.buildHeaders({
|
|
4007
|
+
options: e,
|
|
4008
|
+
method: r,
|
|
4009
|
+
bodyHeaders: c,
|
|
4010
|
+
retryCount: t
|
|
4011
|
+
}),
|
|
4012
|
+
...n.signal && { signal: n.signal },
|
|
4013
|
+
...globalThis.ReadableStream && l instanceof globalThis.ReadableStream && { duplex: "half" },
|
|
4014
|
+
...l && { body: l },
|
|
4015
|
+
...this.fetchOptions ?? {},
|
|
4016
|
+
...n.fetchOptions ?? {}
|
|
4017
|
+
},
|
|
4018
|
+
url: s,
|
|
4019
|
+
timeout: n.timeout
|
|
4020
|
+
};
|
|
4021
|
+
}
|
|
4022
|
+
async buildHeaders({ options: e, method: t, bodyHeaders: n, retryCount: r }) {
|
|
4023
|
+
let i = {};
|
|
4024
|
+
this.idempotencyHeader && t !== "get" && (e.idempotencyKey ||= this.defaultIdempotencyKey(), i[this.idempotencyHeader] = e.idempotencyKey);
|
|
4025
|
+
let a = H([
|
|
4026
|
+
i,
|
|
4027
|
+
{
|
|
4028
|
+
Accept: "application/json",
|
|
4029
|
+
"User-Agent": this.getUserAgent(),
|
|
4030
|
+
"X-Stainless-Retry-Count": String(r),
|
|
4031
|
+
...e.timeout ? { "X-Stainless-Timeout": String(Math.trunc(e.timeout / 1e3)) } : {},
|
|
4032
|
+
...he(),
|
|
4033
|
+
"OpenAI-Organization": this.organization,
|
|
4034
|
+
"OpenAI-Project": this.project
|
|
4035
|
+
},
|
|
4036
|
+
await this.authHeaders(e),
|
|
4037
|
+
this._options.defaultHeaders,
|
|
4038
|
+
n,
|
|
4039
|
+
e.headers
|
|
4040
|
+
]);
|
|
4041
|
+
return this.validateHeaders(a), a.values;
|
|
4042
|
+
}
|
|
4043
|
+
_makeAbort(e) {
|
|
4044
|
+
return () => e.abort();
|
|
4045
|
+
}
|
|
4046
|
+
buildBody({ options: { body: e, headers: n } }) {
|
|
4047
|
+
if (!e) return {
|
|
4048
|
+
bodyHeaders: void 0,
|
|
4049
|
+
body: void 0
|
|
4050
|
+
};
|
|
4051
|
+
let r = H([n]);
|
|
4052
|
+
return ArrayBuffer.isView(e) || e instanceof ArrayBuffer || e instanceof DataView || typeof e == "string" && r.values.has("content-type") || globalThis.Blob && e instanceof globalThis.Blob || e instanceof FormData || e instanceof URLSearchParams || globalThis.ReadableStream && e instanceof globalThis.ReadableStream ? {
|
|
4053
|
+
bodyHeaders: void 0,
|
|
4054
|
+
body: e
|
|
4055
|
+
} : typeof e == "object" && (Symbol.asyncIterator in e || Symbol.iterator in e && "next" in e && typeof e.next == "function") ? {
|
|
4056
|
+
bodyHeaders: void 0,
|
|
4057
|
+
body: ve(e)
|
|
4058
|
+
} : typeof e == "object" && r.values.get("content-type") === "application/x-www-form-urlencoded" ? {
|
|
4059
|
+
bodyHeaders: { "content-type": "application/x-www-form-urlencoded" },
|
|
4060
|
+
body: this.stringifyQuery(e)
|
|
4061
|
+
} : t(this, Ui, "f").call(this, {
|
|
4062
|
+
body: e,
|
|
4063
|
+
headers: r
|
|
4064
|
+
});
|
|
4065
|
+
}
|
|
4066
|
+
};
|
|
4067
|
+
Hi = $, Ui = /* @__PURE__ */ new WeakMap(), Vi = /* @__PURE__ */ new WeakSet(), Wi = function() {
|
|
4068
|
+
return this.baseURL !== "https://api.openai.com/v1";
|
|
4069
|
+
}, $.OpenAI = Hi, $.DEFAULT_TIMEOUT = 6e5, $.OpenAIError = a, $.APIError = o, $.APIConnectionError = c, $.APIConnectionTimeoutError = l, $.APIUserAbortError = s, $.NotFoundError = p, $.ConflictError = m, $.RateLimitError = g, $.BadRequestError = u, $.AuthenticationError = d, $.InternalServerError = _, $.PermissionDeniedError = f, $.UnprocessableEntityError = h, $.InvalidWebhookSignatureError = b, $.toFile = kt, $.Completions = Pr, $.Chat = Xn, $.Embeddings = Br, $.Files = Wr, $.Images = ei, $.Audio = nr, $.Moderations = ni, $.Models = ti, $.FineTuning = Z, $.Graders = $r, $.VectorStores = Fi, $.Webhooks = Bi, $.Beta = Nr, $.Batches = rr, $.Uploads = ji, $.Responses = Ti, $.Realtime = ai, $.Conversations = zr, $.Evals = Ur, $.Containers = Lr, $.Skills = ki, $.Videos = Ii;
|
|
4070
|
+
//#endregion
|
|
4071
|
+
//#region node_modules/openai/azure.mjs
|
|
4072
|
+
var Gi = class extends $ {
|
|
4073
|
+
constructor({ baseURL: e = U("OPENAI_BASE_URL"), apiKey: t = U("AZURE_OPENAI_API_KEY"), apiVersion: n = U("OPENAI_API_VERSION"), endpoint: r, deployment: i, azureADTokenProvider: o, dangerouslyAllowBrowser: s, ...c } = {}) {
|
|
4074
|
+
if (!n) throw new a("The OPENAI_API_VERSION environment variable is missing or empty; either provide it, or instantiate the AzureOpenAI client with an apiVersion option, like new AzureOpenAI({ apiVersion: 'My API Version' }).");
|
|
4075
|
+
if (typeof o == "function" && (s = !0), !o && !t) throw new a("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");
|
|
4076
|
+
if (o && t) throw new a("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");
|
|
4077
|
+
if (c.defaultQuery = {
|
|
4078
|
+
...c.defaultQuery,
|
|
4079
|
+
"api-version": n
|
|
4080
|
+
}, !e) {
|
|
4081
|
+
if (r ||= process.env.AZURE_OPENAI_ENDPOINT, !r) throw new a("Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable");
|
|
4082
|
+
e = `${r}/openai`;
|
|
4083
|
+
} else if (r) throw new a("baseURL and endpoint are mutually exclusive");
|
|
4084
|
+
super({
|
|
4085
|
+
apiKey: o ?? t,
|
|
4086
|
+
baseURL: e,
|
|
4087
|
+
...c,
|
|
4088
|
+
...s === void 0 ? {} : { dangerouslyAllowBrowser: s }
|
|
4089
|
+
}), this.apiVersion = "", this.apiVersion = n, this.deploymentName = i;
|
|
4090
|
+
}
|
|
4091
|
+
async buildRequest(e, t = {}) {
|
|
4092
|
+
if (Ki.has(e.path) && e.method === "post" && e.body !== void 0) {
|
|
4093
|
+
if (!ie(e.body)) throw Error("Expected request body to be an object");
|
|
4094
|
+
let t = this.deploymentName || e.body.model || e.__metadata?.model;
|
|
4095
|
+
t !== void 0 && !this.baseURL.includes("/deployments") && (e.path = `/deployments/${t}${e.path}`);
|
|
4096
|
+
}
|
|
4097
|
+
return super.buildRequest(e, t);
|
|
4098
|
+
}
|
|
4099
|
+
async authHeaders(e) {
|
|
4100
|
+
return typeof this._options.apiKey == "string" ? H([{ "api-key": this.apiKey }]) : super.authHeaders(e);
|
|
4101
|
+
}
|
|
4102
|
+
}, Ki = new Set([
|
|
4103
|
+
"/completions",
|
|
4104
|
+
"/chat/completions",
|
|
4105
|
+
"/embeddings",
|
|
4106
|
+
"/audio/transcriptions",
|
|
4107
|
+
"/audio/translations",
|
|
4108
|
+
"/audio/speech",
|
|
4109
|
+
"/images/generations",
|
|
4110
|
+
"/batches",
|
|
4111
|
+
"/images/edits"
|
|
4112
|
+
]);
|
|
4113
|
+
//#endregion
|
|
4114
|
+
export { c as APIConnectionError, l as APIConnectionTimeoutError, o as APIError, ct as APIPromise, s as APIUserAbortError, d as AuthenticationError, Gi as AzureOpenAI, u as BadRequestError, m as ConflictError, _ as InternalServerError, b as InvalidWebhookSignatureError, p as NotFoundError, $ as OpenAI, $ as default, a as OpenAIError, dt as PagePromise, f as PermissionDeniedError, g as RateLimitError, h as UnprocessableEntityError, kt as toFile };
|