fabricatio 0.2.8.dev0__tar.gz → 0.2.8.dev1__tar.gz

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 (131) hide show
  1. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/PKG-INFO +1 -1
  2. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/pyproject.toml +1 -1
  3. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/actions/article.py +107 -10
  4. fabricatio-0.2.8.dev1/python/fabricatio/capabilities/advanced_judge.py +23 -0
  5. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/capabilities/rating.py +1 -1
  6. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/capabilities/review.py +2 -2
  7. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/models/action.py +1 -1
  8. fabricatio-0.2.8.dev1/python/fabricatio/models/extra/advanced_judge.py +22 -0
  9. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/models/extra/article_base.py +21 -2
  10. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/models/extra/article_essence.py +6 -9
  11. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/models/extra/article_main.py +9 -1
  12. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/models/extra/article_outline.py +9 -0
  13. fabricatio-0.2.8.dev1/templates.tar.gz +0 -0
  14. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/uv.lock +1 -1
  15. fabricatio-0.2.8.dev0/templates.tar.gz +0 -0
  16. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/.github/workflows/build-package.yaml +0 -0
  17. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/.github/workflows/ruff.yaml +0 -0
  18. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/.github/workflows/tests.yaml +0 -0
  19. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/.gitignore +0 -0
  20. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/.python-version +0 -0
  21. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/Cargo.lock +0 -0
  22. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/Cargo.toml +0 -0
  23. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/LICENSE +0 -0
  24. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/Makefile +0 -0
  25. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/README.md +0 -0
  26. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/correct/correct.py +0 -0
  27. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/correct/correct_loop.py +0 -0
  28. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/extract_and_inject/.gitignore +0 -0
  29. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/extract_and_inject/article_rag.py +0 -0
  30. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/extract_and_inject/ask.py +0 -0
  31. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/extract_and_inject/extract_and_inject.py +0 -0
  32. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/extract_article/extract.py +0 -0
  33. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/llm_usages/llm_usage.py +0 -0
  34. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/make_a_rating/rating.py +0 -0
  35. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/make_diary/commits.json +0 -0
  36. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/make_diary/diary.py +0 -0
  37. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/minor/hello_fabricatio.py +0 -0
  38. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/minor/write_a_poem.py +0 -0
  39. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/propose_task/propose.py +0 -0
  40. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/reviewer/review.py +0 -0
  41. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/search_bibtex/.gitignore +0 -0
  42. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/search_bibtex/search.py +0 -0
  43. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/simple_chat/chat.py +0 -0
  44. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/simple_rag/simple_rag.py +0 -0
  45. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/task_handle/handle_task.py +0 -0
  46. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/write_article/.gitignore +0 -0
  47. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/write_article/write_article.py +0 -0
  48. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/write_outline/.gitignore +0 -0
  49. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/write_outline/write_outline.py +0 -0
  50. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/examples/write_outline/write_outline_corrected.py +0 -0
  51. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/__init__.py +0 -0
  52. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/_rust.pyi +0 -0
  53. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/_rust_instances.py +0 -0
  54. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/actions/article_rag.py +0 -0
  55. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/actions/output.py +0 -0
  56. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/actions/rag.py +0 -0
  57. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/capabilities/correct.py +0 -0
  58. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/capabilities/propose.py +0 -0
  59. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/capabilities/rag.py +0 -0
  60. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/capabilities/task.py +0 -0
  61. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/config.py +0 -0
  62. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/core.py +0 -0
  63. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/decorators.py +0 -0
  64. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/fs/__init__.py +0 -0
  65. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/fs/curd.py +0 -0
  66. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/fs/readers.py +0 -0
  67. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/journal.py +0 -0
  68. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/models/events.py +0 -0
  69. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/models/extra/article_proposal.py +0 -0
  70. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/models/generic.py +0 -0
  71. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/models/kwargs_types.py +0 -0
  72. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/models/role.py +0 -0
  73. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/models/task.py +0 -0
  74. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/models/tool.py +0 -0
  75. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/models/usages.py +0 -0
  76. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/models/utils.py +0 -0
  77. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/parser.py +0 -0
  78. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/py.typed +0 -0
  79. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/toolboxes/__init__.py +0 -0
  80. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/toolboxes/arithmetic.py +0 -0
  81. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/toolboxes/fs.py +0 -0
  82. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/workflows/articles.py +0 -0
  83. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/python/fabricatio/workflows/rag.py +0 -0
  84. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/src/bib_tools.rs +0 -0
  85. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/src/hash.rs +0 -0
  86. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/src/hbs_helpers.rs +0 -0
  87. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/src/lib.rs +0 -0
  88. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/src/templates.rs +0 -0
  89. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/as_prompt.hbs +0 -0
  90. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/binary-exploitation-ctf-solver.hbs +0 -0
  91. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/claude-xml.hbs +0 -0
  92. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/clean-up-code.hbs +0 -0
  93. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/co_validation.hbs +0 -0
  94. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/correct.hbs +0 -0
  95. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/create_json_obj.hbs +0 -0
  96. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/cryptography-ctf-solver.hbs +0 -0
  97. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/dependencies.hbs +0 -0
  98. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/document-the-code.hbs +0 -0
  99. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/draft_rating_criteria.hbs +0 -0
  100. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/draft_rating_manual.hbs +0 -0
  101. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/draft_rating_weights_klee.hbs +0 -0
  102. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/draft_tool_usage_code.hbs +0 -0
  103. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/extract_criteria_from_reasons.hbs +0 -0
  104. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/extract_reasons_from_examples.hbs +0 -0
  105. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/find-security-vulnerabilities.hbs +0 -0
  106. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/fix-bugs.hbs +0 -0
  107. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/generic_string.hbs +0 -0
  108. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/improve-performance.hbs +0 -0
  109. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/liststr.hbs +0 -0
  110. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/make_choice.hbs +0 -0
  111. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/make_judgment.hbs +0 -0
  112. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/pathstr.hbs +0 -0
  113. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/rate_fine_grind.hbs +0 -0
  114. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/refactor.hbs +0 -0
  115. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/refined_query.hbs +0 -0
  116. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/retrieved_display.hbs +0 -0
  117. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/reverse-engineering-ctf-solver.hbs +0 -0
  118. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/review_string.hbs +0 -0
  119. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/task_briefing.hbs +0 -0
  120. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/web-ctf-solver.hbs +0 -0
  121. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/write-git-commit.hbs +0 -0
  122. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/write-github-pull-request.hbs +0 -0
  123. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/templates/built-in/write-github-readme.hbs +0 -0
  124. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/tests/test_config.py +0 -0
  125. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/tests/test_models/test_action.py +0 -0
  126. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/tests/test_models/test_advanced.py +0 -0
  127. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/tests/test_models/test_generic.py +0 -0
  128. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/tests/test_models/test_role.py +0 -0
  129. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/tests/test_models/test_task.py +0 -0
  130. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/tests/test_models/test_tool.py +0 -0
  131. {fabricatio-0.2.8.dev0 → fabricatio-0.2.8.dev1}/tests/test_models/test_usages.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fabricatio
