writer 0.8.3rc21__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.
Files changed (265) hide show
  1. writer/ai/__init__.py +277 -28
  2. writer/app_runner.py +236 -32
  3. writer/app_templates/default/.wf/components-blueprints_blueprint-0-0decp3w5erhvl0nw.jsonl +11 -0
  4. writer/app_templates/default/.wf/components-page-0-c0f99a9e-5004-4e75-a6c6-36f17490b134.jsonl +22 -10
  5. writer/app_templates/default/.wf/components-root.jsonl +1 -1
  6. writer/app_templates/default/.wf/components-workflows_root.jsonl +1 -0
  7. writer/app_templates/default/.wf/components-workflows_workflow-0-lfltcky7l1fsm6j2.jsonl +1 -0
  8. writer/app_templates/default/.wf/metadata.json +1 -1
  9. writer/app_templates/default/README.md +3 -0
  10. writer/app_templates/default/main.py +8 -5
  11. writer/app_templates/default/requirements.txt +1 -0
  12. writer/app_templates/default/static/agent_builder_demo.png +0 -0
  13. writer/app_templates/hello/main.py +3 -0
  14. writer/auth.py +7 -2
  15. writer/autogen.py +26 -9
  16. writer/blocks/__init__.py +21 -1
  17. writer/blocks/addtostatelist.py +5 -4
  18. writer/blocks/apitrigger.py +45 -0
  19. writer/blocks/base_block.py +134 -14
  20. writer/blocks/changepage.py +1 -1
  21. writer/blocks/code.py +27 -11
  22. writer/blocks/crontrigger.py +49 -0
  23. writer/blocks/foreach.py +3 -3
  24. writer/blocks/httprequest.py +8 -24
  25. writer/blocks/ifelse.py +71 -0
  26. writer/blocks/logmessage.py +2 -2
  27. writer/blocks/returnvalue.py +2 -2
  28. writer/blocks/runblueprint.py +2 -2
  29. writer/blocks/setstate.py +5 -5
  30. writer/blocks/sharedblueprint.py +86 -0
  31. writer/blocks/writeraddchatmessage.py +45 -7
  32. writer/blocks/writeraddtokg.py +31 -4
  33. writer/blocks/writeraskkg.py +27 -34
  34. writer/blocks/writerchat.py +14 -9
  35. writer/blocks/writerchatreply.py +279 -0
  36. writer/blocks/writerchatreplywithtoolconfig.py +393 -0
  37. writer/blocks/writerclassification.py +42 -5
  38. writer/blocks/writercompletion.py +4 -4
  39. writer/blocks/writerfileapi.py +4 -4
  40. writer/blocks/writerinitchat.py +5 -4
  41. writer/blocks/writerkeyvaluestorage.py +106 -0
  42. writer/blocks/writernocodeapp.py +4 -4
  43. writer/blocks/writerparsepdf.py +8 -6
  44. writer/blocks/writerstructuredoutput.py +105 -0
  45. writer/blocks/writertoolcalling.py +106 -51
  46. writer/blocks/writervision.py +141 -0
  47. writer/blocks/writerwebsearch.py +175 -0
  48. writer/blueprints.py +715 -251
  49. writer/command_line.py +52 -16
  50. writer/core.py +200 -35
  51. writer/core_ui.py +4 -0
  52. writer/evaluator.py +38 -24
  53. writer/journal.py +227 -0
  54. writer/keyvalue_storage.py +93 -0
  55. writer/logs.py +277 -0
  56. writer/serve.py +402 -198
  57. writer/ss_types.py +41 -0
  58. writer/static/assets/BaseMarkdown-Wrvby5J8.js +1 -0
  59. writer/static/assets/BlueprintToolbar-BuXNRxWT.js +1 -0
  60. writer/static/assets/BlueprintToolbar-wpfX0jo_.css +1 -0
  61. writer/static/assets/BuilderApp-PTOI76jZ.js +8 -0
  62. writer/static/assets/BuilderApp-WimUfNZr.css +1 -0
  63. writer/static/assets/BuilderApplicationSelect-DXzy4e_h.js +7 -0
  64. writer/static/assets/BuilderApplicationSelect-XaM1D5fv.css +1 -0
  65. writer/static/assets/BuilderBlueprintLibraryPanel-Ckrhknlh.css +1 -0
  66. writer/static/assets/BuilderBlueprintLibraryPanel-DBDzhTlc.js +1 -0
  67. writer/static/assets/{BuilderEmbeddedCodeEditor-DiDqfWdt.css → BuilderEmbeddedCodeEditor-B0bcjlhk.css} +1 -1
  68. writer/static/assets/{BuilderEmbeddedCodeEditor-CbK-r9w6.js → BuilderEmbeddedCodeEditor-Dn7eDICN.js} +7 -7
  69. writer/static/assets/BuilderGraphSelect-C-LRsO8W.js +7 -0
  70. writer/static/assets/BuilderGraphSelect-D7B61d5s.css +1 -0
  71. writer/static/assets/{BuilderInsertionLabel-CDlWX-mE.js → BuilderInsertionLabel-BhyL9wgn.js} +1 -1
  72. writer/static/assets/{BuilderInsertionOverlay-B7-TsHNC.js → BuilderInsertionOverlay-MkAIVruY.js} +1 -1
  73. writer/static/assets/BuilderJournal-A0LcEwGI.js +7 -0
  74. writer/static/assets/BuilderJournal-DHv3Pvvm.css +1 -0
  75. writer/static/assets/BuilderModelSelect-CdSo_sih.js +7 -0
  76. writer/static/assets/BuilderModelSelect-Dc4IPLp2.css +1 -0
  77. writer/static/assets/BuilderSettings-BDwZBveu.js +16 -0
  78. writer/static/assets/BuilderSettings-lZkOXEYw.css +1 -0
  79. writer/static/assets/BuilderSettingsArtifactAPITriggerDetails-3O6jKBXD.js +4 -0
  80. writer/static/assets/BuilderSettingsArtifactAPITriggerDetails-DnX66iRg.css +1 -0
  81. writer/static/assets/BuilderSettingsDeploySharedBlueprint-BR_3ptsd.js +1 -0
  82. writer/static/assets/BuilderSettingsDeploySharedBlueprint-KJTl8gxP.css +1 -0
  83. writer/static/assets/BuilderSettingsHandlers-CBtEQFSo.js +1 -0
  84. writer/static/assets/BuilderSettingsHandlers-DJPeASfz.css +1 -0
  85. writer/static/assets/BuilderSidebarComponentTree-DLltgas5.js +1 -0
  86. writer/static/assets/BuilderSidebarComponentTree-DYu1F793.css +1 -0
  87. writer/static/assets/BuilderSidebarToolkit-CApZNTAq.js +7 -0
  88. writer/static/assets/BuilderSidebarToolkit-CwqbjRv8.css +1 -0
  89. writer/static/assets/BuilderTemplateEditor-CYSDeWgV.css +1 -0
  90. writer/static/assets/BuilderTemplateEditor-DnRDRcA0.js +87 -0
  91. writer/static/assets/BuilderVault-2vGoV0sx.js +1 -0
  92. writer/static/assets/BuilderVault-Cx6oQSES.css +1 -0
  93. writer/static/assets/ComponentRenderer-72hqvEvI.css +1 -0
  94. writer/static/assets/ComponentRenderer-D4Pj1i3s.js +1 -0
  95. writer/static/assets/SharedCopyClipboardButton-BipJKGtz.css +1 -0
  96. writer/static/assets/SharedCopyClipboardButton-DNI9kLe6.js +1 -0
  97. writer/static/assets/WdsCheckbox-DKvpPA4D.css +1 -0
  98. writer/static/assets/WdsCheckbox-edQcn1cf.js +1 -0
  99. writer/static/assets/WdsDropdownMenu-CzzPN9Wg.css +1 -0
  100. writer/static/assets/WdsDropdownMenu-DQnrRBNV.js +1 -0
  101. writer/static/assets/WdsFieldWrapper-Cmufx5Nj.js +1 -0
  102. writer/static/assets/WdsFieldWrapper-CsemOh8D.css +1 -0
  103. writer/static/assets/WdsTabs-DKj7BqI0.css +1 -0
  104. writer/static/assets/WdsTabs-DcfY_zn5.js +1 -0
  105. writer/static/assets/{art-paper-WsD9P5Lu.svg → art-paper-D70v1WMA.svg} +0 -1
  106. writer/static/assets/{cssMode-6B7VrieQ.js → cssMode-BYq4oZGq.js} +1 -1
  107. writer/static/assets/{freemarker2-Dy54TNCQ.js → freemarker2-CnNourkO.js} +1 -1
  108. writer/static/assets/{handlebars-BnWqX2x5.js → handlebars-Bm22yapJ.js} +1 -1
  109. writer/static/assets/{html-CIuj_eOg.js → html-CAKAfoZF.js} +1 -1
  110. writer/static/assets/{htmlMode-5fUQN2xJ.js → htmlMode-BGZ97n-V.js} +1 -1
  111. writer/static/assets/index-BKNuk68o.css +1 -0
  112. writer/static/assets/index-BQNXU3IR.js +17 -0
  113. writer/static/assets/index-DHXAd5Yn.js +4 -0
  114. writer/static/assets/index-Zki-pfO-.js +8525 -0
  115. writer/static/assets/index.esm-B1ZQtduY.js +17 -0
  116. writer/static/assets/{javascript-PLzaI1wY.js → javascript-X1f02eyK.js} +1 -1
  117. writer/static/assets/{jsonMode-CzZfZ4-D.js → jsonMode-hT0bNgT8.js} +1 -1
  118. writer/static/assets/{liquid-Cy21vWLb.js → liquid-KmCCiJw2.js} +1 -1
  119. writer/static/assets/{mapbox-gl-BjXsUCYi.js → mapbox-gl-C0cyFYYW.js} +1 -1
  120. writer/static/assets/{mdx-Cgik3q5p.js → mdx-DtRFauUw.js} +1 -1
  121. writer/static/assets/pdf-B6-yWJ-Y.js +12 -0
  122. writer/static/assets/pdf.worker.min-CyUfim15.mjs +21 -0
  123. writer/static/assets/{plotly.min-Dk-1ahEu.js → plotly.min-DutuuatZ.js} +1 -1
  124. writer/static/assets/{python-h6gjz_bN.js → python-DVhxg746.js} +1 -1
  125. writer/static/assets/{razor-BQ1k9241.js → razor-DR5Ns_BC.js} +1 -1
  126. writer/static/assets/{tsMode-BaBWt05D.js → tsMode-BNUEZzir.js} +1 -1
  127. writer/static/assets/{typescript-B42-gYGT.js → typescript-CRVt7Hx0.js} +1 -1
  128. writer/static/assets/useBlueprintRun-C00bCxh-.js +1 -0
  129. writer/static/assets/useKeyValueEditor-nDmI7cTJ.js +1 -0
  130. writer/static/assets/useListResources-DLkZhRSJ.js +1 -0
  131. writer/static/assets/{xml-BOez4Prd.js → xml-C_6-t1tb.js} +1 -1
  132. writer/static/assets/{yaml-BQhoEOIz.js → yaml-DIw8G7jk.js} +1 -1
  133. writer/static/components/annotatedtext.svg +3 -3
  134. writer/static/components/avatar.svg +3 -3
  135. writer/static/components/blueprints_addtostatelist.svg +3 -3
  136. writer/static/components/blueprints_apitrigger.svg +4 -0
  137. writer/static/components/blueprints_category_Logic.svg +3 -3
  138. writer/static/components/blueprints_category_Other.svg +3 -3
  139. writer/static/components/blueprints_category_Writer.svg +24 -5
  140. writer/static/components/blueprints_code.svg +6 -6
  141. writer/static/components/blueprints_crontrigger.svg +6 -0
  142. writer/static/components/blueprints_foreach.svg +3 -3
  143. writer/static/components/blueprints_httprequest.svg +6 -6
  144. writer/static/components/blueprints_logmessage.svg +10 -3
  145. writer/static/components/blueprints_parsejson.svg +3 -3
  146. writer/static/components/blueprints_returnvalue.svg +3 -3
  147. writer/static/components/blueprints_runblueprint.svg +3 -3
  148. writer/static/components/blueprints_setstate.svg +3 -3
  149. writer/static/components/blueprints_writeraddchatmessage.svg +14 -6
  150. writer/static/components/blueprints_writeraddtokg.svg +14 -6
  151. writer/static/components/blueprints_writerchatreply.svg +19 -0
  152. writer/static/components/blueprints_writerclassification.svg +23 -8
  153. writer/static/components/blueprints_writercompletion.svg +13 -5
  154. writer/static/components/blueprints_writernocodeapp.svg +13 -3
  155. writer/static/components/button.svg +3 -3
  156. writer/static/components/category_Content.svg +3 -3
  157. writer/static/components/category_Embed.svg +3 -3
  158. writer/static/components/category_Input.svg +4 -4
  159. writer/static/components/category_Layout.svg +6 -6
  160. writer/static/components/category_Other.svg +3 -3
  161. writer/static/components/chatbot.svg +3 -3
  162. writer/static/components/checkboxinput.svg +3 -3
  163. writer/static/components/colorinput.svg +6 -6
  164. writer/static/components/column.svg +3 -3
  165. writer/static/components/columns.svg +3 -3
  166. writer/static/components/dataframe.svg +3 -3
  167. writer/static/components/dateinput.svg +3 -3
  168. writer/static/components/dropdowninput.svg +4 -4
  169. writer/static/components/fileinput.svg +3 -3
  170. writer/static/components/googlemaps.svg +3 -3
  171. writer/static/components/heading.svg +6 -6
  172. writer/static/components/horizontalstack.svg +3 -3
  173. writer/static/components/html.svg +6 -6
  174. writer/static/components/icon.svg +3 -3
  175. writer/static/components/iframe.svg +3 -3
  176. writer/static/components/image.svg +10 -3
  177. writer/static/components/jsonviewer.svg +3 -3
  178. writer/static/components/link.svg +7 -7
  179. writer/static/components/mapbox.svg +3 -3
  180. writer/static/components/message.svg +3 -3
  181. writer/static/components/metric.svg +3 -3
  182. writer/static/components/multiselectinput.svg +3 -3
  183. writer/static/components/numberinput.svg +3 -3
  184. writer/static/components/pagination.svg +3 -3
  185. writer/static/components/pdf.svg +3 -3
  186. writer/static/components/plotlygraph.svg +6 -6
  187. writer/static/components/progressbar.svg +4 -4
  188. writer/static/components/radioinput.svg +3 -3
  189. writer/static/components/rangeinput.svg +3 -3
  190. writer/static/components/ratinginput.svg +3 -3
  191. writer/static/components/repeater.svg +3 -3
  192. writer/static/components/reuse.svg +3 -3
  193. writer/static/components/section.svg +3 -3
  194. writer/static/components/selectinput.svg +4 -4
  195. writer/static/components/separator.svg +3 -3
  196. writer/static/components/sidebar.svg +3 -3
  197. writer/static/components/sliderinput.svg +3 -3
  198. writer/static/components/step.svg +3 -3
  199. writer/static/components/steps.svg +3 -3
  200. writer/static/components/switchinput.svg +3 -3
  201. writer/static/components/tab.svg +3 -3
  202. writer/static/components/tabs.svg +3 -3
  203. writer/static/components/tags.svg +10 -3
  204. writer/static/components/text.svg +3 -3
  205. writer/static/components/textareainput.svg +10 -3
  206. writer/static/components/textinput.svg +3 -3
  207. writer/static/components/timeinput.svg +3 -3
  208. writer/static/components/timer.svg +3 -3
  209. writer/static/components/videoplayer.svg +10 -3
  210. writer/static/components/webcamcapture.svg +3 -3
  211. writer/static/index.html +3 -11
  212. writer/static/status/cancelled.svg +5 -0
  213. writer/static/status/skipped.svg +4 -0
  214. writer/static/status/stopped.svg +4 -0
  215. writer/sync.py +431 -0
  216. writer/ui.py +49 -41
  217. writer/vault.py +48 -0
  218. writer/wf_project.py +5 -5
  219. writer-1.25.1rc1.dist-info/METADATA +92 -0
  220. writer-1.25.1rc1.dist-info/RECORD +382 -0
  221. {writer-0.8.3rc21.dist-info → writer-1.25.1rc1.dist-info}/WHEEL +1 -1
  222. writer/app_templates/default/.wf/components-blueprints_blueprint-0-t84xyhxau9ej3823.jsonl +0 -18
  223. writer/app_templates/default/static/welcome.svg +0 -40
  224. writer/static/assets/BaseMarkdown-BH_nSq9H.js +0 -1
  225. writer/static/assets/BlueprintToolbar-BO-WERxH.css +0 -1
  226. writer/static/assets/BlueprintToolbar-CHWL-rTm.js +0 -1
  227. writer/static/assets/BuilderApp-0XXiQ2l7.js +0 -7
  228. writer/static/assets/BuilderApp-CAhvLO4a.css +0 -1
  229. writer/static/assets/BuilderApplicationSelect-CwzU4F1-.js +0 -7
  230. writer/static/assets/BuilderApplicationSelect-DYYFtqjx.css +0 -1
  231. writer/static/assets/BuilderGraphSelect-CVO4gzts.css +0 -1
  232. writer/static/assets/BuilderGraphSelect-DV5Xy0HK.js +0 -7
  233. writer/static/assets/BuilderInstanceTracker-BECcXNnW.css +0 -1
  234. writer/static/assets/BuilderInstanceTracker-Dr0XhpSH.js +0 -1
  235. writer/static/assets/BuilderModelSelect-QHUGd86u.css +0 -1
  236. writer/static/assets/BuilderModelSelect-ow0XEf2t.js +0 -7
  237. writer/static/assets/BuilderSettings-C2WRfSor.css +0 -1
  238. writer/static/assets/BuilderSettings-D5bjbcWj.js +0 -24
  239. writer/static/assets/BuilderSettingsHandlers-1QLaHR8J.css +0 -1
  240. writer/static/assets/BuilderSettingsHandlers-j1aMAV4J.js +0 -1
  241. writer/static/assets/BuilderSidebarComponentTree-0YajaJke.css +0 -1
  242. writer/static/assets/BuilderSidebarComponentTree-CtaOZfpV.js +0 -1
  243. writer/static/assets/BuilderSidebarPanel-BMJVzhd3.js +0 -1
  244. writer/static/assets/BuilderSidebarPanel-BrLsNxVM.css +0 -1
  245. writer/static/assets/BuilderSidebarToolkit-BbjOOp8E.js +0 -1
  246. writer/static/assets/BuilderSidebarToolkit-BvZDShKD.css +0 -1
  247. writer/static/assets/ComponentRenderer-B76bKRZO.css +0 -1
  248. writer/static/assets/ComponentRenderer-CZs4z773.js +0 -1
  249. writer/static/assets/SharedMoreDropdown-BWKlox8E.css +0 -1
  250. writer/static/assets/SharedMoreDropdown-DKv_HNef.js +0 -7
  251. writer/static/assets/WdsDropdownMenu-C1UyKOJR.css +0 -1
  252. writer/static/assets/WdsDropdownMenu-CGiATY2E.js +0 -1
  253. writer/static/assets/WdsLoaderDots-qdyk2N-2.js +0 -1
  254. writer/static/assets/index-BJMAe9SN.js +0 -8
  255. writer/static/assets/index-CPCeQU9V.css +0 -1
  256. writer/static/assets/index-ChWW_c_j.js +0 -439
  257. writer/static/assets/instancePath-BsbOTTI8.js +0 -1
  258. writer/static/assets/material-symbols-outlined-latin-wght-normal-DuE-q1Ez.woff2 +0 -0
  259. writer/static/assets/useBlueprintRun-CBOvzWTA.js +0 -1
  260. writer/static/assets/useComponentDescription-FHKxu8gg.js +0 -1
  261. writer/static/assets/useListResources-BpMgq7XI.js +0 -1
  262. writer-0.8.3rc21.dist-info/METADATA +0 -117
  263. writer-0.8.3rc21.dist-info/RECORD +0 -342
  264. {writer-0.8.3rc21.dist-info → writer-1.25.1rc1.dist-info}/entry_points.txt +0 -0
  265. {writer-0.8.3rc21.dist-info → writer-1.25.1rc1.dist-info/licenses}/LICENSE.txt +0 -0
