fabricatio 0.2.8.dev4__tar.gz → 0.2.9__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.8.dev4 → fabricatio-0.2.9}/Cargo.lock +8 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/Cargo.toml +2 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/PKG-INFO +1 -1
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/make_a_rating/rating.py +25 -6
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/make_diary/diary.py +2 -2
- fabricatio-0.2.9/examples/reviewer/censor.py +32 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/reviewer/review.py +5 -1
- fabricatio-0.2.9/examples/rules/draft_ruleset.py +59 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/task_handle/handle_task.py +2 -2
- fabricatio-0.2.9/examples/write_article/.gitignore +3 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/write_article/write_article.py +1 -1
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/write_outline/write_outline.py +3 -2
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/write_outline/write_outline_corrected.py +2 -8
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/pyproject.toml +2 -2
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/__init__.py +4 -11
- fabricatio-0.2.9/python/fabricatio/actions/__init__.py +1 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/actions/article.py +98 -110
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/actions/article_rag.py +15 -10
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/actions/output.py +60 -4
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/actions/rag.py +2 -1
- fabricatio-0.2.9/python/fabricatio/actions/rules.py +72 -0
- fabricatio-0.2.9/python/fabricatio/capabilities/__init__.py +1 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/capabilities/censor.py +23 -6
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/capabilities/check.py +46 -27
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/capabilities/correct.py +35 -16
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/capabilities/rag.py +5 -4
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/capabilities/rating.py +56 -49
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/capabilities/review.py +1 -1
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/capabilities/task.py +2 -1
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/config.py +5 -3
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/fs/readers.py +20 -1
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/models/action.py +59 -36
- fabricatio-0.2.9/python/fabricatio/models/extra/__init__.py +1 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/models/extra/advanced_judge.py +4 -4
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/models/extra/article_base.py +124 -61
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/models/extra/article_main.py +100 -17
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/models/extra/article_outline.py +2 -3
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/models/extra/article_proposal.py +15 -14
- fabricatio-0.2.9/python/fabricatio/models/extra/patches.py +20 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/models/extra/problem.py +31 -23
- fabricatio-0.2.9/python/fabricatio/models/extra/rule.py +52 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/models/generic.py +369 -78
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/models/task.py +1 -1
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/models/tool.py +149 -14
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/models/usages.py +46 -42
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/parser.py +5 -5
- fabricatio-0.2.8.dev4/python/fabricatio/_rust.pyi → fabricatio-0.2.9/python/fabricatio/rust.pyi +42 -4
- fabricatio-0.2.8.dev4/python/fabricatio/_rust_instances.py → fabricatio-0.2.9/python/fabricatio/rust_instances.py +1 -1
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/utils.py +5 -5
- fabricatio-0.2.9/python/fabricatio/workflows/__init__.py +1 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/workflows/articles.py +3 -5
- fabricatio-0.2.9/src/hbs_helpers.rs +21 -0
- fabricatio-0.2.9/src/language.rs +41 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/src/lib.rs +6 -1
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/src/templates.rs +5 -1
- fabricatio-0.2.9/src/word_split.rs +27 -0
- fabricatio-0.2.9/templates/built-in/check_string.hbs +22 -0
- fabricatio-0.2.9/templates/built-in/co_validation.hbs +7 -0
- fabricatio-0.2.9/templates/built-in/create_json_obj.hbs +26 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/draft_rating_criteria.hbs +1 -0
- fabricatio-0.2.9/templates/built-in/draft_rating_manual.hbs +36 -0
- fabricatio-0.2.9/templates/built-in/draft_rating_weights_klee.hbs +37 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/extract_criteria_from_reasons.hbs +4 -3
- fabricatio-0.2.9/templates/built-in/extract_reasons_from_examples.hbs +41 -0
- fabricatio-0.2.9/templates/built-in/liststr.hbs +25 -0
- fabricatio-0.2.9/templates/built-in/rate_fine_grind.hbs +15 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/refined_query.hbs +1 -1
- fabricatio-0.2.9/templates/built-in/rule_requirement.hbs +7 -0
- fabricatio-0.2.9/templates/built-in/ruleset_requirement_breakdown.hbs +19 -0
- fabricatio-0.2.9/templates.tar.gz +0 -0
- fabricatio-0.2.9/tests/test_models/test_problem.py +96 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/uv.lock +143 -144
- fabricatio-0.2.8.dev4/python/fabricatio/models/extra/patches.py +0 -7
- fabricatio-0.2.8.dev4/python/fabricatio/models/extra/rule.py +0 -21
- fabricatio-0.2.8.dev4/src/hbs_helpers.rs +0 -9
- fabricatio-0.2.8.dev4/templates/built-in/check_string.hbs +0 -19
- fabricatio-0.2.8.dev4/templates/built-in/co_validation.hbs +0 -26
- fabricatio-0.2.8.dev4/templates/built-in/create_json_obj.hbs +0 -74
- fabricatio-0.2.8.dev4/templates/built-in/draft_rating_manual.hbs +0 -41
- fabricatio-0.2.8.dev4/templates/built-in/draft_rating_weights_klee.hbs +0 -44
- fabricatio-0.2.8.dev4/templates/built-in/extract_reasons_from_examples.hbs +0 -48
- fabricatio-0.2.8.dev4/templates/built-in/liststr.hbs +0 -44
- fabricatio-0.2.8.dev4/templates/built-in/rate_fine_grind.hbs +0 -51
- fabricatio-0.2.8.dev4/templates/built-in/ruleset_requirement_breakdown.hbs +0 -7
- fabricatio-0.2.8.dev4/templates.tar.gz +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/.github/workflows/build-package.yaml +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/.github/workflows/ruff.yaml +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/.github/workflows/tests.yaml +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/.gitignore +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/.python-version +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/LICENSE +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/Makefile +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/README.md +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/correct/correct.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/correct/correct_loop.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/extract_and_inject/.gitignore +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/extract_and_inject/article_rag.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/extract_and_inject/ask.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/extract_and_inject/extract_and_inject.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/extract_article/extract.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/llm_usages/llm_usage.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/make_diary/commits.json +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/minor/hello_fabricatio.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/minor/write_a_poem.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/propose_task/propose.py +0 -0
- {fabricatio-0.2.8.dev4/examples/write_article → fabricatio-0.2.9/examples/rules}/.gitignore +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/search_bibtex/.gitignore +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/search_bibtex/search.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/simple_chat/chat.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/simple_rag/simple_rag.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/write_article/article_rag.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/write_outline/.gitignore +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/capabilities/advanced_judge.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/capabilities/propose.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/core.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/decorators.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/fs/__init__.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/fs/curd.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/journal.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/models/adv_kwargs_types.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/models/events.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/models/extra/article_essence.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/models/kwargs_types.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/models/role.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/models/utils.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/py.typed +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/toolboxes/__init__.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/toolboxes/arithmetic.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/toolboxes/fs.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/python/fabricatio/workflows/rag.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/src/bib_tools.rs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/src/hash.rs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/as_prompt.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/binary-exploitation-ctf-solver.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/claude-xml.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/clean-up-code.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/cryptography-ctf-solver.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/dependencies.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/document-the-code.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/draft_tool_usage_code.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/find-security-vulnerabilities.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/fix-bugs.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/fix_troubled_obj.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/fix_troubled_string.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/generic_string.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/improve-performance.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/make_choice.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/make_judgment.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/pathstr.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/refactor.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/retrieved_display.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/reverse-engineering-ctf-solver.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/review_string.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/task_briefing.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/web-ctf-solver.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/write-git-commit.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/write-github-pull-request.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/templates/built-in/write-github-readme.hbs +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/tests/test_config.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/tests/test_models/test_action.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/tests/test_models/test_advanced.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/tests/test_models/test_generic.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/tests/test_models/test_role.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/tests/test_models/test_task.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/tests/test_models/test_tool.py +0 -0
- {fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/tests/test_models/test_usages.py +0 -0
@@ -452,7 +452,9 @@ dependencies = [
|
|
452
452
|
"pythonize",
|
453
453
|
"rayon",
|
454
454
|
"serde_json",
|
455
|
+
"unicode-segmentation",
|
455
456
|
"walkdir",
|
457
|
+
"whichlang",
|
456
458
|
]
|
457
459
|
|
458
460
|
[[package]]
|
@@ -2099,6 +2101,12 @@ dependencies = [
|
|
2099
2101
|
"wasm-bindgen",
|
2100
2102
|
]
|
2101
2103
|
|
2104
|
+
[[package]]
|
2105
|
+
name = "whichlang"
|
2106
|
+
version = "0.1.1"
|
2107
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
2108
|
+
checksum = "0b9aa3ad29c3d08283ac6b769e3ec15ad1ddb88af7d2e9bc402c574973b937e7"
|
2109
|
+
|
2102
2110
|
[[package]]
|
2103
2111
|
name = "winapi-util"
|
2104
2112
|
version = "0.1.9"
|
@@ -5,11 +5,12 @@ from typing import Dict, List, Set, Unpack
|
|
5
5
|
|
6
6
|
import orjson
|
7
7
|
from fabricatio import Action, JsonCapture, Role, WorkFlow, logger
|
8
|
+
from fabricatio.capabilities.rating import Rating
|
8
9
|
from fabricatio.models.events import Event
|
9
10
|
from fabricatio.models.task import Task
|
10
11
|
|
11
12
|
|
12
|
-
class Rate(Action):
|
13
|
+
class Rate(Action, Rating):
|
13
14
|
"""Rate the task."""
|
14
15
|
|
15
16
|
output_key: str = "task_output"
|
@@ -49,7 +50,7 @@ class WhatToRate(Action):
|
|
49
50
|
)
|
50
51
|
|
51
52
|
|
52
|
-
class MakeCriteria(Action):
|
53
|
+
class MakeCriteria(Action, Rating):
|
53
54
|
"""Make criteria for rating."""
|
54
55
|
|
55
56
|
output_key: str = "criteria"
|
@@ -60,7 +61,7 @@ class MakeCriteria(Action):
|
|
60
61
|
return set(criteria)
|
61
62
|
|
62
63
|
|
63
|
-
class MakeCompositeScore(Action):
|
64
|
+
class MakeCompositeScore(Action, Rating):
|
64
65
|
"""Make a composite score."""
|
65
66
|
|
66
67
|
output_key: str = "task_output"
|
@@ -72,6 +73,15 @@ class MakeCompositeScore(Action):
|
|
72
73
|
)
|
73
74
|
|
74
75
|
|
76
|
+
class Best(Action, Rating):
|
77
|
+
"""Select the best."""
|
78
|
+
|
79
|
+
output_key: str = "task_output"
|
80
|
+
|
81
|
+
async def _execute(self, rate_topic: str, to_rate: List[str], **cxt: Unpack) -> str:
|
82
|
+
return (await self.best(to_rate, topic=rate_topic)).pop(0)
|
83
|
+
|
84
|
+
|
75
85
|
async def main() -> None:
|
76
86
|
"""Main function."""
|
77
87
|
role = Role(
|
@@ -100,23 +110,32 @@ async def main() -> None:
|
|
100
110
|
"rate_topic": "if the food is 'good'",
|
101
111
|
},
|
102
112
|
),
|
113
|
+
Event.quick_instantiate("best"): WorkFlow(
|
114
|
+
name="choose the best",
|
115
|
+
steps=(WhatToRate, Best),
|
116
|
+
extra_init_context={"rate_topic": "if the food is 'good'"},
|
117
|
+
),
|
103
118
|
},
|
104
119
|
)
|
105
120
|
task = await role.propose_task(
|
106
121
|
"rate these food, so that i can decide what to eat today. choco cake, strawberry icecream, giga burger, cup of coffee, rotten bread from the trash bin, and a salty of fruit salad",
|
107
122
|
)
|
108
|
-
rating = await task.
|
123
|
+
rating = await task.delegate("rate_food")
|
109
124
|
|
110
125
|
logger.success(f"Result: \n{rating}")
|
111
126
|
|
112
|
-
generated_criteria = await task.
|
127
|
+
generated_criteria = await task.delegate("make_criteria_for_food")
|
113
128
|
|
114
129
|
logger.success(f"Generated Criteria: \n{generated_criteria}")
|
115
130
|
|
116
|
-
composite_score = await task.
|
131
|
+
composite_score = await task.delegate("make_composite_score")
|
117
132
|
|
118
133
|
logger.success(f"Composite Score: \n{composite_score}")
|
119
134
|
|
135
|
+
best = await task.delegate("best")
|
136
|
+
|
137
|
+
logger.success(f"Best: \n{best}")
|
138
|
+
|
120
139
|
|
121
140
|
if __name__ == "__main__":
|
122
141
|
asyncio.run(main())
|
@@ -4,7 +4,7 @@ import asyncio
|
|
4
4
|
from datetime import datetime
|
5
5
|
from typing import Optional, Set, Unpack
|
6
6
|
|
7
|
-
from fabricatio import Action, Event, Role, Task, WorkFlow,
|
7
|
+
from fabricatio import Action, Event, Role, Task, WorkFlow, logger, toolboxes
|
8
8
|
from fabricatio.fs.readers import safe_json_read
|
9
9
|
from fabricatio.models.tool import ToolBox
|
10
10
|
from pydantic import Field
|
@@ -48,7 +48,7 @@ class WriteDiary(Action):
|
|
48
48
|
class DumpText(Action):
|
49
49
|
"""Dump the text to a file."""
|
50
50
|
|
51
|
-
toolboxes: Set[ToolBox] = Field(default_factory=lambda: {fs_toolbox})
|
51
|
+
toolboxes: Set[ToolBox] = Field(default_factory=lambda: {toolboxes.fs_toolbox})
|
52
52
|
output_key: str = "task_output"
|
53
53
|
|
54
54
|
async def _execute(self, task_input: Task, dump_text: str, **_: Unpack) -> Optional[str]:
|
@@ -0,0 +1,32 @@
|
|
1
|
+
"""Example of review usage."""
|
2
|
+
|
3
|
+
import asyncio
|
4
|
+
|
5
|
+
from fabricatio import Role, logger
|
6
|
+
from fabricatio.capabilities.censor import Censor
|
7
|
+
|
8
|
+
|
9
|
+
class Coder(Role, Censor):
|
10
|
+
"""Reviewer role."""
|
11
|
+
|
12
|
+
|
13
|
+
async def main() -> None:
|
14
|
+
"""Main function."""
|
15
|
+
role = Coder(
|
16
|
+
name="Bob",
|
17
|
+
description="A role that reviews the code.",
|
18
|
+
)
|
19
|
+
|
20
|
+
code = await role.aask(
|
21
|
+
"write a cli app using rust with clap which can generate a basic manifest of a standard rust project, output code only,no extra explanation"
|
22
|
+
)
|
23
|
+
|
24
|
+
ruleset = await role.draft_ruleset("should not use clap to write cli.", rule_count=1)
|
25
|
+
logger.success(f"Code: \n{code}")
|
26
|
+
code = await role.censor_string(code, ruleset)
|
27
|
+
|
28
|
+
logger.success(f"Code: \n{code}")
|
29
|
+
|
30
|
+
|
31
|
+
if __name__ == "__main__":
|
32
|
+
asyncio.run(main())
|
@@ -3,11 +3,15 @@
|
|
3
3
|
import asyncio
|
4
4
|
|
5
5
|
from fabricatio import Role, logger
|
6
|
+
from fabricatio.capabilities.review import Review
|
6
7
|
|
7
8
|
|
9
|
+
class Reviewer(Role, Review):
|
10
|
+
"""Reviewer role."""
|
11
|
+
|
8
12
|
async def main() -> None:
|
9
13
|
"""Main function."""
|
10
|
-
role =
|
14
|
+
role = Reviewer(
|
11
15
|
name="Reviewer",
|
12
16
|
description="A role that reviews the code.",
|
13
17
|
)
|
@@ -0,0 +1,59 @@
|
|
1
|
+
"""Example of using the library."""
|
2
|
+
|
3
|
+
import asyncio
|
4
|
+
from typing import TYPE_CHECKING
|
5
|
+
|
6
|
+
from fabricatio import Event, Role, WorkFlow, logger
|
7
|
+
from fabricatio.actions.output import PersistentAll
|
8
|
+
from fabricatio.actions.rules import DraftRuleSet
|
9
|
+
from fabricatio.models.task import Task
|
10
|
+
from fabricatio.utils import ok
|
11
|
+
|
12
|
+
if TYPE_CHECKING:
|
13
|
+
from fabricatio.models.extra.rule import RuleSet
|
14
|
+
|
15
|
+
|
16
|
+
async def main() -> None:
|
17
|
+
"""Main function."""
|
18
|
+
Role(
|
19
|
+
name="Undergraduate Researcher",
|
20
|
+
llm_model="openai/qwen-plus",
|
21
|
+
llm_rpm=1000,
|
22
|
+
llm_tpm=3000000,
|
23
|
+
llm_max_tokens=8190,
|
24
|
+
registry={
|
25
|
+
Event.quick_instantiate(ns := "article"): WorkFlow(
|
26
|
+
name="write ruleset",
|
27
|
+
description="Generate a draft ruleset for article.",
|
28
|
+
steps=(
|
29
|
+
DraftRuleSet(
|
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"
|
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"
|
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"
|
33
|
+
"4.to cover more references, we usually cite more than one articles that have similar opinions in a single sentence if possible.\n"
|
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.",
|
35
|
+
rule_count=5,
|
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
|
+
),
|
47
|
+
PersistentAll(persist_dir="persistent"),
|
48
|
+
),
|
49
|
+
)
|
50
|
+
},
|
51
|
+
)
|
52
|
+
|
53
|
+
proposed_task: Task[RuleSet] = Task(name="write an ruleset")
|
54
|
+
ruleset = ok(await proposed_task.delegate(ns), "Failed to generate ruleset")
|
55
|
+
logger.success(f"The rule is: \n{ruleset.display()}")
|
56
|
+
|
57
|
+
|
58
|
+
if __name__ == "__main__":
|
59
|
+
asyncio.run(main())
|
@@ -3,7 +3,7 @@
|
|
3
3
|
import asyncio
|
4
4
|
from typing import Any, Set, Unpack
|
5
5
|
|
6
|
-
from fabricatio import Action, Event, PythonCapture, Role, Task, ToolBox, WorkFlow,
|
6
|
+
from fabricatio import Action, Event, PythonCapture, Role, Task, ToolBox, WorkFlow, logger, toolboxes
|
7
7
|
from pydantic import Field
|
8
8
|
|
9
9
|
|
@@ -23,7 +23,7 @@ class WriteCode(Action):
|
|
23
23
|
class DumpText(Action):
|
24
24
|
"""Dump the text to a file."""
|
25
25
|
|
26
|
-
toolboxes: Set[ToolBox] = Field(default_factory=lambda: {fs_toolbox})
|
26
|
+
toolboxes: Set[ToolBox] = Field(default_factory=lambda: {toolboxes.fs_toolbox})
|
27
27
|
output_key: str = "task_output"
|
28
28
|
|
29
29
|
async def _execute(self, task_input: Task, dump_text: str, **_: Unpack) -> Any:
|
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
import asyncio
|
4
4
|
|
5
|
-
from fabricatio import Event, Role,
|
5
|
+
from fabricatio import Event, Role, logger
|
6
|
+
from fabricatio.workflows.articles import WriteOutlineCorrectedWorkFlow
|
6
7
|
|
7
8
|
|
8
9
|
async def main() -> None:
|
@@ -10,7 +11,7 @@ async def main() -> None:
|
|
10
11
|
role = Role(
|
11
12
|
name="Undergraduate Researcher",
|
12
13
|
description="Write an outline for an article in typst format.",
|
13
|
-
registry={Event.quick_instantiate(ns := "article"):
|
14
|
+
registry={Event.quick_instantiate(ns := "article"): WriteOutlineCorrectedWorkFlow},
|
14
15
|
)
|
15
16
|
|
16
17
|
proposed_task = await role.propose_task(
|
{fabricatio-0.2.8.dev4 → fabricatio-0.2.9}/examples/write_outline/write_outline_corrected.py
RENAMED
@@ -3,7 +3,7 @@
|
|
3
3
|
import asyncio
|
4
4
|
|
5
5
|
from fabricatio import Event, Role, WorkFlow, logger
|
6
|
-
from fabricatio.actions.article import
|
6
|
+
from fabricatio.actions.article import GenerateArticleProposal, GenerateInitialOutline
|
7
7
|
from fabricatio.actions.output import DumpFinalizedOutput
|
8
8
|
|
9
9
|
|
@@ -20,13 +20,7 @@ async def main() -> None:
|
|
20
20
|
description="Generate an outline for an article. dump the outline to the given path. in typst format.",
|
21
21
|
steps=(
|
22
22
|
GenerateArticleProposal(llm_model="deepseek/deepseek-reasoner", llm_temperature=1.3),
|
23
|
-
|
24
|
-
output_key="article_proposal",
|
25
|
-
llm_model="deepseek/deepseek-reasoner",
|
26
|
-
llm_temperature=1.3,
|
27
|
-
),
|
28
|
-
GenerateOutline(llm_model="deepseek/deepseek-chat", llm_temperature=1.4, llm_top_p=0.5),
|
29
|
-
CorrectOutline(output_key="to_dump", llm_temperature=1.4, llm_top_p=0.45),
|
23
|
+
GenerateInitialOutline(llm_model="deepseek/deepseek-chat", llm_temperature=1.4, llm_top_p=0.5),
|
30
24
|
DumpFinalizedOutput(output_key="task_output"),
|
31
25
|
),
|
32
26
|
)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "fabricatio"
|
3
|
-
version = "0.2.
|
3
|
+
version = "0.2.9"
|
4
4
|
description = "A LLM multi-agent framework."
|
5
5
|
readme = "README.md"
|
6
6
|
license = { file = "LICENSE" }
|
@@ -57,7 +57,7 @@ build-backend = "maturin"
|
|
57
57
|
|
58
58
|
[tool.maturin]
|
59
59
|
python-source = "python"
|
60
|
-
module-name = "fabricatio.
|
60
|
+
module-name = "fabricatio.rust"
|
61
61
|
data = "extra"
|
62
62
|
[dependency-groups]
|
63
63
|
dev = [
|
@@ -1,10 +1,6 @@
|
|
1
1
|
"""Fabricatio is a Python library for building llm app using event-based agent structure."""
|
2
2
|
|
3
|
-
from
|
4
|
-
|
5
|
-
from fabricatio import actions, toolboxes, workflows
|
6
|
-
from fabricatio._rust import BibManager
|
7
|
-
from fabricatio._rust_instances import TEMPLATE_MANAGER
|
3
|
+
from fabricatio import actions, capabilities, toolboxes, workflows
|
8
4
|
from fabricatio.core import env
|
9
5
|
from fabricatio.journal import logger
|
10
6
|
from fabricatio.models import extra
|
@@ -14,6 +10,8 @@ from fabricatio.models.role import Role
|
|
14
10
|
from fabricatio.models.task import Task
|
15
11
|
from fabricatio.models.tool import ToolBox
|
16
12
|
from fabricatio.parser import Capture, GenericCapture, JsonCapture, PythonCapture
|
13
|
+
from fabricatio.rust import BibManager
|
14
|
+
from fabricatio.rust_instances import TEMPLATE_MANAGER
|
17
15
|
|
18
16
|
__all__ = [
|
19
17
|
"TEMPLATE_MANAGER",
|
@@ -29,15 +27,10 @@ __all__ = [
|
|
29
27
|
"ToolBox",
|
30
28
|
"WorkFlow",
|
31
29
|
"actions",
|
30
|
+
"capabilities",
|
32
31
|
"env",
|
33
32
|
"extra",
|
34
33
|
"logger",
|
35
34
|
"toolboxes",
|
36
35
|
"workflows",
|
37
36
|
]
|
38
|
-
|
39
|
-
|
40
|
-
if find_spec("pymilvus"):
|
41
|
-
from fabricatio.capabilities.rag import RAG
|
42
|
-
|
43
|
-
__all__ += ["RAG"]
|
@@ -0,0 +1 @@
|
|
1
|
+
"""A module containing some builtin actins."""
|