3
- Version: 0.2.8.dev0
3
+ Version: 0.2.8.dev1
4
4
  Classifier: License :: OSI Approved :: MIT License
5
5
  Classifier: Programming Language :: Rust
6
6
  Classifier: Programming Language :: Python :: 3.12
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fabricatio"
3
- version = "0.2.8-dev0"
3
+ version = "0.2.8-dev1"
4
4
  description = "A LLM multi-agent framework."
5
5
  readme = "README.md"
6
6
  license = { file = "LICENSE" }
@@ -4,9 +4,11 @@ from asyncio import gather
4
4
  from pathlib import Path
5
5
  from typing import Any, Callable, List, Optional
6
6
 
7
+ from fabricatio.capabilities.advanced_judge import AdvancedJudge
7
8
  from fabricatio.fs import safe_text_read
8
9
  from fabricatio.journal import logger
9
10
  from fabricatio.models.action import Action
11
+ from fabricatio.models.extra.article_base import ArticleRefPatch
10
12
  from fabricatio.models.extra.article_essence import ArticleEssence
11
13
  from fabricatio.models.extra.article_main import Article
12
14
  from fabricatio.models.extra.article_outline import ArticleOutline
@@ -88,10 +90,10 @@ class GenerateArticleProposal(Action):
88
90
  return proposal
89
91
 
90
92
 