@@ -1,4 +1,5 @@
1
1
  import json
2
+ import re
2
3
 
3
4
  from writer.abstract import register_abstract_template
4
5
  from writer.blocks.base_block import WriterBlock
@@ -27,7 +28,7 @@ class WriterClassification(WriterBlock):
27
28
  "name": "Categories",
28
29
  "type": "Key-Value",
29
30
  "default": "{}",
30
- "desc": "The keys should be the categories you want to classify the text in, for example 'valid' and 'invalid', and the values the criteria for each category.",
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.",
31
32
  },
32
33
  "additionalContext": {
33
34
  "name": "Additional context",
@@ -40,7 +41,7 @@ class WriterClassification(WriterBlock):
40
41
  "category": {"field": "categories", "style": "dynamic"},
41
42
  "error": {
42
43
  "name": "Error",
43
- "description": "If the function raises an Exception.",
44
+ "description": "There was an error classifying the text.",
44
45
  "style": "error",
45
46
  },
46
47
  },
@@ -55,6 +56,12 @@ class WriterClassification(WriterBlock):
55
56
  text = self._get_field("text", required=True)
56
57
  additional_context = self._get_field("additionalContext")
57
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)}")
58
65
 
59
66
  config = {}
60
67
 
@@ -73,9 +80,39 @@ CONTENT:
73
80
  ------
