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.
- fabricatio-0.2.7.dev5/PKG-INFO +181 -0
- fabricatio-0.2.7.dev5/README.md +138 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/pyproject.toml +1 -1
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/actions/article.py +26 -19
- fabricatio-0.2.7.dev5/python/fabricatio/models/extra/article_base.py +291 -0
- fabricatio-0.2.7.dev5/python/fabricatio/models/extra/article_main.py +230 -0
- fabricatio-0.2.7.dev5/python/fabricatio/models/extra/article_outline.py +187 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/extra/article_proposal.py +12 -14
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/generic.py +79 -6
- fabricatio-0.2.7.dev5/templates.tar.gz +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/uv.lock +1 -1
- fabricatio-0.2.7.dev3/PKG-INFO +0 -436
- fabricatio-0.2.7.dev3/README.md +0 -393
- fabricatio-0.2.7.dev3/python/fabricatio/models/extra/article_main.py +0 -359
- fabricatio-0.2.7.dev3/python/fabricatio/models/extra/article_outline.py +0 -276
- fabricatio-0.2.7.dev3/templates.tar.gz +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/.github/workflows/build-package.yaml +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/.github/workflows/ruff.yaml +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/.github/workflows/tests.yaml +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/.gitignore +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/.python-version +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/Cargo.lock +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/Cargo.toml +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/LICENSE +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/Makefile +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/correct/correct.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/correct/correct_loop.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/extract_and_inject/.gitignore +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/extract_and_inject/article_rag.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/extract_and_inject/ask.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/extract_and_inject/extract_and_inject.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/extract_article/extract.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/llm_usages/llm_usage.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/make_a_rating/rating.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/make_diary/commits.json +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/make_diary/diary.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/minor/hello_fabricatio.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/minor/write_a_poem.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/propose_task/propose.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/reviewer/review.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/search_bibtex/.gitignore +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/search_bibtex/search.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/simple_chat/chat.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/simple_rag/simple_rag.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/task_handle/handle_task.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/write_article/.gitignore +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/write_article/write_article.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/write_outline/.gitignore +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/write_outline/write_outline.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/examples/write_outline/write_outline_corrected.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/__init__.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/_rust.pyi +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/_rust_instances.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/actions/article_rag.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/actions/output.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/actions/rag.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/capabilities/correct.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/capabilities/propose.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/capabilities/rag.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/capabilities/rating.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/capabilities/review.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/capabilities/task.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/config.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/core.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/decorators.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/fs/__init__.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/fs/curd.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/fs/readers.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/journal.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/action.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/events.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/extra/article_essence.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/kwargs_types.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/role.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/task.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/tool.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/usages.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/models/utils.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/parser.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/py.typed +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/toolboxes/__init__.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/toolboxes/arithmetic.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/toolboxes/fs.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/workflows/articles.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/python/fabricatio/workflows/rag.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/src/bib_tools.rs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/src/hash.rs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/src/hbs_helpers.rs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/src/lib.rs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/src/templates.rs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/as_prompt.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/binary-exploitation-ctf-solver.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/claude-xml.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/clean-up-code.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/co_validation.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/correct.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/create_json_obj.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/cryptography-ctf-solver.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/dependencies.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/document-the-code.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/draft_rating_criteria.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/draft_rating_manual.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/draft_rating_weights_klee.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/draft_tool_usage_code.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/extract_criteria_from_reasons.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/extract_reasons_from_examples.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/find-security-vulnerabilities.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/fix-bugs.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/generic_string.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/improve-performance.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/liststr.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/make_choice.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/make_judgment.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/pathstr.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/rate_fine_grind.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/refactor.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/refined_query.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/retrieved_display.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/reverse-engineering-ctf-solver.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/review_string.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/task_briefing.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/web-ctf-solver.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/write-git-commit.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/write-github-pull-request.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/templates/built-in/write-github-readme.hbs +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/tests/test_config.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/tests/test_models/test_action.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/tests/test_models/test_advanced.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/tests/test_models/test_generic.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/tests/test_models/test_role.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/tests/test_models/test_task.py +0 -0
- {fabricatio-0.2.7.dev3 → fabricatio-0.2.7.dev5}/tests/test_models/test_tool.py +0 -0
- {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
|
+

|
47
|
+

|
48
|
+

|
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
|
+

|
4
|
+

|
5
|
+

|
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)
|
@@ -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 =
|
96
|
-
|
97
|
-
|
98
|
-
|
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
|
-
|
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
|
-
|
110
|
-
|
111
|
-
reference=f"#
|
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.
|
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(
|