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,393 @@
|
|
|
1
|
+
from writer.abstract import register_abstract_template
|
|
2
|
+
from writer.blocks.base_block import WriterBlock
|
|
3
|
+
from writer.ss_types import AbstractTemplate, WriterConfigurationError
|
|
4
|
+
|
|
5
|
+
DEFAULT_MODEL = "palmyra-x5"
|
|
6
|
+
|
|
7
|
+
class WriterChatReplyWithToolConfig(WriterBlock):
|
|
8
|
+
def __init__(self, component, runner, execution_environment):
|
|
9
|
+
super().__init__(component, runner, execution_environment)
|
|
10
|
+
|
|
11
|
+
@classmethod
|
|
12
|
+
def register(cls, type: str):
|
|
13
|
+
super(WriterChatReplyWithToolConfig, cls).register(type)
|
|
14
|
+
register_abstract_template(
|
|
15
|
+
type,
|
|
16
|
+
AbstractTemplate(
|
|
17
|
+
baseType="blueprints_node",
|
|
18
|
+
writer={
|
|
19
|
+
"name": "Chat reply with tool config",
|
|
20
|
+
"description": "Initializes conversations, adds messages, and generates replies with tool configuration. NOTE: This is a temporary block with MCP tools mocked - tool calls use hardcoded mock responses instead of making actual HTTP requests.",
|
|
21
|
+
"category": "Writer",
|
|
22
|
+
"featureFlags": ["mcp"],
|
|
23
|
+
"fields": {
|
|
24
|
+
"conversationStateElement": {
|
|
25
|
+
"name": "Conversation Object",
|
|
26
|
+
"desc": "The variable that has your conversation object.",
|
|
27
|
+
"init": "chat",
|
|
28
|
+
"type": "Binding",
|
|
29
|
+
},
|
|
30
|
+
"systemPrompt": {
|
|
31
|
+
"name": "System prompt",
|
|
32
|
+
"type": "Text",
|
|
33
|
+
"control": "Textarea",
|
|
34
|
+
"default": "",
|
|
35
|
+
"desc": "A system prompt to set the context for the conversation. Can be left empty if conversation is already initialized in state.",
|
|
36
|
+
},
|
|
37
|
+
"message": {
|
|
38
|
+
"name": "Message",
|
|
39
|
+
"type": "Object",
|
|
40
|
+
"init": '{ "role": "user", "content": "Hello" }',
|
|
41
|
+
"desc": "A message object. Content can be text string or array of objects for multimodal (text + images) with X5 model.",
|
|
42
|
+
"validator": {
|
|
43
|
+
"type": "object",
|
|
44
|
+
"properties": {
|
|
45
|
+
"role": {"type": "string"},
|
|
46
|
+
"content": {
|
|
47
|
+
"oneOf": [
|
|
48
|
+
{"type": "string"},
|
|
49
|
+
{
|
|
50
|
+
"type": "array",
|
|
51
|
+
"items": {
|
|
52
|
+
"oneOf": [
|
|
53
|
+
{
|
|
54
|
+
"type": "object",
|
|
55
|
+
"properties": {
|
|
56
|
+
"type": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"enum": ["text"],
|
|
59
|
+
},
|
|
60
|
+
"text": {"type": "string"},
|
|
61
|
+
},
|
|
62
|
+
"required": ["type", "text"],
|
|
63
|
+
"additionalProperties": False,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"type": "object",
|
|
67
|
+
"properties": {
|
|
68
|
+
"type": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"enum": ["image_url"],
|
|
71
|
+
},
|
|
72
|
+
"image_url": {
|
|
73
|
+
"type": "object",
|
|
74
|
+
"properties": {
|
|
75
|
+
"url": {"type": "string"}
|
|
76
|
+
},
|
|
77
|
+
"required": ["url"],
|
|
78
|
+
"additionalProperties": False,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
"required": ["type", "image_url"],
|
|
82
|
+
"additionalProperties": False,
|
|
83
|
+
},
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
"additionalProperties": False,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
"generateReply": {
|
|
94
|
+
"name": "Generate reply",
|
|
95
|
+
"type": "Boolean",
|
|
96
|
+
"default": "yes",
|
|
97
|
+
"desc": "If set to 'yes', the block will generate a reply from the model after adding the message. If set to 'no', it will only add the message to the conversation.",
|
|
98
|
+
"validator": {
|
|
99
|
+
"type": "boolean",
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
"initModelId": {
|
|
103
|
+
"name": "Initial model",
|
|
104
|
+
"type": "Model Id",
|
|
105
|
+
"default": DEFAULT_MODEL,
|
|
106
|
+
},
|
|
107
|
+
"initTemperature": {
|
|
108
|
+
"name": "Initial temperature",
|
|
109
|
+
"type": "Number",
|
|
110
|
+
"default": "0.7",
|
|
111
|
+
"validator": {
|
|
112
|
+
"type": "number",
|
|
113
|
+
"minimum": 0,
|
|
114
|
+
"maximum": 2,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
"initMaxTokens": {
|
|
118
|
+
"name": "Initial max tokens",
|
|
119
|
+
"type": "Number",
|
|
120
|
+
"default": "1024",
|
|
121
|
+
"validator": {
|
|
122
|
+
"type": "number",
|
|
123
|
+
"minimum": 1,
|
|
124
|
+
"maximum": 16384,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
"useStreaming": {
|
|
128
|
+
"name": "Use streaming",
|
|
129
|
+
"type": "Boolean",
|
|
130
|
+
"default": "yes",
|
|
131
|
+
"desc": "If set to 'yes', the block will stream the reply as it is generated. If set to 'no', it will wait for the entire reply to be generated before returning.",
|
|
132
|
+
"validator": {
|
|
133
|
+
"type": "boolean",
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
"tools": {
|
|
137
|
+
"name": "Tools",
|
|
138
|
+
"type": "Tools",
|
|
139
|
+
"default": "{}",
|
|
140
|
+
"init": "",
|
|
141
|
+
"category": "Tools",
|
|
142
|
+
},
|
|
143
|
+
"toolConfig": {
|
|
144
|
+
"name": "Tool config",
|
|
145
|
+
"type": "Object",
|
|
146
|
+
"default": "{}",
|
|
147
|
+
"desc": "Additional configuration for tools.",
|
|
148
|
+
"validator": {
|
|
149
|
+
"type": "object",
|
|
150
|
+
"additionalProperties": True,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
"outs": {
|
|
155
|
+
"tools": {
|
|
156
|
+
"name": "Tools",
|
|
157
|
+
"field": "tools",
|
|
158
|
+
"description": "Run associated tools.",
|
|
159
|
+
"style": "dynamic",
|
|
160
|
+
},
|
|
161
|
+
"success": {
|
|
162
|
+
"name": "Success",
|
|
163
|
+
"description": "The reply was generated successfully.",
|
|
164
|
+
"style": "success",
|
|
165
|
+
},
|
|
166
|
+
"error": {
|
|
167
|
+
"name": "Error",
|
|
168
|
+
"description": "There was an error generating the reply.",
|
|
169
|
+
"style": "error",
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
),
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
def _make_callable(self, tool_name: str, app_id: str, function_name: str):
|
|
177
|
+
def callable(**args):
|
|
178
|
+
import json
|
|
179
|
+
import os
|
|
180
|
+
import uuid
|
|
181
|
+
|
|
182
|
+
import httpx
|
|
183
|
+
|
|
184
|
+
from writer.core import get_session
|
|
185
|
+
current_session = get_session()
|
|
186
|
+
|
|
187
|
+
org_id = None
|
|
188
|
+
user_id = None
|
|
189
|
+
|
|
190
|
+
if current_session and current_session.headers:
|
|
191
|
+
org_id = current_session.headers.get("x-organization-id")
|
|
192
|
+
user_id = current_session.headers.get("x-user-id")
|
|
193
|
+
|
|
194
|
+
if not org_id:
|
|
195
|
+
org_id = os.getenv("WRITER_ORG_ID")
|
|
196
|
+
|
|
197
|
+
if not org_id:
|
|
198
|
+
raise ValueError("Organization ID not found. Set x-organization-id header or WRITER_ORG_ID environment variable.")
|
|
199
|
+
|
|
200
|
+
if not user_id:
|
|
201
|
+
user_id = os.getenv("WRITER_USER_ID", "1")
|
|
202
|
+
|
|
203
|
+
try:
|
|
204
|
+
user_id = int(user_id)
|
|
205
|
+
except (ValueError, TypeError):
|
|
206
|
+
user_id = 1
|
|
207
|
+
|
|
208
|
+
# url = f"http://localhost:8001/api/v1/namespaces/default/services/mcp-gateway:80/proxy/api/private/mcp-gateway/organization/1/mcp"
|
|
209
|
+
# auth_token_header = "X-Auth-Token-Data-User-Individual"
|
|
210
|
+
# auth_token_data = json.dumps({
|
|
211
|
+
# "userId": user_id,
|
|
212
|
+
# "authType": "Password",
|
|
213
|
+
# "confirmed": True
|
|
214
|
+
# }).encode()
|
|
215
|
+
#
|
|
216
|
+
# headers = {
|
|
217
|
+
# "Content-Type": "application/json",
|
|
218
|
+
# auth_token_header: auth_token_data,
|
|
219
|
+
# }
|
|
220
|
+
#
|
|
221
|
+
# jsonrpc_request = {
|
|
222
|
+
# "jsonrpc": "2.0",
|
|
223
|
+
# "id": str(uuid.uuid4()),
|
|
224
|
+
# "method": "tools/call",
|
|
225
|
+
# "params": {
|
|
226
|
+
# "name": function_name,
|
|
227
|
+
# "arguments": args
|
|
228
|
+
# }
|
|
229
|
+
# }
|
|
230
|
+
|
|
231
|
+
result = {
|
|
232
|
+
'id': '2c22bbee-65eb-4471-bd05-4e1be617db74',
|
|
233
|
+
'jsonrpc': '2.0',
|
|
234
|
+
'result': {
|
|
235
|
+
'content': [{
|
|
236
|
+
'text': '[\n 45873434,\n 45873113,\n 45785840\n]',
|
|
237
|
+
'type': 'text'
|
|
238
|
+
}]
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
# if "error" in result:
|
|
243
|
+
# error = result["error"]
|
|
244
|
+
# error_message = error.get("message", "Unknown MCP error") if isinstance(error, dict) else str(error)
|
|
245
|
+
# raise RuntimeError(f"MCP gateway API returned error: {error_message}")
|
|
246
|
+
|
|
247
|
+
result_data = result.get("result", {})
|
|
248
|
+
|
|
249
|
+
content_items = result_data.get("content", [])
|
|
250
|
+
if content_items:
|
|
251
|
+
return_value = []
|
|
252
|
+
for item in content_items:
|
|
253
|
+
if isinstance(item, dict):
|
|
254
|
+
if item.get("type") == "text":
|
|
255
|
+
return_value.append(item.get("text", ""))
|
|
256
|
+
elif item.get("type") == "image":
|
|
257
|
+
return_value.append(f"[Image: {item.get('mimeType', 'image/png')}]")
|
|
258
|
+
else:
|
|
259
|
+
return_value.append(str(item))
|
|
260
|
+
else:
|
|
261
|
+
return_value.append(str(item))
|
|
262
|
+
return_value = "\n".join(return_value) if return_value else ""
|
|
263
|
+
else:
|
|
264
|
+
return_value = result_data.get("result") or result_data.get("content") or result_data
|
|
265
|
+
|
|
266
|
+
return return_value
|
|
267
|
+
|
|
268
|
+
return callable
|
|
269
|
+
|
|
270
|
+
def run(self):
|
|
271
|
+
try:
|
|
272
|
+
import writer.ai
|
|
273
|
+
|
|
274
|
+
conversation_state_element = self._get_field("conversationStateElement", required=True)
|
|
275
|
+
message = self._get_field("message", as_json=True)
|
|
276
|
+
generate_reply = self._get_field("generateReply", False, "yes") == "yes"
|
|
277
|
+
|
|
278
|
+
system_prompt = self._get_field("systemPrompt", False, default_field_value=None)
|
|
279
|
+
init_model_id = self._get_field("initModelId", False, default_field_value=DEFAULT_MODEL)
|
|
280
|
+
try:
|
|
281
|
+
init_temperature = float(self._get_field("initTemperature", False, "0.7"))
|
|
282
|
+
init_max_tokens = int(self._get_field("initMaxTokens", False, "1024"))
|
|
283
|
+
except ValueError as e:
|
|
284
|
+
raise WriterConfigurationError(f"Invalid numeric value in configuration: {e}")
|
|
285
|
+
use_streaming = self._get_field("useStreaming", False, "yes") == "yes"
|
|
286
|
+
tools_raw = self._get_field("tools", True)
|
|
287
|
+
|
|
288
|
+
tools = []
|
|
289
|
+
|
|
290
|
+
conversation = self.evaluator.evaluate_expression(
|
|
291
|
+
conversation_state_element, self.instance_path, self.execution_environment
|
|
292
|
+
)
|
|
293
|
+
|
|
294
|
+
if conversation is None:
|
|
295
|
+
config = {
|
|
296
|
+
"temperature": init_temperature,
|
|
297
|
+
"model": init_model_id,
|
|
298
|
+
"max_tokens": init_max_tokens,
|
|
299
|
+
}
|
|
300
|
+
conversation = writer.ai.Conversation(
|
|
301
|
+
prompt_or_history=system_prompt, config=config
|
|
302
|
+
)
|
|
303
|
+
self._set_state(conversation_state_element, conversation)
|
|
304
|
+
elif not isinstance(conversation, writer.ai.Conversation):
|
|
305
|
+
raise WriterConfigurationError(
|
|
306
|
+
"The state element specified doesn't contain a Conversation."
|
|
307
|
+
)
|
|
308
|
+
|
|
309
|
+
if message not in (None, {}, ""):
|
|
310
|
+
writer.ai.Conversation.validate_message(message)
|
|
311
|
+
conversation += message
|
|
312
|
+
self._set_state(conversation_state_element, conversation)
|
|
313
|
+
|
|
314
|
+
if not generate_reply:
|
|
315
|
+
self.result = ""
|
|
316
|
+
self.outcome = "success"
|
|
317
|
+
return
|
|
318
|
+
|
|
319
|
+
for tool_name, tool_raw in tools_raw.items():
|
|
320
|
+
if not isinstance(tool_raw, dict):
|
|
321
|
+
continue
|
|
322
|
+
|
|
323
|
+
if not isinstance(tool_name, str) or not tool_name:
|
|
324
|
+
continue
|
|
325
|
+
|
|
326
|
+
tool_type = tool_raw.get("type")
|
|
327
|
+
if tool_type != "mcp":
|
|
328
|
+
continue
|
|
329
|
+
|
|
330
|
+
try:
|
|
331
|
+
app_id = tool_raw.get("appId")
|
|
332
|
+
function_name = tool_raw.get("functionName")
|
|
333
|
+
|
|
334
|
+
if not app_id:
|
|
335
|
+
continue
|
|
336
|
+
|
|
337
|
+
if not function_name:
|
|
338
|
+
continue
|
|
339
|
+
|
|
340
|
+
mcp_function = tool_raw.get("function", {})
|
|
341
|
+
description = mcp_function.get("description", "")
|
|
342
|
+
parameters = mcp_function.get("parameters", {})
|
|
343
|
+
|
|
344
|
+
if parameters:
|
|
345
|
+
if not isinstance(parameters, dict):
|
|
346
|
+
continue
|
|
347
|
+
|
|
348
|
+
if "properties" in parameters:
|
|
349
|
+
parameters = parameters.get("properties", {})
|
|
350
|
+
elif "type" not in parameters:
|
|
351
|
+
parameters = {
|
|
352
|
+
"type": "object",
|
|
353
|
+
"properties": parameters
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
tool = writer.ai.FunctionTool(
|
|
357
|
+
type="function",
|
|
358
|
+
name=tool_name,
|
|
359
|
+
description=description,
|
|
360
|
+
callable=self._make_callable(tool_name, app_id, function_name),
|
|
361
|
+
parameters=parameters or {},
|
|
362
|
+
)
|
|
363
|
+
tools.append(tool)
|
|
364
|
+
|
|
365
|
+
except Exception:
|
|
366
|
+
continue
|
|
367
|
+
|
|
368
|
+
if tools_raw and len(tools) == 0:
|
|
369
|
+
raise WriterConfigurationError(
|
|
370
|
+
"No valid tools could be created from the provided tools configuration. "
|
|
371
|
+
"Please check that tools have the required fields and valid structure."
|
|
372
|
+
)
|
|
373
|
+
|
|
374
|
+
msg = ""
|
|
375
|
+
if not use_streaming:
|
|
376
|
+
reply = conversation.complete(tools=tools)
|
|
377
|
+
msg = reply.get("content") or ""
|
|
378
|
+
conversation += reply
|
|
379
|
+
self._set_state(conversation_state_element, conversation)
|
|
380
|
+
else:
|
|
381
|
+
for chunk in conversation.stream_complete(tools=tools):
|
|
382
|
+
if chunk.get("content") is None:
|
|
383
|
+
chunk["content"] = ""
|
|
384
|
+
msg += chunk.get("content")
|
|
385
|
+
conversation += chunk
|
|
386
|
+
self._set_state(conversation_state_element, conversation)
|
|
387
|
+
self.result = msg
|
|
388
|
+
self._set_state(conversation_state_element, conversation)
|
|
389
|
+
self.outcome = "success"
|
|
390
|
+
except BaseException as e:
|
|
391
|
+
self.outcome = "error"
|
|
392
|
+
raise e
|
|
393
|
+
|
|
@@ -1,50 +1,53 @@
|
|
|
1
1
|
import json
|
|
2
|
+
import re
|
|
2
3
|
|
|
3
4
|
from writer.abstract import register_abstract_template
|
|
4
|
-
from writer.blocks.base_block import
|
|
5
|
+
from writer.blocks.base_block import WriterBlock
|
|
5
6
|
from writer.ss_types import AbstractTemplate
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
class WriterClassification(
|
|
9
|
-
|
|
9
|
+
class WriterClassification(WriterBlock):
|
|
10
10
|
@classmethod
|
|
11
11
|
def register(cls, type: str):
|
|
12
12
|
super(WriterClassification, cls).register(type)
|
|
13
|
-
register_abstract_template(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
13
|
+
register_abstract_template(
|
|
14
|
+
type,
|
|
15
|
+
AbstractTemplate(
|
|
16
|
+
baseType="blueprints_node",
|
|
17
|
+
writer={
|
|
18
|
+
"name": "Classification",
|
|
19
|
+
"description": "Classifies text into predefined categories using AI. Useful for tagging and routing inputs.",
|
|
20
|
+
"category": "Writer",
|
|
21
|
+
"fields": {
|
|
22
|
+
"text": {
|
|
23
|
+
"name": "Text",
|
|
24
|
+
"type": "Text",
|
|
25
|
+
"desc": "The text you want to classify.",
|
|
26
|
+
},
|
|
27
|
+
"categories": {
|
|
28
|
+
"name": "Categories",
|
|
29
|
+
"type": "Key-Value",
|
|
30
|
+
"default": "{}",
|
|
31
|
+
"desc": "The keys should be the categories you want to classify the text into, for example 'valid' and 'invalid', and the values are the criteria for each category. Category names should contain only letters of the English alphabet, digits, underscores, and spaces.",
|
|
32
|
+
},
|
|
33
|
+
"additionalContext": {
|
|
34
|
+
"name": "Additional context",
|
|
35
|
+
"type": "Text",
|
|
36
|
+
"control": "Textarea",
|
|
37
|
+
"desc": "Any additional information that might help the AI in making the classification decision.",
|
|
38
|
+
},
|
|
28
39
|
},
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
|
|
40
|
+
"outs": {
|
|
41
|
+
"category": {"field": "categories", "style": "dynamic"},
|
|
42
|
+
"error": {
|
|
43
|
+
"name": "Error",
|
|
44
|
+
"description": "There was an error classifying the text.",
|
|
45
|
+
"style": "error",
|
|
46
|
+
},
|
|
33
47
|
},
|
|
34
48
|
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"field": "categories",
|
|
38
|
-
"style": "dynamic"
|
|
39
|
-
},
|
|
40
|
-
"error": {
|
|
41
|
-
"name": "Error",
|
|
42
|
-
"description": "If the function raises an Exception.",
|
|
43
|
-
"style": "error",
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
}
|
|
47
|
-
))
|
|
49
|
+
),
|
|
50
|
+
)
|
|
48
51
|
|
|
49
52
|
def run(self):
|
|
50
53
|
try:
|
|
@@ -53,6 +56,12 @@ class WriterClassification(WorkflowBlock):
|
|
|
53
56
|
text = self._get_field("text", required=True)
|
|
54
57
|
additional_context = self._get_field("additionalContext")
|
|
55
58
|
categories = self._get_field("categories", as_json=True, required=True)
|
|
59
|
+
conversation = writer.ai.Conversation()
|
|
60
|
+
|
|
61
|
+
invalid_categories = [category for category in categories if not re.fullmatch(r"[\w ]+", category, flags=re.ASCII)]
|
|
62
|
+
if invalid_categories:
|
|
63
|
+
self.outcome = "error"
|
|
64
|
+
raise ValueError(f"Category names should contain only letters of the English alphabet, digits, underscores and spaces. Invalid categories: {', '.join(invalid_categories)}")
|
|
56
65
|
|
|
57
66
|
config = {}
|
|
58
67
|
|
|
@@ -71,9 +80,39 @@ CONTENT:
|
|
|
71
80
|
------
|
|
72
81
|
{ text }
|
|
73
82
|
"""
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
|
|
84
|
+
response_format = {
|
|
85
|
+
"type": "json_schema",
|
|
86
|
+
"json_schema": {
|
|
87
|
+
"schema": {
|
|
88
|
+
"type": "string",
|
|
89
|
+
"enum": list(categories.keys())
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
conversation += {
|
|
95
|
+
"role": "user",
|
|
96
|
+
"content": prompt,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
msg = conversation.complete(response_format=response_format, config=config)
|
|
100
|
+
raw_content = msg.get("content")
|
|
101
|
+
if not raw_content:
|
|
102
|
+
self.outcome = "error"
|
|
103
|
+
raise RuntimeError("No content returned from the model. Please validate the prompt and model configuration.")
|
|
104
|
+
|
|
105
|
+
try:
|
|
106
|
+
# Attempt to parse the raw content as JSON
|
|
107
|
+
category_result = json.loads(raw_content)
|
|
108
|
+
except json.JSONDecodeError:
|
|
109
|
+
self.outcome = "error"
|
|
110
|
+
raise RuntimeError(
|
|
111
|
+
f"Failed to decode JSON content. The raw content was: {raw_content}. Please validate the prompt and model configuration."
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
self.result = category_result
|
|
115
|
+
self.outcome = f"category_{category_result}"
|
|
77
116
|
except BaseException as e:
|
|
78
117
|
self.outcome = "error"
|
|
79
|
-
raise e
|
|
118
|
+
raise e
|
|
@@ -1,56 +1,60 @@
|
|
|
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
|
-
DEFAULT_MODEL = "palmyra-
|
|
6
|
-
|
|
7
|
-
class WriterCompletion(WorkflowBlock):
|
|
5
|
+
DEFAULT_MODEL = "palmyra-x5"
|
|
8
6
|
|
|
7
|
+
class WriterCompletion(WriterBlock):
|
|
9
8
|
@classmethod
|
|
10
9
|
def register(cls, type: str):
|
|
11
10
|
super(WriterCompletion, cls).register(type)
|
|
12
|
-
register_abstract_template(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
"type": "Text",
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
11
|
+
register_abstract_template(
|
|
12
|
+
type,
|
|
13
|
+
AbstractTemplate(
|
|
14
|
+
baseType="blueprints_node",
|
|
15
|
+
writer={
|
|
16
|
+
"name": "Text generation",
|
|
17
|
+
"description": "Generates text using a Writer model. Use for completions, summaries, or creative writing.",
|
|
18
|
+
"category": "Writer",
|
|
19
|
+
"fields": {
|
|
20
|
+
"prompt": {"name": "Prompt", "type": "Text", "control": "Textarea"},
|
|
21
|
+
"modelId": {"name": "Model", "type": "Model Id", "default": DEFAULT_MODEL},
|
|
22
|
+
"temperature": {
|
|
23
|
+
"name": "Temperature",
|
|
24
|
+
"type": "Number",
|
|
25
|
+
"default": "0.7",
|
|
26
|
+
"validator": {
|
|
27
|
+
"type": "number",
|
|
28
|
+
"minimum": 0,
|
|
29
|
+
"maximum": 1,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
"max_tokens": {
|
|
33
|
+
"name": "Max output tokens",
|
|
34
|
+
"type": "Number",
|
|
35
|
+
"default": "1024",
|
|
36
|
+
"validator": {
|
|
37
|
+
"type": "number",
|
|
38
|
+
"minimum": 1,
|
|
39
|
+
"maximum": 16384,
|
|
40
|
+
}
|
|
37
41
|
}
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
"outs": {
|
|
41
|
-
"success": {
|
|
42
|
-
"name": "Success",
|
|
43
|
-
"description": "If the function doesn't raise an Exception.",
|
|
44
|
-
"style": "success",
|
|
45
42
|
},
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
"outs": {
|
|
44
|
+
"success": {
|
|
45
|
+
"name": "Success",
|
|
46
|
+
"description": "Text was generated successfully.",
|
|
47
|
+
"style": "success",
|
|
48
|
+
},
|
|
49
|
+
"error": {
|
|
50
|
+
"name": "Error",
|
|
51
|
+
"description": "There was an error generating text.",
|
|
52
|
+
"style": "error",
|
|
53
|
+
},
|
|
50
54
|
},
|
|
51
55
|
},
|
|
52
|
-
|
|
53
|
-
)
|
|
56
|
+
),
|
|
57
|
+
)
|
|
54
58
|
|
|
55
59
|
def run(self):
|
|
56
60
|
try:
|
|
@@ -59,10 +63,11 @@ class WriterCompletion(WorkflowBlock):
|
|
|
59
63
|
prompt = self._get_field("prompt")
|
|
60
64
|
temperature = float(self._get_field("temperature", False, "0.7"))
|
|
61
65
|
model_id = self._get_field("modelId", False, default_field_value=DEFAULT_MODEL)
|
|
62
|
-
|
|
66
|
+
max_tokens = int(self._get_field("max_tokens", False, "1024"))
|
|
67
|
+
config = {"temperature": temperature, "model": model_id, "max_tokens": max_tokens}
|
|
63
68
|
result = writer.ai.complete(prompt, config).strip()
|
|
64
69
|
self.result = result
|
|
65
70
|
self.outcome = "success"
|
|
66
71
|
except BaseException as e:
|
|
67
72
|
self.outcome = "error"
|
|
68
|
-
raise e
|
|
73
|
+
raise e
|