fabricatio 0.2.9.dev3__tar.gz → 0.2.9.dev4__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.
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/PKG-INFO +1 -1
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/pyproject.toml +1 -1
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/actions/article.py +5 -9
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/actions/article_rag.py +9 -2
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/capabilities/check.py +13 -8
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/capabilities/correct.py +5 -6
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/capabilities/rating.py +46 -40
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/config.py +2 -2
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/fs/readers.py +20 -1
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/extra/advanced_judge.py +3 -3
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/extra/article_base.py +58 -60
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/extra/article_main.py +89 -20
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/extra/article_proposal.py +15 -14
- fabricatio-0.2.9.dev4/python/fabricatio/models/extra/patches.py +20 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/generic.py +20 -3
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/usages.py +6 -4
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/parser.py +5 -5
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/rust.pyi +2 -7
- fabricatio-0.2.9.dev4/templates/built-in/co_validation.hbs +7 -0
- fabricatio-0.2.9.dev4/templates/built-in/create_json_obj.hbs +26 -0
- fabricatio-0.2.9.dev4/templates/built-in/draft_rating_weights_klee.hbs +37 -0
- fabricatio-0.2.9.dev4/templates/built-in/extract_reasons_from_examples.hbs +39 -0
- fabricatio-0.2.9.dev4/templates/built-in/rate_fine_grind.hbs +15 -0
- fabricatio-0.2.9.dev4/templates.tar.gz +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/uv.lock +78 -78
- fabricatio-0.2.9.dev3/python/fabricatio/models/extra/patches.py +0 -20
- fabricatio-0.2.9.dev3/templates/built-in/co_validation.hbs +0 -26
- fabricatio-0.2.9.dev3/templates/built-in/create_json_obj.hbs +0 -74
- fabricatio-0.2.9.dev3/templates/built-in/draft_rating_weights_klee.hbs +0 -44
- fabricatio-0.2.9.dev3/templates/built-in/extract_reasons_from_examples.hbs +0 -49
- fabricatio-0.2.9.dev3/templates/built-in/rate_fine_grind.hbs +0 -43
- fabricatio-0.2.9.dev3/templates.tar.gz +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/.github/workflows/build-package.yaml +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/.github/workflows/ruff.yaml +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/.github/workflows/tests.yaml +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/.gitignore +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/.python-version +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/Cargo.lock +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/Cargo.toml +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/LICENSE +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/Makefile +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/README.md +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/correct/correct.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/correct/correct_loop.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/extract_and_inject/.gitignore +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/extract_and_inject/article_rag.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/extract_and_inject/ask.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/extract_and_inject/extract_and_inject.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/extract_article/extract.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/llm_usages/llm_usage.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/make_a_rating/rating.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/make_diary/commits.json +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/make_diary/diary.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/minor/hello_fabricatio.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/minor/write_a_poem.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/propose_task/propose.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/reviewer/censor.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/reviewer/review.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/rules/.gitignore +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/rules/draft_ruleset.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/search_bibtex/.gitignore +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/search_bibtex/search.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/simple_chat/chat.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/simple_rag/simple_rag.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/task_handle/handle_task.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/write_article/.gitignore +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/write_article/article_rag.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/write_article/write_article.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/write_outline/.gitignore +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/write_outline/write_outline.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/examples/write_outline/write_outline_corrected.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/__init__.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/actions/__init__.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/actions/output.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/actions/rag.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/actions/rules.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/capabilities/__init__.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/capabilities/advanced_judge.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/capabilities/censor.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/capabilities/propose.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/capabilities/rag.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/capabilities/review.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/capabilities/task.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/core.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/decorators.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/fs/__init__.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/fs/curd.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/journal.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/action.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/adv_kwargs_types.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/events.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/extra/__init__.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/extra/article_essence.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/extra/article_outline.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/extra/problem.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/extra/rule.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/kwargs_types.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/role.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/task.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/tool.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/utils.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/py.typed +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/rust_instances.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/toolboxes/__init__.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/toolboxes/arithmetic.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/toolboxes/fs.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/utils.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/workflows/__init__.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/workflows/articles.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/workflows/rag.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/src/bib_tools.rs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/src/hash.rs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/src/hbs_helpers.rs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/src/language.rs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/src/lib.rs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/src/templates.rs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/src/word_split.rs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/as_prompt.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/binary-exploitation-ctf-solver.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/check_string.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/claude-xml.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/clean-up-code.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/cryptography-ctf-solver.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/dependencies.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/document-the-code.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/draft_rating_criteria.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/draft_rating_manual.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/draft_tool_usage_code.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/extract_criteria_from_reasons.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/find-security-vulnerabilities.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/fix-bugs.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/fix_troubled_obj.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/fix_troubled_string.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/generic_string.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/improve-performance.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/liststr.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/make_choice.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/make_judgment.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/pathstr.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/refactor.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/refined_query.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/retrieved_display.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/reverse-engineering-ctf-solver.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/review_string.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/rule_requirement.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/ruleset_requirement_breakdown.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/task_briefing.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/web-ctf-solver.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/write-git-commit.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/write-github-pull-request.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/templates/built-in/write-github-readme.hbs +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/tests/test_config.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/tests/test_models/test_action.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/tests/test_models/test_advanced.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/tests/test_models/test_generic.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/tests/test_models/test_problem.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/tests/test_models/test_role.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/tests/test_models/test_task.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/tests/test_models/test_tool.py +0 -0
- {fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/tests/test_models/test_usages.py +0 -0
@@ -105,7 +105,6 @@ class GenerateArticleProposal(Action, Propose):
|
|
105
105
|
task_input: Optional[Task] = None,
|
106
106
|
article_briefing: Optional[str] = None,
|
107
107
|
article_briefing_path: Optional[str] = None,
|
108
|
-
langauge: Optional[str] = None,
|
109
108
|
**_,
|
110
109
|
) -> Optional[ArticleProposal]:
|
111
110
|
if article_briefing is None and article_briefing_path is None and task_input is None:
|
@@ -122,17 +121,14 @@ class GenerateArticleProposal(Action, Propose):
|
|
122
121
|
)
|
123
122
|
)
|
124
123
|
|
125
|
-
|
124
|
+
logger.info("Start generating the proposal.")
|
125
|
+
return ok(
|
126
126
|
await self.propose(
|
127
127
|
ArticleProposal,
|
128
|
-
f"{briefing}\n\nWrite the value string using `{detect_language(briefing)}`",
|
128
|
+
f"{briefing}\n\nWrite the value string using `{detect_language(briefing)}` as written language.",
|
129
129
|
),
|
130
130
|
"Could not generate the proposal.",
|
131
131
|
).update_ref(briefing)
|
132
|
-
if langauge:
|
133
|
-
proposal.language = langauge
|
134
|
-
|
135
|
-
return proposal
|
136
132
|
|
137
133
|
|
138
134
|
class GenerateInitialOutline(Action, Propose):
|
@@ -149,7 +145,7 @@ class GenerateInitialOutline(Action, Propose):
|
|
149
145
|
return ok(
|
150
146
|
await self.propose(
|
151
147
|
ArticleOutline,
|
152
|
-
f"{(
|
148
|
+
f"{(article_proposal.as_prompt())}\n\nNote that you should use `{article_proposal.language}` to write the `ArticleOutline`\n"
|
153
149
|
f"You Must make sure every chapter have sections, and every section have subsections.",
|
154
150
|
),
|
155
151
|
"Could not generate the initial outline.",
|
@@ -318,7 +314,7 @@ class GenerateArticle(Action, Censor):
|
|
318
314
|
self.censor_obj_inplace(
|
319
315
|
subsec,
|
320
316
|
ruleset=ok(article_gen_ruleset or self.ruleset, "No ruleset provided"),
|
321
|
-
reference=f"{article_outline.as_prompt()}\n# Error Need to be fixed\n{err}",
|
317
|
+
reference=f"{article_outline.as_prompt()}\n# Error Need to be fixed\n{err}\nYou should use `{subsec.language}` to write the new `Subsection`.",
|
322
318
|
)
|
323
319
|
for _, _, subsec in article.iter_subsections()
|
324
320
|
if (err := subsec.introspect()) and logger.warning(f"Found Introspection Error:\n{err}") is None
|
@@ -29,6 +29,9 @@ class TweakArticleRAG(Action, RAG, Censor):
|
|
29
29
|
ruleset: Optional[RuleSet] = None
|
30
30
|
"""The ruleset to be used for censoring the article."""
|
31
31
|
|
32
|
+
ref_limit: int = 30
|
33
|
+
"""The limit of references to be retrieved"""
|
34
|
+
|
32
35
|
async def _execute(
|
33
36
|
self,
|
34
37
|
article: Article,
|
@@ -88,11 +91,15 @@ class TweakArticleRAG(Action, RAG, Censor):
|
|
88
91
|
f"{subsec.display()}\n"
|
89
92
|
f"# Requirement\n"
|
90
93
|
f"Search related articles in the base to find reference candidates, "
|
91
|
-
f"
|
94
|
+
f"provide queries in both `English` and `{subsec.language}` can get more accurate results.",
|
92
95
|
)
|
93
96
|
)
|
94
97
|
await self.censor_obj_inplace(
|
95
98
|
subsec,
|
96
99
|
ruleset=ruleset,
|
97
|
-
reference=await self.aretrieve_compact(refind_q, final_limit=
|
100
|
+
reference=f"{await self.aretrieve_compact(refind_q, final_limit=self.ref_limit)}\n\n"
|
101
|
+
f"You can use Reference above to rewrite the `{subsec.__class__.__name__}`.\n"
|
102
|
+
f"You should Always use `{subsec.language}` as written language, "
|
103
|
+
f"which is the original language of the `{subsec.title}`. "
|
104
|
+
f"since rewrite a `{subsec.__class__.__name__}` in a different language is usually a bad choice",
|
98
105
|
)
|
@@ -8,7 +8,7 @@ from fabricatio.capabilities.advanced_judge import AdvancedJudge
|
|
8
8
|
from fabricatio.capabilities.propose import Propose
|
9
9
|
from fabricatio.config import configs
|
10
10
|
from fabricatio.journal import logger
|
11
|
-
from fabricatio.models.extra.patches import
|
11
|
+
from fabricatio.models.extra.patches import RuleSetMetadata
|
12
12
|
from fabricatio.models.extra.problem import Improvement
|
13
13
|
from fabricatio.models.extra.rule import Rule, RuleSet
|
14
14
|
from fabricatio.models.generic import Display, WithBriefing
|
@@ -42,12 +42,17 @@ class Check(AdvancedJudge, Propose):
|
|
42
42
|
- Returns None if any step in rule generation fails
|
43
43
|
- Uses `alist_str` for requirement breakdown and iterative rule proposal
|
44
44
|
"""
|
45
|
-
rule_reqs =
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
rule_reqs = (
|
46
|
+
await self.alist_str(
|
47
|
+
TEMPLATE_MANAGER.render_template(
|
48
|
+
configs.templates.ruleset_requirement_breakdown_template,
|
49
|
+
{"ruleset_requirement": ruleset_requirement},
|
50
|
+
),
|
51
|
+
rule_count,
|
52
|
+
**override_kwargs(kwargs, default=None),
|
53
|
+
)
|
54
|
+
if rule_count > 1
|
55
|
+
else [ruleset_requirement]
|
51
56
|
)
|
52
57
|
|
53
58
|
if rule_reqs is None:
|
@@ -65,7 +70,7 @@ class Check(AdvancedJudge, Propose):
|
|
65
70
|
return None
|
66
71
|
|
67
72
|
ruleset_patch = await self.propose(
|
68
|
-
|
73
|
+
RuleSetMetadata,
|
69
74
|
f"{ruleset_requirement}\n\nYou should use `{detect_language(ruleset_requirement)}`!",
|
70
75
|
**override_kwargs(kwargs, default=None),
|
71
76
|
)
|
@@ -57,7 +57,7 @@ class Correct(Rating, Propose):
|
|
57
57
|
self.decide_solution(
|
58
58
|
ps,
|
59
59
|
**fallback_kwargs(
|
60
|
-
kwargs, topic=f"which solution is better to deal this problem {ps.problem.
|
60
|
+
kwargs, topic=f"which solution is better to deal this problem {ps.problem.description}\n\n"
|
61
61
|
),
|
62
62
|
)
|
63
63
|
for ps in improvement.problem_solutions
|
@@ -167,13 +167,12 @@ class Correct(Rating, Propose):
|
|
167
167
|
logger.info(f"Improvement {improvement.focused_on} not decided, start deciding...")
|
168
168
|
improvement = await self.decide_improvement(improvement, **override_kwargs(kwargs, default=None))
|
169
169
|
|
170
|
-
|
171
|
-
|
170
|
+
total = len(improvement.problem_solutions)
|
171
|
+
for idx, ps in enumerate(improvement.problem_solutions):
|
172
|
+
logger.info(f"[{idx + 1}/{total}] Fixing {obj.__class__.__name__} for problem `{ps.problem.name}`")
|
172
173
|
fixed_obj = await self.fix_troubled_obj(obj, ps, reference, **kwargs)
|
173
174
|
if fixed_obj is None:
|
174
|
-
logger.error(
|
175
|
-
f"Failed to fix troubling obj {obj.__class__.__name__} when deal with problem: {ps.problem.name}",
|
176
|
-
)
|
175
|
+
logger.error(f"[{idx + 1}/{total}] Failed to fix problem `{ps.problem.name}`")
|
177
176
|
return None
|
178
177
|
obj = fixed_obj
|
179
178
|
return obj
|
@@ -5,19 +5,19 @@ from random import sample
|
|
5
5
|
from typing import Dict, List, Optional, Set, Tuple, Union, Unpack, overload
|
6
6
|
|
7
7
|
from more_itertools import flatten, windowed
|
8
|
-
from pydantic import NonNegativeInt, PositiveInt
|
8
|
+
from pydantic import Field, NonNegativeInt, PositiveInt, create_model
|
9
9
|
|
10
|
+
from fabricatio.capabilities.propose import Propose
|
10
11
|
from fabricatio.config import configs
|
11
12
|
from fabricatio.journal import logger
|
12
|
-
from fabricatio.models.generic import Display
|
13
|
+
from fabricatio.models.generic import Display, ProposedAble
|
13
14
|
from fabricatio.models.kwargs_types import CompositeScoreKwargs, ValidateKwargs
|
14
|
-
from fabricatio.models.usages import LLMUsage
|
15
15
|
from fabricatio.parser import JsonCapture
|
16
16
|
from fabricatio.rust_instances import TEMPLATE_MANAGER
|
17
|
-
from fabricatio.utils import ok, override_kwargs
|
17
|
+
from fabricatio.utils import fallback_kwargs, ok, override_kwargs
|
18
18
|
|
19
19
|
|
20
|
-
class Rating(
|
20
|
+
class Rating(Propose):
|
21
21
|
"""A class that provides functionality to rate tasks based on a rating manual and score range.
|
22
22
|
|
23
23
|
References:
|
@@ -30,7 +30,7 @@ class Rating(LLMUsage):
|
|
30
30
|
rating_manual: Dict[str, str],
|
31
31
|
score_range: Tuple[float, float],
|
32
32
|
**kwargs: Unpack[ValidateKwargs[Dict[str, float]]],
|
33
|
-
) ->
|
33
|
+
) -> Dict[str, float] | List[Dict[str, float]] | List[Optional[Dict[str, float]]] | None:
|
34
34
|
"""Rate a given string based on a rating manual and score range.
|
35
35
|
|
36
36
|
Args:
|
@@ -42,45 +42,49 @@ class Rating(LLMUsage):
|
|
42
42
|
Returns:
|
43
43
|
Dict[str, float]: A dictionary with the ratings for each dimension.
|
44
44
|
"""
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
"to_rate": to_rate,
|
62
|
-
"min_score": score_range[0],
|
63
|
-
"max_score": score_range[1],
|
64
|
-
"rating_manual": rating_manual,
|
65
|
-
},
|
45
|
+
min_score, max_score = score_range
|
46
|
+
tip = (max_score - min_score) / 9
|
47
|
+
|
48
|
+
model = create_model( # pyright: ignore [reportCallIssue]
|
49
|
+
"RatingResult",
|
50
|
+
__base__=ProposedAble,
|
51
|
+
__doc__=f"The rating result contains the scores against each criterion, with min_score={min_score} and max_score={max_score}.",
|
52
|
+
**{ # pyright: ignore [reportArgumentType]
|
53
|
+
criterion: (
|
54
|
+
float,
|
55
|
+
Field(
|
56
|
+
ge=min_score,
|
57
|
+
le=max_score,
|
58
|
+
description=desc,
|
59
|
+
examples=[round(min_score + tip * i, 2) for i in range(10)],
|
60
|
+
),
|
66
61
|
)
|
62
|
+
for criterion, desc in rating_manual.items()
|
63
|
+
},
|
64
|
+
)
|
65
|
+
|
66
|
+
res = await self.propose(
|
67
|
+
model,
|
68
|
+
TEMPLATE_MANAGER.render_template(
|
69
|
+
configs.templates.rate_fine_grind_template,
|
70
|
+
{"to_rate": to_rate, "min_score": min_score, "max_score": max_score},
|
67
71
|
)
|
68
72
|
if isinstance(to_rate, str)
|
69
73
|
else [
|
70
74
|
TEMPLATE_MANAGER.render_template(
|
71
75
|
configs.templates.rate_fine_grind_template,
|
72
|
-
{
|
73
|
-
"to_rate": item,
|
74
|
-
"min_score": score_range[0],
|
75
|
-
"max_score": score_range[1],
|
76
|
-
"rating_manual": rating_manual,
|
77
|
-
},
|
76
|
+
{"to_rate": t, "min_score": min_score, "max_score": max_score},
|
78
77
|
)
|
79
|
-
for
|
78
|
+
for t in to_rate
|
80
79
|
],
|
81
|
-
|
82
|
-
**kwargs,
|
80
|
+
**override_kwargs(kwargs, default=None),
|
83
81
|
)
|
82
|
+
default = kwargs.get("default")
|
83
|
+
if isinstance(res, list):
|
84
|
+
return [r.model_dump() if r else default for r in res]
|
85
|
+
if res is None:
|
86
|
+
return default
|
87
|
+
return res.model_dump()
|
84
88
|
|
85
89
|
@overload
|
86
90
|
async def rate(
|
@@ -112,7 +116,7 @@ class Rating(LLMUsage):
|
|
112
116
|
manual: Optional[Dict[str, str]] = None,
|
113
117
|
score_range: Tuple[float, float] = (0.0, 1.0),
|
114
118
|
**kwargs: Unpack[ValidateKwargs],
|
115
|
-
) ->
|
119
|
+
) -> Dict[str, float] | List[Dict[str, float]] | List[Optional[Dict[str, float]]] | None:
|
116
120
|
"""Rate a given string or a sequence of strings based on a topic, criteria, and score range.
|
117
121
|
|
118
122
|
Args:
|
@@ -133,7 +137,7 @@ class Rating(LLMUsage):
|
|
133
137
|
or dict(zip(criteria, criteria, strict=True))
|
134
138
|
)
|
135
139
|
|
136
|
-
return await self.rate_fine_grind(to_rate, manual, score_range, **kwargs)
|
140
|
+
return await self.rate_fine_grind(to_rate, manual, score_range, **fallback_kwargs(kwargs, co_extractor={}))
|
137
141
|
|
138
142
|
async def draft_rating_manual(
|
139
143
|
self, topic: str, criteria: Optional[Set[str]] = None, **kwargs: Unpack[ValidateKwargs[Dict[str, str]]]
|
@@ -244,7 +248,7 @@ class Rating(LLMUsage):
|
|
244
248
|
|
245
249
|
# extract reasons from the comparison of ordered pairs of extracted from examples
|
246
250
|
reasons = flatten(
|
247
|
-
await self.aask_validate(
|
251
|
+
await self.aask_validate( # pyright: ignore [reportArgumentType]
|
248
252
|
question=[
|
249
253
|
TEMPLATE_MANAGER.render_template(
|
250
254
|
configs.templates.extract_reasons_from_examples_template,
|
@@ -319,9 +323,11 @@ class Rating(LLMUsage):
|
|
319
323
|
validator=lambda resp: JsonCapture.validate_with(resp, target_type=float),
|
320
324
|
**kwargs,
|
321
325
|
)
|
326
|
+
if not all(relative_weights):
|
327
|
+
raise ValueError(f"found illegal weight: {relative_weights}")
|
322
328
|
weights = [1.0]
|
323
329
|
for rw in relative_weights:
|
324
|
-
weights.append(weights[-1] * rw)
|
330
|
+
weights.append(weights[-1] * rw) # pyright: ignore [reportOperatorIssue]
|
325
331
|
total = sum(weights)
|
326
332
|
return dict(zip(criteria_seq, [w / total for w in weights], strict=True))
|
327
333
|
|
@@ -44,7 +44,7 @@ class LLMConfig(BaseModel):
|
|
44
44
|
top_p (NonNegativeFloat): The top p of the LLM model. Controls diversity via nucleus sampling. Set to 0.35 as per request.
|
45
45
|
generation_count (PositiveInt): The number of generations to generate. Default is 1.
|
46
46
|
stream (bool): Whether to stream the LLM model's response. Default is False.
|
47
|
-
max_tokens (PositiveInt): The maximum number of tokens to generate.
|
47
|
+
max_tokens (PositiveInt): The maximum number of tokens to generate.
|
48
48
|
"""
|
49
49
|
|
50
50
|
model_config = ConfigDict(use_attribute_docstrings=True)
|
@@ -79,7 +79,7 @@ class LLMConfig(BaseModel):
|
|
79
79
|
"""Whether to stream the LLM model's response. Default is False."""
|
80
80
|
|
81
81
|
max_tokens: Optional[PositiveInt] = Field(default=None)
|
82
|
-
"""The maximum number of tokens to generate.
|
82
|
+
"""The maximum number of tokens to generate."""
|
83
83
|
|
84
84
|
rpm: Optional[PositiveInt] = Field(default=100)
|
85
85
|
"""The rate limit of the LLM model in requests per minute. None means not checked."""
|
@@ -1,9 +1,10 @@
|
|
1
1
|
"""Filesystem readers for Fabricatio."""
|
2
2
|
|
3
3
|
from pathlib import Path
|
4
|
-
from typing import Dict
|
4
|
+
from typing import Dict, List, Tuple
|
5
5
|
|
6
6
|
import orjson
|
7
|
+
import regex
|
7
8
|
from magika import Magika
|
8
9
|
|
9
10
|
from fabricatio.config import configs
|
@@ -44,3 +45,21 @@ def safe_json_read(path: Path | str) -> Dict:
|
|
44
45
|
except (orjson.JSONDecodeError, IsADirectoryError, FileNotFoundError) as e:
|
45
46
|
logger.error(f"Failed to read file {path}: {e!s}")
|
46
47
|
return {}
|
48
|
+
|
49
|
+
|
50
|
+
def extract_sections(string: str, level: int, section_char: str = "#") -> List[Tuple[str, str]]:
|
51
|
+
"""Extract sections from markdown-style text by header level.
|
52
|
+
|
53
|
+
Args:
|
54
|
+
string (str): Input text to parse
|
55
|
+
level (int): Header level (e.g., 1 for '#', 2 for '##')
|
56
|
+
section_char (str, optional): The character used for headers (default: '#')
|
57
|
+
|
58
|
+
Returns:
|
59
|
+
List[Tuple[str, str]]: List of (header_text, section_content) tuples
|
60
|
+
"""
|
61
|
+
return regex.findall(
|
62
|
+
r"^%s{%d}\s+(.+?)\n((?:(?!^%s{%d}\s).|\n)*)" % (section_char, level, section_char, level),
|
63
|
+
string,
|
64
|
+
regex.MULTILINE,
|
65
|
+
)
|
{fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/extra/advanced_judge.py
RENAMED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
from typing import List
|
4
4
|
|
5
|
-
from fabricatio.models.generic import
|
5
|
+
from fabricatio.models.generic import SketchedAble
|
6
6
|
|
7
7
|
|
8
|
-
class JudgeMent(
|
8
|
+
class JudgeMent(SketchedAble):
|
9
9
|
"""Represents a judgment result containing supporting/denying evidence and final verdict.
|
10
10
|
|
11
11
|
The class stores both affirmative and denies evidence, truth and reasons lists along with the final boolean judgment.
|
12
12
|
"""
|
13
13
|
|
14
14
|
issue_to_judge: str
|
15
|
-
"""The issue to be judged"""
|
15
|
+
"""The issue to be judged, true for affirmation, false for denial."""
|
16
16
|
|
17
17
|
deny_evidence: List[str]
|
18
18
|
"""List of clues supporting the denial."""
|
{fabricatio-0.2.9.dev3 → fabricatio-0.2.9.dev4}/python/fabricatio/models/extra/article_base.py
RENAMED
@@ -17,7 +17,10 @@ from fabricatio.models.generic import (
|
|
17
17
|
ResolveUpdateConflict,
|
18
18
|
SequencePatch,
|
19
19
|
SketchedAble,
|
20
|
+
Titled,
|
21
|
+
WordCount,
|
20
22
|
)
|
23
|
+
from pydantic import Field
|
21
24
|
|
22
25
|
|
23
26
|
class ReferringType(StrEnum):
|
@@ -38,44 +41,44 @@ class ArticleRef(ProposedUpdateAble):
|
|
38
41
|
- Referring to a chapter titled `Introduction`:
|
39
42
|
Using Python
|
40
43
|
```python
|
41
|
-
ArticleRef(
|
44
|
+
ArticleRef(chap="Introduction")
|
42
45
|
```
|
43
46
|
Using JSON
|
44
47
|
```json
|
45
|
-
{
|
48
|
+
{chap="Introduction"}
|
46
49
|
```
|
47
50
|
- Referring to a section titled `Background` under the `Introduction` chapter:
|
48
51
|
Using Python
|
49
52
|
```python
|
50
|
-
ArticleRef(
|
53
|
+
ArticleRef(chap="Introduction", sec="Background")
|
51
54
|
```
|
52
55
|
Using JSON
|
53
56
|
```json
|
54
|
-
{
|
57
|
+
{chap="Introduction", sec="Background"}
|
55
58
|
```
|
56
59
|
- Referring to a subsection titled `Related Work` under the `Background` section of the `Introduction` chapter:
|
57
60
|
Using Python
|
58
61
|
```python
|
59
|
-
ArticleRef(
|
62
|
+
ArticleRef(chap="Introduction", sec="Background", subsec="Related Work")
|
60
63
|
```
|
61
64
|
Using JSON
|
62
65
|
```json
|
63
|
-
{
|
66
|
+
{chap="Introduction", sec="Background", subsec="Related Work"}
|
64
67
|
```
|
65
68
|
"""
|
66
69
|
|
67
|
-
|
70
|
+
chap: str
|
68
71
|
"""`title` Field of the referenced chapter"""
|
69
|
-
|
72
|
+
sec: Optional[str] = None
|
70
73
|
"""`title` Field of the referenced section."""
|
71
|
-
|
74
|
+
subsec: Optional[str] = None
|
72
75
|
"""`title` Field of the referenced subsection."""
|
73
76
|
|
74
77
|
def update_from_inner(self, other: Self) -> Self:
|
75
78
|
"""Updates the current instance with the attributes of another instance."""
|
76
|
-
self.
|
77
|
-
self.
|
78
|
-
self.
|
79
|
+
self.chap = other.chap
|
80
|
+
self.sec = other.sec
|
81
|
+
self.subsec = other.subsec
|
79
82
|
return self
|
80
83
|
|
81
84
|
def deref(self, article: "ArticleBase") -> Optional["ArticleOutlineBase"]:
|
@@ -87,39 +90,41 @@ class ArticleRef(ProposedUpdateAble):
|
|
87
90
|
Returns:
|
88
91
|
ArticleMainBase | ArticleOutline | None: The dereferenced section or subsection, or None if not found.
|
89
92
|
"""
|
90
|
-
chap = next((chap for chap in article.chapters if chap.title == self.
|
91
|
-
if self.
|
93
|
+
chap = next((chap for chap in article.chapters if chap.title == self.chap), None)
|
94
|
+
if self.sec is None or chap is None:
|
92
95
|
return chap
|
93
|
-
sec = next((sec for sec in chap.sections if sec.title == self.
|
94
|
-
if self.
|
96
|
+
sec = next((sec for sec in chap.sections if sec.title == self.sec), None)
|
97
|
+
if self.subsec is None or sec is None:
|
95
98
|
return sec
|
96
|
-
return next((subsec for subsec in sec.subsections if subsec.title == self.
|
99
|
+
return next((subsec for subsec in sec.subsections if subsec.title == self.subsec), None)
|
97
100
|
|
98
101
|
@property
|
99
102
|
def referring_type(self) -> ReferringType:
|
100
103
|
"""Determine the type of reference based on the presence of specific attributes."""
|
101
|
-
if self.
|
104
|
+
if self.subsec is not None:
|
102
105
|
return ReferringType.SUBSECTION
|
103
|
-
if self.
|
106
|
+
if self.sec is not None:
|
104
107
|
return ReferringType.SECTION
|
105
108
|
return ReferringType.CHAPTER
|
106
109
|
|
107
110
|
|
108
|
-
class ArticleMetaData(SketchedAble, Described, Language):
|
111
|
+
class ArticleMetaData(SketchedAble, Described, WordCount, Titled, Language):
|
109
112
|
"""Metadata for an article component."""
|
110
113
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
114
|
+
description: str = Field(
|
115
|
+
alias="elaboration",
|
116
|
+
description=Described.model_fields["description"].description,
|
117
|
+
)
|
118
|
+
|
119
|
+
title: str = Field(alias="heading", description=Titled.model_fields["title"].description)
|
115
120
|
|
116
|
-
|
121
|
+
aims: List[str]
|
117
122
|
"""List of writing aims of the research component in academic style."""
|
118
|
-
title: str
|
119
|
-
"""Do not add any prefix or suffix to the title. should not contain special characters."""
|
120
123
|
|
121
|
-
|
122
|
-
"""
|
124
|
+
support_to: List[ArticleRef]
|
125
|
+
"""List of references to other future components in this article that this component supports to."""
|
126
|
+
depend_on: List[ArticleRef]
|
127
|
+
"""List of references to other previous components in this article that this component depends on."""
|
123
128
|
|
124
129
|
|
125
130
|
class ArticleRefSequencePatch(SequencePatch[ArticleRef]):
|
@@ -147,8 +152,8 @@ class ArticleOutlineBase(
|
|
147
152
|
self.support_to.extend(other.support_to)
|
148
153
|
self.depend_on.clear()
|
149
154
|
self.depend_on.extend(other.depend_on)
|
150
|
-
self.
|
151
|
-
self.
|
155
|
+
self.aims.clear()
|
156
|
+
self.aims.extend(other.aims)
|
152
157
|
self.description = other.description
|
153
158
|
return self
|
154
159
|
|
@@ -272,22 +277,19 @@ class ChapterBase[T: SectionBase](ArticleOutlineBase):
|
|
272
277
|
return ""
|
273
278
|
|
274
279
|
|
275
|
-
class ArticleBase[T: ChapterBase](FinalizedDumpAble, AsPrompt, Language, ABC):
|
280
|
+
class ArticleBase[T: ChapterBase](FinalizedDumpAble, AsPrompt, WordCount, Described, Titled, Language, ABC):
|
276
281
|
"""Base class for article outlines."""
|
277
282
|
|
278
|
-
title: str
|
279
|
-
|
283
|
+
title: str = Field(alias="heading", description=Titled.model_fields["title"].description)
|
284
|
+
description: str = Field(alias="abstract")
|
285
|
+
"""The abstract serves as a concise summary of an academic article, encapsulating its core purpose, methodologies, key results,
|
286
|
+
and conclusions while enabling readers to rapidly assess the relevance and significance of the study.
|
287
|
+
Functioning as the article's distilled essence, it succinctly articulates the research problem, objectives,
|
288
|
+
and scope, providing a roadmap for the full text while also facilitating database indexing, literature reviews,
|
289
|
+
and citation tracking through standardized metadata. Additionally, it acts as an accessibility gateway,
|
290
|
+
allowing scholars to gauge the study's contribution to existing knowledge, its methodological rigor,
|
291
|
+
and its broader implications without engaging with the entire manuscript, thereby optimizing scholarly communication efficiency."""
|
280
292
|
|
281
|
-
prospect: str
|
282
|
-
"""Consolidated research statement with four pillars:
|
283
|
-
1. Problem Identification: Current limitations
|
284
|
-
2. Methodological Response: Technical approach
|
285
|
-
3. Empirical Validation: Evaluation strategy
|
286
|
-
4. Scholarly Impact: Field contributions
|
287
|
-
"""
|
288
|
-
|
289
|
-
abstract: str
|
290
|
-
"""The abstract is a concise summary of the academic paper's main findings."""
|
291
293
|
chapters: List[T]
|
292
294
|
"""Chapters of the article. Contains at least one chapter. You can also add more as needed."""
|
293
295
|
|
@@ -415,14 +417,12 @@ class ArticleBase[T: ChapterBase](FinalizedDumpAble, AsPrompt, Language, ABC):
|
|
415
417
|
if not ref.deref(self):
|
416
418
|
summary += f"Invalid internal reference in `{component.__class__.__name__}` titled `{component.title}`, because the referred {ref.referring_type} is not exists within the article, see the original obj dump: {ref.model_dump()}\n"
|
417
419
|
|
418
|
-
if ref.
|
419
|
-
summary += f"Chapter titled `{ref.
|
420
|
-
if ref.
|
421
|
-
summary += f"Section Titled `{ref.
|
422
|
-
if ref.
|
423
|
-
summary +=
|
424
|
-
f"Subsection Titled `{ref.referred_subsection_title}` is not any of {subsec_titles_set}"
|
425
|
-
)
|
420
|
+
if ref.chap not in (chap_titles_set):
|
421
|
+
summary += f"Chapter titled `{ref.chap}` is not any of {chap_titles_set}\n"
|
422
|
+
if ref.sec and ref.sec not in (sec_titles_set):
|
423
|
+
summary += f"Section Titled `{ref.sec}` is not any of {sec_titles_set}\n"
|
424
|
+
if ref.subsec and ref.subsec not in (subsec_titles_set):
|
425
|
+
summary += f"Subsection Titled `{ref.subsec}` is not any of {subsec_titles_set}"
|
426
426
|
|
427
427
|
if summary:
|
428
428
|
return (
|
@@ -453,17 +453,15 @@ class ArticleBase[T: ChapterBase](FinalizedDumpAble, AsPrompt, Language, ABC):
|
|
453
453
|
r for r in chain(component.depend_on, component.support_to) if not r.deref(self) and r not in res_seq
|
454
454
|
):
|
455
455
|
res_seq.append(ref)
|
456
|
-
if ref.
|
457
|
-
summary.append(
|
458
|
-
f"Chapter titled `{ref.referred_chapter_title}` is not exist, since it is not any of {chap_titles_set}."
|
459
|
-
)
|
460
|
-
if ref.referred_section_title and (ref.referred_section_title not in sec_titles_set):
|
456
|
+
if ref.chap not in chap_titles_set:
|
461
457
|
summary.append(
|
462
|
-
f"
|
458
|
+
f"Chapter titled `{ref.chap}` is not exist, since it is not any of {chap_titles_set}."
|
463
459
|
)
|
464
|
-
if ref.
|
460
|
+
if ref.sec and (ref.sec not in sec_titles_set):
|
461
|
+
summary.append(f"Section Titled `{ref.sec}` is not exist, since it is not any of {sec_titles_set}")
|
462
|
+
if ref.subsec and (ref.subsec not in subsec_titles_set):
|
465
463
|
summary.append(
|
466
|
-
f"Subsection Titled `{ref.
|
464
|
+
f"Subsection Titled `{ref.subsec}` is not exist, since it is not any of {subsec_titles_set}"
|
467
465
|
)
|
468
466
|
|
469
467
|
return res_seq, "\n".join(summary)
|