fabricatio 0.2.10.dev1__tar.gz → 0.2.11__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.10.dev1 → fabricatio-0.2.11}/.gitignore +1 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/Cargo.lock +113 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/Cargo.toml +2 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/PKG-INFO +19 -8
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/README.md +9 -2
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/extract_and_inject/chunk_article.py +2 -3
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/make_a_rating/rating.py +4 -4
- fabricatio-0.2.11/examples/propose_task/.gitignore +2 -0
- fabricatio-0.2.11/examples/propose_task/propose.py +49 -0
- fabricatio-0.2.11/examples/write_article/.gitignore +4 -0
- fabricatio-0.2.11/examples/write_article/post_process.py +12 -0
- fabricatio-0.2.11/examples/write_article/write_article.py +189 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/pyproject.toml +17 -9
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/actions/article.py +55 -10
- fabricatio-0.2.11/python/fabricatio/actions/article_rag.py +390 -0
- fabricatio-0.2.11/python/fabricatio/actions/fs.py +25 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/actions/output.py +17 -3
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/actions/rag.py +3 -3
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/actions/rules.py +14 -3
- fabricatio-0.2.11/python/fabricatio/capabilities/extract.py +70 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/capabilities/rating.py +5 -2
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/capabilities/task.py +16 -16
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/config.py +9 -2
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/decorators.py +43 -26
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/fs/__init__.py +9 -2
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/fs/readers.py +6 -10
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/action.py +16 -11
- fabricatio-0.2.11/python/fabricatio/models/extra/aricle_rag.py +254 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/extra/article_base.py +56 -7
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/extra/article_main.py +102 -6
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/extra/problem.py +5 -1
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/generic.py +31 -13
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/kwargs_types.py +4 -2
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/task.py +13 -1
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/usages.py +10 -27
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/parser.py +16 -12
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/rust.pyi +167 -62
- fabricatio-0.2.11/python/fabricatio/utils.py +94 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/src/bib_tools.rs +16 -3
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/src/hbs_helpers.rs +6 -0
- fabricatio-0.2.11/src/language.rs +126 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/src/lib.rs +3 -1
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/src/templates.rs +58 -14
- fabricatio-0.2.11/src/typst_tools.rs +85 -0
- fabricatio-0.2.11/templates/built-in/extract.hbs +6 -0
- fabricatio-0.2.11/templates.tar.gz +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/tests/test_models/test_problem.py +17 -37
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/uv.lock +170 -149
- fabricatio-0.2.10.dev1/examples/propose_task/propose.py +0 -32
- fabricatio-0.2.10.dev1/examples/write_article/.gitignore +0 -3
- fabricatio-0.2.10.dev1/examples/write_article/write_article.py +0 -241
- fabricatio-0.2.10.dev1/python/fabricatio/actions/article_rag.py +0 -136
- fabricatio-0.2.10.dev1/python/fabricatio/models/extra/aricle_rag.py +0 -120
- fabricatio-0.2.10.dev1/python/fabricatio/utils.py +0 -67
- fabricatio-0.2.10.dev1/src/language.rs +0 -40
- fabricatio-0.2.10.dev1/templates.tar.gz +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/.github/workflows/build-package.yaml +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/.github/workflows/ruff.yaml +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/.github/workflows/tests.yaml +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/.python-version +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/LICENSE +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/Makefile +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/correct/correct.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/correct/correct_loop.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/extract_and_inject/.gitignore +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/extract_and_inject/article_rag.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/extract_and_inject/ask.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/extract_and_inject/extract_and_inject.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/extract_article/extract.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/llm_usages/llm_usage.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/make_diary/commits.json +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/make_diary/diary.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/minor/hello_fabricatio.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/minor/write_a_poem.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/reviewer/censor.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/reviewer/review.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/rules/.gitignore +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/rules/draft_ruleset.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/search_bibtex/.gitignore +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/search_bibtex/search.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/simple_chat/chat.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/simple_rag/simple_rag.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/task_handle/handle_task.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/write_article/article_rag.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/write_outline/.gitignore +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/write_outline/write_outline.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/examples/write_outline/write_outline_corrected.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/__init__.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/actions/__init__.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/capabilities/__init__.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/capabilities/advanced_judge.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/capabilities/censor.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/capabilities/check.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/capabilities/correct.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/capabilities/propose.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/capabilities/rag.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/capabilities/review.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/constants.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/core.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/fs/curd.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/journal.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/adv_kwargs_types.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/events.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/extra/__init__.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/extra/advanced_judge.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/extra/article_essence.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/extra/article_outline.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/extra/article_proposal.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/extra/patches.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/extra/rag.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/extra/rule.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/role.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/models/tool.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/py.typed +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/rust_instances.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/toolboxes/__init__.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/toolboxes/arithmetic.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/toolboxes/fs.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/workflows/__init__.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/workflows/articles.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/python/fabricatio/workflows/rag.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/src/hash.rs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/src/word_split.rs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/as_prompt.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/binary-exploitation-ctf-solver.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/check_string.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/claude-xml.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/clean-up-code.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/co_validation.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/create_json_obj.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/cryptography-ctf-solver.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/dependencies.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/document-the-code.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/draft_rating_criteria.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/draft_rating_manual.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/draft_rating_weights_klee.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/draft_tool_usage_code.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/extract_criteria_from_reasons.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/extract_reasons_from_examples.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/find-security-vulnerabilities.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/fix-bugs.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/fix_troubled_obj.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/fix_troubled_string.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/generic_string.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/improve-performance.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/liststr.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/make_choice.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/make_judgment.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/pathstr.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/rate_fine_grind.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/refactor.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/refined_query.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/retrieved_display.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/reverse-engineering-ctf-solver.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/review_string.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/rule_requirement.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/ruleset_requirement_breakdown.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/task_briefing.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/web-ctf-solver.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/write-git-commit.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/write-github-pull-request.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/templates/built-in/write-github-readme.hbs +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/tests/test_config.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/tests/test_models/test_action.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/tests/test_models/test_advanced.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/tests/test_models/test_generic.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/tests/test_models/test_role.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/tests/test_models/test_task.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/tests/test_models/test_tool.py +0 -0
- {fabricatio-0.2.10.dev1 → fabricatio-0.2.11}/tests/test_models/test_usages.py +0 -0
@@ -17,6 +17,15 @@ version = "2.0.0"
|
|
17
17
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
18
18
|
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
|
19
19
|
|
20
|
+
[[package]]
|
21
|
+
name = "aho-corasick"
|
22
|
+
version = "1.1.3"
|
23
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
24
|
+
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
25
|
+
dependencies = [
|
26
|
+
"memchr",
|
27
|
+
]
|
28
|
+
|
20
29
|
[[package]]
|
21
30
|
name = "anstream"
|
22
31
|
version = "0.6.18"
|
@@ -451,7 +460,9 @@ dependencies = [
|
|
451
460
|
"pyo3",
|
452
461
|
"pythonize",
|
453
462
|
"rayon",
|
463
|
+
"regex",
|
454
464
|
"serde_json",
|
465
|
+
"tex2typst-rs",
|
455
466
|
"unicode-segmentation",
|
456
467
|
"walkdir",
|
457
468
|
"whichlang",
|
@@ -1198,6 +1209,48 @@ dependencies = [
|
|
1198
1209
|
"sha2",
|
1199
1210
|
]
|
1200
1211
|
|
1212
|
+
[[package]]
|
1213
|
+
name = "phf"
|
1214
|
+
version = "0.11.3"
|
1215
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1216
|
+
checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078"
|
1217
|
+
dependencies = [
|
1218
|
+
"phf_macros",
|
1219
|
+
"phf_shared",
|
1220
|
+
]
|
1221
|
+
|
1222
|
+
[[package]]
|
1223
|
+
name = "phf_generator"
|
1224
|
+
version = "0.11.3"
|
1225
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1226
|
+
checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d"
|
1227
|
+
dependencies = [
|
1228
|
+
"phf_shared",
|
1229
|
+
"rand",
|
1230
|
+
]
|
1231
|
+
|
1232
|
+
[[package]]
|
1233
|
+
name = "phf_macros"
|
1234
|
+
version = "0.11.3"
|
1235
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1236
|
+
checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216"
|
1237
|
+
dependencies = [
|
1238
|
+
"phf_generator",
|
1239
|
+
"phf_shared",
|
1240
|
+
"proc-macro2",
|
1241
|
+
"quote",
|
1242
|
+
"syn",
|
1243
|
+
]
|
1244
|
+
|
1245
|
+
[[package]]
|
1246
|
+
name = "phf_shared"
|
1247
|
+
version = "0.11.3"
|
1248
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1249
|
+
checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5"
|
1250
|
+
dependencies = [
|
1251
|
+
"siphasher",
|
1252
|
+
]
|
1253
|
+
|
1201
1254
|
[[package]]
|
1202
1255
|
name = "pin-project-lite"
|
1203
1256
|
version = "0.2.16"
|
@@ -1319,6 +1372,21 @@ version = "5.2.0"
|
|
1319
1372
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1320
1373
|
checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
|
1321
1374
|
|
1375
|
+
[[package]]
|
1376
|
+
name = "rand"
|
1377
|
+
version = "0.8.5"
|
1378
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1379
|
+
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
1380
|
+
dependencies = [
|
1381
|
+
"rand_core",
|
1382
|
+
]
|
1383
|
+
|
1384
|
+
[[package]]
|
1385
|
+
name = "rand_core"
|
1386
|
+
version = "0.6.4"
|
1387
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1388
|
+
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
1389
|
+
|
1322
1390
|
[[package]]
|
1323
1391
|
name = "rayon"
|
1324
1392
|
version = "1.10.0"
|
@@ -1359,6 +1427,35 @@ dependencies = [
|
|
1359
1427
|
"thiserror",
|
1360
1428
|
]
|
1361
1429
|
|
1430
|
+
[[package]]
|
1431
|
+
name = "regex"
|
1432
|
+
version = "1.11.1"
|
1433
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1434
|
+
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
|
1435
|
+
dependencies = [
|
1436
|
+
"aho-corasick",
|
1437
|
+
"memchr",
|
1438
|
+
"regex-automata",
|
1439
|
+
"regex-syntax",
|
1440
|
+
]
|
1441
|
+
|
1442
|
+
[[package]]
|
1443
|
+
name = "regex-automata"
|
1444
|
+
version = "0.4.9"
|
1445
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1446
|
+
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
1447
|
+
dependencies = [
|
1448
|
+
"aho-corasick",
|
1449
|
+
"memchr",
|
1450
|
+
"regex-syntax",
|
1451
|
+
]
|
1452
|
+
|
1453
|
+
[[package]]
|
1454
|
+
name = "regex-syntax"
|
1455
|
+
version = "0.8.5"
|
1456
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1457
|
+
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
1458
|
+
|
1362
1459
|
[[package]]
|
1363
1460
|
name = "reqwest"
|
1364
1461
|
version = "0.12.15"
|
@@ -1590,6 +1687,12 @@ version = "1.3.0"
|
|
1590
1687
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1591
1688
|
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
1592
1689
|
|
1690
|
+
[[package]]
|
1691
|
+
name = "siphasher"
|
1692
|
+
version = "1.0.1"
|
1693
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1694
|
+
checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d"
|
1695
|
+
|
1593
1696
|
[[package]]
|
1594
1697
|
name = "slab"
|
1595
1698
|
version = "0.4.9"
|
@@ -1737,6 +1840,16 @@ dependencies = [
|
|
1737
1840
|
"windows-sys 0.59.0",
|
1738
1841
|
]
|
1739
1842
|
|
1843
|
+
[[package]]
|
1844
|
+
name = "tex2typst-rs"
|
1845
|
+
version = "0.4.1"
|
1846
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1847
|
+
checksum = "3b0b6b6ad0966ace50ba5e817e4f48d759857c015f5936d4976232df786d432d"
|
1848
|
+
dependencies = [
|
1849
|
+
"phf",
|
1850
|
+
"regex",
|
1851
|
+
]
|
1852
|
+
|
1740
1853
|
[[package]]
|
1741
1854
|
name = "thiserror"
|
1742
1855
|
version = "2.0.12"
|
@@ -13,7 +13,9 @@ nucleo-matcher = "0.3.1"
|
|
13
13
|
pyo3 = { version = "0.23.4", features = ["extension-module"] }
|
14
14
|
pythonize = "0.23.0"
|
15
15
|
rayon = "1.10.0"
|
16
|
+
regex = "1.11.1"
|
16
17
|
serde_json = "1.0.138"
|
18
|
+
tex2typst-rs = "0.4.1"
|
17
19
|
unicode-segmentation = "1.12.0"
|
18
20
|
walkdir = "2.5.0"
|
19
21
|
whichlang = "0.1.1"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: fabricatio
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.11
|
4
4
|
Classifier: License :: OSI Approved :: MIT License
|
5
5
|
Classifier: Programming Language :: Rust
|
6
6
|
Classifier: Programming Language :: Python :: 3.12
|
@@ -14,23 +14,26 @@ Requires-Dist: asyncstdlib>=3.13.0
|
|
14
14
|
Requires-Dist: json-repair>=0.39.1
|
15
15
|
Requires-Dist: litellm>=1.60.0
|
16
16
|
Requires-Dist: loguru>=0.7.3
|
17
|
-
Requires-Dist: magika>=0.5.1
|
18
17
|
Requires-Dist: more-itertools>=10.6.0
|
19
|
-
Requires-Dist: orjson>=3.10.15
|
20
18
|
Requires-Dist: pydantic>=2.10.6
|
21
19
|
Requires-Dist: pydantic-settings>=2.7.1
|
22
20
|
Requires-Dist: pymitter>=1.0.0
|
23
|
-
Requires-Dist: questionary>=2.1.0
|
24
|
-
Requires-Dist: regex>=2024.11.6
|
25
21
|
Requires-Dist: rich>=13.9.4
|
22
|
+
Requires-Dist: ujson>=5.10.0
|
23
|
+
Requires-Dist: fabricatio[calc,ftd,plot,qa,rag,cli] ; extra == 'full'
|
26
24
|
Requires-Dist: pymilvus>=2.5.4 ; extra == 'rag'
|
27
|
-
Requires-Dist: fabricatio[calc,plot,rag] ; extra == 'full'
|
28
25
|
Requires-Dist: sympy>=1.13.3 ; extra == 'calc'
|
29
26
|
Requires-Dist: matplotlib>=3.10.1 ; extra == 'plot'
|
30
|
-
|
27
|
+
Requires-Dist: questionary>=2.1.0 ; extra == 'qa'
|
28
|
+
Requires-Dist: magika>=0.6.1 ; extra == 'ftd'
|
29
|
+
Requires-Dist: typer-slim[standard]>=0.15.2 ; extra == 'cli'
|
31
30
|
Provides-Extra: full
|
31
|
+
Provides-Extra: rag
|
32
32
|
Provides-Extra: calc
|
33
33
|
Provides-Extra: plot
|
34
|
+
Provides-Extra: qa
|
35
|
+
Provides-Extra: ftd
|
36
|
+
Provides-Extra: cli
|
34
37
|
License-File: LICENSE
|
35
38
|
Summary: A LLM multi-agent framework.
|
36
39
|
Keywords: ai,agents,multi-agent,llm,pyo3
|
@@ -47,7 +50,8 @@ Project-URL: Issues, https://github.com/Whth/fabricatio/issues
|
|
47
50
|
|
48
51
|
## Overview
|
49
52
|
|
50
|
-
Fabricatio is a streamlined Python library for building LLM applications using an event-based agent structure. It
|
53
|
+
Fabricatio is a streamlined Python library for building LLM applications using an event-based agent structure. It
|
54
|
+
leverages Rust for performance-critical tasks, Handlebars for templating, and PyO3 for Python bindings.
|
51
55
|
|
52
56
|
## Features
|
53
57
|
|
@@ -87,6 +91,7 @@ import asyncio
|
|
87
91
|
from fabricatio import Action, Role, Task, logger, WorkFlow
|
88
92
|
from typing import Any
|
89
93
|
|
94
|
+
|
90
95
|
class Hello(Action):
|
91
96
|
name: str = "hello"
|
92
97
|
output_key: str = "task_output"
|
@@ -96,6 +101,7 @@ class Hello(Action):
|
|
96
101
|
logger.info("executing talk action")
|
97
102
|
return ret
|
98
103
|
|
104
|
+
|
99
105
|
async def main() -> None:
|
100
106
|
role = Role(
|
101
107
|
name="talker",
|
@@ -107,6 +113,7 @@ async def main() -> None:
|
|
107
113
|
result = await task.delegate()
|
108
114
|
logger.success(f"Result: {result}")
|
109
115
|
|
116
|
+
|
110
117
|
if __name__ == "__main__":
|
111
118
|
asyncio.run(main())
|
112
119
|
```
|
@@ -114,6 +121,7 @@ if __name__ == "__main__":
|
|
114
121
|
### Examples
|
115
122
|
|
116
123
|
For various usage scenarios, refer to the following examples:
|
124
|
+
|
117
125
|
- Simple Chat
|
118
126
|
- Retrieval-Augmented Generation (RAG)
|
119
127
|
- Article Extraction
|
@@ -161,6 +169,7 @@ max_tokens = 8192
|
|
161
169
|
## Contributing
|
162
170
|
|
163
171
|
Contributions are welcome! Follow these steps:
|
172
|
+
|
164
173
|
1. Fork the repository.
|
165
174
|
2. Create your feature branch (`git checkout -b feature/new-feature`).
|
166
175
|
3. Commit your changes (`git commit -am 'Add new feature'`).
|
@@ -174,6 +183,8 @@ Fabricatio is licensed under the MIT License. See [LICENSE](LICENSE) for details
|
|
174
183
|
## Acknowledgments
|
175
184
|
|
176
185
|
Special thanks to the contributors and maintainers of:
|
186
|
+
|
177
187
|
- [PyO3](https://github.com/PyO3/pyo3)
|
178
188
|
- [Maturin](https://github.com/PyO3/maturin)
|
179
189
|
- [Handlebars.rs](https://github.com/sunng87/handlebars-rust)
|
190
|
+
|
@@ -4,7 +4,8 @@
|
|
4
4
|
|
5
5
|
## Overview
|
6
6
|
|
7
|
-
Fabricatio is a streamlined Python library for building LLM applications using an event-based agent structure. It
|
7
|
+
Fabricatio is a streamlined Python library for building LLM applications using an event-based agent structure. It
|
8
|
+
leverages Rust for performance-critical tasks, Handlebars for templating, and PyO3 for Python bindings.
|
8
9
|
|
9
10
|
## Features
|
10
11
|
|
@@ -44,6 +45,7 @@ import asyncio
|
|
44
45
|
from fabricatio import Action, Role, Task, logger, WorkFlow
|
45
46
|
from typing import Any
|
46
47
|
|
48
|
+
|
47
49
|
class Hello(Action):
|
48
50
|
name: str = "hello"
|
49
51
|
output_key: str = "task_output"
|
@@ -53,6 +55,7 @@ class Hello(Action):
|
|
53
55
|
logger.info("executing talk action")
|
54
56
|
return ret
|
55
57
|
|
58
|
+
|
56
59
|
async def main() -> None:
|
57
60
|
role = Role(
|
58
61
|
name="talker",
|
@@ -64,6 +67,7 @@ async def main() -> None:
|
|
64
67
|
result = await task.delegate()
|
65
68
|
logger.success(f"Result: {result}")
|
66
69
|
|
70
|
+
|
67
71
|
if __name__ == "__main__":
|
68
72
|
asyncio.run(main())
|
69
73
|
```
|
@@ -71,6 +75,7 @@ if __name__ == "__main__":
|
|
71
75
|
### Examples
|
72
76
|
|
73
77
|
For various usage scenarios, refer to the following examples:
|
78
|
+
|
74
79
|
- Simple Chat
|
75
80
|
- Retrieval-Augmented Generation (RAG)
|
76
81
|
- Article Extraction
|
@@ -118,6 +123,7 @@ max_tokens = 8192
|
|
118
123
|
## Contributing
|
119
124
|
|
120
125
|
Contributions are welcome! Follow these steps:
|
126
|
+
|
121
127
|
1. Fork the repository.
|
122
128
|
2. Create your feature branch (`git checkout -b feature/new-feature`).
|
123
129
|
3. Commit your changes (`git commit -am 'Add new feature'`).
|
@@ -131,6 +137,7 @@ Fabricatio is licensed under the MIT License. See [LICENSE](LICENSE) for details
|
|
131
137
|
## Acknowledgments
|
132
138
|
|
133
139
|
Special thanks to the contributors and maintainers of:
|
140
|
+
|
134
141
|
- [PyO3](https://github.com/PyO3/pyo3)
|
135
142
|
- [Maturin](https://github.com/PyO3/maturin)
|
136
|
-
- [Handlebars.rs](https://github.com/sunng87/handlebars-rust)
|
143
|
+
- [Handlebars.rs](https://github.com/sunng87/handlebars-rust)
|
@@ -14,8 +14,6 @@ async def main() -> None:
|
|
14
14
|
Role(
|
15
15
|
name="Researcher",
|
16
16
|
description="chunk the article",
|
17
|
-
llm_rpm=50,
|
18
|
-
llm_tpm=100000,
|
19
17
|
registry={
|
20
18
|
Event.quick_instantiate(e := "Chunk"): WorkFlow(
|
21
19
|
name="Chunk",
|
@@ -26,8 +24,9 @@ async def main() -> None:
|
|
26
24
|
).update_init_context(
|
27
25
|
article_path=gather_files("bare_md", "md"),
|
28
26
|
bib_manager=BibManager(path="ref.bib"),
|
29
|
-
max_chunk_size=
|
27
|
+
max_chunk_size=600,
|
30
28
|
max_overlapping_rate=0.3,
|
29
|
+
override_inject=True,
|
31
30
|
),
|
32
31
|
},
|
33
32
|
)
|
@@ -3,7 +3,7 @@
|
|
3
3
|
import asyncio
|
4
4
|
from typing import Dict, List, Set, Unpack
|
5
5
|
|
6
|
-
import
|
6
|
+
import ujson
|
7
7
|
from fabricatio import Action, JsonCapture, Role, WorkFlow, logger
|
8
8
|
from fabricatio.capabilities.rating import Rating
|
9
9
|
from fabricatio.models.events import Event
|
@@ -33,9 +33,9 @@ class WhatToRate(Action):
|
|
33
33
|
async def _execute(self, task_input: Task, rate_topic: str, **cxt: Unpack) -> List[str]:
|
34
34
|
def _validate(resp: str) -> List[str] | None:
|
35
35
|
if (
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
(cap := JsonCapture.convert_with(resp, ujson.loads)) is not None
|
37
|
+
and isinstance(cap, list)
|
38
|
+
and all(isinstance(i, str) for i in cap)
|
39
39
|
):
|
40
40
|
return cap
|
41
41
|
return None
|
@@ -0,0 +1,49 @@
|
|
1
|
+
"""Example of proposing a task to a role."""
|
2
|
+
|
3
|
+
import asyncio
|
4
|
+
from typing import Any
|
5
|
+
|
6
|
+
from fabricatio import Action, Event, Role, Task, WorkFlow, logger
|
7
|
+
from fabricatio.actions.output import PersistentAll
|
8
|
+
from fabricatio.capabilities.propose import Propose
|
9
|
+
from fabricatio.fs import safe_text_read
|
10
|
+
from fabricatio.models.extra.article_outline import ArticleOutline
|
11
|
+
from fabricatio.utils import ok
|
12
|
+
|
13
|
+
|
14
|
+
class ProposeObj(Action, Propose):
|
15
|
+
"""Action that says hello to the world."""
|
16
|
+
|
17
|
+
output_key: str = "task_output"
|
18
|
+
|
19
|
+
async def _execute(self, briefing: str, **_) -> Any:
|
20
|
+
return await self.propose(
|
21
|
+
ArticleOutline,
|
22
|
+
f"{briefing}\n\n\n\n\nAccording to the above plaintext article outline, "
|
23
|
+
f"I need you to create an `ArticleOutline` obj against it."
|
24
|
+
f"Note the heading shall not contain any heading numbers.",
|
25
|
+
)
|
26
|
+
|
27
|
+
async def main() -> None:
|
28
|
+
"""Main function."""
|
29
|
+
Role(
|
30
|
+
name="talker",
|
31
|
+
description="talker role",
|
32
|
+
llm_model="openai/qwq-plus",
|
33
|
+
llm_max_tokens=8190,
|
34
|
+
llm_stream=True,
|
35
|
+
llm_temperature=0.6,
|
36
|
+
registry={
|
37
|
+
Event.quick_instantiate("talk"): WorkFlow(
|
38
|
+
name="talk", steps=(ProposeObj, PersistentAll(persist_dir="persis"))
|
39
|
+
).update_init_context(briefing=safe_text_read("briefing.txt"))
|
40
|
+
},
|
41
|
+
)
|
42
|
+
|
43
|
+
task: Task[ArticleOutline] = Task(name="write outline")
|
44
|
+
article_outline = ok(await task.delegate("talk"))
|
45
|
+
logger.success(f"article_outline:\n{article_outline.display()}")
|
46
|
+
|
47
|
+
|
48
|
+
if __name__ == "__main__":
|
49
|
+
asyncio.run(main())
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"""Fix the article."""
|
2
|
+
|
3
|
+
from fabricatio.models.extra.article_main import Article
|
4
|
+
|
5
|
+
a = Article.from_persistent(
|
6
|
+
r"persistent\to_dump\Article_20250408_103051_51d822.json")
|
7
|
+
a.convert_tex()
|
8
|
+
|
9
|
+
|
10
|
+
from fabricatio.fs.curd import dump_text
|
11
|
+
|
12
|
+
dump_text("corrected.typ",a.finalized_dump())
|
@@ -0,0 +1,189 @@
|
|
1
|
+
"""Example of using the library."""
|
2
|
+
|
3
|
+
import asyncio
|
4
|
+
from pathlib import Path
|
5
|
+
|
6
|
+
import typer
|
7
|
+
from fabricatio import Event, Role, WorkFlow, logger
|
8
|
+
from fabricatio.actions.article import ExtractOutlineFromRaw, GenerateArticleProposal, GenerateInitialOutline
|
9
|
+
from fabricatio.actions.article_rag import ArticleConsultRAG, WriteArticleContentRAG
|
10
|
+
from fabricatio.actions.output import DumpFinalizedOutput, PersistentAll
|
11
|
+
from fabricatio.models.extra.article_outline import ArticleOutline
|
12
|
+
from fabricatio.models.task import Task
|
13
|
+
from fabricatio.utils import ok
|
14
|
+
from typer import Typer
|
15
|
+
|
16
|
+
Role(
|
17
|
+
name="Undergraduate Researcher",
|
18
|
+
description="Write an outline for an article in typst format.",
|
19
|
+
llm_model="openai/qwen-plus",
|
20
|
+
llm_temperature=0.6,
|
21
|
+
llm_max_tokens=8191,
|
22
|
+
llm_rpm=600,
|
23
|
+
llm_tpm=1000000,
|
24
|
+
registry={
|
25
|
+
Event.quick_instantiate(ns := "article"): WorkFlow(
|
26
|
+
name="Generate Article",
|
27
|
+
description="Generate an article. dump the outline to the given path. in typst format.",
|
28
|
+
steps=(
|
29
|
+
GenerateArticleProposal,
|
30
|
+
GenerateInitialOutline(output_key="article_outline"),
|
31
|
+
PersistentAll,
|
32
|
+
(
|
33
|
+
a := WriteArticleContentRAG(
|
34
|
+
output_key="to_dump",
|
35
|
+
ref_limit=40,
|
36
|
+
llm_model="openai/qwen-max",
|
37
|
+
target_collection="article_chunks_700",
|
38
|
+
extractor_model="openai/qwen-max",
|
39
|
+
query_model="openai/deepseek-r1-250120",
|
40
|
+
)
|
41
|
+
),
|
42
|
+
DumpFinalizedOutput(output_key="task_output"),
|
43
|
+
PersistentAll,
|
44
|
+
),
|
45
|
+
),
|
46
|
+
Event.quick_instantiate(ns2 := "complete"): WorkFlow(
|
47
|
+
name="Generate Article",
|
48
|
+
description="Generate an article with given raw article outline. dump the outline to the given path. in typst format.",
|
49
|
+
steps=(
|
50
|
+
ExtractOutlineFromRaw(output_key="article_outline"),
|
51
|
+
PersistentAll,
|
52
|
+
a,
|
53
|
+
DumpFinalizedOutput(output_key="task_output"),
|
54
|
+
PersistentAll,
|
55
|
+
),
|
56
|
+
),
|
57
|
+
Event.quick_instantiate(ns3 := "finish"): WorkFlow(
|
58
|
+
name="Finish Article",
|
59
|
+
description="Finish an article with given article outline. dump the outline to the given path. in typst format.",
|
60
|
+
steps=(
|
61
|
+
a,
|
62
|
+
DumpFinalizedOutput(output_key="task_output"),
|
63
|
+
PersistentAll,
|
64
|
+
),
|
65
|
+
),
|
66
|
+
Event.quick_instantiate(ns4 := "consult"): WorkFlow(
|
67
|
+
name="Consult Article",
|
68
|
+
description="Consult an article with given article outline. dump the outline to the given path. in typst format.",
|
69
|
+
steps=(ArticleConsultRAG(ref_q_model="openai/qwen-max").to_task_output(),),
|
70
|
+
),
|
71
|
+
},
|
72
|
+
)
|
73
|
+
|
74
|
+
|
75
|
+
app = Typer()
|
76
|
+
|
77
|
+
|
78
|
+
@app.command()
|
79
|
+
def consult(
|
80
|
+
collection_name: str = typer.Option("article_chunks", "-c", "--collection-name", help="Name of the collection."),
|
81
|
+
) -> None:
|
82
|
+
"""Consult an article based on a given article outline."""
|
83
|
+
_ = asyncio.run(
|
84
|
+
Task(name="Answer Question")
|
85
|
+
.update_init_context(
|
86
|
+
collection_name=collection_name,
|
87
|
+
)
|
88
|
+
.delegate(ns4)
|
89
|
+
)
|
90
|
+
|
91
|
+
logger.info("Finished")
|
92
|
+
|
93
|
+
|
94
|
+
@app.command()
|
95
|
+
def finish(
|
96
|
+
article_outline_path: Path = typer.Argument( # noqa: B008
|
97
|
+
help="Path to the article outline raw file."
|
98
|
+
),
|
99
|
+
dump_path: Path = typer.Option(Path("out.typ"), "-d", "--dump-path", help="Path to dump the final output."), # noqa: B008
|
100
|
+
persist_dir: Path = typer.Option( # noqa: B008
|
101
|
+
Path("persistent"), "-p", "--persist-dir", help="Directory to persist the output."
|
102
|
+
),
|
103
|
+
collection_name: str = typer.Option("article_chunks", "-c", "--collection-name", help="Name of the collection."),
|
104
|
+
supervisor: bool = typer.Option(False, "-s", "--supervisor", help="Whether to use the supervisor mode."),
|
105
|
+
) -> None:
|
106
|
+
"""Finish an article based on a given article outline."""
|
107
|
+
path = ok(
|
108
|
+
asyncio.run(
|
109
|
+
Task(name="write an article")
|
110
|
+
.update_init_context(
|
111
|
+
article_outline=ArticleOutline.from_persistent(article_outline_path),
|
112
|
+
dump_path=dump_path,
|
113
|
+
persist_dir=persist_dir,
|
114
|
+
collection_name=collection_name,
|
115
|
+
supervisor=supervisor,
|
116
|
+
)
|
117
|
+
.delegate(ns3)
|
118
|
+
),
|
119
|
+
"Failed to generate an article ",
|
120
|
+
)
|
121
|
+
logger.success(f"The outline is saved in:\n{path}")
|
122
|
+
|
123
|
+
|
124
|
+
@app.command()
|
125
|
+
def completion(
|
126
|
+
article_outline_raw_path: Path = typer.Option( # noqa: B008
|
127
|
+
Path("article_outline_raw.txt"), "-a", "--article-outline-raw", help="Path to the article outline raw file."
|
128
|
+
),
|
129
|
+
dump_path: Path = typer.Option(Path("out.typ"), "-d", "--dump-path", help="Path to dump the final output."), # noqa: B008
|
130
|
+
persist_dir: Path = typer.Option( # noqa: B008
|
131
|
+
Path("persistent"), "-p", "--persist-dir", help="Directory to persist the output."
|
132
|
+
),
|
133
|
+
collection_name: str = typer.Option("article_chunks", "-c", "--collection-name", help="Name of the collection."),
|
134
|
+
supervisor: bool = typer.Option(False, "-s", "--supervisor", help="Whether to use the supervisor mode."),
|
135
|
+
) -> None:
|
136
|
+
"""Write an article based on a raw article outline."""
|
137
|
+
path = ok(
|
138
|
+
asyncio.run(
|
139
|
+
Task(name="write an article")
|
140
|
+
.update_init_context(
|
141
|
+
article_outline_raw_path=article_outline_raw_path,
|
142
|
+
dump_path=dump_path,
|
143
|
+
persist_dir=persist_dir,
|
144
|
+
collection_name=collection_name,
|
145
|
+
supervisor=supervisor,
|
146
|
+
)
|
147
|
+
.delegate(ns2)
|
148
|
+
),
|
149
|
+
"Failed to generate an article ",
|
150
|
+
)
|
151
|
+
logger.success(f"The outline is saved in:\n{path}")
|
152
|
+
|
153
|
+
|
154
|
+
@app.command()
|
155
|
+
def write(
|
156
|
+
article_briefing: Path = typer.Option( # noqa: B008
|
157
|
+
Path("article_briefing.txt"), "-a", "--article-briefing", help="Path to the article briefing file."
|
158
|
+
),
|
159
|
+
dump_path: Path = typer.Option(Path("out.typ"), "-d", "--dump-path", help="Path to dump the final output."), # noqa: B008
|
160
|
+
persist_dir: Path = typer.Option( # noqa: B008
|
161
|
+
Path("persistent"), "-p", "--persist-dir", help="Directory to persist the output."
|
162
|
+
),
|
163
|
+
collection_name: str = typer.Option("article_chunks", "-c", "--collection-name", help="Name of the collection."),
|
164
|
+
supervisor: bool = typer.Option(False, "-s", "--supervisor", help="Whether to use the supervisor mode."),
|
165
|
+
) -> None:
|
166
|
+
"""Write an article based on a briefing.
|
167
|
+
|
168
|
+
This function generates an article outline and content based on the provided briefing.
|
169
|
+
The outline and content are then dumped to the specified path and persisted in the given directory.
|
170
|
+
"""
|
171
|
+
path = ok(
|
172
|
+
asyncio.run(
|
173
|
+
Task(name="write an article")
|
174
|
+
.update_init_context(
|
175
|
+
article_briefing=article_briefing.read_text(),
|
176
|
+
dump_path=dump_path,
|
177
|
+
persist_dir=persist_dir,
|
178
|
+
collection_name=collection_name,
|
179
|
+
supervisor=supervisor,
|
180
|
+
)
|
181
|
+
.delegate(ns)
|
182
|
+
),
|
183
|
+
"Failed to generate an article ",
|
184
|
+
)
|
185
|
+
logger.success(f"The outline is saved in:\n{path}")
|
186
|
+
|
187
|
+
|
188
|
+
if __name__ == "__main__":
|
189
|
+
app()
|