fabricatio 0.2.9.dev0__tar.gz → 0.2.9.dev2__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.dev0 → fabricatio-0.2.9.dev2}/Cargo.lock +7 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/Cargo.toml +1 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/PKG-INFO +1 -1
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/rules/draft_ruleset.py +14 -5
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/write_article/.gitignore +1 -1
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/pyproject.toml +1 -1
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/actions/output.py +43 -3
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/capabilities/censor.py +1 -3
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/capabilities/check.py +3 -4
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/capabilities/correct.py +4 -4
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/config.py +1 -1
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/action.py +43 -28
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/extra/article_base.py +6 -4
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/extra/article_main.py +3 -4
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/extra/article_outline.py +2 -3
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/extra/article_proposal.py +4 -4
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/generic.py +91 -40
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/rust.pyi +9 -4
- fabricatio-0.2.9.dev2/src/hbs_helpers.rs +18 -0
- fabricatio-0.2.9.dev2/src/language.rs +42 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/src/lib.rs +2 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/src/templates.rs +4 -1
- fabricatio-0.2.9.dev2/templates/built-in/liststr.hbs +22 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/refined_query.hbs +1 -1
- fabricatio-0.2.9.dev2/templates/built-in/rule_requirement.hbs +7 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/ruleset_requirement_breakdown.hbs +1 -1
- fabricatio-0.2.9.dev2/templates.tar.gz +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/uv.lock +58 -59
- fabricatio-0.2.9.dev0/src/hbs_helpers.rs +0 -9
- fabricatio-0.2.9.dev0/templates/built-in/liststr.hbs +0 -45
- fabricatio-0.2.9.dev0/templates/built-in/rule_requirement.hbs +0 -12
- fabricatio-0.2.9.dev0/templates.tar.gz +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/.github/workflows/build-package.yaml +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/.github/workflows/ruff.yaml +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/.github/workflows/tests.yaml +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/.gitignore +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/.python-version +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/LICENSE +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/Makefile +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/README.md +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/correct/correct.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/correct/correct_loop.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/extract_and_inject/.gitignore +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/extract_and_inject/article_rag.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/extract_and_inject/ask.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/extract_and_inject/extract_and_inject.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/extract_article/extract.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/llm_usages/llm_usage.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/make_a_rating/rating.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/make_diary/commits.json +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/make_diary/diary.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/minor/hello_fabricatio.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/minor/write_a_poem.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/propose_task/propose.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/reviewer/review.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/rules/.gitignore +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/search_bibtex/.gitignore +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/search_bibtex/search.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/simple_chat/chat.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/simple_rag/simple_rag.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/task_handle/handle_task.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/write_article/article_rag.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/write_article/write_article.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/write_outline/.gitignore +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/write_outline/write_outline.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/examples/write_outline/write_outline_corrected.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/__init__.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/actions/__init__.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/actions/article.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/actions/article_rag.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/actions/rag.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/actions/rules.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/capabilities/__init__.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/capabilities/advanced_judge.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/capabilities/propose.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/capabilities/rag.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/capabilities/rating.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/capabilities/review.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/capabilities/task.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/core.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/decorators.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/fs/__init__.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/fs/curd.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/fs/readers.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/journal.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/adv_kwargs_types.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/events.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/extra/__init__.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/extra/advanced_judge.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/extra/article_essence.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/extra/patches.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/extra/problem.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/extra/rule.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/kwargs_types.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/role.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/task.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/tool.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/usages.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/utils.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/parser.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/py.typed +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/rust_instances.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/toolboxes/__init__.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/toolboxes/arithmetic.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/toolboxes/fs.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/utils.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/workflows/__init__.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/workflows/articles.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/workflows/rag.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/src/bib_tools.rs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/src/hash.rs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/as_prompt.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/binary-exploitation-ctf-solver.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/check_string.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/claude-xml.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/clean-up-code.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/co_validation.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/create_json_obj.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/cryptography-ctf-solver.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/dependencies.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/document-the-code.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/draft_rating_criteria.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/draft_rating_manual.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/draft_rating_weights_klee.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/draft_tool_usage_code.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/extract_criteria_from_reasons.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/extract_reasons_from_examples.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/find-security-vulnerabilities.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/fix-bugs.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/fix_troubled_obj.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/fix_troubled_string.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/generic_string.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/improve-performance.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/make_choice.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/make_judgment.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/pathstr.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/rate_fine_grind.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/refactor.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/retrieved_display.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/reverse-engineering-ctf-solver.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/review_string.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/task_briefing.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/web-ctf-solver.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/write-git-commit.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/write-github-pull-request.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/templates/built-in/write-github-readme.hbs +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/tests/test_config.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/tests/test_models/test_action.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/tests/test_models/test_advanced.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/tests/test_models/test_generic.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/tests/test_models/test_role.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/tests/test_models/test_task.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/tests/test_models/test_tool.py +0 -0
- {fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/tests/test_models/test_usages.py +0 -0
@@ -453,6 +453,7 @@ dependencies = [
|
|
453
453
|
"rayon",
|
454
454
|
"serde_json",
|
455
455
|
"walkdir",
|
456
|
+
"whichlang",
|
456
457
|
]
|
457
458
|
|
458
459
|
[[package]]
|
@@ -2099,6 +2100,12 @@ dependencies = [
|
|
2099
2100
|
"wasm-bindgen",
|
2100
2101
|
]
|
2101
2102
|
|
2103
|
+
[[package]]
|
2104
|
+
name = "whichlang"
|
2105
|
+
version = "0.1.1"
|
2106
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
2107
|
+
checksum = "0b9aa3ad29c3d08283ac6b769e3ec15ad1ddb88af7d2e9bc402c574973b937e7"
|
2108
|
+
|
2102
2109
|
[[package]]
|
2103
2110
|
name = "winapi-util"
|
2104
2111
|
version = "0.1.9"
|
@@ -17,24 +17,33 @@ async def main() -> None:
|
|
17
17
|
"""Main function."""
|
18
18
|
Role(
|
19
19
|
name="Undergraduate Researcher",
|
20
|
-
|
21
|
-
llm_model="openai/deepseek-v3-250324",
|
20
|
+
llm_model="openai/qwen-plus",
|
22
21
|
llm_rpm=1000,
|
23
22
|
llm_tpm=3000000,
|
24
23
|
llm_max_tokens=8190,
|
25
24
|
registry={
|
26
25
|
Event.quick_instantiate(ns := "article"): WorkFlow(
|
27
26
|
name="write ruleset",
|
28
|
-
description="Generate
|
27
|
+
description="Generate a draft ruleset for article.",
|
29
28
|
steps=(
|
30
29
|
DraftRuleSet(
|
31
|
-
ruleset_requirement="1.when try to use an article as reference cited in our article, you should obey the format like (author1, author2 et al., YYYY)
|
30
|
+
ruleset_requirement="1.when try to use an article as reference cited in our article, you should obey the format like `(author1, author2 et al., YYYY)#cite(<bibtex_cite_key>)`\n"
|
32
31
|
"2.we use typst to generate numeric citation. For example, for an article whose `bibtex_key` is `YanWindEnergy2018`, you can create a numeric citation by typing `#cite(<YanWindEnergy2018>)`(note that `bibtex_key` with `<` and `>` wrapped is needed), those notations could automatically be processed and output by compiler as a numeric citation like `[1]` in the upper right corner of text.\n"
|
33
32
|
"3.in addition, since `#cite()` can ONLY cite ONE article at once, we need use multiple `#cite()` notations to cite multiple articles, for example, there are three articles whose `bibtex_key` are `YanWindEnergy2018`, `YanWindEnergy2019`, `YanWindEnergy2020, you can cite them three as numeric citation by typing `#cite(<YanWindEnergy2018>)#cite(<YanWindEnergy2019>)#cite(<YanWindEnergy2020>)` those notations could automatically be processed and output by compiler as a numeric citation like `[1,2,3]` in the upper right corner of text.\n"
|
34
33
|
"4.to cover more references, we usually cite more than one articles that have similar opinions in a single sentence if possible.\n"
|
35
34
|
"5.when using `#cite()` notation, you must be aware of the cite key should be wrapped by `<` and `>`, compiler wont let it pass compilation otherwise.",
|
36
35
|
rule_count=5,
|
37
|
-
|
36
|
+
output_key="en_ruleset"
|
37
|
+
),
|
38
|
+
DraftRuleSet(
|
39
|
+
ruleset_requirement="1. 当在文章中引用其他文章作为参考文献时, 应遵循`(作者1, 作者2等, 年份)#cite(<bibtex_cite_key>)`的格式进行标注。\n"
|
40
|
+
"2. 我们使用Typst生成数字引用格式。例如, 对于BibTeX键为`YanWindEnergy2018`的文献, 可通过输入`#cite(<YanWindEnergy2018>)`创建数字引用(注意:BibTeX键必须用尖括号`<`和`>`包裹)。这些标记会被编译器自动处理并输出为右上角的数字引用格式, 例如文本旁的[1]。\n"
|
41
|
+
"3. 此外, 由于`#cite()`每次只能引用单一文献, 需通过叠加多个`#cite()`标记实现多文献引用。例如, 若需引用三个BibTeX键分别为`YanWindEnergy2018`、`YanWindEnergy2019`和`YanWindEnergy2020`的文献, 应输入`#cite(<YanWindEnergy2018>)#cite(<YanWindEnergy2019>)#cite(<YanWindEnergy2020>)`, 编译后将呈现为[1,2,3]的右上角数字引用格式。\n"
|
42
|
+
"4. 为增加参考文献的覆盖率, 我们通常建议在可能的情况下, 将多个观点相似的文献合并引用于同一句子中。"
|
43
|
+
"5. 使用`#cite()`时需注意:BibTeX键必须用尖括号`<`和`>`包裹, 否则编译器将拒绝通过编译。",
|
44
|
+
rule_count=5,
|
45
|
+
output_key="zh_ruleset"
|
46
|
+
),
|
38
47
|
PersistentAll(persist_dir="persistent"),
|
39
48
|
),
|
40
49
|
)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"""Dump the finalized output to a file."""
|
2
2
|
|
3
3
|
from pathlib import Path
|
4
|
-
from typing import Iterable, List, Optional, Type
|
4
|
+
from typing import Any, Iterable, List, Optional, Type
|
5
5
|
|
6
6
|
from fabricatio.journal import logger
|
7
7
|
from fabricatio.models.action import Action
|
@@ -33,6 +33,7 @@ class DumpFinalizedOutput(Action):
|
|
33
33
|
"Could not find the path of file to dump the data.",
|
34
34
|
)
|
35
35
|
)
|
36
|
+
logger.info(f"Saving output to {dump_path.as_posix()}")
|
36
37
|
ok(to_dump, "Could not dump the data since the path is not specified.").finalized_dump_to(dump_path)
|
37
38
|
return dump_path.as_posix()
|
38
39
|
|
@@ -41,7 +42,11 @@ class PersistentAll(Action):
|
|
41
42
|
"""Persist all the data to a file."""
|
42
43
|
|
43
44
|
output_key: str = "persistent_count"
|
45
|
+
"""The number of objects persisted."""
|
44
46
|
persist_dir: Optional[str] = None
|
47
|
+
"""The directory to persist the data."""
|
48
|
+
override: bool = False
|
49
|
+
"""Whether to remove the existing dir before dumping."""
|
45
50
|
|
46
51
|
async def _execute(
|
47
52
|
self,
|
@@ -64,16 +69,22 @@ class PersistentAll(Action):
|
|
64
69
|
if persist_dir.is_file():
|
65
70
|
logger.warning("Dump should be a directory, but it is a file. Skip dumping.")
|
66
71
|
return count
|
67
|
-
|
72
|
+
if self.override and persist_dir.is_dir():
|
73
|
+
logger.info(f"Override the existing directory {persist_dir.as_posix()}.")
|
74
|
+
persist_dir.rmdir()
|
75
|
+
logger.info(f"Starting persistence in directory {persist_dir}")
|
68
76
|
for k, v in cxt.items():
|
69
77
|
final_dir = persist_dir.joinpath(k)
|
78
|
+
logger.debug(f"Checking key {k} for persistence")
|
70
79
|
if isinstance(v, PersistentAble):
|
80
|
+
logger.info(f"Persisting object {k} to {final_dir}")
|
71
81
|
final_dir.mkdir(parents=True, exist_ok=True)
|
72
82
|
v.persist(final_dir)
|
73
83
|
count += 1
|
74
84
|
if isinstance(v, Iterable) and any(
|
75
85
|
persistent_ables := (pers for pers in v if isinstance(pers, PersistentAble))
|
76
86
|
):
|
87
|
+
logger.info(f"Persisting collection {k} to {final_dir}")
|
77
88
|
final_dir.mkdir(parents=True, exist_ok=True)
|
78
89
|
for per in persistent_ables:
|
79
90
|
per.persist(final_dir)
|
@@ -93,10 +104,39 @@ class RetrieveFromPersistent[T: PersistentAble](Action):
|
|
93
104
|
"""The class of the object to retrieve."""
|
94
105
|
|
95
106
|
async def _execute(self, /, **__) -> Optional[T | List[T]]:
|
96
|
-
logger.info(f"Retrieve `{self.retrieve_cls.__name__}` from
|
107
|
+
logger.info(f"Retrieve `{self.retrieve_cls.__name__}` from {self.load_path}")
|
97
108
|
if not (p := Path(self.load_path)).exists():
|
109
|
+
logger.warning(f"Path {self.load_path} does not exist")
|
98
110
|
return None
|
99
111
|
|
100
112
|
if p.is_dir():
|
113
|
+
logger.info(f"Found directory with {len(list(p.glob('*')))} items")
|
101
114
|
return [self.retrieve_cls.from_persistent(per) for per in p.glob("*")]
|
102
115
|
return self.retrieve_cls.from_persistent(self.load_path)
|
116
|
+
|
117
|
+
|
118
|
+
class GatherAsList(Action):
|
119
|
+
"""Gather the objects from the context as a list.
|
120
|
+
|
121
|
+
Notes:
|
122
|
+
If both `gather_suffix` and `gather_prefix` are specified, only the objects with the suffix will be gathered.
|
123
|
+
"""
|
124
|
+
output_key: str = "gathered"
|
125
|
+
"""Gather the objects from the context as a list."""
|
126
|
+
gather_suffix: Optional[str] = None
|
127
|
+
"""Gather the objects from the context as a list."""
|
128
|
+
gather_prefix: Optional[str] = None
|
129
|
+
"""Gather the objects from the context as a list."""
|
130
|
+
|
131
|
+
async def _execute(self, **cxt) -> List[Any]:
|
132
|
+
|
133
|
+
if self.gather_suffix is not None:
|
134
|
+
result = [cxt[k] for k in cxt if k.endswith(self.gather_suffix)]
|
135
|
+
logger.debug(f"Gathered {len(result)} items with suffix {self.gather_suffix}")
|
136
|
+
return result
|
137
|
+
if self.gather_prefix is None:
|
138
|
+
logger.error(err:="Either `gather_suffix` or `gather_prefix` must be specified.")
|
139
|
+
raise ValueError(err)
|
140
|
+
result = [cxt[k] for k in cxt if k.startswith(self.gather_prefix)]
|
141
|
+
logger.debug(f"Gathered {len(result)} items with prefix {self.gather_prefix}")
|
142
|
+
return result
|
@@ -20,8 +20,6 @@ class Censor(Correct, Check):
|
|
20
20
|
Inherits from both Correct and Check classes.
|
21
21
|
Provides methods to censor objects and strings by first checking them against a ruleset and then correcting them if necessary.
|
22
22
|
|
23
|
-
Attributes:
|
24
|
-
ruleset (RuleSet): The ruleset to be used for censoring.
|
25
23
|
"""
|
26
24
|
|
27
25
|
async def censor_obj[M: SketchedAble](
|
@@ -42,7 +40,7 @@ class Censor(Correct, Check):
|
|
42
40
|
"""
|
43
41
|
imp = await self.check_obj(obj, ruleset, **override_kwargs(kwargs, default=None))
|
44
42
|
if imp is None:
|
45
|
-
return
|
43
|
+
return None
|
46
44
|
return await self.correct_obj(obj, imp, **kwargs)
|
47
45
|
|
48
46
|
async def censor_string(
|
@@ -11,6 +11,7 @@ from fabricatio.models.extra.problem import Improvement
|
|
11
11
|
from fabricatio.models.extra.rule import Rule, RuleSet
|
12
12
|
from fabricatio.models.generic import Display, WithBriefing
|
13
13
|
from fabricatio.models.kwargs_types import ValidateKwargs
|
14
|
+
from fabricatio.rust import detect_language
|
14
15
|
from fabricatio.utils import override_kwargs
|
15
16
|
|
16
17
|
|
@@ -56,9 +57,7 @@ class Check(AdvancedJudge, Propose):
|
|
56
57
|
|
57
58
|
ruleset_patch = await self.propose(
|
58
59
|
RuleSetBriefingPatch,
|
59
|
-
f"
|
60
|
-
f"You need to write a concise and detailed patch for this ruleset that can be applied to the ruleset nicely.\n"
|
61
|
-
f"Note that all fields in this patch will be directly copied to the ruleset obj, including `name` and `description`, so write when knowing the subject.\n",
|
60
|
+
f"{ruleset_requirement}\n\nYou should use `{detect_language(ruleset_requirement)}`!",
|
62
61
|
**override_kwargs(kwargs, default=None),
|
63
62
|
)
|
64
63
|
|
@@ -98,7 +97,7 @@ class Check(AdvancedJudge, Propose):
|
|
98
97
|
Improvement,
|
99
98
|
TEMPLATE_MANAGER.render_template(
|
100
99
|
configs.templates.check_string_template,
|
101
|
-
{"to_check": input_text, "rule": rule, "judge": judge.display(), "reference": reference},
|
100
|
+
{"to_check": input_text, "rule": rule.display(), "judge": judge.display(), "reference": reference},
|
102
101
|
),
|
103
102
|
**kwargs,
|
104
103
|
)
|
@@ -78,11 +78,11 @@ class Correct(Rating, Propose):
|
|
78
78
|
TEMPLATE_MANAGER.render_template(
|
79
79
|
configs.templates.fix_troubled_obj_template,
|
80
80
|
{
|
81
|
-
"problem": problem_solutions.problem,
|
81
|
+
"problem": problem_solutions.problem.display(),
|
82
82
|
"solution": ok(
|
83
83
|
problem_solutions.final_solution(),
|
84
84
|
f"No solution found for problem: {problem_solutions.problem}",
|
85
|
-
),
|
85
|
+
).display(),
|
86
86
|
"reference": reference,
|
87
87
|
},
|
88
88
|
),
|
@@ -111,11 +111,11 @@ class Correct(Rating, Propose):
|
|
111
111
|
TEMPLATE_MANAGER.render_template(
|
112
112
|
configs.templates.fix_troubled_string_template,
|
113
113
|
{
|
114
|
-
"problem": problem_solutions.problem,
|
114
|
+
"problem": problem_solutions.problem.display(),
|
115
115
|
"solution": ok(
|
116
116
|
problem_solutions.final_solution(),
|
117
117
|
f"No solution found for problem: {problem_solutions.problem}",
|
118
|
-
),
|
118
|
+
).display(),
|
119
119
|
"reference": reference,
|
120
120
|
"string_to_fix": input_text,
|
121
121
|
},
|
@@ -303,7 +303,7 @@ class CacheConfig(BaseModel):
|
|
303
303
|
|
304
304
|
model_config = ConfigDict(use_attribute_docstrings=True)
|
305
305
|
|
306
|
-
type:
|
306
|
+
type: LiteLLMCacheType = LiteLLMCacheType.LOCAL
|
307
307
|
"""The type of cache to use. If None, the default cache type will be used."""
|
308
308
|
params: CacheKwargs = Field(default_factory=CacheKwargs)
|
309
309
|
"""The parameters for the cache. If type is None, the default parameters will be used."""
|
@@ -1,7 +1,12 @@
|
|
1
|
-
"""Module that contains the classes for
|
1
|
+
"""Module that contains the classes for defining and executing task workflows.
|
2
2
|
|
3
|
-
This module
|
4
|
-
|
3
|
+
This module provides the Action and WorkFlow classes for creating structured
|
4
|
+
task execution pipelines. Actions represent atomic operations, while WorkFlows
|
5
|
+
orchestrate sequences of actions with shared context and error handling.
|
6
|
+
|
7
|
+
Classes:
|
8
|
+
Action: Base class for defining executable actions with context management.
|
9
|
+
WorkFlow: Manages action sequences, context propagation, and task lifecycle.
|
5
10
|
"""
|
6
11
|
|
7
12
|
import traceback
|
@@ -50,28 +55,26 @@ class Action(WithBriefing, LLMUsage):
|
|
50
55
|
self.description = self.description or self.__class__.__doc__ or ""
|
51
56
|
|
52
57
|
@abstractmethod
|
53
|
-
async def _execute(self, *_, **cxt) -> Any:
|
54
|
-
"""
|
55
|
-
|
56
|
-
This method must be implemented by subclasses to define the actual behavior.
|
58
|
+
async def _execute(self, *_:Any, **cxt) -> Any:
|
59
|
+
"""Implement the core logic of the action.
|
57
60
|
|
58
61
|
Args:
|
59
|
-
**cxt:
|
62
|
+
**cxt: Context dictionary containing input/output data.
|
60
63
|
|
61
64
|
Returns:
|
62
|
-
|
65
|
+
Result of the action execution to be stored in context.
|
63
66
|
"""
|
64
67
|
pass
|
65
68
|
|
66
69
|
@final
|
67
70
|
async def act(self, cxt: Dict[str, Any]) -> Dict[str, Any]:
|
68
|
-
"""
|
71
|
+
"""Execute action and update context.
|
69
72
|
|
70
73
|
Args:
|
71
|
-
cxt:
|
74
|
+
cxt (Dict[str, Any]): Shared context dictionary.
|
72
75
|
|
73
76
|
Returns:
|
74
|
-
|
77
|
+
Updated context dictionary with new/modified entries.
|
75
78
|
"""
|
76
79
|
ret = await self._execute(**cxt)
|
77
80
|
|
@@ -83,10 +86,10 @@ class Action(WithBriefing, LLMUsage):
|
|
83
86
|
|
84
87
|
@property
|
85
88
|
def briefing(self) -> str:
|
86
|
-
"""
|
89
|
+
"""Generate formatted action description with personality context.
|
87
90
|
|
88
91
|
Returns:
|
89
|
-
|
92
|
+
Briefing text combining personality and action description.
|
90
93
|
"""
|
91
94
|
if self.personality:
|
92
95
|
return f"## Your personality: \n{self.personality}\n# The action you are going to perform: \n{super().briefing}"
|
@@ -98,10 +101,15 @@ class Action(WithBriefing, LLMUsage):
|
|
98
101
|
return self
|
99
102
|
|
100
103
|
class WorkFlow(WithBriefing, ToolBoxUsage):
|
101
|
-
"""
|
104
|
+
"""Manages sequences of actions to fulfill tasks.
|
102
105
|
|
103
|
-
|
104
|
-
|
106
|
+
Handles context propagation between actions, error handling, and task lifecycle
|
107
|
+
events like cancellation and completion.
|
108
|
+
|
109
|
+
Attributes:
|
110
|
+
steps (Tuple): Sequence of Action instances or classes to execute.
|
111
|
+
task_input_key (str): Key for storing task instance in context.
|
112
|
+
task_output_key (str): Key to retrieve final result from context.
|
105
113
|
"""
|
106
114
|
|
107
115
|
description: str = ""
|
@@ -137,26 +145,29 @@ class WorkFlow(WithBriefing, ToolBoxUsage):
|
|
137
145
|
self._instances = tuple(step if isinstance(step, Action) else step() for step in self.steps)
|
138
146
|
|
139
147
|
def inject_personality(self, personality: str) -> Self:
|
140
|
-
"""Set
|
148
|
+
"""Set personality for actions without existing personality.
|
141
149
|
|
142
150
|
Args:
|
143
|
-
personality:
|
151
|
+
personality (str): Shared personality context
|
144
152
|
|
145
153
|
Returns:
|
146
|
-
|
154
|
+
Workflow instance with updated actions
|
147
155
|
"""
|
148
156
|
for action in filter(lambda a: not a.personality, self._instances):
|
149
157
|
action.personality = personality
|
150
158
|
return self
|
151
159
|
|
152
160
|
async def serve(self, task: Task) -> None:
|
153
|
-
"""Execute
|
154
|
-
|
155
|
-
This method manages the complete lifecycle of processing a task through
|
156
|
-
the workflow's sequence of actions.
|
161
|
+
"""Execute workflow to complete given task.
|
157
162
|
|
158
163
|
Args:
|
159
|
-
task:
|
164
|
+
task (Task): Task instance to be processed.
|
165
|
+
|
166
|
+
Steps:
|
167
|
+
1. Initialize context with task instance and extra data
|
168
|
+
2. Execute each action sequentially
|
169
|
+
3. Handle task cancellation and exceptions
|
170
|
+
4. Extract final result from context
|
160
171
|
"""
|
161
172
|
logger.info(f"Start execute workflow: {self.name}")
|
162
173
|
|
@@ -206,10 +217,14 @@ class WorkFlow(WithBriefing, ToolBoxUsage):
|
|
206
217
|
await task.fail()
|
207
218
|
|
208
219
|
async def _init_context[T](self, task: Task[T]) -> None:
|
209
|
-
"""Initialize
|
220
|
+
"""Initialize workflow execution context.
|
210
221
|
|
211
222
|
Args:
|
212
|
-
task:
|
223
|
+
task (Task[T]): Task being processed
|
224
|
+
|
225
|
+
Context includes:
|
226
|
+
- Task instance stored under task_input_key
|
227
|
+
- Any extra_init_context values
|
213
228
|
"""
|
214
229
|
logger.debug(f"Initializing context for workflow: {self.name}")
|
215
230
|
initial_context = {self.task_input_key: task, **dict(self.extra_init_context)}
|
@@ -230,7 +245,7 @@ class WorkFlow(WithBriefing, ToolBoxUsage):
|
|
230
245
|
Returns:
|
231
246
|
Self: The workflow instance for method chaining.
|
232
247
|
"""
|
233
|
-
self.provide_tools_to(self._instances)
|
248
|
+
self.provide_tools_to(i for i in self._instances if isinstance(i,ToolBoxUsage))
|
234
249
|
return self
|
235
250
|
|
236
251
|
def update_init_context(self, /, **kwargs) -> Self:
|
{fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/extra/article_base.py
RENAMED
@@ -7,8 +7,6 @@ from typing import Generator, List, Optional, Self, Tuple, overload
|
|
7
7
|
|
8
8
|
from fabricatio.models.generic import (
|
9
9
|
AsPrompt,
|
10
|
-
CensoredAble,
|
11
|
-
Display,
|
12
10
|
FinalizedDumpAble,
|
13
11
|
Introspect,
|
14
12
|
ModelHash,
|
@@ -16,6 +14,7 @@ from fabricatio.models.generic import (
|
|
16
14
|
ProposedUpdateAble,
|
17
15
|
ResolveUpdateConflict,
|
18
16
|
SequencePatch,
|
17
|
+
SketchedAble,
|
19
18
|
)
|
20
19
|
|
21
20
|
|
@@ -30,7 +29,7 @@ class ReferringType(StrEnum):
|
|
30
29
|
type RefKey = Tuple[str, Optional[str], Optional[str]]
|
31
30
|
|
32
31
|
|
33
|
-
class ArticleRef(
|
32
|
+
class ArticleRef(ProposedUpdateAble):
|
34
33
|
"""Reference to a specific chapter, section or subsection within the article. You SHALL not refer to an article component that is external and not present within our own article.
|
35
34
|
|
36
35
|
Examples:
|
@@ -104,7 +103,7 @@ class ArticleRef(CensoredAble, ProposedUpdateAble):
|
|
104
103
|
return ReferringType.CHAPTER
|
105
104
|
|
106
105
|
|
107
|
-
class ArticleMetaData(
|
106
|
+
class ArticleMetaData(SketchedAble):
|
108
107
|
"""Metadata for an article component."""
|
109
108
|
|
110
109
|
description: str
|
@@ -120,6 +119,9 @@ class ArticleMetaData(CensoredAble, Display):
|
|
120
119
|
title: str
|
121
120
|
"""Do not add any prefix or suffix to the title. should not contain special characters."""
|
122
121
|
|
122
|
+
expected_word_count: int
|
123
|
+
"""Expected word count of this research component."""
|
124
|
+
|
123
125
|
|
124
126
|
class ArticleRefSequencePatch(SequencePatch[ArticleRef]):
|
125
127
|
"""Patch for article refs."""
|
{fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/extra/article_main.py
RENAMED
@@ -14,11 +14,11 @@ from fabricatio.models.extra.article_base import (
|
|
14
14
|
from fabricatio.models.extra.article_outline import (
|
15
15
|
ArticleOutline,
|
16
16
|
)
|
17
|
-
from fabricatio.models.generic import
|
17
|
+
from fabricatio.models.generic import PersistentAble, SequencePatch, SketchedAble, WithRef
|
18
18
|
from fabricatio.utils import ok
|
19
19
|
|
20
20
|
|
21
|
-
class Paragraph(
|
21
|
+
class Paragraph(SketchedAble):
|
22
22
|
"""Structured academic paragraph blueprint for controlled content generation."""
|
23
23
|
|
24
24
|
description: str
|
@@ -73,8 +73,7 @@ class ArticleChapter(ChapterBase[ArticleSection]):
|
|
73
73
|
|
74
74
|
|
75
75
|
class Article(
|
76
|
-
|
77
|
-
CensoredAble,
|
76
|
+
SketchedAble,
|
78
77
|
WithRef[ArticleOutline],
|
79
78
|
PersistentAble,
|
80
79
|
ArticleBase[ArticleChapter],
|
{fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/extra/article_outline.py
RENAMED
@@ -9,7 +9,7 @@ from fabricatio.models.extra.article_base import (
|
|
9
9
|
SubSectionBase,
|
10
10
|
)
|
11
11
|
from fabricatio.models.extra.article_proposal import ArticleProposal
|
12
|
-
from fabricatio.models.generic import
|
12
|
+
from fabricatio.models.generic import PersistentAble, SketchedAble, WithRef
|
13
13
|
|
14
14
|
|
15
15
|
class ArticleSubsectionOutline(SubSectionBase):
|
@@ -25,8 +25,7 @@ class ArticleChapterOutline(ChapterBase[ArticleSectionOutline]):
|
|
25
25
|
|
26
26
|
|
27
27
|
class ArticleOutline(
|
28
|
-
|
29
|
-
CensoredAble,
|
28
|
+
SketchedAble,
|
30
29
|
WithRef[ArticleProposal],
|
31
30
|
PersistentAble,
|
32
31
|
ArticleBase[ArticleChapterOutline],
|
{fabricatio-0.2.9.dev0 → fabricatio-0.2.9.dev2}/python/fabricatio/models/extra/article_proposal.py
RENAMED
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
from typing import Dict, List
|
4
4
|
|
5
|
-
from fabricatio.models.generic import AsPrompt,
|
5
|
+
from fabricatio.models.generic import AsPrompt, SketchedAble, PersistentAble, WithRef
|
6
6
|
|
7
7
|
|
8
|
-
class ArticleProposal(
|
8
|
+
class ArticleProposal(SketchedAble, WithRef[str], AsPrompt, PersistentAble):
|
9
9
|
"""Structured proposal for academic paper development with core research elements.
|
10
10
|
|
11
11
|
Guides LLM in generating comprehensive research proposals with clearly defined components.
|
@@ -41,8 +41,8 @@ class ArticleProposal(CensoredAble, Display, WithRef[str], AsPrompt, PersistentA
|
|
41
41
|
abstract: str
|
42
42
|
"""A concise summary of the research proposal, outlining the main points and objectives."""
|
43
43
|
|
44
|
-
|
45
|
-
"""The
|
44
|
+
expected_word_count: int
|
45
|
+
"""The estimated word count of the final academic paper."""
|
46
46
|
|
47
47
|
def _as_prompt_inner(self) -> Dict[str, str]:
|
48
48
|
return {
|