fabricatio 0.2.7.dev3__tar.gz → 0.2.7.dev5__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 (133) hide show
  1. fabricatio-0.2.7.dev5/PKG-INFO +181 -0
  2. fabricatio-0.2.7.dev5/README.md +138 -0
  3. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/pyproject.toml +1 -1
  4. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/actions/article.py +26 -19
  5. fabricatio-0.2.7.dev5/python/fabricatio/models/extra/article_base.py +291 -0
  6. fabricatio-0.2.7.dev5/python/fabricatio/models/extra/article_main.py +230 -0
  7. fabricatio-0.2.7.dev5/python/fabricatio/models/extra/article_outline.py +187 -0
  8. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/extra/article_proposal.py +12 -14
  9. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/generic.py +79 -6
  10. fabricatio-0.2.7.dev5/templates.tar.gz +0 -0
  11. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/uv.lock +1 -1
  12. fabricatio-0.2.7.dev3/PKG-INFO +0 -436
  13. fabricatio-0.2.7.dev3/README.md +0 -393
  14. fabricatio-0.2.7.dev3/python/fabricatio/models/extra/article_main.py +0 -359
  15. fabricatio-0.2.7.dev3/python/fabricatio/models/extra/article_outline.py +0 -276
  16. fabricatio-0.2.7.dev3/templates.tar.gz +0 -0
  17. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/.github/workflows/build-package.yaml +0 -0
  18. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/.github/workflows/ruff.yaml +0 -0
  19. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/.github/workflows/tests.yaml +0 -0
  20. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/.gitignore +0 -0
  21. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/.python-version +0 -0
  22. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/Cargo.lock +0 -0
  23. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/Cargo.toml +0 -0
  24. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/LICENSE +0 -0
  25. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/Makefile +0 -0
  26. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/correct/correct.py +0 -0
  27. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/correct/correct_loop.py +0 -0
  28. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/extract_and_inject/.gitignore +0 -0
  29. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/extract_and_inject/article_rag.py +0 -0
  30. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/extract_and_inject/ask.py +0 -0
  31. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/extract_and_inject/extract_and_inject.py +0 -0
  32. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/extract_article/extract.py +0 -0
  33. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/llm_usages/llm_usage.py +0 -0
  34. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/make_a_rating/rating.py +0 -0
  35. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/make_diary/commits.json +0 -0
  36. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/make_diary/diary.py +0 -0
  37. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/minor/hello_fabricatio.py +0 -0
  38. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/minor/write_a_poem.py +0 -0
  39. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/propose_task/propose.py +0 -0
  40. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/reviewer/review.py +0 -0
  41. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/search_bibtex/.gitignore +0 -0
  42. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/search_bibtex/search.py +0 -0
  43. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/simple_chat/chat.py +0 -0
  44. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/simple_rag/simple_rag.py +0 -0
  45. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/task_handle/handle_task.py +0 -0
  46. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/write_article/.gitignore +0 -0
  47. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/write_article/write_article.py +0 -0
  48. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/write_outline/.gitignore +0 -0
  49. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/write_outline/write_outline.py +0 -0
  50. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/write_outline/write_outline_corrected.py +0 -0
  51. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/__init__.py +0 -0
  52. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/_rust.pyi +0 -0
  53. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/_rust_instances.py +0 -0
  54. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/actions/article_rag.py +0 -0
  55. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/actions/output.py +0 -0
  56. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/actions/rag.py +0 -0
  57. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/capabilities/correct.py +0 -0
  58. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/capabilities/propose.py +0 -0
  59. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/capabilities/rag.py +0 -0
  60. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/capabilities/rating.py +0 -0
  61. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/capabilities/review.py +0 -0
  62. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/capabilities/task.py +0 -0
  63. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/config.py +0 -0
  64. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/core.py +0 -0
  65. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/decorators.py +0 -0
  66. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/fs/__init__.py +0 -0
  67. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/fs/curd.py +0 -0
  68. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/fs/readers.py +0 -0
  69. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/journal.py +0 -0
  70. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/action.py +0 -0
  71. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/events.py +0 -0
  72. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/extra/article_essence.py +0 -0
  73. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/kwargs_types.py +0 -0
  74. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/role.py +0 -0
  75. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/task.py +0 -0
  76. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/tool.py +0 -0
  77. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/usages.py +0 -0
  78. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/utils.py +0 -0
  79. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/parser.py +0 -0
  80. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/py.typed +0 -0
  81. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/toolboxes/__init__.py +0 -0
  82. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/toolboxes/arithmetic.py +0 -0
  83. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/toolboxes/fs.py +0 -0
  84. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/workflows/articles.py +0 -0
  85. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/workflows/rag.py +0 -0
  86. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/src/bib_tools.rs +0 -0
  87. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/src/hash.rs +0 -0
  88. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/src/hbs_helpers.rs +0 -0
  89. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/src/lib.rs +0 -0
  90. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/src/templates.rs +0 -0
  91. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/as_prompt.hbs +0 -0
  92. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/binary-exploitation-ctf-solver.hbs +0 -0
  93. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/claude-xml.hbs +0 -0
  94. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/clean-up-code.hbs +0 -0
  95. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/co_validation.hbs +0 -0
  96. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/correct.hbs +0 -0
  97. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/create_json_obj.hbs +0 -0
  98. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/cryptography-ctf-solver.hbs +0 -0
  99. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/dependencies.hbs +0 -0
  100. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/document-the-code.hbs +0 -0
  101. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/draft_rating_criteria.hbs +0 -0
  102. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/draft_rating_manual.hbs +0 -0
  103. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/draft_rating_weights_klee.hbs +0 -0
  104. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/draft_tool_usage_code.hbs +0 -0
  105. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/extract_criteria_from_reasons.hbs +0 -0
  106. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/extract_reasons_from_examples.hbs +0 -0
  107. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/find-security-vulnerabilities.hbs +0 -0
  108. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/fix-bugs.hbs +0 -0
  109. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/generic_string.hbs +0 -0
  110. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/improve-performance.hbs +0 -0
  111. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/liststr.hbs +0 -0
  112. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/make_choice.hbs +0 -0
  113. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/make_judgment.hbs +0 -0
  114. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/pathstr.hbs +0 -0
  115. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/rate_fine_grind.hbs +0 -0
  116. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/refactor.hbs +0 -0
  117. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/refined_query.hbs +0 -0
  118. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/retrieved_display.hbs +0 -0
  119. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/reverse-engineering-ctf-solver.hbs +0 -0
  120. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/review_string.hbs +0 -0
  121. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/task_briefing.hbs +0 -0
  122. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/web-ctf-solver.hbs +0 -0
  123. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/write-git-commit.hbs +0 -0
  124. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/write-github-pull-request.hbs +0 -0
  125. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/write-github-readme.hbs +0 -0
  126. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/tests/test_config.py +0 -0
  127. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/tests/test_models/test_action.py +0 -0
  128. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/tests/test_models/test_advanced.py +0 -0
  129. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/tests/test_models/test_generic.py +0 -0
  130. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/tests/test_models/test_role.py +0 -0
  131. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/tests/test_models/test_task.py +0 -0
  132. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/tests/test_models/test_tool.py +0 -0
  133. {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/tests/test_models/test_usages.py +0 -0
@@ -0,0 +1,181 @@
1
+ Metadata-Version: 2.4
2
+ Name: fabricatio
3
+ Version: 0.2.7.dev5
4
+ Classifier: License :: OSI Approved :: MIT License
5
+ Classifier: Programming Language :: Rust
6
+ Classifier: Programming Language :: Python :: 3.12
7
+ Classifier: Programming Language :: Python :: Implementation :: CPython
8
+ Classifier: Framework :: AsyncIO
9
+ Classifier: Framework :: Pydantic :: 2
10
+ Classifier: Typing :: Typed
11
+ Requires-Dist: appdirs>=1.4.4
12
+ Requires-Dist: asyncio>=3.4.3
13
+ Requires-Dist: asyncstdlib>=3.13.0
14
+ Requires-Dist: json-repair>=0.39.1
15
+ Requires-Dist: litellm>=1.60.0
16
+ Requires-Dist: loguru>=0.7.3
17
+ Requires-Dist: magika>=0.5.1
18
+ Requires-Dist: more-itertools>=10.6.0
19
+ Requires-Dist: orjson>=3.10.15
20
+ Requires-Dist: pydantic>=2.10.6
21
+ Requires-Dist: pydantic-settings>=2.7.1
22
+ Requires-Dist: pymitter>=1.0.0
23
+ Requires-Dist: questionary>=2.1.0
24
+ Requires-Dist: regex>=2024.11.6
25
+ Requires-Dist: rich>=13.9.4
26
+ Requires-Dist: pymilvus>=2.5.4 ; extra == 'rag'
27
+ Requires-Dist: fabricatio[calc,plot,rag] ; extra == 'full'
28
+ Requires-Dist: sympy>=1.13.3 ; extra == 'calc'
29
+ Requires-Dist: matplotlib>=3.10.1 ; extra == 'plot'
30
+ Provides-Extra: rag
31
+ Provides-Extra: full
32
+ Provides-Extra: calc
33
+ Provides-Extra: plot
34
+ License-File: LICENSE
35
+ Summary: A LLM multi-agent framework.
36
+ Keywords: ai,agents,multi-agent,llm,pyo3
37
+ Author-email: Whth <zettainspector@foxmail.com>
38
+ Requires-Python: >=3.12, <3.13
39
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
40
+ Project-URL: Homepage, https://github.com/Whth/fabricatio
41
+ Project-URL: Repository, https://github.com/Whth/fabricatio
42
+ Project-URL: Issues, https://github.com/Whth/fabricatio/issues
43
+
44
+ # Fabricatio
45
+
46
+ ![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)
47
+ ![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)
48
+ ![Build Status](https://img.shields.io/badge/build-passing-brightgreen)
49
+
50
+ ## Overview
51
+
52
+ Fabricatio is a streamlined Python library for building LLM applications using an event-based agent structure. It leverages Rust for performance-critical tasks, Handlebars for templating, and PyO3 for Python bindings.
53
+
54
+ ## Features
55
+
56
+ - **Event-Driven Architecture**: Robust task management through an EventEmitter pattern.
57
+ - **LLM Integration & Templating**: Seamlessly interact with large language models and dynamic content generation.
58
+ - **Async & Extensible**: Fully asynchronous execution with easy extension via custom actions and workflows.
59
+
60
+ ## Installation
61
+
62
+ ### Using UV (Recommended)
63
+
64
+ ```bash
65
+ # Install uv if not already installed
66
+ pip install uv
67
+
68
+ # Clone the repository
69
+ git clone https://github.com/Whth/fabricatio.git
70
+ cd fabricatio
71
+
72
+ # Install the package in development mode with uv
73
+ uv --with-editable . maturin develop --uv -r
74
+ ```
75
+
76
+ ### Building Distribution
77
+
78
+ ```bash
79
+ # Build distribution packages
80
+ make bdist
81
+ ```
82
+
83
+ ## Usage
84
+
85
+ ### Basic Example
86
+
87
+ ```python
88
+ import asyncio
89
+ from fabricatio import Action, Role, Task, logger, WorkFlow
90
+ from typing import Any
91
+
92
+ class Hello(Action):
93
+ name: str = "hello"
94
+ output_key: str = "task_output"
95
+
96
+ async def _execute(self, task_input: Task[str], **_) -> Any:
97
+ ret = "Hello fabricatio!"
98
+ logger.info("executing talk action")
99
+ return ret
100
+
101
+ async def main() -> None:
102
+ role = Role(
103
+ name="talker",
104
+ description="talker role",
105
+ registry={Task.pending_label: WorkFlow(name="talk", steps=(Hello,))}
106
+ )
107
+
108
+ task = Task(name="say hello", goals="say hello", description="say hello to the world")
109
+ result = await task.delegate()
110
+ logger.success(f"Result: {result}")
111
+
112
+ if __name__ == "__main__":
113
+ asyncio.run(main())
114
+ ```
115
+
116
+ ### Examples
117
+
118
+ For various usage scenarios, refer to the following examples:
119
+ - Simple Chat
120
+ - Retrieval-Augmented Generation (RAG)
121
+ - Article Extraction
122
+ - Propose Task
123
+ - Code Review
124
+ - Write Outline
125
+
126
+ _(For full example details, please check our detailed documentation, see [Examples](./examples))_
127
+
128
+ ## Configuration
129
+
130
+ The configuration for Fabricatio is managed via environment variables or TOML files. For example:
131
+
132
+ ```toml
133
+ [llm]
134
+ api_endpoint = "https://api.openai.com"
135
+ api_key = "your_openai_api_key"
136
+ timeout = 300
137
+ max_retries = 3
138
+ model = "gpt-3.5-turbo"
139
+ temperature = 1.0
140
+ stop_sign = ["\n\n\n", "User:"]
141
+ top_p = 0.35
142
+ generation_count = 1
143
+ stream = false
144
+ max_tokens = 8192
145
+ ```
146
+
147
+ ## Development Setup
148
+
149
+ 1. **Clone the Repository**:
150
+ ```bash
151
+ git clone https://github.com/Whth/fabricatio.git
152
+ cd fabricatio
153
+ ```
154
+ 2. **Install Dependencies**:
155
+ ```bash
156
+ uv --with-editable . maturin develop --uv -r
157
+ ```
158
+ 3. **Run Tests**:
159
+ ```bash
160
+ make test
161
+ ```
162
+
163
+ ## Contributing
164
+
165
+ Contributions are welcome! Follow these steps:
166
+ 1. Fork the repository.
167
+ 2. Create your feature branch (`git checkout -b feature/new-feature`).
168
+ 3. Commit your changes (`git commit -am 'Add new feature'`).
169
+ 4. Push to the branch (`git push origin feature/new-feature`).
170
+ 5. Create a new Pull Request.
171
+
172
+ ## License
173
+
174
+ Fabricatio is licensed under the MIT License. See [LICENSE](LICENSE) for details.
175
+
176
+ ## Acknowledgments
177
+
178
+ Special thanks to the contributors and maintainers of:
179
+ - [PyO3](https://github.com/PyO3/pyo3)
180
+ - [Maturin](https://github.com/PyO3/maturin)
181
+ - [Handlebars.rs](https://github.com/sunng87/handlebars-rust)
@@ -0,0 +1,138 @@
1
+ # Fabricatio
2
+
3
+ ![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)
4
+ ![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)
5
+ ![Build Status](https://img.shields.io/badge/build-passing-brightgreen)
6
+
7
+ ## Overview
8
+
9
+ Fabricatio is a streamlined Python library for building LLM applications using an event-based agent structure. It leverages Rust for performance-critical tasks, Handlebars for templating, and PyO3 for Python bindings.
10
+
11
+ ## Features
12
+
13
+ - **Event-Driven Architecture**: Robust task management through an EventEmitter pattern.
14
+ - **LLM Integration & Templating**: Seamlessly interact with large language models and dynamic content generation.
15
+ - **Async & Extensible**: Fully asynchronous execution with easy extension via custom actions and workflows.
16
+
17
+ ## Installation
18
+
19
+ ### Using UV (Recommended)
20
+
21
+ ```bash
22
+ # Install uv if not already installed
23
+ pip install uv
24
+
25
+ # Clone the repository
26
+ git clone https://github.com/Whth/fabricatio.git
27
+ cd fabricatio
28
+
29
+ # Install the package in development mode with uv
30
+ uv --with-editable . maturin develop --uv -r
31
+ ```
32
+
33
+ ### Building Distribution
34
+
35
+ ```bash
36
+ # Build distribution packages
37
+ make bdist
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ ### Basic Example
43
+
44
+ ```python
45
+ import asyncio
46
+ from fabricatio import Action, Role, Task, logger, WorkFlow
47
+ from typing import Any
48
+
49
+ class Hello(Action):
50
+ name: str = "hello"
51
+ output_key: str = "task_output"
52
+
53
+ async def _execute(self, task_input: Task[str], **_) -> Any:
54
+ ret = "Hello fabricatio!"
55
+ logger.info("executing talk action")
56
+ return ret
57
+
58
+ async def main() -> None:
59
+ role = Role(
60
+ name="talker",
61
+ description="talker role",
62
+ registry={Task.pending_label: WorkFlow(name="talk", steps=(Hello,))}
63
+ )
64
+
65
+ task = Task(name="say hello", goals="say hello", description="say hello to the world")
66
+ result = await task.delegate()
67
+ logger.success(f"Result: {result}")
68
+
69
+ if __name__ == "__main__":
70
+ asyncio.run(main())
71
+ ```
72
+
73
+ ### Examples
74
+
75
+ For various usage scenarios, refer to the following examples:
76
+ - Simple Chat
77
+ - Retrieval-Augmented Generation (RAG)
78
+ - Article Extraction
79
+ - Propose Task
80
+ - Code Review
81
+ - Write Outline
82
+
83
+ _(For full example details, please check our detailed documentation, see [Examples](./examples))_
84
+
85
+ ## Configuration
86
+
87
+ The configuration for Fabricatio is managed via environment variables or TOML files. For example:
88
+
89
+ ```toml
90
+ [llm]
91
+ api_endpoint = "https://api.openai.com"
92
+ api_key = "your_openai_api_key"
93
+ timeout = 300
94
+ max_retries = 3
95
+ model = "gpt-3.5-turbo"
96
+ temperature = 1.0
97
+ stop_sign = ["\n\n\n", "User:"]
98
+ top_p = 0.35
99
+ generation_count = 1
100
+ stream = false
101
+ max_tokens = 8192
102
+ ```
103
+
104
+ ## Development Setup
105
+
106
+ 1. **Clone the Repository**:
107
+ ```bash
108
+ git clone https://github.com/Whth/fabricatio.git
109
+ cd fabricatio
110
+ ```
111
+ 2. **Install Dependencies**:
112
+ ```bash
113
+ uv --with-editable . maturin develop --uv -r
114
+ ```
115
+ 3. **Run Tests**:
116
+ ```bash
117
+ make test
118
+ ```
119
+
120
+ ## Contributing
121
+
122
+ Contributions are welcome! Follow these steps:
123
+ 1. Fork the repository.
124
+ 2. Create your feature branch (`git checkout -b feature/new-feature`).
125
+ 3. Commit your changes (`git commit -am 'Add new feature'`).
126
+ 4. Push to the branch (`git push origin feature/new-feature`).
127
+ 5. Create a new Pull Request.
128
+
129
+ ## License
130
+
131
+ Fabricatio is licensed under the MIT License. See [LICENSE](LICENSE) for details.
132
+
133
+ ## Acknowledgments
134
+
135
+ Special thanks to the contributors and maintainers of:
136
+ - [PyO3](https://github.com/PyO3/pyo3)
137
+ - [Maturin](https://github.com/PyO3/maturin)
138
+ - [Handlebars.rs](https://github.com/sunng87/handlebars-rust)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fabricatio"
3
- version = "0.2.7-dev3"
3
+ version = "0.2.7-dev5"
4
4
  description = "A LLM multi-agent framework."
5
5
  readme = "README.md"
6
6
  license = { file = "LICENSE" }
@@ -61,7 +61,7 @@ class GenerateArticleProposal(Action):
61
61
  logger.error("Task not approved, since all inputs are None.")
62
62
  return None
63
63
 
64
- return (
64
+ return ok(
65
65
  await self.propose(
66
66
  ArticleProposal,
67
67
  briefing := (
@@ -70,14 +70,15 @@ class GenerateArticleProposal(Action):
70
70
  ok(
71
71
  article_briefing_path
72
72
  or await self.awhich_pathstr(
73
- f"{task_input.briefing}\nExtract the path of file which contains the article briefing."
73
+ f"{ok(task_input).briefing}\nExtract the path of file which contains the article briefing."
74
74
  ),
75
75
  "Could not find the path of file to read.",
76
76
  )
77
77
  )
78
78
  ),
79
79
  **self.prepend_sys_msg(),
80
- )
80
+ ),
81
+ "Could not generate the proposal."
81
82
  ).update_ref(briefing)
82
83
 
83
84
 
@@ -92,27 +93,33 @@ class GenerateOutline(Action):
92
93
  article_proposal: ArticleProposal,
93
94
  **_,
94
95
  ) -> Optional[ArticleOutline]:
95
- out = await self.propose(
96
- ArticleOutline,
97
- article_proposal.as_prompt(),
98
- **self.prepend_sys_msg(),
96
+ out = ok(
97
+ await self.propose(
98
+ ArticleOutline,
99
+ article_proposal.as_prompt(),
100
+ **self.prepend_sys_msg(),
101
+ ),
102
+ "Could not generate the outline.",
99
103
  )
100
104
 
101
- manual = await self.draft_rating_manual(
105
+ manual = ok(await self.draft_rating_manual(
102
106
  topic=(
103
107
  topic
104
108
  := "Fix the internal referring error, make sure there is no more `ArticleRef` pointing to a non-existing article component."
105
109
  ),
106
- )
107
- while err := out.resolve_ref_error():
110
+ ),"Could not generate the rating manual.")
111
+
112
+ while pack := out.find_illegal():
113
+ component, err = ok(pack)
108
114
  logger.warning(f"Found error in the outline: \n{err}")
109
- out = await self.correct_obj(
110
- out,
111
- reference=f"# Referring Error\n{err}",
115
+ corrected = ok(await self.correct_obj(
116
+ component,
117
+ reference=f"# Original Article Outline\n{out.display()}\n# Error Need to be fixed\n{err}",
112
118
  topic=topic,
113
119
  rating_manual=manual,
114
120
  supervisor_check=False,
115
- )
121
+ ),"Could not correct the component.")
122
+ component.update_from(corrected)
116
123
  return out.update_ref(article_proposal)
117
124
 
118
125
 
@@ -156,15 +163,15 @@ class GenerateArticle(Action):
156
163
  ) -> Optional[Article]:
157
164
  article: Article = Article.from_outline(article_outline).update_ref(article_outline)
158
165
 
159
- writing_manual = await self.draft_rating_manual(
166
+ writing_manual = ok(await self.draft_rating_manual(
160
167
  topic=(
161
168
  topic_1
162
169
  := "improve the content of the subsection to fit the outline. SHALL never add or remove any section or subsection, you can only add or delete paragraphs within the subsection."
163
170
  ),
164
- )
165
- err_resolve_manual = await self.draft_rating_manual(
171
+ ))
172
+ err_resolve_manual = ok(await self.draft_rating_manual(
166
173
  topic=(topic_2 := "this article component has violated the constrain, please correct it.")
167
- )
174
+ ))
168
175
  for c, deps in article.iter_dfs_with_deps(chapter=False):
169
176
  logger.info(f"Updating the article component: \n{c.display()}")
170
177
 
@@ -180,7 +187,7 @@ class GenerateArticle(Action):
180
187
  ),
181
188
  "Could not correct the article component.",
182
189
  )
183
- while err := c.resolve_update_error(out):
190
+ while err := c.resolve_update_conflict(out):
184
191
  logger.warning(f"Found error in the article component: \n{err}")
185
192
  out = ok(
186
193
  await self.correct_obj(