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,123 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
from writer.abstract import register_abstract_template
|
|
5
|
+
from writer.blocks.base_block import WriterBlock
|
|
6
|
+
from writer.ss_types import AbstractTemplate
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class WriterAskGraphQuestion(WriterBlock):
|
|
10
|
+
@classmethod
|
|
11
|
+
def register(cls, type: str):
|
|
12
|
+
super(WriterAskGraphQuestion, cls).register(type)
|
|
13
|
+
register_abstract_template(type, AbstractTemplate(
|
|
14
|
+
baseType="blueprints_node",
|
|
15
|
+
writer={
|
|
16
|
+
"name": "Ask graph question",
|
|
17
|
+
"description": "Asks a natural language question using one or more knowledge graphs and puts the result into a state variable.",
|
|
18
|
+
"category": "Writer",
|
|
19
|
+
"fields": {
|
|
20
|
+
"question": {
|
|
21
|
+
"name": "Question",
|
|
22
|
+
"type": "Text",
|
|
23
|
+
"desc": "The natural language question to ask.",
|
|
24
|
+
"control": "Textarea",
|
|
25
|
+
},
|
|
26
|
+
"useStreaming": {
|
|
27
|
+
"name": "Use streaming",
|
|
28
|
+
"type": "Boolean",
|
|
29
|
+
"default": "yes",
|
|
30
|
+
"validator": {
|
|
31
|
+
"type": "boolean",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
"stateElement": {
|
|
35
|
+
"name": "Link Variable",
|
|
36
|
+
"type": "Binding",
|
|
37
|
+
"desc": "Set the variable here and use it across your agent.",
|
|
38
|
+
},
|
|
39
|
+
"graphIds": {
|
|
40
|
+
"name": "Graph Ids",
|
|
41
|
+
"type": "Graph Ids",
|
|
42
|
+
"desc": "IDs of the graphs to query.",
|
|
43
|
+
"default": "",
|
|
44
|
+
"validator": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"subqueries": {
|
|
49
|
+
"name": "Use subqueries",
|
|
50
|
+
"type": "Boolean",
|
|
51
|
+
"desc": "Enables LLM to ask follow-up questions to the knowledge graph. This improves answers, but may be slower.",
|
|
52
|
+
"default": "yes",
|
|
53
|
+
"validator": {
|
|
54
|
+
"type": "boolean",
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"outs": {
|
|
59
|
+
"success": {
|
|
60
|
+
"name": "Success",
|
|
61
|
+
"description": "Successfully streamed the answer.",
|
|
62
|
+
"style": "success"
|
|
63
|
+
},
|
|
64
|
+
"error": {
|
|
65
|
+
"name": "Error",
|
|
66
|
+
"description": "There was an error answering the question.",
|
|
67
|
+
"style": "error"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
))
|
|
72
|
+
|
|
73
|
+
def run(self):
|
|
74
|
+
try:
|
|
75
|
+
client = self.writer_sdk_client
|
|
76
|
+
|
|
77
|
+
graph_ids = self._get_field(
|
|
78
|
+
"graphIds", as_json=True, required=True)
|
|
79
|
+
use_streaming = self._get_field(
|
|
80
|
+
"useStreaming", False, "yes") == "yes"
|
|
81
|
+
if isinstance(graph_ids, str):
|
|
82
|
+
graph_ids = [graph_ids]
|
|
83
|
+
elif not isinstance(graph_ids, list):
|
|
84
|
+
raise ValueError(
|
|
85
|
+
"graphIds must be a string or a list of strings")
|
|
86
|
+
if len(graph_ids) == 0:
|
|
87
|
+
raise ValueError("graphIds must not be empty")
|
|
88
|
+
|
|
89
|
+
question = self._get_field("question", required=True)
|
|
90
|
+
state_element = self._get_field("stateElement", required=False)
|
|
91
|
+
if not state_element and use_streaming:
|
|
92
|
+
raise ValueError(
|
|
93
|
+
"A state element must be provided when using streaming.")
|
|
94
|
+
subqueries = self._get_field(
|
|
95
|
+
"subqueries", default_field_value="yes") == "yes"
|
|
96
|
+
|
|
97
|
+
answer_so_far = ""
|
|
98
|
+
|
|
99
|
+
response = client.graphs.question(
|
|
100
|
+
graph_ids=graph_ids,
|
|
101
|
+
question=question,
|
|
102
|
+
stream=use_streaming,
|
|
103
|
+
subqueries=subqueries
|
|
104
|
+
)
|
|
105
|
+
if use_streaming:
|
|
106
|
+
for chunk in response:
|
|
107
|
+
try:
|
|
108
|
+
delta = chunk.model_extra.get("answer", "")
|
|
109
|
+
answer_so_far += delta
|
|
110
|
+
self._set_state(state_element, answer_so_far)
|
|
111
|
+
except json.JSONDecodeError:
|
|
112
|
+
logging.error(
|
|
113
|
+
"Could not parse stream chunk from graph.question")
|
|
114
|
+
else:
|
|
115
|
+
answer_so_far = response.answer
|
|
116
|
+
self._set_state(state_element, answer_so_far)
|
|
117
|
+
|
|
118
|
+
self.result = answer_so_far
|
|
119
|
+
self.outcome = "success"
|
|
120
|
+
|
|
121
|
+
except BaseException as e:
|
|
122
|
+
self.outcome = "error"
|
|
123
|
+
raise e
|
writer/blocks/writerchat.py
CHANGED
|
@@ -1,80 +1,93 @@
|
|
|
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 WriterChat(
|
|
7
|
-
|
|
6
|
+
class WriterChat(WriterBlock):
|
|
8
7
|
@classmethod
|
|
9
8
|
def register(cls, type: str):
|
|
10
9
|
super(WriterChat, 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
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"name": "Tools",
|
|
42
|
-
"field": "tools",
|
|
43
|
-
"description": "Run associated tools.",
|
|
44
|
-
"style": "dynamic"
|
|
10
|
+
register_abstract_template(
|
|
11
|
+
type,
|
|
12
|
+
AbstractTemplate(
|
|
13
|
+
baseType="blueprints_node",
|
|
14
|
+
writer={
|
|
15
|
+
"name": "Generate chat reply",
|
|
16
|
+
"description": "Generates an AI chat response using the full conversation history. Requires prior messages.",
|
|
17
|
+
"category": "Writer",
|
|
18
|
+
"deprecated": True,
|
|
19
|
+
"fields": {
|
|
20
|
+
"conversationStateElement": {
|
|
21
|
+
"name": "Conversation state element",
|
|
22
|
+
"desc": "The variable that has your conversation object.",
|
|
23
|
+
"type": "Binding",
|
|
24
|
+
},
|
|
25
|
+
"useStreaming": {
|
|
26
|
+
"name": "Use streaming",
|
|
27
|
+
"type": "Boolean",
|
|
28
|
+
"default": "yes",
|
|
29
|
+
"validator": {
|
|
30
|
+
"type": "boolean",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
"tools": {
|
|
34
|
+
"name": "Tools",
|
|
35
|
+
"type": "Tools",
|
|
36
|
+
"default": "{}",
|
|
37
|
+
"init": "",
|
|
38
|
+
"category": "Tools",
|
|
39
|
+
},
|
|
45
40
|
},
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
|
|
41
|
+
"outs": {
|
|
42
|
+
"tools": {
|
|
43
|
+
"name": "Tools",
|
|
44
|
+
"field": "tools",
|
|
45
|
+
"description": "Run associated tools.",
|
|
46
|
+
"style": "dynamic",
|
|
47
|
+
},
|
|
48
|
+
"success": {
|
|
49
|
+
"name": "Success",
|
|
50
|
+
"description": "The reply was generated successfully.",
|
|
51
|
+
"style": "success",
|
|
52
|
+
},
|
|
53
|
+
"error": {
|
|
54
|
+
"name": "Error",
|
|
55
|
+
"description": "There was an error generating the reply.",
|
|
56
|
+
"style": "error",
|
|
57
|
+
},
|
|
55
58
|
},
|
|
56
59
|
},
|
|
57
|
-
|
|
58
|
-
)
|
|
60
|
+
),
|
|
61
|
+
)
|
|
59
62
|
|
|
60
63
|
def _make_callable(self, tool_name: str):
|
|
61
64
|
def callable(**args):
|
|
62
65
|
expanded_execution_environment = self.execution_environment | args
|
|
63
|
-
return_value = self.runner.run_branch(
|
|
66
|
+
return_value = self.runner.run_branch(
|
|
67
|
+
self.component.id,
|
|
68
|
+
f"tools_{tool_name}",
|
|
69
|
+
expanded_execution_environment,
|
|
70
|
+
f"Blueprint branch execution (chat tool {tool_name})",
|
|
71
|
+
)
|
|
64
72
|
|
|
65
73
|
if return_value is None:
|
|
66
74
|
self.outcome = "error"
|
|
67
|
-
raise ValueError(
|
|
75
|
+
raise ValueError(
|
|
76
|
+
f'No value has been returned for the outcome branch "{tool_name}". Use the block "Return value" to specify one.'
|
|
77
|
+
)
|
|
68
78
|
|
|
69
79
|
return return_value
|
|
80
|
+
|
|
70
81
|
return callable
|
|
71
82
|
|
|
72
83
|
def run(self):
|
|
73
84
|
try:
|
|
74
85
|
import writer.ai
|
|
75
86
|
|
|
76
|
-
conversation_state_element = self._get_field(
|
|
77
|
-
|
|
87
|
+
conversation_state_element = self._get_field(
|
|
88
|
+
"conversationStateElement", required=True)
|
|
89
|
+
use_streaming = self._get_field(
|
|
90
|
+
"useStreaming", False, "yes") == "yes"
|
|
78
91
|
tools_raw = self._get_field("tools", True)
|
|
79
92
|
tools = []
|
|
80
93
|
|
|
@@ -87,21 +100,27 @@ class WriterChat(WorkflowBlock):
|
|
|
87
100
|
name=tool_name,
|
|
88
101
|
description=tool_raw.get("description"),
|
|
89
102
|
callable=self._make_callable(tool_name),
|
|
90
|
-
parameters=tool_raw.get("parameters")
|
|
103
|
+
parameters=tool_raw.get("parameters"),
|
|
91
104
|
)
|
|
92
105
|
elif tool_type == "graph":
|
|
93
|
-
tool =
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
106
|
+
tool = writer.ai.GraphTool(
|
|
107
|
+
type="graph",
|
|
108
|
+
graph_ids=tool_raw.get("graph_ids"),
|
|
109
|
+
subqueries=False,
|
|
110
|
+
description=tool_name,
|
|
111
|
+
)
|
|
97
112
|
else:
|
|
98
113
|
continue
|
|
99
114
|
tools.append(tool)
|
|
100
115
|
|
|
101
|
-
conversation = self.evaluator.evaluate_expression(
|
|
116
|
+
conversation = self.evaluator.evaluate_expression(
|
|
117
|
+
conversation_state_element, self.instance_path, self.execution_environment
|
|
118
|
+
)
|
|
102
119
|
|
|
103
120
|
if conversation is None or not isinstance(conversation, writer.ai.Conversation):
|
|
104
|
-
raise ValueError(
|
|
121
|
+
raise ValueError(
|
|
122
|
+
"The state element specified doesn't contain a conversation. Initialize one using the block 'Start chat conversation'."
|
|
123
|
+
)
|
|
105
124
|
|
|
106
125
|
msg = ""
|
|
107
126
|
if not use_streaming:
|
|
@@ -115,9 +134,9 @@ class WriterChat(WorkflowBlock):
|
|
|
115
134
|
msg += chunk.get("content")
|
|
116
135
|
conversation += chunk
|
|
117
136
|
self._set_state(conversation_state_element, conversation)
|
|
118
|
-
|
|
137
|
+
|
|
119
138
|
self.result = msg
|
|
120
139
|
self.outcome = "success"
|
|
121
140
|
except BaseException as e:
|
|
122
141
|
self.outcome = "error"
|
|
123
|
-
raise e
|
|
142
|
+
raise e
|
|
@@ -0,0 +1,279 @@
|
|
|
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
|
+
|
|
8
|
+
class WriterChatReply(WriterBlock):
|
|
9
|
+
@classmethod
|
|
10
|
+
def register(cls, type: str):
|
|
11
|
+
super(WriterChatReply, cls).register(type)
|
|
12
|
+
register_abstract_template(
|
|
13
|
+
type,
|
|
14
|
+
AbstractTemplate(
|
|
15
|
+
baseType="blueprints_node",
|
|
16
|
+
writer={
|
|
17
|
+
"name": "Chat reply",
|
|
18
|
+
"description": "Initializes conversations, adds messages, and generates replies.",
|
|
19
|
+
"category": "Writer",
|
|
20
|
+
"fields": {
|
|
21
|
+
"conversationStateElement": {
|
|
22
|
+
"name": "Conversation Object",
|
|
23
|
+
"desc": "The variable that has your conversation object.",
|
|
24
|
+
"init": "chat",
|
|
25
|
+
"type": "Binding",
|
|
26
|
+
},
|
|
27
|
+
"systemPrompt": {
|
|
28
|
+
"name": "System prompt",
|
|
29
|
+
"type": "Text",
|
|
30
|
+
"control": "Textarea",
|
|
31
|
+
"default": "",
|
|
32
|
+
"desc": "A system prompt to set the context for the conversation. Can be left empty if conversation is already initialized in state.",
|
|
33
|
+
},
|
|
34
|
+
"message": {
|
|
35
|
+
"name": "Message",
|
|
36
|
+
"type": "Object",
|
|
37
|
+
"init": '{ "role": "user", "content": "Hello" }',
|
|
38
|
+
"desc": "A message object. Content can be text string or array of objects for multimodal (text + images) with X5 model.",
|
|
39
|
+
"validator": {
|
|
40
|
+
"type": "object",
|
|
41
|
+
"properties": {
|
|
42
|
+
"role": {"type": "string"},
|
|
43
|
+
"content": {
|
|
44
|
+
"oneOf": [
|
|
45
|
+
{"type": "string"},
|
|
46
|
+
{
|
|
47
|
+
"type": "array",
|
|
48
|
+
"items": {
|
|
49
|
+
"oneOf": [
|
|
50
|
+
{
|
|
51
|
+
"type": "object",
|
|
52
|
+
"properties": {
|
|
53
|
+
"type": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"enum": ["text"],
|
|
56
|
+
},
|
|
57
|
+
"text": {"type": "string"},
|
|
58
|
+
},
|
|
59
|
+
"required": ["type", "text"],
|
|
60
|
+
"additionalProperties": False,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"type": "object",
|
|
64
|
+
"properties": {
|
|
65
|
+
"type": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"enum": ["image_url"],
|
|
68
|
+
},
|
|
69
|
+
"image_url": {
|
|
70
|
+
"type": "object",
|
|
71
|
+
"properties": {
|
|
72
|
+
"url": {"type": "string"}
|
|
73
|
+
},
|
|
74
|
+
"required": ["url"],
|
|
75
|
+
"additionalProperties": False,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
"required": ["type", "image_url"],
|
|
79
|
+
"additionalProperties": False,
|
|
80
|
+
},
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
"additionalProperties": False,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
"generateReply": {
|
|
91
|
+
"name": "Generate reply",
|
|
92
|
+
"type": "Boolean",
|
|
93
|
+
"default": "yes",
|
|
94
|
+
"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.",
|
|
95
|
+
"validator": {
|
|
96
|
+
"type": "boolean",
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
"initModelId": {
|
|
100
|
+
"name": "Initial model",
|
|
101
|
+
"type": "Model Id",
|
|
102
|
+
"default": DEFAULT_MODEL,
|
|
103
|
+
},
|
|
104
|
+
"initTemperature": {
|
|
105
|
+
"name": "Initial temperature",
|
|
106
|
+
"type": "Number",
|
|
107
|
+
"default": "0.7",
|
|
108
|
+
"validator": {
|
|
109
|
+
"type": "number",
|
|
110
|
+
"minimum": 0,
|
|
111
|
+
"maximum": 2,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
"initMaxTokens": {
|
|
115
|
+
"name": "Initial max tokens",
|
|
116
|
+
"type": "Number",
|
|
117
|
+
"default": "1024",
|
|
118
|
+
"validator": {
|
|
119
|
+
"type": "number",
|
|
120
|
+
"minimum": 1,
|
|
121
|
+
"maximum": 16384,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
"useStreaming": {
|
|
125
|
+
"name": "Use streaming",
|
|
126
|
+
"type": "Boolean",
|
|
127
|
+
"default": "yes",
|
|
128
|
+
"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.",
|
|
129
|
+
"validator": {
|
|
130
|
+
"type": "boolean",
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
"tools": {
|
|
134
|
+
"name": "Tools",
|
|
135
|
+
"type": "Tools",
|
|
136
|
+
"default": "{}",
|
|
137
|
+
"init": "",
|
|
138
|
+
"category": "Tools",
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
"outs": {
|
|
142
|
+
"tools": {
|
|
143
|
+
"name": "Tools",
|
|
144
|
+
"field": "tools",
|
|
145
|
+
"description": "Run associated tools.",
|
|
146
|
+
"style": "dynamic",
|
|
147
|
+
},
|
|
148
|
+
"success": {
|
|
149
|
+
"name": "Success",
|
|
150
|
+
"description": "The reply was generated successfully.",
|
|
151
|
+
"style": "success",
|
|
152
|
+
},
|
|
153
|
+
"error": {
|
|
154
|
+
"name": "Error",
|
|
155
|
+
"description": "There was an error generating the reply.",
|
|
156
|
+
"style": "error",
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
),
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
def _make_callable(self, tool_name: str):
|
|
164
|
+
def callable(**args):
|
|
165
|
+
expanded_execution_environment = self.execution_environment | args
|
|
166
|
+
return_value = self.runner.run_branch(
|
|
167
|
+
self.component.id,
|
|
168
|
+
f"tools_{tool_name}",
|
|
169
|
+
expanded_execution_environment,
|
|
170
|
+
f"Blueprint branch execution (chat tool {tool_name})",
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
if return_value is None:
|
|
174
|
+
self.outcome = "error"
|
|
175
|
+
raise ValueError(
|
|
176
|
+
f'No value has been returned for the outcome branch "{tool_name}". Use the block "Return value" to specify one.'
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
return return_value
|
|
180
|
+
|
|
181
|
+
return callable
|
|
182
|
+
|
|
183
|
+
def run(self):
|
|
184
|
+
try:
|
|
185
|
+
import writer.ai
|
|
186
|
+
|
|
187
|
+
conversation_state_element = self._get_field("conversationStateElement", required=True)
|
|
188
|
+
message = self._get_field("message", as_json=True)
|
|
189
|
+
generate_reply = self._get_field("generateReply", False, "yes") == "yes"
|
|
190
|
+
|
|
191
|
+
system_prompt = self._get_field("systemPrompt", False, default_field_value=None)
|
|
192
|
+
init_model_id = self._get_field("initModelId", False, default_field_value=DEFAULT_MODEL)
|
|
193
|
+
try:
|
|
194
|
+
init_temperature = float(self._get_field("initTemperature", False, "0.7"))
|
|
195
|
+
init_max_tokens = int(self._get_field("initMaxTokens", False, "1024"))
|
|
196
|
+
except ValueError as e:
|
|
197
|
+
raise WriterConfigurationError(f"Invalid numeric value in configuration: {e}")
|
|
198
|
+
use_streaming = self._get_field("useStreaming", False, "yes") == "yes"
|
|
199
|
+
tools_raw = self._get_field("tools", True)
|
|
200
|
+
tools = []
|
|
201
|
+
|
|
202
|
+
conversation = self.evaluator.evaluate_expression(
|
|
203
|
+
conversation_state_element, self.instance_path, self.execution_environment
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
if conversation is None:
|
|
207
|
+
config = {
|
|
208
|
+
"temperature": init_temperature,
|
|
209
|
+
"model": init_model_id,
|
|
210
|
+
"max_tokens": init_max_tokens,
|
|
211
|
+
}
|
|
212
|
+
conversation = writer.ai.Conversation(
|
|
213
|
+
prompt_or_history=system_prompt, config=config
|
|
214
|
+
)
|
|
215
|
+
self._set_state(conversation_state_element, conversation)
|
|
216
|
+
elif not isinstance(conversation, writer.ai.Conversation):
|
|
217
|
+
raise WriterConfigurationError(
|
|
218
|
+
"The state element specified doesn't contain a Conversation."
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
if message not in (None, {}, ""):
|
|
222
|
+
writer.ai.Conversation.validate_message(message)
|
|
223
|
+
conversation += message
|
|
224
|
+
self._set_state(conversation_state_element, conversation)
|
|
225
|
+
|
|
226
|
+
if not generate_reply:
|
|
227
|
+
# Fast exit if no reply generation is needed
|
|
228
|
+
self.result = ""
|
|
229
|
+
self.outcome = "success"
|
|
230
|
+
return
|
|
231
|
+
|
|
232
|
+
for tool_name, tool_raw in tools_raw.items():
|
|
233
|
+
tool_type = tool_raw.get("type")
|
|
234
|
+
tool = None
|
|
235
|
+
if tool_type == "function":
|
|
236
|
+
tool = writer.ai.FunctionTool(
|
|
237
|
+
type="function",
|
|
238
|
+
name=tool_name,
|
|
239
|
+
description=tool_raw.get("description"),
|
|
240
|
+
callable=self._make_callable(tool_name),
|
|
241
|
+
parameters=tool_raw.get("parameters"),
|
|
242
|
+
)
|
|
243
|
+
elif tool_type == "graph":
|
|
244
|
+
tool = writer.ai.GraphTool(
|
|
245
|
+
type="graph",
|
|
246
|
+
graph_ids=tool_raw.get("graph_ids"),
|
|
247
|
+
subqueries=False,
|
|
248
|
+
description=tool_name,
|
|
249
|
+
)
|
|
250
|
+
elif tool_type == "web_search":
|
|
251
|
+
tool = writer.ai.WebSearchTool(
|
|
252
|
+
type="web_search",
|
|
253
|
+
include_domains=tool_raw.get("include_domains"),
|
|
254
|
+
exclude_domains=tool_raw.get("exclude_domains"),
|
|
255
|
+
include_raw_content=tool_raw.get("include_raw_content"),
|
|
256
|
+
)
|
|
257
|
+
else:
|
|
258
|
+
continue
|
|
259
|
+
tools.append(tool)
|
|
260
|
+
|
|
261
|
+
msg = ""
|
|
262
|
+
if not use_streaming:
|
|
263
|
+
reply = conversation.complete(tools=tools)
|
|
264
|
+
msg = reply.get("content") or ""
|
|
265
|
+
conversation += reply
|
|
266
|
+
self._set_state(conversation_state_element, conversation)
|
|
267
|
+
else:
|
|
268
|
+
for chunk in conversation.stream_complete(tools=tools):
|
|
269
|
+
if chunk.get("content") is None:
|
|
270
|
+
chunk["content"] = ""
|
|
271
|
+
msg += chunk.get("content")
|
|
272
|
+
conversation += chunk
|
|
273
|
+
self._set_state(conversation_state_element, conversation)
|
|
274
|
+
self.result = msg
|
|
275
|
+
self._set_state(conversation_state_element, conversation)
|
|
276
|
+
self.outcome = "success"
|
|
277
|
+
except BaseException as e:
|
|
278
|
+
self.outcome = "error"
|
|
279
|
+
raise e
|