fabricatio 0.3.13__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.
Files changed (166) hide show
  1. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/PKG-INFO +7 -7
  2. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/README.md +6 -6
  3. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/llm_usages/llm_usage.py +1 -2
  4. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/minor/hello_fabricatio.py +4 -3
  5. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/minor/write_a_poem.py +6 -4
  6. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/pyproject.toml +1 -1
  7. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/__init__.py +2 -8
  8. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/journal.py +0 -3
  9. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/action.py +6 -21
  10. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/generic.py +7 -6
  11. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/kwargs_types.py +1 -46
  12. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/role.py +41 -25
  13. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/usages.py +12 -5
  14. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/rust.pyi +2 -2
  15. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/utils.py +69 -4
  16. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/src/config.rs +1 -1
  17. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/src/event.rs +35 -34
  18. fabricatio-0.3.14.dev1/templates.tar.gz +0 -0
  19. fabricatio-0.3.14.dev1/uv.lock +1682 -0
  20. fabricatio-0.3.13/templates.tar.gz +0 -0
  21. fabricatio-0.3.13/uv.lock +0 -1682
  22. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/.github/workflows/build-package.yaml +0 -0
  23. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/.github/workflows/ruff.yaml +0 -0
  24. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/.github/workflows/tests.yaml +0 -0
  25. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/.gitignore +0 -0
  26. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/.python-version +0 -0
  27. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/Cargo.lock +0 -0
  28. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/Cargo.toml +0 -0
  29. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/LICENSE +0 -0
  30. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/Makefile +0 -0
  31. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/correct/correct.py +0 -0
  32. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/correct/correct_loop.py +0 -0
  33. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/extract_and_inject/.gitignore +0 -0
  34. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/extract_and_inject/article_rag.py +0 -0
  35. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/extract_and_inject/ask.py +0 -0
  36. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/extract_and_inject/chunk_article.py +0 -0
  37. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/extract_and_inject/extract_and_inject.py +0 -0
  38. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/extract_article/extract.py +0 -0
  39. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/make_a_rating/rating.py +0 -0
  40. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/make_diary/commits.json +0 -0
  41. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/make_diary/diary.py +0 -0
  42. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/propose_task/.gitignore +0 -0
  43. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/propose_task/propose.py +0 -0
  44. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/reviewer/censor.py +0 -0
  45. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/reviewer/review.py +0 -0
  46. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/rules/.gitignore +0 -0
  47. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/rules/draft_ruleset.py +0 -0
  48. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/search_bibtex/.gitignore +0 -0
  49. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/search_bibtex/search.py +0 -0
  50. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/simple_chat/chat.py +0 -0
  51. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/simple_rag/simple_rag.py +0 -0
  52. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/task_handle/handle_task.py +0 -0
  53. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/write_article/.gitignore +0 -0
  54. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/write_article/article_rag.py +0 -0
  55. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/write_article/post_process.py +0 -0
  56. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/write_article/write_article.py +0 -0
  57. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/write_outline/.gitignore +0 -0
  58. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/write_outline/write_outline.py +0 -0
  59. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/examples/write_outline/write_outline_corrected.py +0 -0
  60. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/actions/__init__.py +0 -0
  61. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/actions/article.py +0 -0
  62. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/actions/article_rag.py +0 -0
  63. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/actions/fs.py +0 -0
  64. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/actions/output.py +0 -0
  65. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/actions/rag.py +0 -0
  66. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/actions/rules.py +0 -0
  67. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/__init__.py +0 -0
  68. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/advanced_judge.py +0 -0
  69. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/advanced_rag.py +0 -0
  70. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/censor.py +0 -0
  71. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/check.py +0 -0
  72. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/correct.py +0 -0
  73. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/extract.py +0 -0
  74. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/propose.py +0 -0
  75. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/rag.py +0 -0
  76. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/rating.py +0 -0
  77. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/review.py +0 -0
  78. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/capabilities/task.py +0 -0
  79. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/core.py +0 -0
  80. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/decorators.py +0 -0
  81. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/fs/__init__.py +0 -0
  82. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/fs/curd.py +0 -0
  83. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/fs/readers.py +0 -0
  84. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/adv_kwargs_types.py +0 -0
  85. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/__init__.py +0 -0
  86. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/advanced_judge.py +0 -0
  87. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/aricle_rag.py +0 -0
  88. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/article_base.py +0 -0
  89. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/article_essence.py +0 -0
  90. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/article_main.py +0 -0
  91. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/article_outline.py +0 -0
  92. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/article_proposal.py +0 -0
  93. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/patches.py +0 -0
  94. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/problem.py +0 -0
  95. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/rag.py +0 -0
  96. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/extra/rule.py +0 -0
  97. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/task.py +0 -0
  98. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/models/tool.py +0 -0
  99. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/parser.py +0 -0
  100. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/py.typed +0 -0
  101. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/toolboxes/__init__.py +0 -0
  102. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/toolboxes/arithmetic.py +0 -0
  103. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/toolboxes/fs.py +0 -0
  104. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/workflows/__init__.py +0 -0
  105. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/workflows/articles.py +0 -0
  106. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/python/fabricatio/workflows/rag.py +0 -0
  107. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/src/bib_tools.rs +0 -0
  108. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/src/hash.rs +0 -0
  109. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/src/hbs_helpers.rs +0 -0
  110. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/src/language.rs +0 -0
  111. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/src/lib.rs +0 -0
  112. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/src/macro_utils/Cargo.toml +0 -0
  113. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/src/macro_utils/src/lib.rs +0 -0
  114. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/src/templates.rs +0 -0
  115. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/src/typst_tools.rs +0 -0
  116. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/src/word_split.rs +0 -0
  117. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/as_prompt.hbs +0 -0
  118. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/binary-exploitation-ctf-solver.hbs +0 -0
  119. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/chap_summary.hbs +0 -0
  120. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/check_string.hbs +0 -0
  121. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/claude-xml.hbs +0 -0
  122. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/clean-up-code.hbs +0 -0
  123. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/co_validation.hbs +0 -0
  124. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/create_json_obj.hbs +0 -0
  125. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/cryptography-ctf-solver.hbs +0 -0
  126. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/dependencies.hbs +0 -0
  127. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/document-the-code.hbs +0 -0
  128. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/draft_rating_criteria.hbs +0 -0
  129. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/draft_rating_manual.hbs +0 -0
  130. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/draft_rating_weights_klee.hbs +0 -0
  131. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/draft_tool_usage_code.hbs +0 -0
  132. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/extract.hbs +0 -0
  133. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/extract_criteria_from_reasons.hbs +0 -0
  134. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/extract_reasons_from_examples.hbs +0 -0
  135. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/find-security-vulnerabilities.hbs +0 -0
  136. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/fix-bugs.hbs +0 -0
  137. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/fix_troubled_obj.hbs +0 -0
  138. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/fix_troubled_string.hbs +0 -0
  139. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/generic_string.hbs +0 -0
  140. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/improve-performance.hbs +0 -0
  141. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/liststr.hbs +0 -0
  142. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/make_choice.hbs +0 -0
  143. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/make_judgment.hbs +0 -0
  144. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/pathstr.hbs +0 -0
  145. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/rate_fine_grind.hbs +0 -0
  146. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/refactor.hbs +0 -0
  147. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/refined_query.hbs +0 -0
  148. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/retrieved_display.hbs +0 -0
  149. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/reverse-engineering-ctf-solver.hbs +0 -0
  150. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/review_string.hbs +0 -0
  151. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/rule_requirement.hbs +0 -0
  152. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/ruleset_requirement_breakdown.hbs +0 -0
  153. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/task_briefing.hbs +0 -0
  154. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/web-ctf-solver.hbs +0 -0
  155. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/write-git-commit.hbs +0 -0
  156. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/write-github-pull-request.hbs +0 -0
  157. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/templates/built-in/write-github-readme.hbs +0 -0
  158. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/tests/test_config.py +0 -0
  159. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/tests/test_models/test_action.py +0 -0
  160. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/tests/test_models/test_advanced.py +0 -0
  161. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/tests/test_models/test_generic.py +0 -0
  162. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/tests/test_models/test_problem.py +0 -0
  163. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/tests/test_models/test_role.py +0 -0
  164. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/tests/test_models/test_task.py +0 -0
  165. {fabricatio-0.3.13 → fabricatio-0.3.14.dev1}/tests/test_models/test_tool.py +0 -0
  166. {fabricatio-0.3.13 → 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.13
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
- role = Role(
104
+ Role(
105
105
  name="talker",
106
106
  description="talker role",
107
- registry={Task.pending_label: WorkFlow(name="talk", steps=(Hello,))}
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
- role = Role(
60
+ Role(
61
61
  name="talker",
62
62
  description="talker role",
63
- registry={Task.pending_label: WorkFlow(name="talk", steps=(Hello,))}
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,7 +3,7 @@
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
7
 
8
8
  task = Task(name="say hello")
9
9
 
@@ -21,9 +21,10 @@ class Hello(Action):
21
21
 
22
22
  async def main() -> None:
23
23
  """Main function."""
24
- Role(name="talker", description="talker role", registry={task.pending_label: WorkFlow(name="talk", steps=(Hello,))})
24
+ Role(name="talker", description="talker role",
25
+ registry={Event.quick_instantiate("talk"): WorkFlow(name="talk", steps=(Hello,))})
25
26
 
26
- logger.success(f"Result: {await task.delegate()}")
27
+ logger.success(f"Result: {await task.delegate("talk")}")
27
28
 
28
29
 
29
30
  if __name__ == "__main__":
@@ -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={task.pending_label: WorkFlow(name="poetry_creation", steps=(WritePoem,))},
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
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fabricatio"
3
- version = "0.3.13"
3
+ version = "0.3.14-dev1"
4
4
  description = "A LLM multi-agent framework."
5
5
  readme = "README.md"
6
6
  license = { file = "LICENSE" }
@@ -2,35 +2,29 @@
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.core import env
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
10
9
  from fabricatio.models.role import Role
11
10
  from fabricatio.models.task import Task
12
11
  from fabricatio.models.tool import ToolBox
13
- from fabricatio.parser import Capture, GenericCapture, JsonCapture, PythonCapture
14
12
 
15
13
  __all__ = [
16
14
  "CONFIG",
17
15
  "TEMPLATE_MANAGER",
18
16
  "Action",
19
17
  "BibManager",
20
- "Capture",
21
18
  "Event",
22
- "GenericCapture",
23
- "JsonCapture",
24
- "PythonCapture",
25
19
  "Role",
26
20
  "Task",
27
21
  "ToolBox",
28
22
  "WorkFlow",
29
23
  "actions",
30
24
  "capabilities",
31
- "env",
32
25
  "extra",
33
26
  "logger",
27
+ "parser",
34
28
  "toolboxes",
35
29
  "workflows",
36
30
  ]
@@ -4,10 +4,7 @@ import sys
4
4
 
5
5
  from fabricatio.rust import CONFIG
6
6
  from loguru import logger
7
- from rich import pretty, traceback
8
7
 
9
- pretty.install()
10
- traceback.install()
11
8
  logger.remove()
12
9
  logger.add(sys.stderr, level=CONFIG.debug.log_level)
13
10
 
@@ -12,14 +12,13 @@ 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
 
19
19
  from fabricatio.journal import logger
20
20
  from fabricatio.models.generic import WithBriefing
21
21
  from fabricatio.models.task import Task
22
- from fabricatio.models.usages import ToolBoxUsage
23
22
  from fabricatio.utils import override_kwargs
24
23
 
25
24
  OUTPUT_KEY = "task_output"
@@ -106,7 +105,7 @@ class Action(WithBriefing):
106
105
  return self
107
106
 
108
107
 
109
- class WorkFlow(WithBriefing, ToolBoxUsage):
108
+ class WorkFlow(WithBriefing):
110
109
  """Manages sequences of actions to fulfill tasks.
111
110
 
112
111
  Handles context propagation between actions, error handling, and task lifecycle
@@ -148,6 +147,10 @@ class WorkFlow(WithBriefing, ToolBoxUsage):
148
147
  # Convert any action classes to instances
149
148
  self._instances = tuple(step if isinstance(step, Action) else step() for step in self.steps)
150
149
 
150
+ def iter_actions(self) -> Generator[Action, None, None]:
151
+ """Iterate over action instances."""
152
+ yield from self._instances
153
+
151
154
  def inject_personality(self, personality: str) -> Self:
152
155
  """Set personality for actions without existing personality.
153
156
 
@@ -249,24 +252,6 @@ class WorkFlow(WithBriefing, ToolBoxUsage):
249
252
 
250
253
  await self._context.put({self.task_input_key: task, **ctx})
251
254
 
252
- def steps_fallback_to_self(self) -> Self:
253
- """Configure all steps to use this workflow's configuration as fallback.
254
-
255
- Returns:
256
- Self: The workflow instance for method chaining.
257
- """
258
- self.hold_to(self._instances)
259
- return self
260
-
261
- def steps_supply_tools_from_self(self) -> Self:
262
- """Provide this workflow's tools to all steps in the workflow.
263
-
264
- Returns:
265
- Self: The workflow instance for method chaining.
266
- """
267
- self.provide_tools_to(i for i in self._instances if isinstance(i, ToolBoxUsage))
268
- return self
269
-
270
255
  def update_init_context(self, /, **kwargs) -> Self:
271
256
  """Update the initial context with additional key-value pairs.
272
257
 
@@ -7,12 +7,10 @@ from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Self,
7
7
 
8
8
  import ujson
9
9
  from fabricatio.rust import CONFIG, TEMPLATE_MANAGER, blake3_hash, detect_language
10
- from litellm.utils import token_counter
11
10
  from pydantic import (
12
11
  BaseModel,
13
12
  ConfigDict,
14
13
  Field,
15
- HttpUrl,
16
14
  NonNegativeFloat,
17
15
  PositiveFloat,
18
16
  PositiveInt,
@@ -24,7 +22,6 @@ from pydantic.json_schema import GenerateJsonSchema, JsonSchemaValue
24
22
  from fabricatio.fs import dump_text
25
23
  from fabricatio.fs.readers import safe_text_read
26
24
  from fabricatio.journal import logger
27
- from fabricatio.parser import JsonCapture
28
25
  from fabricatio.utils import ok
29
26
 
30
27
 
@@ -497,6 +494,8 @@ class InstantiateFromString(Base):
497
494
  Returns:
498
495
  Self | None: The instance of the class or None if the string is not valid.
499
496
  """
497
+ from fabricatio.parser import JsonCapture
498
+
500
499
  obj = JsonCapture.convert_with(string, cls.model_validate_json)
501
500
  logger.debug(f"Instantiate `{cls.__name__}` from string, {'Failed' if obj is None else 'Success'}.")
502
501
  return obj
@@ -666,6 +665,8 @@ class Vectorizable:
666
665
  Raises:
667
666
  ValueError: If the chunk exceeds the maximum sequence length.
668
667
  """
668
+ from litellm.utils import token_counter
669
+
669
670
  max_length = max_length or CONFIG.embedding.max_sequence_length
670
671
  chunk = self._prepare_vectorization_inner()
671
672
  if max_length and (length := token_counter(text=chunk)) > max_length:
@@ -681,7 +682,7 @@ class ScopedConfig(Base):
681
682
  Allows configuration values to be overridden in a hierarchical manner.
682
683
  """
683
684
 
684
- llm_api_endpoint: Optional[HttpUrl] = None
685
+ llm_api_endpoint: Optional[str] = None
685
686
  """The OpenAI API endpoint."""
686
687
 
687
688
  llm_api_key: Optional[SecretStr] = None
@@ -726,7 +727,7 @@ class ScopedConfig(Base):
726
727
  llm_frequency_penalty: Optional[PositiveFloat] = None
727
728
  """The frequency penalty of the LLM model."""
728
729
 
729
- embedding_api_endpoint: Optional[HttpUrl] = None
730
+ embedding_api_endpoint: Optional[str] = None
730
731
  """The OpenAI API endpoint."""
731
732
 
732
733
  embedding_api_key: Optional[SecretStr] = None
@@ -747,7 +748,7 @@ class ScopedConfig(Base):
747
748
  embedding_caching: Optional[bool] = False
748
749
  """Whether to cache the embedding result."""
749
750
 
750
- milvus_uri: Optional[HttpUrl] = Field(default=None)
751
+ milvus_uri: Optional[str] = Field(default=None)
751
752
  """The URI of the Milvus server."""
752
753
 
753
754
  milvus_token: Optional[SecretStr] = Field(default=None)
@@ -1,9 +1,6 @@
1
1
  """This module contains the types for the keyword arguments of the methods in the models module."""
2
2
 
3
- from typing import Any, Dict, List, Literal, NotRequired, Optional, Required, TypedDict
4
-
5
- from litellm.caching.caching import CacheMode
6
- from litellm.types.caching import CachingSupportedCallTypes
3
+ from typing import Dict, List, Literal, NotRequired, Optional, Required, TypedDict
7
4
 
8
5
 
9
6
  class ChunkKwargs(TypedDict):
@@ -70,7 +67,6 @@ class ValidateKwargs[T](GenerateKwargs, total=False):
70
67
  max_validations: int
71
68
 
72
69
 
73
-
74
70
  class CompositeScoreKwargs(ValidateKwargs[List[Dict[str, float]]], total=False):
75
71
  """Arguments for composite score generation operations.
76
72
 
@@ -125,47 +121,6 @@ class ChooseKwargs[T](ValidateKwargs[T], total=False):
125
121
  k: int
126
122
 
127
123
 
128
- class CacheKwargs(TypedDict, total=False):
129
- """Configuration parameters for the caching system.
130
-
131
- These arguments control the behavior of various caching backends,
132
- including in-memory, Redis, S3, and vector database caching options.
133
- """
134
-
135
- mode: CacheMode # when default_on cache is always on, when default_off cache is opt in
136
- host: str
137
- port: str
138
- password: str
139
- namespace: str
140
- ttl: float
141
- default_in_memory_ttl: float
142
- default_in_redis_ttl: float
143
- similarity_threshold: float
144
- supported_call_types: list[CachingSupportedCallTypes]
145
- # s3 Bucket, boto3 configuration
146
- s3_bucket_name: str
147
- s3_region_name: str
148
- s3_api_version: str
149
- s3_use_ssl: bool
150
- s3_verify: bool | str
151
- s3_endpoint_url: str
152
- s3_aws_access_key_id: str
153
- s3_aws_secret_access_key: str
154
- s3_aws_session_token: str
155
- s3_config: Any
156
- s3_path: str
157
- redis_semantic_cache_use_async: bool
158
- redis_semantic_cache_embedding_model: str
159
- redis_flush_size: int
160
- redis_startup_nodes: list
161
- disk_cache_dir: Any
162
- qdrant_api_base: str
163
- qdrant_api_key: str
164
- qdrant_collection_name: str
165
- qdrant_quantization_config: str
166
- qdrant_semantic_cache_embedding_model: str
167
-
168
-
169
124
  class RerankOptions(TypedDict, total=False):
170
125
  """Optional keyword arguments for the rerank method."""
171
126
 
@@ -1,40 +1,35 @@
1
1
  """Module that contains the Role class for managing workflows and their event registrations."""
2
-
3
- from typing import Any, Self, Set
2
+ from functools import partial
3
+ from typing import Any, Dict, Self
4
4
 
5
5
  from fabricatio.rust import Event
6
- from pydantic import Field, ConfigDict
6
+ from pydantic import ConfigDict, Field
7
7
 
8
- from fabricatio.capabilities.propose import Propose
9
8
  from fabricatio.core import env
10
9
  from fabricatio.journal import logger
11
10
  from fabricatio.models.action import WorkFlow
12
11
  from fabricatio.models.generic import WithBriefing
13
- from fabricatio.models.tool import ToolBox
14
- from fabricatio.models.usages import ToolBoxUsage
12
+ from fabricatio.utils import is_subclass_of_base
13
+
14
+ is_toolbox_usage = partial(is_subclass_of_base, base_module="fabricatio.models.usages",
15
+ base_name="ToolBoxUsage")
16
+ is_scoped_config = partial(is_subclass_of_base, base_module="fabricatio.models.generic",
17
+ base_name="ScopedConfig")
15
18
 
16
19
 
17
- class Role(WithBriefing, Propose, ToolBoxUsage):
20
+ class Role(WithBriefing):
18
21
  """Class that represents a role with a registry of events and workflows.
19
22
 
20
23
  A Role serves as a container for workflows, managing their registration to events
21
24
  and providing them with shared configuration like tools and personality.
22
-
23
- Attributes:
24
- registry: Mapping of events to workflows that handle them
25
- toolboxes: Set of toolboxes available to this role and its workflows
26
25
  """
27
- # fixme: not use arbitrary_types_allowed
28
26
  model_config = ConfigDict(use_attribute_docstrings=True, arbitrary_types_allowed=True)
29
27
  description: str = ""
30
28
  """A brief description of the role's responsibilities and capabilities."""
31
29
 
32
- registry: dict[Event | str, WorkFlow] = Field(default_factory=dict)
30
+ registry: Dict[Event, WorkFlow] = Field(default_factory=dict)
33
31
  """The registry of events and workflows."""
34
32
 
35
- toolboxes: Set[ToolBox] = Field(default_factory=set)
36
- """Collection of tools available to this role."""
37
-
38
33
  def model_post_init(self, __context: Any) -> None:
39
34
  """Initialize the role by resolving configurations and registering workflows.
40
35
 
@@ -51,7 +46,7 @@ class Role(WithBriefing, Propose, ToolBoxUsage):
51
46
  """
52
47
  for event, workflow in self.registry.items():
53
48
  logger.debug(
54
- f"Registering workflow: `{workflow.name}` for event: `{Event.instantiate_from(event).collapse()}`"
49
+ f"Registering workflow: `{workflow.name}` for event: `{event.collapse()}`"
55
50
  )
56
51
  env.on(event, workflow.serve)
57
52
  return self
@@ -67,12 +62,33 @@ class Role(WithBriefing, Propose, ToolBoxUsage):
67
62
  """
68
63
  for workflow in self.registry.values():
69
64
  logger.debug(f"Resolving config for workflow: `{workflow.name}`")
70
- (
71
- workflow.fallback_to(self)
72
- .steps_fallback_to_self()
73
- .inject_personality(self.briefing)
74
- .supply_tools_from(self)
75
- .steps_supply_tools_from_self()
76
- )
77
-
65
+ self._configure_scoped_config(workflow)
66
+ self._configure_toolbox_usage(workflow)
67
+ workflow.inject_personality(self.briefing)
78
68
  return self
69
+
70
+ def _configure_scoped_config(self, workflow) -> None:
71
+ """Configure scoped configuration for workflow and its actions."""
72
+ if not is_scoped_config(self.__class__):
73
+ return
74
+
75
+ fallback_target = self
76
+ if is_scoped_config(workflow):
77
+ workflow.fallback_to(self)
78
+ fallback_target = workflow
79
+
80
+ for action in (a for a in workflow.iter_actions() if is_scoped_config(a)):
81
+ action.fallback_to(fallback_target)
82
+
83
+ def _configure_toolbox_usage(self, workflow) -> None:
84
+ """Configure toolbox usage for workflow and its actions."""
85
+ if not is_toolbox_usage(self.__class__):
86
+ return
87
+
88
+ supply_target = self
89
+ if is_toolbox_usage(workflow):
90
+ workflow.supply_tools_from(self)
91
+ supply_target = workflow
92
+
93
+ for action in (a for a in workflow.iter_actions() if is_toolbox_usage(a)):
94
+ action.supply_tools_from(supply_target)
@@ -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.parser import GenericCapture, JsonCapture
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
- ).unicode_string(),
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=ok(kwargs.get("stream") or self.llm_stream or CONFIG.llm.stream, "stream is not set at any place"),
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, overload, Union
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 expose(self) -> str:
727
+ def get_secret_value(self) -> str:
728
728
  """Expose the secret string."""
729
729
 
730
730