74
81
  { text }
75
82
  """
76
- result = writer.ai.complete(prompt, config).strip()
77
- self.result = result
78
- self.outcome = f"category_{result}"
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}"
79
116
  except BaseException as e:
80
117
  self.outcome = "error"
81
118
  raise e
@@ -2,7 +2,7 @@ from writer.abstract import register_abstract_template
2
2
  from writer.blocks.base_block import WriterBlock
3
3
  from writer.ss_types import AbstractTemplate
4
4
 
5
- DEFAULT_MODEL = "palmyra-x-004"
5
+ DEFAULT_MODEL = "palmyra-x5"
6
6
 
7
7
  class WriterCompletion(WriterBlock):
8
8
  @classmethod
@@ -36,19 +36,19 @@ class WriterCompletion(WriterBlock):
36
36
  "validator": {
37
37
  "type": "number",
38
38
  "minimum": 1,
39
- "maximum": 8192,
39
+ "maximum": 16384,
40
40
  }
41
41
  }
42
42
  },
43
43
  "outs": {
44
44
  "success": {
45
45
  "name": "Success",
46
- "description": "If the function doesn't raise an Exception.",
46
+ "description": "Text was generated successfully.",
47
47
  "style": "success",
48
48
  },
49
49
  "error": {
50
50
  "name": "Error",
51
- "description": "If the function raises an Exception.",
51
+ "description": "There was an error generating text.",
52
52
  "style": "error",
53
53
  },
54
54
  },
@@ -13,7 +13,7 @@ class WriterUploadFile(WriterBlock):
13
13
  register_abstract_template(type, AbstractTemplate(
14
14
  baseType="blueprints_node",
15
15
  writer={
16
- "name": "Add files to Writer Cloud",
16
+ "name": "Add files to Writer cloud",
17
17
  "description": "Uploads files to the Writer platform.",
18
18
  "category": "Writer",
19
19
  "fields": {
@@ -21,7 +21,7 @@ class WriterUploadFile(WriterBlock):
21
21
  "name": "Files",
22
22
  "type": "Object",
23
23
  "default": "[]",
24
- "desc": "A list of files to be uploaded and added to the knowledge graph. You can use files uploaded via the File Input component or specify dictionaries with data, type and name.",
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
25
  "validator": {
26
26
  "type": "array"
27
27
  }
@@ -35,7 +35,7 @@ class WriterUploadFile(WriterBlock):
35
35
  },
36
36
  "error": {
37
37
  "name": "Error",
38
- "description": "If the function raises an Exception.",
38
+ "description": "There was an error uploading the files.",
39
39
  "style": "error"
40
40
  }
41
41
  }
@@ -73,7 +73,7 @@ class WriterUploadFile(WriterBlock):
73
73
  "id": file.id,
74
74
  "name": file.name,
75
75
  "status": file.status,
76
- "created_at": file.created_at,
76
+ "created_at": file.created_at.isoformat(),
77
77
  "graph_ids": file.graph_ids
78
78
  })
79
79
  if len(outputs) == 0:
@@ -2,7 +2,7 @@ from writer.abstract import register_abstract_template
2
2
  from writer.blocks.base_block import WriterBlock
3
3
  from writer.ss_types import AbstractTemplate, WriterConfigurationError
4
4
 
5
- DEFAULT_MODEL = "palmyra-x-004"
5
+ DEFAULT_MODEL = "palmyra-x5"
6
6
 
7
7
 
8
8
  class WriterInitChat(WriterBlock):
@@ -16,6 +16,7 @@ class WriterInitChat(WriterBlock):
16
16
  "name": "Start chat conversation",
17
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",
@@ -44,19 +45,19 @@ class WriterInitChat(WriterBlock):
44
45
  "validator": {
45
46
  "type": "number",
46
47
  "minimum": 1,
47
- "maximum": 8192,
48
+ "maximum": 16384,
48
49
  }
49
50
  }
50
51
  },
51
52
  "outs": {
52
53
  "success": {
53
54
  "name": "Success",
54
- "description": "If the function doesn't raise an Exception.",
55
+ "description": "The conversation was initialized.",
55
56
  "style": "success",
56
57
  },
57
58
  "error": {
58
59
  "name": "Error",
59
- "description": "If the function raises an Exception.",
60
+ "description": "There was an error initializing the conversation.",
60
61
  "style": "error",
61
62
  },
62
63
  },
@@ -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}")
@@ -12,8 +12,8 @@ class WriterNoCodeApp(WriterBlock):
12
12
  AbstractTemplate(
13
13
  baseType="blueprints_node",
14
14
  writer={
15
- "name": "AI Studio Agent",
16
- "description": "Runs an Writer AI Studio Agent app by ID.",
15
+ "name": "AI Studio agent",
16
+ "description": "Runs a Writer AI Studio agent app by ID.",
17
17
  "category": "Writer",
18
18
  "fields": {
19
19
  "appId": {
@@ -30,12 +30,12 @@ class WriterNoCodeApp(WriterBlock):
30
30
  "outs": {
31
31
  "success": {
32
32
  "name": "Success",
33
- "description": "If the execution was successful.",
33
+ "description": "The agent ran successfully.",
34
34
  "style": "success",
35
35
  },
36
36
  "error": {
37
37
  "name": "Error",
38
- "description": "If the function raises an Exception.",
38
+ "description": "There was an error running the agent.",
39
39
  "style": "error",
40
40
  },
41
41
  },
@@ -25,23 +25,25 @@ class WriterParsePDFByFileID(WriterBlock):
25
25
  "type": "string",
26
26
  "format": "uuid"
27
27
  }
28
- },
28
+ },
29
29
  "markdown": {
30
- "name": "Use Markdown",
31
- "type": "Text",
30
+ "name": "Enable markdown",
31
+ "type": "Boolean",
32
32
  "default": "yes",
33
- "options": {"yes": "Yes", "no": "No"},
33
+ "validator": {
34
+ "type": "boolean",
35
+ },
34
36
  }
35
37
  },
36
38
  "outs": {
37
39
  "success": {
38
40
  "name": "Success",
39
- "description": "If the execution was successful.",
41
+ "description": "The PDF was parsed successfully.",
40
42
  "style": "success",
41
43
  },
42
44
  "error": {
43
45
  "name": "Error",
44
- "description": "If the function raises an Exception.",
46
+ "description": "There was an error parsing the PDF.",
45
47
  "style": "error",
46
48
  },
47
49
  },
@@ -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