writer 0.8.3rc4__py3-none-any.whl → 1.25.1rc1__py3-none-any.whl
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.
- writer/__init__.py +1 -1
- writer/abstract.py +1 -1
- writer/{ai.py → ai/__init__.py} +867 -163
- writer/app_runner.py +596 -241
- writer/app_templates/default/.wf/components-blueprints_blueprint-0-0decp3w5erhvl0nw.jsonl +11 -0
- writer/app_templates/default/.wf/components-blueprints_root.jsonl +1 -0
- writer/app_templates/default/.wf/components-page-0-c0f99a9e-5004-4e75-a6c6-36f17490b134.jsonl +27 -0
- writer/app_templates/default/.wf/components-root.jsonl +1 -0
- writer/app_templates/default/.wf/components-workflows_root.jsonl +1 -0
- writer/app_templates/default/.wf/components-workflows_workflow-0-lfltcky7l1fsm6j2.jsonl +1 -0
- writer/app_templates/default/.wf/metadata.json +3 -0
- writer/app_templates/default/README.md +3 -0
- writer/app_templates/default/main.py +16 -0
- writer/app_templates/default/requirements.txt +1 -0
- writer/app_templates/default/static/README.md +8 -0
- writer/app_templates/default/static/agent_builder_demo.png +0 -0
- writer/app_templates/default/static/favicon.png +0 -0
- writer/app_templates/hello/.wf/components-blueprints_blueprint-0-t84xyhxau9ej3823.jsonl +18 -0
- writer/app_templates/hello/.wf/components-blueprints_root.jsonl +1 -0
- writer/app_templates/hello/.wf/components-page-0-c0f99a9e-5004-4e75-a6c6-36f17490b134.jsonl +15 -0
- writer/app_templates/hello/.wf/components-root.jsonl +1 -0
- writer/app_templates/hello/.wf/metadata.json +3 -0
- writer/app_templates/hello/main.py +16 -0
- writer/app_templates/hello/static/README.md +8 -0
- writer/app_templates/hello/static/favicon.png +0 -0
- writer/app_templates/hello/static/welcome.svg +40 -0
- writer/auth.py +7 -2
- writer/autogen.py +352 -0
- writer/blocks/__init__.py +51 -17
- writer/blocks/addtostatelist.py +10 -9
- writer/blocks/apitrigger.py +45 -0
- writer/blocks/base_block.py +332 -21
- writer/blocks/base_trigger.py +14 -0
- writer/blocks/calleventhandler.py +39 -35
- writer/blocks/changepage.py +48 -0
- writer/blocks/code.py +102 -0
- writer/blocks/crontrigger.py +49 -0
- writer/blocks/foreach.py +70 -53
- writer/blocks/httprequest.py +112 -99
- writer/blocks/ifelse.py +71 -0
- writer/blocks/logmessage.py +34 -39
- writer/blocks/parsejson.py +30 -29
- writer/blocks/returnvalue.py +7 -7
- writer/blocks/runblueprint.py +63 -0
- writer/blocks/setstate.py +43 -33
- writer/blocks/sharedblueprint.py +86 -0
- writer/blocks/uieventtrigger.py +49 -0
- writer/blocks/writeraddchatmessage.py +50 -12
- writer/blocks/writeraddtokg.py +38 -11
- writer/blocks/writeraskkg.py +123 -0
- writer/blocks/writerchat.py +80 -61
- writer/blocks/writerchatreply.py +279 -0
- writer/blocks/writerchatreplywithtoolconfig.py +393 -0
- writer/blocks/writerclassification.py +78 -39
- writer/blocks/writercompletion.py +49 -44
- writer/blocks/writerfileapi.py +85 -0
- writer/blocks/writerinitchat.py +24 -12
- writer/blocks/writerkeyvaluestorage.py +106 -0
- writer/blocks/writernocodeapp.py +35 -37
- writer/blocks/writerparsepdf.py +73 -0
- writer/blocks/writerstructuredoutput.py +105 -0
- writer/blocks/writertoolcalling.py +251 -0
- writer/blocks/writervision.py +141 -0
- writer/blocks/writerwebsearch.py +175 -0
- writer/blueprints.py +839 -0
- writer/command_line.py +52 -16
- writer/core.py +562 -290
- writer/core_ui.py +6 -2
- writer/evaluator.py +98 -46
- writer/journal.py +227 -0
- writer/keyvalue_storage.py +93 -0
- writer/logs.py +277 -0
- writer/serve.py +625 -327
- writer/ss_types.py +101 -12
- writer/static/assets/Arrow.dom-GBJpMYQS.js +1 -0
- writer/static/assets/BaseMarkdown-Wrvby5J8.js +1 -0
- writer/static/assets/BlueprintToolbar-BuXNRxWT.js +1 -0
- writer/static/assets/BlueprintToolbar-wpfX0jo_.css +1 -0
- writer/static/assets/BuilderApp-PTOI76jZ.js +8 -0
- writer/static/assets/BuilderApp-WimUfNZr.css +1 -0
- writer/static/assets/BuilderApplicationSelect-DXzy4e_h.js +7 -0
- writer/static/assets/BuilderApplicationSelect-XaM1D5fv.css +1 -0
- writer/static/assets/BuilderBlueprintLibraryPanel-Ckrhknlh.css +1 -0
- writer/static/assets/BuilderBlueprintLibraryPanel-DBDzhTlc.js +1 -0
- writer/static/assets/BuilderEmbeddedCodeEditor-B0bcjlhk.css +1 -0
- writer/static/assets/BuilderEmbeddedCodeEditor-Dn7eDICN.js +726 -0
- writer/static/assets/BuilderGraphSelect-C-LRsO8W.js +7 -0
- writer/static/assets/BuilderGraphSelect-D7B61d5s.css +1 -0
- writer/static/assets/BuilderInsertionLabel-BhyL9wgn.js +1 -0
- writer/static/assets/BuilderInsertionLabel-_YS5WPfq.css +1 -0
- writer/static/assets/BuilderInsertionOverlay-D2XS0ij9.css +1 -0
- writer/static/assets/BuilderInsertionOverlay-MkAIVruY.js +1 -0
- writer/static/assets/BuilderJournal-A0LcEwGI.js +7 -0
- writer/static/assets/BuilderJournal-DHv3Pvvm.css +1 -0
- writer/static/assets/BuilderModelSelect-CdSo_sih.js +7 -0
- writer/static/assets/BuilderModelSelect-Dc4IPLp2.css +1 -0
- writer/static/assets/BuilderSettings-BDwZBveu.js +16 -0
- writer/static/assets/BuilderSettings-lZkOXEYw.css +1 -0
- writer/static/assets/BuilderSettingsArtifactAPITriggerDetails-3O6jKBXD.js +4 -0
- writer/static/assets/BuilderSettingsArtifactAPITriggerDetails-DnX66iRg.css +1 -0
- writer/static/assets/BuilderSettingsDeploySharedBlueprint-BR_3ptsd.js +1 -0
- writer/static/assets/BuilderSettingsDeploySharedBlueprint-KJTl8gxP.css +1 -0
- writer/static/assets/BuilderSettingsHandlers-CBtEQFSo.js +1 -0
- writer/static/assets/BuilderSettingsHandlers-DJPeASfz.css +1 -0
- writer/static/assets/BuilderSidebarComponentTree-DLltgas5.js +1 -0
- writer/static/assets/BuilderSidebarComponentTree-DYu1F793.css +1 -0
- writer/static/assets/BuilderSidebarToolkit-CApZNTAq.js +7 -0
- writer/static/assets/BuilderSidebarToolkit-CwqbjRv8.css +1 -0
- writer/static/assets/BuilderTemplateEditor-CYSDeWgV.css +1 -0
- writer/static/assets/BuilderTemplateEditor-DnRDRcA0.js +87 -0
- writer/static/assets/BuilderVault-2vGoV0sx.js +1 -0
- writer/static/assets/BuilderVault-Cx6oQSES.css +1 -0
- writer/static/assets/ComponentRenderer-72hqvEvI.css +1 -0
- writer/static/assets/ComponentRenderer-D4Pj1i3s.js +1 -0
- writer/static/assets/SharedCopyClipboardButton-BipJKGtz.css +1 -0
- writer/static/assets/SharedCopyClipboardButton-DNI9kLe6.js +1 -0
- writer/static/assets/WdsCheckbox-DKvpPA4D.css +1 -0
- writer/static/assets/WdsCheckbox-edQcn1cf.js +1 -0
- writer/static/assets/WdsDropdownMenu-CzzPN9Wg.css +1 -0
- writer/static/assets/WdsDropdownMenu-DQnrRBNV.js +1 -0
- writer/static/assets/WdsFieldWrapper-Cmufx5Nj.js +1 -0
- writer/static/assets/WdsFieldWrapper-CsemOh8D.css +1 -0
- writer/static/assets/WdsTabs-DKj7BqI0.css +1 -0
- writer/static/assets/WdsTabs-DcfY_zn5.js +1 -0
- writer/static/assets/abap-D8nrxEjS.js +6 -0
- writer/static/assets/apex-BrXDlLUW.js +6 -0
- writer/static/assets/art-paper-D70v1WMA.svg +180 -0
- writer/static/assets/azcli-CElzELwZ.js +6 -0
- writer/static/assets/bat-CUsyEhik.js +6 -0
- writer/static/assets/bicep-BtxyJn6H.js +7 -0
- writer/static/assets/cameligo-ClBCoF8h.js +6 -0
- writer/static/assets/clojure-B9TqLHAk.js +6 -0
- writer/static/assets/codicon-BA2IlpFX.ttf +0 -0
- writer/static/assets/coffee-DYsfeylR.js +6 -0
- writer/static/assets/cpp-VVGvvgir.js +6 -0
- writer/static/assets/csharp-Z6z2stHy.js +6 -0
- writer/static/assets/csp-DgZoLDI1.js +6 -0
- writer/static/assets/css-KqQ96-gC.js +8 -0
- writer/static/assets/css.worker-DvNUQFd1.js +84 -0
- writer/static/assets/cssMode-BYq4oZGq.js +9 -0
- writer/static/assets/cypher-CYoSlgTu.js +6 -0
- writer/static/assets/dart-BGDl7St1.js +6 -0
- writer/static/assets/dockerfile-CuCtxA7T.js +6 -0
- writer/static/assets/ecl-BCTFAUpS.js +6 -0
- writer/static/assets/editor.worker-BVwmgLrR.js +11 -0
- writer/static/assets/elixir-C7hRTYZ9.js +6 -0
- writer/static/assets/flow9-Bi_qi707.js +6 -0
- writer/static/assets/freemarker2-CnNourkO.js +8 -0
- writer/static/assets/fsharp-CxaaEKKi.js +6 -0
- writer/static/assets/go-DUImKuGY.js +6 -0
- writer/static/assets/graphql-D5sGVkLV.js +6 -0
- writer/static/assets/handlebars-Bm22yapJ.js +6 -0
- writer/static/assets/hcl-zD_CCkZ1.js +6 -0
- writer/static/assets/html-CAKAfoZF.js +6 -0
- writer/static/assets/html.worker-BJMlcbMU.js +458 -0
- writer/static/assets/htmlMode-BGZ97n-V.js +9 -0
- writer/static/assets/index-5u5REPT4.js +16 -0
- writer/static/assets/index-BKNuk68o.css +1 -0
- writer/static/assets/index-BQNXU3IR.js +17 -0
- writer/static/assets/index-BQr1pfrb.js +1 -0
- writer/static/assets/index-DHXAd5Yn.js +4 -0
- writer/static/assets/index-Zki-pfO-.js +8525 -0
- writer/static/assets/index.esm-B1ZQtduY.js +17 -0
- writer/static/assets/ini-8kKHd4ZL.js +6 -0
- writer/static/assets/java-De1axCfe.js +6 -0
- writer/static/assets/javascript-X1f02eyK.js +6 -0
- writer/static/assets/json.worker-BwvX8PuZ.js +42 -0
- writer/static/assets/jsonMode-hT0bNgT8.js +11 -0
- writer/static/assets/julia-D3ApGBxz.js +6 -0
- writer/static/assets/kotlin-GbSrCElU.js +6 -0
- writer/static/assets/less-DNUaDNdz.js +7 -0
- writer/static/assets/lexon-Bg9QKxBu.js +6 -0
- writer/static/assets/liquid-KmCCiJw2.js +6 -0
- writer/static/assets/lua-Crkvc3mc.js +6 -0
- writer/static/assets/m3-DsrzVyM1.js +6 -0
- writer/static/assets/mapbox-gl-C0cyFYYW.js +2329 -0
- writer/static/assets/markdown-CY5IOZuu.js +6 -0
- writer/static/assets/marked.esm-273vDTCT.js +45 -0
- writer/static/assets/mdx-DtRFauUw.js +6 -0
- writer/static/assets/mips-BE8RsGBA.js +6 -0
- writer/static/assets/msdax-N5ajIiFQ.js +6 -0
- writer/static/assets/mysql-DRxbB97D.js +6 -0
- writer/static/assets/objective-c-BHUZy23s.js +6 -0
- writer/static/assets/pascal-BemVzBTY.js +6 -0
- writer/static/assets/pascaligo-BACCcnx_.js +6 -0
- writer/static/assets/pdf-B6-yWJ-Y.js +12 -0
- writer/static/assets/pdf.worker.min-CyUfim15.mjs +21 -0
- writer/static/assets/perl-CuU66Ptk.js +6 -0
- writer/static/assets/pgsql-CQ6TMH2r.js +6 -0
- writer/static/assets/php-BvyzZa65.js +6 -0
- writer/static/assets/pla-DrIuu9u1.js +6 -0
- writer/static/assets/plotly.min-DutuuatZ.js +4030 -0
- writer/static/assets/poppins-latin-300-italic-4WBEAciR.woff +0 -0
- writer/static/assets/poppins-latin-300-italic-EWCPeN2Y.woff2 +0 -0
- writer/static/assets/poppins-latin-300-normal-DCNuMXUj.woff +0 -0
- writer/static/assets/poppins-latin-300-normal-Dku2WoCh.woff2 +0 -0
- writer/static/assets/poppins-latin-400-italic-B4GYq972.woff2 +0 -0
- writer/static/assets/poppins-latin-400-italic-BPejoDS-.woff +0 -0
- writer/static/assets/poppins-latin-400-normal-BOb3E3N0.woff +0 -0
- writer/static/assets/poppins-latin-400-normal-cpxAROuN.woff2 +0 -0
- writer/static/assets/poppins-latin-500-italic-Ce_qjtl5.woff +0 -0
- writer/static/assets/poppins-latin-500-italic-o28Otv0U.woff2 +0 -0
- writer/static/assets/poppins-latin-500-normal-C8OXljZJ.woff2 +0 -0
- writer/static/assets/poppins-latin-500-normal-DGXqpDMm.woff +0 -0
- writer/static/assets/poppins-latin-600-italic-BhOZippK.woff +0 -0
- writer/static/assets/poppins-latin-600-italic-CZ4wqKBi.woff2 +0 -0
- writer/static/assets/poppins-latin-600-normal-BJdTmd5m.woff +0 -0
- writer/static/assets/poppins-latin-600-normal-zEkxB9Mr.woff2 +0 -0
- writer/static/assets/poppins-latin-700-italic-CW91C-LJ.woff +0 -0
- writer/static/assets/poppins-latin-700-italic-RKf6esGj.woff2 +0 -0
- writer/static/assets/poppins-latin-700-normal-BVuQR_eA.woff +0 -0
- writer/static/assets/poppins-latin-700-normal-Qrb0O0WB.woff2 +0 -0
- writer/static/assets/poppins-latin-ext-300-italic-CBzyU4Pf.woff +0 -0
- writer/static/assets/poppins-latin-ext-300-italic-DdDvTq5-.woff2 +0 -0
- writer/static/assets/poppins-latin-ext-300-normal-7Zg2msWE.woff2 +0 -0
- writer/static/assets/poppins-latin-ext-300-normal-C9p7gvmA.woff +0 -0
- writer/static/assets/poppins-latin-ext-400-italic-BiCGV3eO.woff2 +0 -0
- writer/static/assets/poppins-latin-ext-400-italic-gsPYOGqV.woff +0 -0
- writer/static/assets/poppins-latin-ext-400-normal-CIpeJEZw.woff2 +0 -0
- writer/static/assets/poppins-latin-ext-400-normal-Ce_uWq1Z.woff +0 -0
- writer/static/assets/poppins-latin-ext-500-italic-CwrTHwbn.woff2 +0 -0
- writer/static/assets/poppins-latin-ext-500-italic-jdc8Bv4M.woff +0 -0
- writer/static/assets/poppins-latin-ext-500-normal-Bl1-S02S.woff +0 -0
- writer/static/assets/poppins-latin-ext-500-normal-H4Q0z8D2.woff2 +0 -0
- writer/static/assets/poppins-latin-ext-600-italic-BqeDa496.woff2 +0 -0
- writer/static/assets/poppins-latin-ext-600-italic-C7MQPb_A.woff +0 -0
- writer/static/assets/poppins-latin-ext-600-normal-Cn4C8475.woff2 +0 -0
- writer/static/assets/poppins-latin-ext-600-normal-DB6FJURc.woff +0 -0
- writer/static/assets/poppins-latin-ext-700-italic-BAdhB_WS.woff2 +0 -0
- writer/static/assets/poppins-latin-ext-700-italic-WKTwQMp8.woff +0 -0
- writer/static/assets/poppins-latin-ext-700-normal-CE2WFKmF.woff +0 -0
- writer/static/assets/poppins-latin-ext-700-normal-DDaViAzG.woff2 +0 -0
- writer/static/assets/postiats-BR_hrfni.js +6 -0
- writer/static/assets/powerquery-CKDUeRmd.js +6 -0
- writer/static/assets/powershell-Dsa4rhA_.js +6 -0
- writer/static/assets/protobuf-CGsvhooB.js +7 -0
- writer/static/assets/pug-D2p3uOX2.js +6 -0
- writer/static/assets/python-DVhxg746.js +6 -0
- writer/static/assets/qsharp-B7F3HtPF.js +6 -0
- writer/static/assets/r-3aLoi2fs.js +6 -0
- writer/static/assets/razor-DR5Ns_BC.js +6 -0
- writer/static/assets/redis-jqFeRM5s.js +6 -0
- writer/static/assets/redshift-BriwQgXR.js +6 -0
- writer/static/assets/restructuredtext-hbBFZ0w9.js +6 -0
- writer/static/assets/ruby-ByThyB2Q.js +6 -0
- writer/static/assets/rust-DIEZMp5R.js +6 -0
- writer/static/assets/sb-C6Gjjw_x.js +6 -0
- writer/static/assets/scala-DZNw3jJB.js +6 -0
- writer/static/assets/scheme-55eqh71t.js +6 -0
- writer/static/assets/scss-D-OVkc4F.js +8 -0
- writer/static/assets/serialization-DJC7NP0N.js +20 -0
- writer/static/assets/shell-DSpi8_qN.js +6 -0
- writer/static/assets/solidity-BHddiNFS.js +6 -0
- writer/static/assets/sophia-D6taVZFb.js +6 -0
- writer/static/assets/sparql-LA0C7mUc.js +6 -0
- writer/static/assets/sql-C3-3IcFM.js +6 -0
- writer/static/assets/st-C4g7059C.js +6 -0
- writer/static/assets/swift-DNI1vH3h.js +8 -0
- writer/static/assets/systemverilog-DL_FVbcQ.js +6 -0
- writer/static/assets/tcl-DVJXmIwd.js +6 -0
- writer/static/assets/ts.worker-CwG1rUES.js +37021 -0
- writer/static/assets/tsMode-BNUEZzir.js +16 -0
- writer/static/assets/twig-BVWDLtw5.js +6 -0
- writer/static/assets/typescript-CRVt7Hx0.js +6 -0
- writer/static/assets/useBlueprintRun-C00bCxh-.js +1 -0
- writer/static/assets/useKeyValueEditor-nDmI7cTJ.js +1 -0
- writer/static/assets/useListResources-DLkZhRSJ.js +1 -0
- writer/static/assets/vb-Btz91-7U.js +6 -0
- writer/static/assets/vega-embed.module-SNP5iNdJ.js +201 -0
- writer/static/assets/wgsl-D8V_buCG.js +303 -0
- writer/static/assets/xml-C_6-t1tb.js +6 -0
- writer/static/assets/yaml-DIw8G7jk.js +6 -0
- writer/static/components/annotatedtext.svg +4 -0
- writer/static/components/avatar.svg +4 -0
- writer/static/components/blueprints_addtostatelist.svg +4 -0
- writer/static/components/blueprints_apitrigger.svg +4 -0
- writer/static/components/blueprints_calleventhandler.svg +9 -0
- writer/static/components/blueprints_category_Logic.svg +4 -0
- writer/static/components/blueprints_category_Other.svg +4 -0
- writer/static/components/blueprints_category_Triggers.svg +4 -0
- writer/static/components/blueprints_category_Writer.svg +25 -0
- writer/static/components/blueprints_code.svg +9 -0
- writer/static/components/blueprints_crontrigger.svg +6 -0
- writer/static/components/blueprints_foreach.svg +4 -0
- writer/static/components/blueprints_httprequest.svg +11 -0
- writer/static/components/blueprints_logmessage.svg +11 -0
- writer/static/components/blueprints_parsejson.svg +4 -0
- writer/static/components/blueprints_returnvalue.svg +4 -0
- writer/static/components/blueprints_runblueprint.svg +4 -0
- writer/static/components/blueprints_setstate.svg +4 -0
- writer/static/components/blueprints_uieventtrigger.svg +4 -0
- writer/static/components/blueprints_writeraddchatmessage.svg +19 -0
- writer/static/components/blueprints_writeraddtokg.svg +19 -0
- writer/static/components/blueprints_writerchat.svg +11 -0
- writer/static/components/blueprints_writerchatreply.svg +19 -0
- writer/static/components/blueprints_writerclassification.svg +24 -0
- writer/static/components/blueprints_writercompletion.svg +14 -0
- writer/static/components/blueprints_writerinitchat.svg +11 -0
- writer/static/components/blueprints_writernocodeapp.svg +14 -0
- writer/static/components/button.svg +4 -0
- writer/static/components/category_Content.svg +4 -0
- writer/static/components/category_Embed.svg +4 -0
- writer/static/components/category_Input.svg +5 -0
- writer/static/components/category_Layout.svg +9 -0
- writer/static/components/category_Other.svg +4 -0
- writer/static/components/chatbot.svg +4 -0
- writer/static/components/checkboxinput.svg +4 -0
- writer/static/components/colorinput.svg +11 -0
- writer/static/components/column.svg +4 -0
- writer/static/components/columns.svg +4 -0
- writer/static/components/dataframe.svg +4 -0
- writer/static/components/dateinput.svg +4 -0
- writer/static/components/dropdowninput.svg +5 -0
- writer/static/components/fileinput.svg +4 -0
- writer/static/components/googlemaps.svg +4 -0
- writer/static/components/header.svg +4 -0
- writer/static/components/heading.svg +9 -0
- writer/static/components/horizontalstack.svg +4 -0
- writer/static/components/html.svg +9 -0
- writer/static/components/icon.svg +4 -0
- writer/static/components/iframe.svg +4 -0
- writer/static/components/image.svg +11 -0
- writer/static/components/jsonviewer.svg +4 -0
- writer/static/components/link.svg +12 -0
- writer/static/components/mapbox.svg +4 -0
- writer/static/components/message.svg +4 -0
- writer/static/components/metric.svg +4 -0
- writer/static/components/multiselectinput.svg +4 -0
- writer/static/components/numberinput.svg +4 -0
- writer/static/components/page.svg +50 -0
- writer/static/components/pagination.svg +4 -0
- writer/static/components/pdf.svg +4 -0
- writer/static/components/plotlygraph.svg +7 -0
- writer/static/components/progressbar.svg +5 -0
- writer/static/components/radioinput.svg +4 -0
- writer/static/components/rangeinput.svg +4 -0
- writer/static/components/ratinginput.svg +4 -0
- writer/static/components/repeater.svg +4 -0
- writer/static/components/reuse.svg +4 -0
- writer/static/components/section.svg +4 -0
- writer/static/components/selectinput.svg +5 -0
- writer/static/components/separator.svg +4 -0
- writer/static/components/sidebar.svg +4 -0
- writer/static/components/sliderinput.svg +4 -0
- writer/static/components/step.svg +4 -0
- writer/static/components/steps.svg +4 -0
- writer/static/components/switchinput.svg +4 -0
- writer/static/components/tab.svg +4 -0
- writer/static/components/tabs.svg +4 -0
- writer/static/components/tags.svg +11 -0
- writer/static/components/text.svg +4 -0
- writer/static/components/textareainput.svg +11 -0
- writer/static/components/textinput.svg +4 -0
- writer/static/components/timeinput.svg +4 -0
- writer/static/components/timer.svg +4 -0
- writer/static/components/vegalitechart.svg +7 -0
- writer/static/components/videoplayer.svg +11 -0
- writer/static/components/webcamcapture.svg +4 -0
- writer/static/favicon.png +0 -0
- writer/static/index.html +84 -0
- writer/static/status/cancelled.svg +5 -0
- writer/static/status/error.svg +5 -0
- writer/static/status/skipped.svg +4 -0
- writer/static/status/stopped.svg +4 -0
- writer/static/status/success.svg +4 -0
- writer/sync.py +431 -0
- writer/ui.py +2268 -0
- writer/vault.py +48 -0
- writer/wf_project.py +90 -66
- writer-1.25.1rc1.dist-info/METADATA +92 -0
- writer-1.25.1rc1.dist-info/RECORD +382 -0
- {writer-0.8.3rc4.dist-info → writer-1.25.1rc1.dist-info}/WHEEL +1 -1
- writer/blocks/runworkflow.py +0 -59
- writer/workflows.py +0 -183
- writer-0.8.3rc4.dist-info/METADATA +0 -117
- writer-0.8.3rc4.dist-info/RECORD +0 -44
- {writer-0.8.3rc4.dist-info → writer-1.25.1rc1.dist-info}/entry_points.txt +0 -0
- {writer-0.8.3rc4.dist-info → writer-1.25.1rc1.dist-info/licenses}/LICENSE.txt +0 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
from uuid import uuid4
|
|
2
|
+
|
|
3
|
+
from writer.abstract import register_abstract_template
|
|
4
|
+
from writer.blocks.base_block import WriterBlock
|
|
5
|
+
from writer.ss_types import AbstractTemplate
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class WriterUploadFile(WriterBlock):
|
|
9
|
+
|
|
10
|
+
@classmethod
|
|
11
|
+
def register(cls, type: str):
|
|
12
|
+
super(WriterUploadFile, cls).register(type)
|
|
13
|
+
register_abstract_template(type, AbstractTemplate(
|
|
14
|
+
baseType="blueprints_node",
|
|
15
|
+
writer={
|
|
16
|
+
"name": "Add files to Writer cloud",
|
|
17
|
+
"description": "Uploads files to the Writer platform.",
|
|
18
|
+
"category": "Writer",
|
|
19
|
+
"fields": {
|
|
20
|
+
"files": {
|
|
21
|
+
"name": "Files",
|
|
22
|
+
"type": "Object",
|
|
23
|
+
"default": "[]",
|
|
24
|
+
"desc": "A list of files to be uploaded to the Writer platform. You can use files uploaded via the File input component or specify dictionaries with data, type and name.",
|
|
25
|
+
"validator": {
|
|
26
|
+
"type": "array"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
"outs": {
|
|
31
|
+
"success": {
|
|
32
|
+
"name": "Success",
|
|
33
|
+
"description": "File successfully uploaded.",
|
|
34
|
+
"style": "success"
|
|
35
|
+
},
|
|
36
|
+
"error": {
|
|
37
|
+
"name": "Error",
|
|
38
|
+
"description": "There was an error uploading the files.",
|
|
39
|
+
"style": "error"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
))
|
|
44
|
+
|
|
45
|
+
def run(self):
|
|
46
|
+
from writer.ai import WriterAIManager
|
|
47
|
+
try:
|
|
48
|
+
files = self._get_field("files", as_json=True, required=True)
|
|
49
|
+
outputs = []
|
|
50
|
+
if not isinstance(files, list):
|
|
51
|
+
raise ValueError("Files must be a list.")
|
|
52
|
+
for file in files:
|
|
53
|
+
if not isinstance(file, dict):
|
|
54
|
+
raise ValueError("Files must be dictionaries and contain `data`, `type` and `name` attributes.")
|
|
55
|
+
if "data" not in file or "type" not in file:
|
|
56
|
+
raise ValueError("A file specified as a dictionary must contain `data` and `type` attributes.")
|
|
57
|
+
|
|
58
|
+
data = file.get("data")
|
|
59
|
+
file_type = file.get("type")
|
|
60
|
+
name = file.get("name")
|
|
61
|
+
file_name = name or f"agent-builder-{file_type}-{uuid4()}"
|
|
62
|
+
content_disposition = f'attachment; filename="{file_name}"'
|
|
63
|
+
|
|
64
|
+
client = WriterAIManager.acquire_client()
|
|
65
|
+
|
|
66
|
+
file = client.files.upload(
|
|
67
|
+
content=data,
|
|
68
|
+
content_type=file_type,
|
|
69
|
+
content_disposition=content_disposition
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
outputs.append({
|
|
73
|
+
"id": file.id,
|
|
74
|
+
"name": file.name,
|
|
75
|
+
"status": file.status,
|
|
76
|
+
"created_at": file.created_at.isoformat(),
|
|
77
|
+
"graph_ids": file.graph_ids
|
|
78
|
+
})
|
|
79
|
+
if len(outputs) == 0:
|
|
80
|
+
raise ValueError("No files were uploaded.")
|
|
81
|
+
self.result = outputs
|
|
82
|
+
self.outcome = "success"
|
|
83
|
+
except BaseException as e:
|
|
84
|
+
self.outcome = "error"
|
|
85
|
+
raise e
|
writer/blocks/writerinitchat.py
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
from writer.abstract import register_abstract_template
|
|
2
|
-
from writer.blocks.base_block import
|
|
2
|
+
from writer.blocks.base_block import WriterBlock
|
|
3
3
|
from writer.ss_types import AbstractTemplate, WriterConfigurationError
|
|
4
4
|
|
|
5
|
-
DEFAULT_MODEL = "palmyra-
|
|
5
|
+
DEFAULT_MODEL = "palmyra-x5"
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
class WriterInitChat(
|
|
8
|
+
class WriterInitChat(WriterBlock):
|
|
9
9
|
|
|
10
10
|
@classmethod
|
|
11
11
|
def register(cls, type: str):
|
|
12
12
|
super(WriterInitChat, cls).register(type)
|
|
13
13
|
register_abstract_template(type, AbstractTemplate(
|
|
14
|
-
baseType="
|
|
14
|
+
baseType="blueprints_node",
|
|
15
15
|
writer={
|
|
16
|
-
"name": "
|
|
17
|
-
"description": "
|
|
16
|
+
"name": "Start chat conversation",
|
|
17
|
+
"description": "Starts a new chat conversation. Use to initialize context for AI interactions.",
|
|
18
18
|
"category": "Writer",
|
|
19
|
+
"deprecated": True,
|
|
19
20
|
"fields": {
|
|
20
21
|
"conversationStateElement": {
|
|
21
22
|
"name": "Conversation state element",
|
|
@@ -23,8 +24,8 @@ class WriterInitChat(WorkflowBlock):
|
|
|
23
24
|
"type": "Text",
|
|
24
25
|
},
|
|
25
26
|
"modelId": {
|
|
26
|
-
"name": "Model
|
|
27
|
-
"type": "
|
|
27
|
+
"name": "Model",
|
|
28
|
+
"type": "Model Id",
|
|
28
29
|
"default": DEFAULT_MODEL
|
|
29
30
|
},
|
|
30
31
|
"temperature": {
|
|
@@ -36,17 +37,27 @@ class WriterInitChat(WorkflowBlock):
|
|
|
36
37
|
"minimum": 0,
|
|
37
38
|
"maximum": 1,
|
|
38
39
|
}
|
|
40
|
+
},
|
|
41
|
+
"max_tokens": {
|
|
42
|
+
"name": "Max output tokens",
|
|
43
|
+
"type": "Number",
|
|
44
|
+
"default": "1024",
|
|
45
|
+
"validator": {
|
|
46
|
+
"type": "number",
|
|
47
|
+
"minimum": 1,
|
|
48
|
+
"maximum": 16384,
|
|
49
|
+
}
|
|
39
50
|
}
|
|
40
51
|
},
|
|
41
52
|
"outs": {
|
|
42
53
|
"success": {
|
|
43
54
|
"name": "Success",
|
|
44
|
-
"description": "
|
|
55
|
+
"description": "The conversation was initialized.",
|
|
45
56
|
"style": "success",
|
|
46
57
|
},
|
|
47
58
|
"error": {
|
|
48
59
|
"name": "Error",
|
|
49
|
-
"description": "
|
|
60
|
+
"description": "There was an error initializing the conversation.",
|
|
50
61
|
"style": "error",
|
|
51
62
|
},
|
|
52
63
|
},
|
|
@@ -60,7 +71,8 @@ class WriterInitChat(WorkflowBlock):
|
|
|
60
71
|
conversation_state_element = self._get_field("conversationStateElement")
|
|
61
72
|
temperature = float(self._get_field("temperature", False, "0.7"))
|
|
62
73
|
model_id = self._get_field("modelId", False, default_field_value=DEFAULT_MODEL)
|
|
63
|
-
|
|
74
|
+
max_tokens = int(self._get_field("max_tokens", False, "1024"))
|
|
75
|
+
config = { "temperature": temperature, "model": model_id, "max_tokens": max_tokens }
|
|
64
76
|
|
|
65
77
|
conversation = self.evaluator.evaluate_expression(conversation_state_element, self.instance_path, self.execution_environment)
|
|
66
78
|
|
|
@@ -79,4 +91,4 @@ class WriterInitChat(WorkflowBlock):
|
|
|
79
91
|
self.outcome = "error"
|
|
80
92
|
raise e
|
|
81
93
|
|
|
82
|
-
|
|
94
|
+
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import re
|
|
2
|
+
|
|
3
|
+
from writer.abstract import register_abstract_template
|
|
4
|
+
from writer.blocks.base_block import WriterBlock
|
|
5
|
+
from writer.ss_types import AbstractTemplate, WriterConfigurationError
|
|
6
|
+
|
|
7
|
+
ALLOWED_CHARS = re.compile(r'^[A-Za-z0-9\-_]+$')
|
|
8
|
+
|
|
9
|
+
class WriterKeyValueStorage(WriterBlock):
|
|
10
|
+
@classmethod
|
|
11
|
+
def register(cls, type: str):
|
|
12
|
+
super(WriterKeyValueStorage, cls).register(type)
|
|
13
|
+
register_abstract_template(
|
|
14
|
+
type,
|
|
15
|
+
AbstractTemplate(
|
|
16
|
+
baseType="blueprints_node",
|
|
17
|
+
writer={
|
|
18
|
+
"name": "Key-Value Storage",
|
|
19
|
+
"description": "Stores data between sessions. Uses unique keys (names) to identify the data. Keys can only contain alphanumeric characters, underscores, and hyphens.",
|
|
20
|
+
"category": "Writer",
|
|
21
|
+
"fields": {
|
|
22
|
+
"action": {
|
|
23
|
+
"name": "Action",
|
|
24
|
+
"type": "Text",
|
|
25
|
+
"description": "What action to perform on the data (save, get, delete, list all keys).",
|
|
26
|
+
"options": {
|
|
27
|
+
"Save": "Save",
|
|
28
|
+
"Get": "Get",
|
|
29
|
+
"Delete": "Delete",
|
|
30
|
+
"List keys": "List keys",
|
|
31
|
+
},
|
|
32
|
+
"default": "Save",
|
|
33
|
+
},
|
|
34
|
+
"key": {
|
|
35
|
+
"name": "Key",
|
|
36
|
+
"type": "Text",
|
|
37
|
+
"description": "Unique identifier of your data that will be used to retrieve, update and delete it.",
|
|
38
|
+
},
|
|
39
|
+
"valueType": {
|
|
40
|
+
"name": "Value type",
|
|
41
|
+
"type": "Text",
|
|
42
|
+
"description": "Specify whether to interpret the value as plain text or JSON.",
|
|
43
|
+
"options": {
|
|
44
|
+
"text": "Plain text",
|
|
45
|
+
"JSON": "JSON",
|
|
46
|
+
},
|
|
47
|
+
"default": "text",
|
|
48
|
+
},
|
|
49
|
+
"value": {
|
|
50
|
+
"name": "Value",
|
|
51
|
+
"type": "Text",
|
|
52
|
+
"description": "Data that you want to store.",
|
|
53
|
+
"control": "Textarea",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
"outs": {
|
|
57
|
+
"success": {
|
|
58
|
+
"name": "Success",
|
|
59
|
+
"description": "The request was successful.",
|
|
60
|
+
"style": "success",
|
|
61
|
+
},
|
|
62
|
+
"error": {
|
|
63
|
+
"name": "Error",
|
|
64
|
+
"description": "The request wasn't successful.",
|
|
65
|
+
"style": "error",
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
),
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
def run(self):
|
|
73
|
+
try:
|
|
74
|
+
self.result = self._execute_action()
|
|
75
|
+
self.outcome = "success"
|
|
76
|
+
except BaseException as e:
|
|
77
|
+
self.outcome = "error"
|
|
78
|
+
raise e
|
|
79
|
+
|
|
80
|
+
def _execute_action(self):
|
|
81
|
+
from writer.journal import JOURNAL_KEY_PREFIX
|
|
82
|
+
from writer.keyvalue_storage import KeyValueStorage
|
|
83
|
+
|
|
84
|
+
action = self._get_field("action", default_field_value="Save")
|
|
85
|
+
|
|
86
|
+
with self.acquire_httpx_client() as client:
|
|
87
|
+
writer_kv_storage = KeyValueStorage(client=client)
|
|
88
|
+
|
|
89
|
+
if action == "List keys":
|
|
90
|
+
response = writer_kv_storage.get_data_keys()
|
|
91
|
+
return [key for key in response if not key.startswith(JOURNAL_KEY_PREFIX)]
|
|
92
|
+
|
|
93
|
+
key = self._get_field("key", required=True)
|
|
94
|
+
if not ALLOWED_CHARS.fullmatch(key):
|
|
95
|
+
raise WriterConfigurationError("Key can only contain alphanumeric characters, underscores and hyphens")
|
|
96
|
+
|
|
97
|
+
if action == "Save":
|
|
98
|
+
value_type = self._get_field("valueType")
|
|
99
|
+
value = self._get_field("value", as_json=value_type == "JSON")
|
|
100
|
+
return writer_kv_storage.save(key, value)
|
|
101
|
+
if action == "Get":
|
|
102
|
+
return writer_kv_storage.get(key, type_="data")["data"]
|
|
103
|
+
if action == "Delete":
|
|
104
|
+
return writer_kv_storage.delete(key)
|
|
105
|
+
|
|
106
|
+
raise WriterConfigurationError(f"Unknown action for the Key-Value Storage: {action}")
|
writer/blocks/writernocodeapp.py
CHANGED
|
@@ -1,49 +1,47 @@
|
|
|
1
1
|
from writer.abstract import register_abstract_template
|
|
2
|
-
from writer.blocks.base_block import
|
|
2
|
+
from writer.blocks.base_block import WriterBlock
|
|
3
3
|
from writer.ss_types import AbstractTemplate
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
class WriterNoCodeApp(
|
|
7
|
-
|
|
6
|
+
class WriterNoCodeApp(WriterBlock):
|
|
8
7
|
@classmethod
|
|
9
8
|
def register(cls, type: str):
|
|
10
9
|
super(WriterNoCodeApp, cls).register(type)
|
|
11
|
-
register_abstract_template(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"type": "Key-Value",
|
|
30
|
-
"default": "{}"
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
"outs": {
|
|
34
|
-
"success": {
|
|
35
|
-
"name": "Success",
|
|
36
|
-
"description": "If the execution was successful.",
|
|
37
|
-
"style": "success",
|
|
10
|
+
register_abstract_template(
|
|
11
|
+
type,
|
|
12
|
+
AbstractTemplate(
|
|
13
|
+
baseType="blueprints_node",
|
|
14
|
+
writer={
|
|
15
|
+
"name": "AI Studio agent",
|
|
16
|
+
"description": "Runs a Writer AI Studio agent app by ID.",
|
|
17
|
+
"category": "Writer",
|
|
18
|
+
"fields": {
|
|
19
|
+
"appId": {
|
|
20
|
+
"name": "App Id",
|
|
21
|
+
"type": "App Id",
|
|
22
|
+
"desc": "The agent id can be found in the agent's URL. It has a UUID format.",
|
|
23
|
+
"validator": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"format": "uuid",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
"appInputs": {"name": "App inputs", "type": "Key-Value", "default": "{}"},
|
|
38
29
|
},
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
"outs": {
|
|
31
|
+
"success": {
|
|
32
|
+
"name": "Success",
|
|
33
|
+
"description": "The agent ran successfully.",
|
|
34
|
+
"style": "success",
|
|
35
|
+
},
|
|
36
|
+
"error": {
|
|
37
|
+
"name": "Error",
|
|
38
|
+
"description": "There was an error running the agent.",
|
|
39
|
+
"style": "error",
|
|
40
|
+
},
|
|
43
41
|
},
|
|
44
42
|
},
|
|
45
|
-
|
|
46
|
-
)
|
|
43
|
+
),
|
|
44
|
+
)
|
|
47
45
|
|
|
48
46
|
def run(self):
|
|
49
47
|
try:
|
|
@@ -61,4 +59,4 @@ class WriterNoCodeApp(WorkflowBlock):
|
|
|
61
59
|
self.outcome = "success"
|
|
62
60
|
except BaseException as e:
|
|
63
61
|
self.outcome = "error"
|
|
64
|
-
raise e
|
|
62
|
+
raise e
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
from writer.abstract import register_abstract_template
|
|
2
|
+
from writer.blocks.base_block import WriterBlock
|
|
3
|
+
from writer.ss_types import AbstractTemplate
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class WriterParsePDFByFileID(WriterBlock):
|
|
7
|
+
@classmethod
|
|
8
|
+
def register(cls, type: str):
|
|
9
|
+
super(WriterParsePDFByFileID, cls).register(type)
|
|
10
|
+
register_abstract_template(
|
|
11
|
+
type,
|
|
12
|
+
AbstractTemplate(
|
|
13
|
+
baseType="blueprints_node",
|
|
14
|
+
writer={
|
|
15
|
+
"name": "Parse PDF tool",
|
|
16
|
+
"description": "Uses Writer API to extract the text content of a PDF file stored in Writer cloud.",
|
|
17
|
+
"category": "Writer",
|
|
18
|
+
"fields": {
|
|
19
|
+
"file": {
|
|
20
|
+
"name": "File",
|
|
21
|
+
"type": "Text",
|
|
22
|
+
"default": "",
|
|
23
|
+
"desc": "UUID of a file object in Files API.",
|
|
24
|
+
"validator": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"format": "uuid"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"markdown": {
|
|
30
|
+
"name": "Enable markdown",
|
|
31
|
+
"type": "Boolean",
|
|
32
|
+
"default": "yes",
|
|
33
|
+
"validator": {
|
|
34
|
+
"type": "boolean",
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"outs": {
|
|
39
|
+
"success": {
|
|
40
|
+
"name": "Success",
|
|
41
|
+
"description": "The PDF was parsed successfully.",
|
|
42
|
+
"style": "success",
|
|
43
|
+
},
|
|
44
|
+
"error": {
|
|
45
|
+
"name": "Error",
|
|
46
|
+
"description": "There was an error parsing the PDF.",
|
|
47
|
+
"style": "error",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
),
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
def run(self):
|
|
55
|
+
try:
|
|
56
|
+
import writer.ai
|
|
57
|
+
|
|
58
|
+
file_uuid = self._get_field("file")
|
|
59
|
+
markdown_input = self._get_field("markdown", False, "yes") == "yes"
|
|
60
|
+
|
|
61
|
+
client = writer.ai.WriterAIManager.acquire_client()
|
|
62
|
+
|
|
63
|
+
response = client.tools.parse_pdf(
|
|
64
|
+
file_uuid,
|
|
65
|
+
format="markdown" if markdown_input else "text"
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
self.result = response.content
|
|
69
|
+
self.outcome = "success"
|
|
70
|
+
|
|
71
|
+
except BaseException as e:
|
|
72
|
+
self.outcome = "error"
|
|
73
|
+
raise e
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
from writer.abstract import register_abstract_template
|
|
4
|
+
from writer.blocks.base_block import WriterBlock
|
|
5
|
+
from writer.ss_types import AbstractTemplate
|
|
6
|
+
|
|
7
|
+
DEFAULT_MODEL = "palmyra-x5"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class WriterStructuredOutput(WriterBlock):
|
|
11
|
+
@classmethod
|
|
12
|
+
def register(cls, type: str):
|
|
13
|
+
super(WriterStructuredOutput, cls).register(type)
|
|
14
|
+
register_abstract_template(
|
|
15
|
+
type,
|
|
16
|
+
AbstractTemplate(
|
|
17
|
+
baseType="blueprints_node",
|
|
18
|
+
writer={
|
|
19
|
+
"name": "Structured output",
|
|
20
|
+
"description": "Defines a JSON response format that the agent will use to structure its output.",
|
|
21
|
+
"category": "Writer",
|
|
22
|
+
"fields": {
|
|
23
|
+
"prompt": {"name": "Prompt", "type": "Text", "control": "Textarea", "desc": "Description of a JSON object to be created."},
|
|
24
|
+
"modelId": {
|
|
25
|
+
"name": "Model",
|
|
26
|
+
"type": "Model Id",
|
|
27
|
+
"default": DEFAULT_MODEL
|
|
28
|
+
},
|
|
29
|
+
"jsonSchema": {
|
|
30
|
+
"name": "JSON Schema",
|
|
31
|
+
"desc": "JSON schema that defines the structure of the response. For example, `{\"type\": \"object\", \"properties\": {...}, \"required\": [...]}`.",
|
|
32
|
+
"type": "JSON",
|
|
33
|
+
"default": "{}"
|
|
34
|
+
},
|
|
35
|
+
"max_tokens": {
|
|
36
|
+
"name": "Max output tokens",
|
|
37
|
+
"type": "Number",
|
|
38
|
+
"default": "1024",
|
|
39
|
+
"validator": {
|
|
40
|
+
"type": "number",
|
|
41
|
+
"minimum": 1,
|
|
42
|
+
"maximum": 16384,
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"outs": {
|
|
47
|
+
"success": {
|
|
48
|
+
"name": "Success",
|
|
49
|
+
"description": "The structured output was generated.",
|
|
50
|
+
"style": "success",
|
|
51
|
+
},
|
|
52
|
+
"error": {
|
|
53
|
+
"name": "Error",
|
|
54
|
+
"description": "There was an error generating the output.",
|
|
55
|
+
"style": "error",
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
),
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
def run(self):
|
|
63
|
+
import writer.ai
|
|
64
|
+
|
|
65
|
+
try:
|
|
66
|
+
prompt = self._get_field("prompt")
|
|
67
|
+
model_id = self._get_field("modelId", False, default_field_value=DEFAULT_MODEL)
|
|
68
|
+
conversation = writer.ai.Conversation()
|
|
69
|
+
schema = self._get_field("jsonSchema", True, default_field_value="{}")
|
|
70
|
+
max_tokens = int(self._get_field("max_tokens", False, "1024"))
|
|
71
|
+
|
|
72
|
+
response_format = {
|
|
73
|
+
"type": "json_schema",
|
|
74
|
+
"json_schema": {
|
|
75
|
+
"schema": schema
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
conversation += {
|
|
80
|
+
"role": "user",
|
|
81
|
+
"content": prompt,
|
|
82
|
+
}
|
|
83
|
+
config = { "model": model_id, "max_tokens": max_tokens }
|
|
84
|
+
msg = conversation.complete(response_format=response_format, config=config)
|
|
85
|
+
conversation += msg
|
|
86
|
+
|
|
87
|
+
raw_content = msg.get("content")
|
|
88
|
+
if not raw_content:
|
|
89
|
+
self.outcome = "error"
|
|
90
|
+
raise RuntimeError("No content returned from the model. Please validate the prompt and model configuration.")
|
|
91
|
+
|
|
92
|
+
try:
|
|
93
|
+
# Attempt to parse the raw content as JSON
|
|
94
|
+
content = json.loads(raw_content)
|
|
95
|
+
except json.JSONDecodeError:
|
|
96
|
+
self.outcome = "error"
|
|
97
|
+
raise RuntimeError(
|
|
98
|
+
f"Failed to decode JSON content. The raw content was: {raw_content}. Please validate the prompt and model configuration."
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
self.result = content
|
|
102
|
+
self.outcome = "success"
|
|
103
|
+
except BaseException as e:
|
|
104
|
+
self.outcome = "error"
|
|
105
|
+
raise e
|