91
- class GenerateOutline(Action):
92
- """Generate the article based on the outline."""
93
+ class GenerateInitialOutline(Action):
94
+ """Generate the initial article outline based on the article proposal."""
93
95
 
94
- output_key: str = "article_outline"
96
+ output_key: str = "initial_article_outline"
95
97
  """The key of the output data."""
96
98
 
97
99
  async def _execute(
@@ -99,15 +101,27 @@ class GenerateOutline(Action):
99
101
  article_proposal: ArticleProposal,
100
102
  **_,
101
103
  ) -> Optional[ArticleOutline]:
102
- out = ok(
104
+ return ok(
103
105
  await self.propose(
104
106
  ArticleOutline,
105
107
  article_proposal.as_prompt(),
106
108
  **self.prepend_sys_msg(),
107
109
  ),
108
- "Could not generate the outline.",
110
+ "Could not generate the initial outline.",
109
111
  )
110
112
 
113
+
114
+ class FixIntrospectedErrors(Action):
115
+ """Fix introspected errors in the article outline."""
116
+
117
+ output_key: str = "introspected_errors_fixed_outline"
118
+ """The key of the output data."""
119
+
120
+ async def _execute(
121
+ self,
122
+ article_outline: ArticleOutline,
123
+ **_,
124
+ ) -> Optional[ArticleOutline]:
111
125
  introspect_manual = ok(
112
126
  await self.draft_rating_manual(
113
127
  topic=(
@@ -118,13 +132,13 @@ class GenerateOutline(Action):
118
132
  "Could not generate the rating manual.",
119
133
  )
120
134
 
121
- while pack := out.find_introspected():
135
+ while pack := article_outline.find_introspected():
122
136
  component, err = ok(pack)
123
137
  logger.warning(f"Found introspected error: {err}")
124
138
  corrected = ok(
125
139
  await self.correct_obj(
126
140
  component,
127
- reference=f"# Original Article Outline\n{out.display()}\n# Error Need to be fixed\n{err}",
141
+ reference=f"# Original Article Outline\n{article_outline.display()}\n# Error Need to be fixed\n{err}",
128
142
  topic=intro_topic,
129
143
  rating_manual=introspect_manual,
130
144
  supervisor_check=False,
@@ -133,6 +147,20 @@ class GenerateOutline(Action):
133
147
  )
134
148
  component.update_from(corrected)
135
149
 
150
+ return article_outline
151
+
152
+
153
+ class FixIllegalReferences(Action):
154
+ """Fix illegal references in the article outline."""
155
+
156
+ output_key: str = "illegal_references_fixed_outline"
157
+ """The key of the output data."""
158
+
159
+ async def _execute(
160
+ self,
161
+ article_outline: ArticleOutline,
162
+ **_,
163
+ ) -> Optional[ArticleOutline]:
136
164
  ref_manual = ok(
137
165
  await self.draft_rating_manual(
138
166
  topic=(
@@ -143,19 +171,87 @@ class GenerateOutline(Action):
143
171
  "Could not generate the rating manual.",
144
172
  )
145
173
 
146
- while pack := out.find_illegal_ref():
174
+ while pack := article_outline.find_illegal_ref():
147
175
  ref, err = ok(pack)
148
176
  logger.warning(f"Found illegal referring error: {err}")
149
177
  ok(
150
178
  await self.correct_obj_inplace(
151
179
  ref,
152
- reference=f"# Original Article Outline\n{out.display()}\n# Error Need to be fixed\n{err}\n\n",
180
+ reference=f"# Original Article Outline\n{article_outline.display()}\n# Error Need to be fixed\n{err}\n\n",
153
181
  topic=ref_topic,
154
182
  rating_manual=ref_manual,
155
183
  supervisor_check=False,
156
184
  )
157
185
  )
158
- return out.update_ref(article_proposal)
186
+ return article_outline.update_ref(article_outline)
187
+
188
+
189
+ class TweakOutlineBackwardRef(Action, AdvancedJudge):
190
+ """Tweak the backward references in the article outline.
191
+
192
+ Ensures that the prerequisites of the current chapter are correctly referenced in the `depend_on` field.
193
+ """
194
+
195
+ output_key: str = "article_outline_bw_ref_checked"
196
+
197
+ async def _execute(self, article_outline: ArticleOutline, **cxt) -> ArticleOutline:
198
+ tweak_depend_on_manual = ok(
199
+ await self.draft_rating_manual(
200
+ topic := "Ensure prerequisites are correctly referenced in the `depend_on` field."
201
+ ),
202
+ "Could not generate the rating manual.",
203
+ )
204
+
205
+ for a in article_outline.iter_dfs():
206
+ if await self.evidently_judge(
207
+ f"{article_outline.as_prompt()}\n\n{a.display()}\n"
208
+ f"Does the `{a.__class__.__name__}`'s `depend_on` field need to be extended or tweaked?"
209
+ ):
210
+ patch=ArticleRefPatch.default()
211
+ patch.tweaked=a.depend_on
212
+
213
+ await self.correct_obj_inplace(
214
+ patch,
215
+ topic=topic,
216
+ reference=f"{article_outline.as_prompt()}\nThe Article component whose `depend_on` field needs to be extended or tweaked",
217
+ rating_manual=tweak_depend_on_manual,
218
+ )
219
+
220
+ return article_outline
221
+
222
+
223
+ class TweakOutlineForwardRef(Action, AdvancedJudge):
224
+ """Tweak the forward references in the article outline.
225
+
226
+ Ensures that the conclusions of the current chapter effectively support the analysis of subsequent chapters.
227
+ """
228
+
229
+ output_key: str = "article_outline_fw_ref_checked"
230
+
231
+ async def _execute(self, article_outline: ArticleOutline, **cxt) -> ArticleOutline:
232
+ tweak_support_to_manual = ok(
233
+ await self.draft_rating_manual(
234
+ topic := "Ensure conclusions support the analysis of subsequent chapters, sections or subsections."
235
+ ),
236
+ "Could not generate the rating manual.",
237
+ )
238
+
239
+ for a in article_outline.iter_dfs():
240
+ if await self.evidently_judge(
241
+ f"{article_outline.as_prompt()}\n\n{a.display()}\n"
242
+ f"Does the `{a.__class__.__name__}`'s `support_to` field need to be extended or tweaked?"
243
+ ):
244
+ patch=ArticleRefPatch.default()
245
+ patch.tweaked=a.support_to
246
+
247
+ await self.correct_obj_inplace(
248
+ patch,
249
+ topic=topic,
250
+ reference=f"{article_outline.as_prompt()}\nThe Article component whose `support_to` field needs to be extended or tweaked",
251
+ rating_manual=tweak_support_to_manual,
252
+ )
253
+
254
+ return article_outline
159
255
 
160
256
 
161
257
  class GenerateArticle(Action):
@@ -191,6 +287,7 @@ class GenerateArticle(Action):
191
287
  ],
192
288
  return_exceptions=True,
193
289
  )
290
+
194
291
  return article
195
292
 
196
293
 
@@ -0,0 +1,23 @@
1
+ """The Capabilities module for advanced judging."""
2
+
3
+ from typing import Optional, Unpack
4
+
5
+ from fabricatio.capabilities.propose import Propose
6
+ from fabricatio.models.extra.advanced_judge import JudgeMent
7
+ from fabricatio.models.kwargs_types import ValidateKwargs
8
+
9
+
10
+ class AdvancedJudge(Propose):
11
+ """A class that judges the evidence and makes a final decision."""
12
+ async def evidently_judge(
13
+ self,
14
+ prompt: str,
15
+ **kwargs: Unpack[ValidateKwargs[JudgeMent]],
16
+ ) -> Optional[JudgeMent]:
17
+ """Judge the evidence and make a final decision."""
18
+ return await self.propose(
19
+ JudgeMent,
20
+ prompt,
21
+ **kwargs
22
+ )
23
+
@@ -16,7 +16,7 @@ from more_itertools import flatten, windowed
16
16
  from pydantic import NonNegativeInt, PositiveInt
17
17
 
18
18
 
19
- class GiveRating(WithBriefing, LLMUsage):
19
+ class Rating(WithBriefing, LLMUsage):
20
20
  """A class that provides functionality to rate tasks based on a rating manual and score range.
21
21
 
22
22
  References:
@@ -4,7 +4,7 @@ from typing import Dict, List, Optional, Self, Set, Unpack, cast
4
4
 
5
5
  from fabricatio._rust_instances import TEMPLATE_MANAGER
6
6
  from fabricatio.capabilities.propose import Propose
7
- from fabricatio.capabilities.rating import GiveRating
7
+ from fabricatio.capabilities.rating import Rating
8
8
  from fabricatio.config import configs
9
9
  from fabricatio.models.generic import Base, Display, ProposedAble, WithBriefing
10
10
  from fabricatio.models.kwargs_types import ReviewKwargs, ValidateKwargs
@@ -175,7 +175,7 @@ class ReviewResult[T](ProposedAble, Display):
175
175
  return self
176
176
 
177
177
 
178
- class Review(GiveRating, Propose):
178
+ class Review(Rating, Propose):
179
179
  """Class that provides functionality to review tasks and strings using a language model.
180
180
 
181
181
  This class extends GiveRating and Propose capabilities to analyze content,
@@ -221,7 +221,7 @@ class WorkFlow(WithBriefing, ToolBoxUsage):
221
221
  self.provide_tools_to(self._instances)
222
222
  return self
223
223
 
224
- def update_init_context(self, **kwargs) -> Self:
224
+ def update_init_context(self, /, **kwargs) -> Self:
225
225
  """Update the initial context with additional key-value pairs.
226
226
 
227
227
  Args:
@@ -0,0 +1,22 @@
1
+ """A module containing the JudgeMent class."""
2
+
3
+ from typing import List
4
+
5
+ from fabricatio.models.generic import ProposedAble
6
+
7
+
8
+ class JudgeMent(ProposedAble):
9
+ """A class representing a judgment made by a judge."""
10
+
11
+ affirm_evidence: List[str]
12
+ """List of evidence supporting the affirmation."""
13
+
14
+ deny_evidence: List[str]
15
+ """List of evidence supporting the denial."""
16
+
17
+ final_judgement: bool
18
+ """The final judgement."""
19
+
20
+ def __bool__(self) -> bool:
21
+ """Return the final judgement."""
22
+ return self.final_judgement
@@ -1,12 +1,13 @@
1
1
  """A foundation for hierarchical document components with dependency tracking."""
2
2
 
3
- from abc import abstractmethod
3
+ from abc import ABC, abstractmethod
4
4
  from enum import StrEnum
5
5
  from functools import cache
6
6
  from itertools import chain
7
7
  from typing import Generator, List, Optional, Self, Tuple
8
8
 
9
9
  from fabricatio.models.generic import (
10
+ AsPrompt,
10
11
  CensoredAble,
11
12
  Display,
12
13
  FinalizedDumpAble,
@@ -121,6 +122,24 @@ class ArticleMetaData(CensoredAble, Display):
121
122
  """Do not add any prefix or suffix to the title. should not contain special characters."""
122
123
 
123
124
 
125
+ class ArticleRefPatch(ProposedUpdateAble, Display):
126
+ """Patch for article refs."""
127
+
128
+ tweaked: List[ArticleRef]
129
+ """Tweaked refs"""
130
+
131
+ def update_from_inner(self, other: Self) -> Self:
132
+ """Updates the current instance with the attributes of another instance."""
133
+ self.tweaked.clear()
134
+ self.tweaked.extend(other.tweaked)
135
+ return self
136
+
137
+ @classmethod
138
+ def default(cls) -> "ArticleRefPatch":
139
+ """Defaults to empty list."""
140
+ return cls(tweaked=[])
141
+
142
+
124
143
  class ArticleOutlineBase(
125
144
  ArticleMetaData,
126
145
  ResolveUpdateConflict,
@@ -267,7 +286,7 @@ class ChapterBase[T: SectionBase](ArticleOutlineBase):
267
286
  return ""
268
287
 
269
288
 
270
- class ArticleBase[T: ChapterBase](FinalizedDumpAble):
289
+ class ArticleBase[T: ChapterBase](FinalizedDumpAble, AsPrompt, ABC):
271
290
  """Base class for article outlines."""
272
291
 
273
292
  language: str
@@ -134,10 +134,10 @@ class Highlightings(BaseModel):
134
134
 
135
135
 
136
136
  class ArticleEssence(ProposedAble, Display, PrepareVectorization):
137
- """Semantic fingerprint of academic paper for structured analysis.
137
+ """ArticleEssence is a structured representation of the core elements of a scientific article."""
138
138
 
139
- Encodes research artifacts with dual human-machine interpretability.
140
- """
139
+ language: str = Field(...)
140
+ """Language of the original article."""
141
141
 
142
142
  title: str = Field(...)
143
143
  """Exact title of the original article without any modification.
@@ -149,7 +149,7 @@ class ArticleEssence(ProposedAble, Display, PrepareVectorization):
149
149
  """
150
150
 
151
151
  authors: List[str]
152
- """Original author names exactly as they appear in the source document. No translation or paraphrasing.
152
+ """Original author full names exactly as they appear in the source document. No translation or paraphrasing.
153
153
  Extract complete list without any modifications or formatting changes."""
154
154
 
155
155
  keywords: List[str]
@@ -170,11 +170,7 @@ class ArticleEssence(ProposedAble, Display, PrepareVectorization):
170
170
  """Domain tags for research focus."""
171
171
 
172
172
  abstract: str = Field(...)
173
- """Three-paragraph structured abstract:
174
- Paragraph 1: Problem & Motivation (2-3 sentences)
175
- Paragraph 2: Methodology & Innovations (3-4 sentences)
176
- Paragraph 3: Results & Impact (2-3 sentences)
177
- Total length: 150-250 words"""
173
+ """Abstract text with original language."""
178
174
 
179
175
  core_contributions: List[str]
180
176
  """3-5 technical contributions using CRediT taxonomy verbs.
@@ -184,6 +180,7 @@ class ArticleEssence(ProposedAble, Display, PrepareVectorization):
184
180
  - 'Established cross-lingual transfer metrics'"""
185
181
 
186
182
  technical_novelty: List[str]
183
+
187
184
  """Patent-style claims with technical specificity.
188
185
  Format: 'A [system/method] comprising [novel components]...'
189
186
  Example:
@@ -1,7 +1,7 @@
1
1
  """ArticleBase and ArticleSubsection classes for managing hierarchical document components."""
2
2
 
3
3
  from itertools import chain
4
- from typing import Generator, List, Self, Tuple, override
4
+ from typing import Dict, Generator, List, Self, Tuple, override
5
5
 
6
6
  from fabricatio.journal import logger
7
7
  from fabricatio.models.extra.article_base import (
@@ -81,6 +81,14 @@ class Article(
81
81
  aiming to provide a comprehensive model for academic papers.
82
82
  """
83
83
 
84
+ def _as_prompt_inner(self) -> Dict[str, str]:
85
+ return {
86
+ "Original Article Briefing": self.referenced.referenced.referenced,
87
+ "Original Article Proposal": self.referenced.referenced.display(),
88
+ "Original Article Outline": self.referenced.display(),
89
+ "Original Article": self.display(),
90
+ }
91
+
84
92
  @override
85
93
  def iter_subsections(self) -> Generator[Tuple[ArticleChapter, ArticleSection, ArticleSubsection], None, None]:
86
94
  return super().iter_subsections()
@@ -1,5 +1,7 @@
1
1
  """A module containing the ArticleOutline class, which represents the outline of an academic paper."""
2
2
 
3
+ from typing import Dict
4
+
3
5
  from fabricatio.models.extra.article_base import (
4
6
  ArticleBase,
5
7
  ChapterBase,
@@ -30,3 +32,10 @@ class ArticleOutline(
30
32
  ArticleBase[ArticleChapterOutline],
31
33
  ):
32
34
  """Outline of an academic paper, containing chapters, sections, subsections."""
35
+
36
+ def _as_prompt_inner(self) -> Dict[str, str]:
37
+ return {
38
+ "Original Article Briefing": self.referenced.referenced,
39
+ "Original Article Proposal": self.referenced.display(),
40
+ "Original Article Outline": self.display(),
41
+ }
Binary file
@@ -248,7 +248,7 @@ wheels = [
248
248
 
249
249
  [[package]]
250
250
  name = "fabricatio"
251
- version = "0.2.8.dev0"
251
+ version = "0.2.8.dev1"
252
252
  source = { editable = "." }
253
253
  dependencies = [
254
254
  { name = "appdirs" },
Binary file
File without changes