fabricatio 0.3.14.dev0__tar.gz → 0.3.14.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/PKG-INFO +7 -7
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/README.md +6 -6
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/llm_usages/llm_usage.py +1 -2
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/minor/hello_fabricatio.py +1 -1
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/minor/write_a_poem.py +6 -4
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/pyproject.toml +1 -1
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/__init__.py +2 -3
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/journal.py +0 -3
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/action.py +1 -1
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/generic.py +5 -5
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/role.py +2 -4
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/usages.py +12 -5
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/rust.pyi +2 -2
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/utils.py +32 -1
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/src/config.rs +1 -1
- fabricatio-0.3.14.dev1/templates.tar.gz +0 -0
- fabricatio-0.3.14.dev1/uv.lock +1682 -0
- fabricatio-0.3.14.dev0/templates.tar.gz +0 -0
- fabricatio-0.3.14.dev0/uv.lock +0 -1682
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/.github/workflows/build-package.yaml +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/.github/workflows/ruff.yaml +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/.github/workflows/tests.yaml +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/.gitignore +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/.python-version +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/Cargo.lock +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/Cargo.toml +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/LICENSE +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/Makefile +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/correct/correct.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/correct/correct_loop.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/extract_and_inject/.gitignore +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/extract_and_inject/article_rag.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/extract_and_inject/ask.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/extract_and_inject/chunk_article.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/extract_and_inject/extract_and_inject.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/extract_article/extract.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/make_a_rating/rating.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/make_diary/commits.json +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/make_diary/diary.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/propose_task/.gitignore +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/propose_task/propose.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/reviewer/censor.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/reviewer/review.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/rules/.gitignore +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/rules/draft_ruleset.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/search_bibtex/.gitignore +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/search_bibtex/search.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/simple_chat/chat.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/simple_rag/simple_rag.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/task_handle/handle_task.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/write_article/.gitignore +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/write_article/article_rag.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/write_article/post_process.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/write_article/write_article.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/write_outline/.gitignore +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/write_outline/write_outline.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/examples/write_outline/write_outline_corrected.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/actions/__init__.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/actions/article.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/actions/article_rag.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/actions/fs.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/actions/output.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/actions/rag.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/actions/rules.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/__init__.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/advanced_judge.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/advanced_rag.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/censor.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/check.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/correct.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/extract.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/propose.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/rag.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/rating.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/review.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/task.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/core.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/decorators.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/fs/__init__.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/fs/curd.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/fs/readers.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/adv_kwargs_types.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/__init__.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/advanced_judge.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/aricle_rag.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/article_base.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/article_essence.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/article_main.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/article_outline.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/article_proposal.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/patches.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/problem.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/rag.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/rule.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/kwargs_types.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/task.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/models/tool.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/parser.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/py.typed +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/toolboxes/__init__.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/toolboxes/arithmetic.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/toolboxes/fs.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/workflows/__init__.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/workflows/articles.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/python/fabricatio/workflows/rag.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/src/bib_tools.rs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/src/event.rs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/src/hash.rs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/src/hbs_helpers.rs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/src/language.rs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/src/lib.rs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/src/macro_utils/Cargo.toml +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/src/macro_utils/src/lib.rs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/src/templates.rs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/src/typst_tools.rs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/src/word_split.rs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/as_prompt.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/binary-exploitation-ctf-solver.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/chap_summary.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/check_string.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/claude-xml.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/clean-up-code.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/co_validation.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/create_json_obj.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/cryptography-ctf-solver.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/dependencies.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/document-the-code.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/draft_rating_criteria.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/draft_rating_manual.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/draft_rating_weights_klee.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/draft_tool_usage_code.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/extract.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/extract_criteria_from_reasons.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/extract_reasons_from_examples.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/find-security-vulnerabilities.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/fix-bugs.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/fix_troubled_obj.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/fix_troubled_string.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/generic_string.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/improve-performance.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/liststr.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/make_choice.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/make_judgment.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/pathstr.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/rate_fine_grind.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/refactor.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/refined_query.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/retrieved_display.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/reverse-engineering-ctf-solver.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/review_string.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/rule_requirement.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/ruleset_requirement_breakdown.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/task_briefing.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/web-ctf-solver.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/write-git-commit.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/write-github-pull-request.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/templates/built-in/write-github-readme.hbs +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/tests/test_config.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/tests/test_models/test_action.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/tests/test_models/test_advanced.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/tests/test_models/test_generic.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/tests/test_models/test_problem.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/tests/test_models/test_role.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/tests/test_models/test_task.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/tests/test_models/test_tool.py +0 -0
- {fabricatio-0.3.14.dev0 → fabricatio-0.3.14.dev1}/tests/test_models/test_usages.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: fabricatio
|
3
|
-
Version: 0.3.14.
|
3
|
+
Version: 0.3.14.dev1
|
4
4
|
Classifier: License :: OSI Approved :: MIT License
|
5
5
|
Classifier: Programming Language :: Rust
|
6
6
|
Classifier: Programming Language :: Python :: 3.12
|
@@ -86,7 +86,7 @@ make bdist
|
|
86
86
|
|
87
87
|
```python
|
88
88
|
import asyncio
|
89
|
-
from fabricatio import Action, Role, Task, logger, WorkFlow
|
89
|
+
from fabricatio import Action, Role, Task, logger, WorkFlow, Event
|
90
90
|
from typing import Any
|
91
91
|
|
92
92
|
|
@@ -101,14 +101,14 @@ class Hello(Action):
|
|
101
101
|
|
102
102
|
|
103
103
|
async def main() -> None:
|
104
|
-
|
104
|
+
Role(
|
105
105
|
name="talker",
|
106
106
|
description="talker role",
|
107
|
-
registry={
|
107
|
+
registry={Event.quick_instantiate("talk"): WorkFlow(name="talk", steps=(Hello,))}
|
108
108
|
)
|
109
109
|
|
110
|
-
task = Task(name="say hello", goals="say hello", description="say hello to the world")
|
111
|
-
result = await task.delegate()
|
110
|
+
task = Task(name="say hello", goals=["say hello"], description="say hello to the world")
|
111
|
+
result = await task.delegate("talk")
|
112
112
|
logger.success(f"Result: {result}")
|
113
113
|
|
114
114
|
|
@@ -163,11 +163,11 @@ max_tokens = 8192
|
|
163
163
|
```bash
|
164
164
|
make test
|
165
165
|
```
|
166
|
+
|
166
167
|
## TODO
|
167
168
|
|
168
169
|
- Add an element based format strategy
|
169
170
|
|
170
|
-
|
171
171
|
## Contributing
|
172
172
|
|
173
173
|
Contributions are welcome! Follow these steps:
|
@@ -42,7 +42,7 @@ make bdist
|
|
42
42
|
|
43
43
|
```python
|
44
44
|
import asyncio
|
45
|
-
from fabricatio import Action, Role, Task, logger, WorkFlow
|
45
|
+
from fabricatio import Action, Role, Task, logger, WorkFlow, Event
|
46
46
|
from typing import Any
|
47
47
|
|
48
48
|
|
@@ -57,14 +57,14 @@ class Hello(Action):
|
|
57
57
|
|
58
58
|
|
59
59
|
async def main() -> None:
|
60
|
-
|
60
|
+
Role(
|
61
61
|
name="talker",
|
62
62
|
description="talker role",
|
63
|
-
registry={
|
63
|
+
registry={Event.quick_instantiate("talk"): WorkFlow(name="talk", steps=(Hello,))}
|
64
64
|
)
|
65
65
|
|
66
|
-
task = Task(name="say hello", goals="say hello", description="say hello to the world")
|
67
|
-
result = await task.delegate()
|
66
|
+
task = Task(name="say hello", goals=["say hello"], description="say hello to the world")
|
67
|
+
result = await task.delegate("talk")
|
68
68
|
logger.success(f"Result: {result}")
|
69
69
|
|
70
70
|
|
@@ -119,11 +119,11 @@ max_tokens = 8192
|
|
119
119
|
```bash
|
120
120
|
make test
|
121
121
|
```
|
122
|
+
|
122
123
|
## TODO
|
123
124
|
|
124
125
|
- Add an element based format strategy
|
125
126
|
|
126
|
-
|
127
127
|
## Contributing
|
128
128
|
|
129
129
|
Contributions are welcome! Follow these steps:
|
@@ -2,9 +2,8 @@
|
|
2
2
|
|
3
3
|
import asyncio
|
4
4
|
|
5
|
-
from fabricatio import Action, Role, Task, WorkFlow
|
5
|
+
from fabricatio import Action, Event, Role, Task, WorkFlow
|
6
6
|
from fabricatio.journal import logger
|
7
|
-
from fabricatio.models.events import Event
|
8
7
|
from fabricatio.parser import PythonCapture
|
9
8
|
|
10
9
|
|
@@ -3,15 +3,17 @@
|
|
3
3
|
import asyncio
|
4
4
|
from typing import Any
|
5
5
|
|
6
|
-
from fabricatio import Action, Role, Task, WorkFlow, logger
|
6
|
+
from fabricatio import Action, Event, Role, Task, WorkFlow, logger
|
7
|
+
from fabricatio.models.usages import LLMUsage
|
7
8
|
|
8
9
|
task = Task(name="write poem")
|
9
10
|
|
10
11
|
|
11
|
-
class WritePoem(Action):
|
12
|
+
class WritePoem(Action, LLMUsage):
|
12
13
|
"""Action that generates a poem."""
|
13
14
|
|
14
15
|
output_key: str = "task_output"
|
16
|
+
llm_stream: bool = False
|
15
17
|
|
16
18
|
async def _execute(self, **_) -> Any:
|
17
19
|
logger.info("Generating poem about the sea")
|
@@ -25,10 +27,10 @@ async def main() -> None:
|
|
25
27
|
Role(
|
26
28
|
name="poet",
|
27
29
|
description="A role that creates poetic content",
|
28
|
-
registry={
|
30
|
+
registry={Event.quick_instantiate(ns := 'poem'): WorkFlow(name="poetry_creation", steps=(WritePoem,))},
|
29
31
|
)
|
30
32
|
|
31
|
-
poem = await task.delegate()
|
33
|
+
poem = await task.delegate(ns)
|
32
34
|
logger.success(f"Poem:\n\n{poem}")
|
33
35
|
|
34
36
|
|
@@ -2,8 +2,7 @@
|
|
2
2
|
|
3
3
|
from fabricatio.rust import CONFIG, TEMPLATE_MANAGER, BibManager, Event
|
4
4
|
|
5
|
-
from fabricatio import actions, capabilities, toolboxes, workflows
|
6
|
-
from fabricatio import parser
|
5
|
+
from fabricatio import actions, capabilities, parser, toolboxes, workflows
|
7
6
|
from fabricatio.journal import logger
|
8
7
|
from fabricatio.models import extra
|
9
8
|
from fabricatio.models.action import Action, WorkFlow
|
@@ -16,7 +15,6 @@ __all__ = [
|
|
16
15
|
"TEMPLATE_MANAGER",
|
17
16
|
"Action",
|
18
17
|
"BibManager",
|
19
|
-
"parser",
|
20
18
|
"Event",
|
21
19
|
"Role",
|
22
20
|
"Task",
|
@@ -26,6 +24,7 @@ __all__ = [
|
|
26
24
|
"capabilities",
|
27
25
|
"extra",
|
28
26
|
"logger",
|
27
|
+
"parser",
|
29
28
|
"toolboxes",
|
30
29
|
"workflows",
|
31
30
|
]
|
@@ -12,7 +12,7 @@ Classes:
|
|
12
12
|
import traceback
|
13
13
|
from abc import abstractmethod
|
14
14
|
from asyncio import Queue, create_task
|
15
|
-
from typing import Any, ClassVar, Dict, Self, Sequence, Tuple, Type, Union, final
|
15
|
+
from typing import Any, ClassVar, Dict, Generator, Self, Sequence, Tuple, Type, Union, final
|
16
16
|
|
17
17
|
from pydantic import Field, PrivateAttr
|
18
18
|
|
@@ -11,7 +11,6 @@ from pydantic import (
|
|
11
11
|
BaseModel,
|
12
12
|
ConfigDict,
|
13
13
|
Field,
|
14
|
-
HttpUrl,
|
15
14
|
NonNegativeFloat,
|
16
15
|
PositiveFloat,
|
17
16
|
PositiveInt,
|
@@ -23,7 +22,6 @@ from pydantic.json_schema import GenerateJsonSchema, JsonSchemaValue
|
|
23
22
|
from fabricatio.fs import dump_text
|
24
23
|
from fabricatio.fs.readers import safe_text_read
|
25
24
|
from fabricatio.journal import logger
|
26
|
-
from fabricatio.parser import JsonCapture
|
27
25
|
from fabricatio.utils import ok
|
28
26
|
|
29
27
|
|
@@ -496,6 +494,8 @@ class InstantiateFromString(Base):
|
|
496
494
|
Returns:
|
497
495
|
Self | None: The instance of the class or None if the string is not valid.
|
498
496
|
"""
|
497
|
+
from fabricatio.parser import JsonCapture
|
498
|
+
|
499
499
|
obj = JsonCapture.convert_with(string, cls.model_validate_json)
|
500
500
|
logger.debug(f"Instantiate `{cls.__name__}` from string, {'Failed' if obj is None else 'Success'}.")
|
501
501
|
return obj
|
@@ -682,7 +682,7 @@ class ScopedConfig(Base):
|
|
682
682
|
Allows configuration values to be overridden in a hierarchical manner.
|
683
683
|
"""
|
684
684
|
|
685
|
-
llm_api_endpoint: Optional[
|
685
|
+
llm_api_endpoint: Optional[str] = None
|
686
686
|
"""The OpenAI API endpoint."""
|
687
687
|
|
688
688
|
llm_api_key: Optional[SecretStr] = None
|
@@ -727,7 +727,7 @@ class ScopedConfig(Base):
|
|
727
727
|
llm_frequency_penalty: Optional[PositiveFloat] = None
|
728
728
|
"""The frequency penalty of the LLM model."""
|
729
729
|
|
730
|
-
embedding_api_endpoint: Optional[
|
730
|
+
embedding_api_endpoint: Optional[str] = None
|
731
731
|
"""The OpenAI API endpoint."""
|
732
732
|
|
733
733
|
embedding_api_key: Optional[SecretStr] = None
|
@@ -748,7 +748,7 @@ class ScopedConfig(Base):
|
|
748
748
|
embedding_caching: Optional[bool] = False
|
749
749
|
"""Whether to cache the embedding result."""
|
750
750
|
|
751
|
-
milvus_uri: Optional[
|
751
|
+
milvus_uri: Optional[str] = Field(default=None)
|
752
752
|
"""The URI of the Milvus server."""
|
753
753
|
|
754
754
|
milvus_token: Optional[SecretStr] = Field(default=None)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
"""Module that contains the Role class for managing workflows and their event registrations."""
|
2
2
|
from functools import partial
|
3
|
-
from typing import Any,
|
3
|
+
from typing import Any, Dict, Self
|
4
4
|
|
5
5
|
from fabricatio.rust import Event
|
6
|
-
from pydantic import
|
6
|
+
from pydantic import ConfigDict, Field
|
7
7
|
|
8
8
|
from fabricatio.core import env
|
9
9
|
from fabricatio.journal import logger
|
@@ -69,7 +69,6 @@ class Role(WithBriefing):
|
|
69
69
|
|
70
70
|
def _configure_scoped_config(self, workflow) -> None:
|
71
71
|
"""Configure scoped configuration for workflow and its actions."""
|
72
|
-
|
73
72
|
if not is_scoped_config(self.__class__):
|
74
73
|
return
|
75
74
|
|
@@ -83,7 +82,6 @@ class Role(WithBriefing):
|
|
83
82
|
|
84
83
|
def _configure_toolbox_usage(self, workflow) -> None:
|
85
84
|
"""Configure toolbox usage for workflow and its actions."""
|
86
|
-
|
87
85
|
if not is_toolbox_usage(self.__class__):
|
88
86
|
return
|
89
87
|
|
@@ -26,8 +26,7 @@ from fabricatio.models.generic import ScopedConfig, WithBriefing
|
|
26
26
|
from fabricatio.models.kwargs_types import ChooseKwargs, EmbeddingKwargs, GenerateKwargs, LLMKwargs, ValidateKwargs
|
27
27
|
from fabricatio.models.task import Task
|
28
28
|
from fabricatio.models.tool import Tool, ToolBox
|
29
|
-
from fabricatio.
|
30
|
-
from fabricatio.utils import ok
|
29
|
+
from fabricatio.utils import first_available, ok
|
31
30
|
|
32
31
|
ROUTER = Router(
|
33
32
|
routing_strategy="usage-based-routing-v2",
|
@@ -91,7 +90,7 @@ class LLMUsage(ScopedConfig):
|
|
91
90
|
api_base=ok(
|
92
91
|
self.llm_api_endpoint or CONFIG.llm.api_endpoint,
|
93
92
|
"llm api endpoint is not set at any place",
|
94
|
-
)
|
93
|
+
),
|
95
94
|
model=m_name,
|
96
95
|
tpm=self.llm_tpm or CONFIG.llm.tpm,
|
97
96
|
rpm=self.llm_rpm or CONFIG.llm.rpm,
|
@@ -109,7 +108,8 @@ class LLMUsage(ScopedConfig):
|
|
109
108
|
stop=kwargs.get("stop") or self.llm_stop_sign or CONFIG.llm.stop_sign,
|
110
109
|
top_p=kwargs.get("top_p") or self.llm_top_p or CONFIG.llm.top_p,
|
111
110
|
max_tokens=kwargs.get("max_tokens") or self.llm_max_tokens or CONFIG.llm.max_tokens,
|
112
|
-
stream=
|
111
|
+
stream=first_available((kwargs.get("stream"), self.llm_stream, CONFIG.llm.stream),
|
112
|
+
"stream is not set at any place"),
|
113
113
|
cache={
|
114
114
|
"no-cache": kwargs.get("no_cache"),
|
115
115
|
"no-store": kwargs.get("no_store"),
|
@@ -337,6 +337,8 @@ class LLMUsage(ScopedConfig):
|
|
337
337
|
Returns:
|
338
338
|
Optional[List[str]]: The validated response as a list of strings.
|
339
339
|
"""
|
340
|
+
from fabricatio.parser import JsonCapture
|
341
|
+
|
340
342
|
return await self.aask_validate(
|
341
343
|
TEMPLATE_MANAGER.render_template(
|
342
344
|
CONFIG.templates.liststr_template,
|
@@ -393,6 +395,8 @@ class LLMUsage(ScopedConfig):
|
|
393
395
|
Returns:
|
394
396
|
Optional[str]: The generated string.
|
395
397
|
"""
|
398
|
+
from fabricatio.parser import GenericCapture
|
399
|
+
|
396
400
|
return await self.aask_validate( # pyright: ignore [reportReturnType]
|
397
401
|
TEMPLATE_MANAGER.render_template(
|
398
402
|
CONFIG.templates.generic_string_template,
|
@@ -420,6 +424,8 @@ class LLMUsage(ScopedConfig):
|
|
420
424
|
Returns:
|
421
425
|
Optional[List[T]]: The final validated selection result list, with element types matching the input `choices`.
|
422
426
|
"""
|
427
|
+
from fabricatio.parser import JsonCapture
|
428
|
+
|
423
429
|
if dup := duplicates_everseen(choices, key=lambda x: x.name):
|
424
430
|
logger.error(err := f"Redundant choices: {dup}")
|
425
431
|
raise ValueError(err)
|
@@ -495,6 +501,8 @@ class LLMUsage(ScopedConfig):
|
|
495
501
|
Returns:
|
496
502
|
bool: The judgment result (True or False) based on the AI's response.
|
497
503
|
"""
|
504
|
+
from fabricatio.parser import JsonCapture
|
505
|
+
|
498
506
|
return await self.aask_validate(
|
499
507
|
question=TEMPLATE_MANAGER.render_template(
|
500
508
|
CONFIG.templates.make_judgment_template,
|
@@ -556,7 +564,6 @@ class EmbeddingUsage(LLMUsage):
|
|
556
564
|
or self.llm_api_endpoint
|
557
565
|
or CONFIG.llm.api_endpoint
|
558
566
|
)
|
559
|
-
.unicode_string()
|
560
567
|
.rstrip("/"),
|
561
568
|
# seems embedding function takes no base_url end with a slash
|
562
569
|
)
|
@@ -11,7 +11,7 @@ Key Features:
|
|
11
11
|
- Text utilities: Word boundary splitting and word counting.
|
12
12
|
"""
|
13
13
|
from enum import StrEnum
|
14
|
-
from typing import Any, Dict, List, Optional, Self, Tuple,
|
14
|
+
from typing import Any, Dict, List, Optional, Self, Tuple, Union, overload
|
15
15
|
|
16
16
|
from pydantic import JsonValue
|
17
17
|
|
@@ -724,7 +724,7 @@ class SecretStr:
|
|
724
724
|
|
725
725
|
def __init__(self, source: str) -> None: ...
|
726
726
|
|
727
|
-
def
|
727
|
+
def get_secret_value(self) -> str:
|
728
728
|
"""Expose the secret string."""
|
729
729
|
|
730
730
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"""A collection of utility functions for the fabricatio package."""
|
2
2
|
|
3
|
-
from typing import Any, Dict, List, Mapping, Optional,
|
3
|
+
from typing import Any, Dict, Iterable, List, Mapping, Optional, Tuple, Type, TypedDict, Unpack, overload
|
4
4
|
|
5
5
|
from fabricatio.decorators import precheck_package
|
6
6
|
from fabricatio.journal import logger
|
@@ -116,6 +116,37 @@ def ok[T](val: Optional[T], msg: str = "Value is None") -> T:
|
|
116
116
|
return val
|
117
117
|
|
118
118
|
|
119
|
+
def first_available[T](iterable: Iterable[T], msg: str = "No available item found in the iterable.") -> T:
|
120
|
+
"""Return the first available item in the iterable that's not None.
|
121
|
+
|
122
|
+
This function searches through the provided iterable and returns the first
|
123
|
+
item that is not None. If all items are None or the iterable is empty,
|
124
|
+
it raises a ValueError.
|
125
|
+
|
126
|
+
Args:
|
127
|
+
iterable: The iterable collection to search through.
|
128
|
+
msg: The message to include in the ValueError if no non-None item is found.
|
129
|
+
|
130
|
+
Returns:
|
131
|
+
T: The first non-None item found in the iterable.
|
132
|
+
If no non-None item is found, it raises a ValueError.
|
133
|
+
|
134
|
+
Raises:
|
135
|
+
ValueError: If no non-None item is found in the iterable.
|
136
|
+
|
137
|
+
Examples:
|
138
|
+
>>> first_available([None, None, "value", "another"])
|
139
|
+
'value'
|
140
|
+
>>> first_available([1, 2, 3])
|
141
|
+
1
|
142
|
+
>>> assert (first_available([None, None]))
|
143
|
+
ValueError: No available item found in the iterable.
|
144
|
+
"""
|
145
|
+
if (first := next((item for item in iterable if item is not None), None)) is not None:
|
146
|
+
return first
|
147
|
+
raise ValueError(msg)
|
148
|
+
|
149
|
+
|
119
150
|
def wrapp_in_block(string: str, title: str, style: str = "-") -> str:
|
120
151
|
"""Wraps a string in a block with a title.
|
121
152
|
|
Binary file
|