fabricatio 0.2.1.dev0__cp313-cp313-win_amd64.whl → 0.3.14.dev5__cp313-cp313-win_amd64.whl
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/__init__.py +12 -20
- fabricatio/actions/__init__.py +1 -5
- fabricatio/actions/article.py +319 -0
- fabricatio/actions/article_rag.py +416 -0
- fabricatio/actions/fs.py +25 -0
- fabricatio/actions/output.py +248 -0
- fabricatio/actions/rag.py +96 -0
- fabricatio/actions/rules.py +83 -0
- fabricatio/capabilities/__init__.py +1 -0
- fabricatio/capabilities/advanced_judge.py +20 -0
- fabricatio/capabilities/advanced_rag.py +61 -0
- fabricatio/capabilities/censor.py +105 -0
- fabricatio/capabilities/check.py +212 -0
- fabricatio/capabilities/correct.py +228 -0
- fabricatio/capabilities/extract.py +74 -0
- fabricatio/capabilities/persist.py +103 -0
- fabricatio/capabilities/propose.py +65 -0
- fabricatio/capabilities/rag.py +263 -0
- fabricatio/capabilities/rating.py +404 -0
- fabricatio/capabilities/review.py +114 -0
- fabricatio/capabilities/task.py +113 -0
- fabricatio/decorators.py +251 -179
- fabricatio/{core.py → emitter.py} +31 -21
- fabricatio/fs/__init__.py +32 -2
- fabricatio/fs/curd.py +32 -9
- fabricatio/fs/readers.py +44 -7
- fabricatio/journal.py +3 -19
- fabricatio/models/action.py +185 -61
- fabricatio/models/adv_kwargs_types.py +63 -0
- fabricatio/models/extra/__init__.py +1 -0
- fabricatio/models/extra/advanced_judge.py +32 -0
- fabricatio/models/extra/aricle_rag.py +284 -0
- fabricatio/models/extra/article_base.py +422 -0
- fabricatio/models/extra/article_essence.py +101 -0
- fabricatio/models/extra/article_main.py +284 -0
- fabricatio/models/extra/article_outline.py +46 -0
- fabricatio/models/extra/article_proposal.py +52 -0
- fabricatio/models/extra/patches.py +20 -0
- fabricatio/models/extra/problem.py +165 -0
- fabricatio/models/extra/rag.py +98 -0
- fabricatio/models/extra/rule.py +52 -0
- fabricatio/models/generic.py +704 -36
- fabricatio/models/kwargs_types.py +112 -17
- fabricatio/models/role.py +74 -27
- fabricatio/models/task.py +94 -60
- fabricatio/models/tool.py +328 -188
- fabricatio/models/usages.py +791 -515
- fabricatio/parser.py +81 -60
- fabricatio/rust.cp313-win_amd64.pyd +0 -0
- fabricatio/rust.pyi +886 -0
- fabricatio/toolboxes/__init__.py +1 -3
- fabricatio/toolboxes/fs.py +17 -1
- fabricatio/utils.py +156 -0
- fabricatio/workflows/__init__.py +1 -0
- fabricatio/workflows/articles.py +24 -0
- fabricatio/workflows/rag.py +11 -0
- fabricatio-0.3.14.dev5.data/scripts/tdown.exe +0 -0
- fabricatio-0.3.14.dev5.data/scripts/ttm.exe +0 -0
- fabricatio-0.3.14.dev5.dist-info/METADATA +188 -0
- fabricatio-0.3.14.dev5.dist-info/RECORD +64 -0
- {fabricatio-0.2.1.dev0.dist-info → fabricatio-0.3.14.dev5.dist-info}/WHEEL +1 -1
- fabricatio/_rust.cp313-win_amd64.pyd +0 -0
- fabricatio/_rust.pyi +0 -53
- fabricatio/_rust_instances.py +0 -8
- fabricatio/actions/communication.py +0 -15
- fabricatio/actions/transmission.py +0 -23
- fabricatio/config.py +0 -263
- fabricatio/models/advanced.py +0 -128
- fabricatio/models/events.py +0 -82
- fabricatio/models/utils.py +0 -78
- fabricatio/toolboxes/task.py +0 -6
- fabricatio-0.2.1.dev0.data/scripts/tdown.exe +0 -0
- fabricatio-0.2.1.dev0.dist-info/METADATA +0 -420
- fabricatio-0.2.1.dev0.dist-info/RECORD +0 -35
- {fabricatio-0.2.1.dev0.dist-info → fabricatio-0.3.14.dev5.dist-info}/licenses/LICENSE +0 -0
fabricatio/toolboxes/__init__.py
CHANGED
@@ -5,13 +5,11 @@ from typing import Set
|
|
5
5
|
from fabricatio.models.tool import ToolBox
|
6
6
|
from fabricatio.toolboxes.arithmetic import arithmetic_toolbox
|
7
7
|
from fabricatio.toolboxes.fs import fs_toolbox
|
8
|
-
from fabricatio.toolboxes.task import task_toolbox
|
9
8
|
|
10
|
-
basic_toolboxes: Set[ToolBox] = {
|
9
|
+
basic_toolboxes: Set[ToolBox] = {arithmetic_toolbox}
|
11
10
|
|
12
11
|
__all__ = [
|
13
12
|
"arithmetic_toolbox",
|
14
13
|
"basic_toolboxes",
|
15
14
|
"fs_toolbox",
|
16
|
-
"task_toolbox",
|
17
15
|
]
|
fabricatio/toolboxes/fs.py
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
"""File system tool box."""
|
2
2
|
|
3
|
-
from fabricatio.fs
|
3
|
+
from fabricatio.fs import (
|
4
|
+
absolute_path,
|
5
|
+
copy_file,
|
6
|
+
create_directory,
|
7
|
+
delete_directory,
|
8
|
+
delete_file,
|
9
|
+
dump_text,
|
10
|
+
gather_files,
|
11
|
+
move_file,
|
12
|
+
safe_json_read,
|
13
|
+
safe_text_read,
|
14
|
+
tree,
|
15
|
+
)
|
4
16
|
from fabricatio.models.tool import ToolBox
|
5
17
|
|
6
18
|
fs_toolbox = (
|
@@ -12,4 +24,8 @@ fs_toolbox = (
|
|
12
24
|
.add_tool(tree)
|
13
25
|
.add_tool(delete_directory)
|
14
26
|
.add_tool(create_directory)
|
27
|
+
.add_tool(absolute_path)
|
28
|
+
.add_tool(safe_text_read)
|
29
|
+
.add_tool(safe_json_read)
|
30
|
+
.add_tool(gather_files)
|
15
31
|
)
|
fabricatio/utils.py
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
"""A collection of utility functions for the fabricatio package."""
|
2
|
+
|
3
|
+
from typing import Any, Dict, Iterable, List, Mapping, Optional, Tuple, Type, overload
|
4
|
+
|
5
|
+
from fabricatio.decorators import precheck_package
|
6
|
+
|
7
|
+
|
8
|
+
def is_subclass_of_base(cls: Type, base_module: str, base_name: str) -> bool:
|
9
|
+
"""Determines if the given class is a subclass of an unimported base class.
|
10
|
+
|
11
|
+
Args:
|
12
|
+
cls: The class to check
|
13
|
+
base_module: The module name of the base class
|
14
|
+
base_name: The class name of the base class
|
15
|
+
|
16
|
+
Returns:
|
17
|
+
bool: True if cls is a subclass of the specified base class, False otherwise
|
18
|
+
"""
|
19
|
+
return any(ancestor.__module__ == base_module and ancestor.__name__ == base_name for ancestor in cls.__mro__)
|
20
|
+
|
21
|
+
|
22
|
+
def is_subclass_of_any_base(cls: Type, bases: List[Tuple[str, str]]) -> bool:
|
23
|
+
"""Determines if the given class is a subclass of the candidate base classes.
|
24
|
+
|
25
|
+
Args:
|
26
|
+
cls: The class to check
|
27
|
+
bases: A list of tuples where each tuple contains (module_name, class_name)
|
28
|
+
|
29
|
+
Returns:
|
30
|
+
bool: True if cls is a subclass of the specified base classes, False otherwise
|
31
|
+
"""
|
32
|
+
for ancestor in cls.__mro__:
|
33
|
+
for base_module, base_name in bases:
|
34
|
+
if ancestor.__module__ == base_module and ancestor.__name__ == base_name:
|
35
|
+
return True
|
36
|
+
return False
|
37
|
+
|
38
|
+
|
39
|
+
@precheck_package(
|
40
|
+
"questionary", "'questionary' is required to run this function. Have you installed `fabricatio[qa]`?."
|
41
|
+
)
|
42
|
+
async def ask_edit(text_seq: List[str]) -> List[str]:
|
43
|
+
"""Asks the user to edit a list of texts.
|
44
|
+
|
45
|
+
Args:
|
46
|
+
text_seq (List[str]): A list of texts to be edited.
|
47
|
+
|
48
|
+
Returns:
|
49
|
+
List[str]: A list of edited texts.
|
50
|
+
If the user does not edit a text, it will not be included in the returned list.
|
51
|
+
"""
|
52
|
+
from questionary import text
|
53
|
+
|
54
|
+
res = []
|
55
|
+
for i, t in enumerate(text_seq):
|
56
|
+
edited = await text(f"[{i}] ", default=t).ask_async()
|
57
|
+
if edited:
|
58
|
+
res.append(edited)
|
59
|
+
return res
|
60
|
+
|
61
|
+
|
62
|
+
@overload
|
63
|
+
async def ask_retain[V](candidates: List[str]) -> List[str]: ...
|
64
|
+
|
65
|
+
|
66
|
+
@overload
|
67
|
+
async def ask_retain[V](candidates: List[str], value_mapping: List[V]) -> List[V]: ...
|
68
|
+
|
69
|
+
|
70
|
+
@precheck_package(
|
71
|
+
"questionary", "'questionary' is required to run this function. Have you installed `fabricatio[qa]`?."
|
72
|
+
)
|
73
|
+
async def ask_retain[V](candidates: List[str], value_mapping: Optional[List[V]] = None) -> List[str] | List[V]:
|
74
|
+
"""Asks the user to retain a list of candidates."""
|
75
|
+
from questionary import Choice, checkbox
|
76
|
+
|
77
|
+
return await checkbox(
|
78
|
+
"Please choose those that should be retained.",
|
79
|
+
choices=[Choice(p, value=p, checked=True) for p in candidates]
|
80
|
+
if value_mapping is None
|
81
|
+
else [Choice(p, value=v, checked=True) for p, v in zip(candidates, value_mapping, strict=True)],
|
82
|
+
).ask_async()
|
83
|
+
|
84
|
+
|
85
|
+
def override_kwargs(kwargs: Mapping[str, Any], **overrides) -> Dict[str, Any]:
|
86
|
+
"""Override the values in kwargs with the provided overrides."""
|
87
|
+
new_kwargs = dict(kwargs.items())
|
88
|
+
new_kwargs.update(overrides)
|
89
|
+
return new_kwargs
|
90
|
+
|
91
|
+
|
92
|
+
def fallback_kwargs(kwargs: Mapping[str, Any], **fallbacks) -> Dict[str, Any]:
|
93
|
+
"""Fallback the values in kwargs with the provided fallbacks."""
|
94
|
+
new_kwargs = dict(kwargs.items())
|
95
|
+
new_kwargs.update({k: v for k, v in fallbacks.items() if k not in new_kwargs})
|
96
|
+
return new_kwargs
|
97
|
+
|
98
|
+
|
99
|
+
def ok[T](val: Optional[T], msg: str = "Value is None") -> T:
|
100
|
+
"""Check if a value is None and raise a ValueError with the provided message if it is.
|
101
|
+
|
102
|
+
Args:
|
103
|
+
val: The value to check.
|
104
|
+
msg: The message to include in the ValueError if val is None.
|
105
|
+
|
106
|
+
Returns:
|
107
|
+
T: The value if it is not None.
|
108
|
+
"""
|
109
|
+
if val is None:
|
110
|
+
raise ValueError(msg)
|
111
|
+
return val
|
112
|
+
|
113
|
+
|
114
|
+
def first_available[T](iterable: Iterable[T], msg: str = "No available item found in the iterable.") -> T:
|
115
|
+
"""Return the first available item in the iterable that's not None.
|
116
|
+
|
117
|
+
This function searches through the provided iterable and returns the first
|
118
|
+
item that is not None. If all items are None or the iterable is empty,
|
119
|
+
it raises a ValueError.
|
120
|
+
|
121
|
+
Args:
|
122
|
+
iterable: The iterable collection to search through.
|
123
|
+
msg: The message to include in the ValueError if no non-None item is found.
|
124
|
+
|
125
|
+
Returns:
|
126
|
+
T: The first non-None item found in the iterable.
|
127
|
+
If no non-None item is found, it raises a ValueError.
|
128
|
+
|
129
|
+
Raises:
|
130
|
+
ValueError: If no non-None item is found in the iterable.
|
131
|
+
|
132
|
+
Examples:
|
133
|
+
>>> first_available([None, None, "value", "another"])
|
134
|
+
'value'
|
135
|
+
>>> first_available([1, 2, 3])
|
136
|
+
1
|
137
|
+
>>> assert (first_available([None, None]))
|
138
|
+
ValueError: No available item found in the iterable.
|
139
|
+
"""
|
140
|
+
if (first := next((item for item in iterable if item is not None), None)) is not None:
|
141
|
+
return first
|
142
|
+
raise ValueError(msg)
|
143
|
+
|
144
|
+
|
145
|
+
def wrapp_in_block(string: str, title: str, style: str = "-") -> str:
|
146
|
+
"""Wraps a string in a block with a title.
|
147
|
+
|
148
|
+
Args:
|
149
|
+
string: The string to wrap.
|
150
|
+
title: The title of the block.
|
151
|
+
style: The style of the block.
|
152
|
+
|
153
|
+
Returns:
|
154
|
+
str: The wrapped string.
|
155
|
+
"""
|
156
|
+
return f"--- Start of {title} ---\n{string}\n--- End of {title} ---".replace("-", style)
|
@@ -0,0 +1 @@
|
|
1
|
+
"""A module containing some builtin workflows."""
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"""Store article essence in the database."""
|
2
|
+
|
3
|
+
from fabricatio.actions.article import GenerateArticleProposal, GenerateInitialOutline
|
4
|
+
from fabricatio.actions.output import DumpFinalizedOutput
|
5
|
+
from fabricatio.models.action import WorkFlow
|
6
|
+
|
7
|
+
WriteOutlineWorkFlow = WorkFlow(
|
8
|
+
name="Generate Article Outline",
|
9
|
+
description="Generate an outline for an article. dump the outline to the given path. in typst format.",
|
10
|
+
steps=(
|
11
|
+
GenerateArticleProposal,
|
12
|
+
GenerateInitialOutline(output_key="article_outline"),
|
13
|
+
DumpFinalizedOutput(output_key="task_output"),
|
14
|
+
),
|
15
|
+
)
|
16
|
+
WriteOutlineCorrectedWorkFlow = WorkFlow(
|
17
|
+
name="Generate Article Outline",
|
18
|
+
description="Generate an outline for an article. dump the outline to the given path. in typst format.",
|
19
|
+
steps=(
|
20
|
+
GenerateArticleProposal,
|
21
|
+
GenerateInitialOutline(output_key="article_outline"),
|
22
|
+
DumpFinalizedOutput(output_key="task_output"),
|
23
|
+
),
|
24
|
+
)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"""The workflow for extracting the essence of an article and storing it in the database."""
|
2
|
+
|
3
|
+
from fabricatio.actions.article import ExtractArticleEssence
|
4
|
+
from fabricatio.actions.rag import InjectToDB
|
5
|
+
from fabricatio.models.action import WorkFlow
|
6
|
+
|
7
|
+
StoreArticle = WorkFlow(
|
8
|
+
name="Extract Article Essence",
|
9
|
+
description="Extract the essence of an article in the given path, and store it in the database.",
|
10
|
+
steps=(ExtractArticleEssence(output_key="to_inject"), InjectToDB(output_key="task_output")),
|
11
|
+
)
|
Binary file
|
Binary file
|
@@ -0,0 +1,188 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: fabricatio
|
3
|
+
Version: 0.3.14.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: asyncio>=3.4.3
|
12
|
+
Requires-Dist: asyncstdlib>=3.13.0
|
13
|
+
Requires-Dist: json-repair>=0.39.1
|
14
|
+
Requires-Dist: litellm>=1.60.0
|
15
|
+
Requires-Dist: loguru>=0.7.3
|
16
|
+
Requires-Dist: more-itertools>=10.6.0
|
17
|
+
Requires-Dist: pydantic>=2.10.6
|
18
|
+
Requires-Dist: pymitter>=1.0.0
|
19
|
+
Requires-Dist: rich>=13.9.4
|
20
|
+
Requires-Dist: ujson>=5.10.0
|
21
|
+
Requires-Dist: fabricatio[ftd,qa,rag,cli] ; extra == 'full'
|
22
|
+
Requires-Dist: pymilvus>=2.5.4 ; extra == 'rag'
|
23
|
+
Requires-Dist: questionary>=2.1.0 ; extra == 'qa'
|
24
|
+
Requires-Dist: magika>=0.6.1 ; extra == 'ftd'
|
25
|
+
Requires-Dist: typer-slim[standard]>=0.15.2 ; extra == 'cli'
|
26
|
+
Provides-Extra: full
|
27
|
+
Provides-Extra: rag
|
28
|
+
Provides-Extra: qa
|
29
|
+
Provides-Extra: ftd
|
30
|
+
Provides-Extra: cli
|
31
|
+
License-File: LICENSE
|
32
|
+
Summary: A LLM multi-agent framework.
|
33
|
+
Keywords: ai,agents,multi-agent,llm,pyo3
|
34
|
+
Author-email: Whth <zettainspector@foxmail.com>
|
35
|
+
Requires-Python: >=3.12, <3.14
|
36
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
37
|
+
Project-URL: Homepage, https://github.com/Whth/fabricatio
|
38
|
+
Project-URL: Repository, https://github.com/Whth/fabricatio
|
39
|
+
Project-URL: Issues, https://github.com/Whth/fabricatio/issues
|
40
|
+
|
41
|
+
# Fabricatio
|
42
|
+
|
43
|
+

|
44
|
+
|
45
|
+
## Overview
|
46
|
+
|
47
|
+
Fabricatio is a streamlined Python library for building LLM applications using an event-based agent structure. It
|
48
|
+
leverages Rust for performance-critical tasks, Handlebars for templating, and PyO3 for Python bindings.
|
49
|
+
|
50
|
+
## Features
|
51
|
+
|
52
|
+
- **Event-Driven Architecture**: Robust task management through an EventEmitter pattern.
|
53
|
+
- **LLM Integration & Templating**: Seamlessly interact with large language models and dynamic content generation.
|
54
|
+
- **Async & Extensible**: Fully asynchronous execution with easy extension via custom actions and workflows.
|
55
|
+
|
56
|
+
## Installation
|
57
|
+
|
58
|
+
### Using UV (Recommended)
|
59
|
+
|
60
|
+
```bash
|
61
|
+
# Install uv if not already installed
|
62
|
+
pip install uv
|
63
|
+
|
64
|
+
# Clone the repository
|
65
|
+
git clone https://github.com/Whth/fabricatio.git
|
66
|
+
cd fabricatio
|
67
|
+
|
68
|
+
# Install the package in development mode with uv
|
69
|
+
uv --with-editable . maturin develop --uv -r
|
70
|
+
```
|
71
|
+
|
72
|
+
### Building Distribution
|
73
|
+
|
74
|
+
```bash
|
75
|
+
# Build distribution packages
|
76
|
+
make bdist
|
77
|
+
```
|
78
|
+
|
79
|
+
## Usage
|
80
|
+
|
81
|
+
### Basic Example
|
82
|
+
|
83
|
+
```python
|
84
|
+
import asyncio
|
85
|
+
from fabricatio import Action, Role, Task, logger, WorkFlow, Event
|
86
|
+
from typing import Any
|
87
|
+
|
88
|
+
|
89
|
+
class Hello(Action):
|
90
|
+
name: str = "hello"
|
91
|
+
output_key: str = "task_output"
|
92
|
+
|
93
|
+
async def _execute(self, task_input: Task[str], **_) -> Any:
|
94
|
+
ret = "Hello fabricatio!"
|
95
|
+
logger.info("executing talk action")
|
96
|
+
return ret
|
97
|
+
|
98
|
+
|
99
|
+
async def main() -> None:
|
100
|
+
Role(
|
101
|
+
name="talker",
|
102
|
+
description="talker role",
|
103
|
+
registry={Event.quick_instantiate("talk"): WorkFlow(name="talk", steps=(Hello,))}
|
104
|
+
)
|
105
|
+
|
106
|
+
task = Task(name="say hello", goals=["say hello"], description="say hello to the world")
|
107
|
+
result = await task.delegate("talk")
|
108
|
+
logger.success(f"Result: {result}")
|
109
|
+
|
110
|
+
|
111
|
+
if __name__ == "__main__":
|
112
|
+
asyncio.run(main())
|
113
|
+
```
|
114
|
+
|
115
|
+
### Examples
|
116
|
+
|
117
|
+
For various usage scenarios, refer to the following examples:
|
118
|
+
|
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
|
+
## TODO
|
164
|
+
|
165
|
+
- Add an element based format strategy
|
166
|
+
|
167
|
+
## Contributing
|
168
|
+
|
169
|
+
Contributions are welcome! Follow these steps:
|
170
|
+
|
171
|
+
1. Fork the repository.
|
172
|
+
2. Create your feature branch (`git checkout -b feature/new-feature`).
|
173
|
+
3. Commit your changes (`git commit -am 'Add new feature'`).
|
174
|
+
4. Push to the branch (`git push origin feature/new-feature`).
|
175
|
+
5. Create a new Pull Request.
|
176
|
+
|
177
|
+
## License
|
178
|
+
|
179
|
+
Fabricatio is licensed under the MIT License. See [LICENSE](LICENSE) for details.
|
180
|
+
|
181
|
+
## Acknowledgments
|
182
|
+
|
183
|
+
Special thanks to the contributors and maintainers of:
|
184
|
+
|
185
|
+
- [PyO3](https://github.com/PyO3/pyo3)
|
186
|
+
- [Maturin](https://github.com/PyO3/maturin)
|
187
|
+
- [Handlebars.rs](https://github.com/sunng87/handlebars-rust)
|
188
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
fabricatio-0.3.14.dev5.dist-info/METADATA,sha256=0MBWyxdGQ7HQZrtsF7zXfaTPqwCd3ci7F2_701zlCfs,5116
|
2
|
+
fabricatio-0.3.14.dev5.dist-info/WHEEL,sha256=6gg8M7kMeWmDzkhJuJzWLhBYdt7OGDF81wlSJjN85_E,96
|
3
|
+
fabricatio-0.3.14.dev5.dist-info/licenses/LICENSE,sha256=do7J7EiCGbq0QPbMAL_FqLYufXpHnCnXBOuqVPwSV8Y,1088
|
4
|
+
fabricatio/actions/article.py,sha256=TPS2fOqCymKv2hK2c_WmMRMKNBkvN8M91QkB9ar8-bg,12507
|
5
|
+
fabricatio/actions/article_rag.py,sha256=e1fVh7Jph2zVD0bRAmK2dJ0BVkSEvF-FPfxUKujkn6s,18407
|
6
|
+
fabricatio/actions/fs.py,sha256=gJR14U4ln35nt8Z7OWLVAZpqGaLnED-r1Yi-lX22tkI,959
|
7
|
+
fabricatio/actions/output.py,sha256=jZL72D5uFobKNiVFapnVxBcjSNqGEThYNlCUKQvZwz8,9935
|
8
|
+
fabricatio/actions/rag.py,sha256=vgCzIfbSd3_vL3QxB12PY4h12V9Pe3sZRsWme0KC6X8,3583
|
9
|
+
fabricatio/actions/rules.py,sha256=dkvCgNDjt2KSO1VgPRsxT4YBmIIMeetZb5tiz-slYkU,3640
|
10
|
+
fabricatio/actions/__init__.py,sha256=wVENCFtpVb1rLFxoOFJt9-8smLWXuJV7IwA8P3EfFz4,48
|
11
|
+
fabricatio/capabilities/advanced_judge.py,sha256=jQ_Gsn6L8EKb6KQi3j0G0GSUz2j8D2220C1hIhrAeU8,682
|
12
|
+
fabricatio/capabilities/advanced_rag.py,sha256=DYh-imLQkjVOgKd__OEbwGzqwNeTtX_6NBGx_bCiFs8,2539
|
13
|
+
fabricatio/capabilities/censor.py,sha256=e0tHll4J_-TT8-Vn1OZ1innVZbJfx55oyGtDoEI99r8,4745
|
14
|
+
fabricatio/capabilities/check.py,sha256=6IC6F0IhYVpSf9pJ8r9lq40l_FF3qf-iJcTRWwpnkdg,8591
|
15
|
+
fabricatio/capabilities/correct.py,sha256=-JR8ZUAtagmNXepVyY679MBUyFCZwtKPjv8dANJMZiE,10403
|
16
|
+
fabricatio/capabilities/extract.py,sha256=E7CLZflWzJ6C6DVLEWysYZ_48g_-F93gZJVU56k2-XA,2523
|
17
|
+
fabricatio/capabilities/persist.py,sha256=9XnKoeZ62YjXVDpYnkbDFf62B_Mz46WVsq1dTr2Wvvc,3421
|
18
|
+
fabricatio/capabilities/propose.py,sha256=v8OiUHc8GU7Jg1zAUghYhrI-AKgmBeUvQMo22ZAOddw,2030
|
19
|
+
fabricatio/capabilities/rag.py,sha256=D5rULrQxPmp4kVLP_jBE4yal1v9N68XOgBdJqGvVHpU,10979
|
20
|
+
fabricatio/capabilities/rating.py,sha256=cm-s2YJMYcS36mR9b7XNwRQ1x0h0uWxLHCapoAORv8I,17815
|
21
|
+
fabricatio/capabilities/review.py,sha256=l06BYcQzPi7VKmWdplj9L6WvZEscZqW1Wx9OhR-UnNw,5061
|
22
|
+
fabricatio/capabilities/task.py,sha256=-b92cGi7b3B30kOSS-90_H6BjA0VF_cjc1BzPbO5MkI,4401
|
23
|
+
fabricatio/capabilities/__init__.py,sha256=v1cHRHIJ2gxyqMLNCs6ERVcCakSasZNYzmMI4lqAcls,57
|
24
|
+
fabricatio/decorators.py,sha256=OohwKgc5dUjybv70D-J2lA0C9zjUuq8-gzU5O8JPl8w,8962
|
25
|
+
fabricatio/emitter.py,sha256=n4vH6E7lcT57qVve_3hUAdfvj0mQUDkWu6iU5aNztB8,6341
|
26
|
+
fabricatio/fs/curd.py,sha256=652nHulbJ3gwt0Z3nywtPMmjhEyglDvEfc3p7ieJNNA,4777
|
27
|
+
fabricatio/fs/readers.py,sha256=UXvcJO3UCsxHu9PPkg34Yh55Zi-miv61jD_wZQJgKRs,1751
|
28
|
+
fabricatio/fs/__init__.py,sha256=USoMI_HcIr3Yc77_JQYYsXrsplYPXtFTaNB9YgFfC4s,713
|
29
|
+
fabricatio/journal.py,sha256=mnbdB1Dw-mhEKIgWlPKn7W07ssg-6dmxMXilIGQMFV8,216
|
30
|
+
fabricatio/models/action.py,sha256=RhjHaEJILiCZux5hzxSZVt_7Evcu3TnFHNuJN8rzgq8,10052
|
31
|
+
fabricatio/models/adv_kwargs_types.py,sha256=IBV3ZcsNLvvEjO_2hBpYg_wLSpNKaMx6Ndam3qXJCw8,2097
|
32
|
+
fabricatio/models/extra/advanced_judge.py,sha256=INUl_41C8jkausDekkjnEmTwNfLCJ23TwFjq2cM23Cw,1092
|
33
|
+
fabricatio/models/extra/aricle_rag.py,sha256=fTxlQyrzyl9bLCC5Zreb71TKaJ7xiHqqyR62HXr2unQ,11935
|
34
|
+
fabricatio/models/extra/article_base.py,sha256=UBNZaauEm3X85Cw-k7pIos129lkI0ocw7bAmRDpiG1k,16783
|
35
|
+
fabricatio/models/extra/article_essence.py,sha256=z3Qz6xVsB9k-K-c4Y2CoKzxZrXaUd4oyt2Mb6hGDYdg,2793
|
36
|
+
fabricatio/models/extra/article_main.py,sha256=nwwcTn-TgCeFNT4vVfE4OCMonwSdvyx1TR-lXPE6Cp4,11268
|
37
|
+
fabricatio/models/extra/article_outline.py,sha256=P0T-1DGCzoNmQ3iQVwSmOul0nwS6qLgr0FF8jDdD7F0,1673
|
38
|
+
fabricatio/models/extra/article_proposal.py,sha256=OQIKoJkmJv0ogYVk7eGK_TOtANVYcBPA_HeV1nuG0Vo,1909
|
39
|
+
fabricatio/models/extra/patches.py,sha256=_WNCxtYzzsVfUxI16vu4IqsLahLYRHdbQN9er9tqhC0,997
|
40
|
+
fabricatio/models/extra/problem.py,sha256=8tTU-3giFHOi5j7NJsvH__JJyYcaGrcfsRnkzQNm0Ew,7216
|
41
|
+
fabricatio/models/extra/rag.py,sha256=C7ptZCuGJmT8WikjpF9KhZ0Bw-VicdB-s8EqEAgMLKE,3967
|
42
|
+
fabricatio/models/extra/rule.py,sha256=WKahNiaIp8s_l2r_FG21F_PP3_hgNm4hfSVCSFyfoBE,2669
|
43
|
+
fabricatio/models/extra/__init__.py,sha256=XlYnS_2B9nhLhtQkjE7rvvfPmAAtXVdNi9bSDAR-Ge8,54
|
44
|
+
fabricatio/models/generic.py,sha256=OJrYClooL2XnyalWTyyLgorycA1d_JNW8VqOYNDJdXc,27873
|
45
|
+
fabricatio/models/kwargs_types.py,sha256=Ik8-Oi_NmwfkvC9B8K4NsoZc_vSWV85xKCSthA1Xv_k,3403
|
46
|
+
fabricatio/models/role.py,sha256=b3zg96YKDsMBqa7SIe9LQHc-IVs2fGWqoQeRQYQIl4o,3856
|
47
|
+
fabricatio/models/task.py,sha256=XZ1l1P-iS02ZF9P8cXv8gEfJKBa17PFPNJ1SbhyhT4Q,11033
|
48
|
+
fabricatio/models/tool.py,sha256=q2wDtZAebWMZlsFifgmJq8N3XvAhVNMb0aUIKkdruGc,12419
|
49
|
+
fabricatio/models/usages.py,sha256=q2jLqa0vJ7ho9ZUkC-2uPuFpK8uClBLIS6TEEYHUotY,33041
|
50
|
+
fabricatio/parser.py,sha256=dYFri9pDlsiwVpEJ-a5jmVU2nFuKN3uBHC8VsVpdEm8,4642
|
51
|
+
fabricatio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
52
|
+
fabricatio/rust.pyi,sha256=zgA4po7lznRxicXPxhRP3mmBY_xyGTnzpkW5D47tS5U,25958
|
53
|
+
fabricatio/toolboxes/arithmetic.py,sha256=WLqhY-Pikv11Y_0SGajwZx3WhsLNpHKf9drzAqOf_nY,1369
|
54
|
+
fabricatio/toolboxes/fs.py,sha256=l4L1CVxJmjw9Ld2XUpIlWfV0_Fu_2Og6d3E13I-S4aE,736
|
55
|
+
fabricatio/toolboxes/__init__.py,sha256=KBJi5OG_pExscdlM7Bnt_UF43j4I3Lv6G71kPVu4KQU,395
|
56
|
+
fabricatio/utils.py,sha256=WYhFB4tHk6jKmjZgAsYhRmg1ZvBjn4X2y4n7yz25HjE,5454
|
57
|
+
fabricatio/workflows/articles.py,sha256=ObYTFUqLUk_CzdmmnX6S7APfxcGmPFqnFr9pdjU7Z4Y,969
|
58
|
+
fabricatio/workflows/rag.py,sha256=-YYp2tlE9Vtfgpg6ROpu6QVO8j8yVSPa6yDzlN3qVxs,520
|
59
|
+
fabricatio/workflows/__init__.py,sha256=5ScFSTA-bvhCesj3U9Mnmi6Law6N1fmh5UKyh58L3u8,51
|
60
|
+
fabricatio/__init__.py,sha256=w7ObFg6ud4pQuC1DhVyQI9x9dtp05QrcJAEk643iJmc,761
|
61
|
+
fabricatio/rust.cp313-win_amd64.pyd,sha256=d1IJuk5R2XnpmCIowBvLFNliTZ1I0YJjcgoIZ-CnnNs,7817728
|
62
|
+
fabricatio-0.3.14.dev5.data/scripts/tdown.exe,sha256=6riiivUWvPctAzLWtOsxC90H-BR_l7oz3yidaumfLAo,3449344
|
63
|
+
fabricatio-0.3.14.dev5.data/scripts/ttm.exe,sha256=0SYYwSdylVLkWeX3k5nnTFa5yKy0gyNxY3OgMjyYMe8,2555904
|
64
|
+
fabricatio-0.3.14.dev5.dist-info/RECORD,,
|
Binary file
|
fabricatio/_rust.pyi
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
from pathlib import Path
|
2
|
-
from typing import Any, Dict, List, Optional
|
3
|
-
|
4
|
-
class TemplateManager:
|
5
|
-
"""TemplateManager class for managing handlebars templates."""
|
6
|
-
def __init__(
|
7
|
-
self, template_dirs: List[Path], suffix: Optional[str] = None, active_loading: Optional[bool] = None
|
8
|
-
) -> None:
|
9
|
-
"""Initialize the template manager.
|
10
|
-
|
11
|
-
Args:
|
12
|
-
template_dirs (List[Path]): A list of paths to directories containing templates.
|
13
|
-
suffix (str, optional): The suffix of template files. None means 'hbs' suffix.
|
14
|
-
active_loading (bool, optional): Whether to enable active loading of templates.
|
15
|
-
"""
|
16
|
-
|
17
|
-
@property
|
18
|
-
def template_count(self) -> int:
|
19
|
-
"""Get the number of templates discovered."""
|
20
|
-
|
21
|
-
def get_template_source(self, name: str) -> Optional[str]:
|
22
|
-
"""Get the source path of a template by name.
|
23
|
-
|
24
|
-
Args:
|
25
|
-
name (str): The name of the template to retrieve.
|
26
|
-
|
27
|
-
Returns:
|
28
|
-
Optional[str]: The source path of the template.
|
29
|
-
"""
|
30
|
-
|
31
|
-
def discover_templates(self) -> None:
|
32
|
-
"""Discover templates in the specified directories."""
|
33
|
-
|
34
|
-
def render_template(self, name: str, data: Dict[str, Any]) -> str:
|
35
|
-
"""Render a template with the given name and data.
|
36
|
-
|
37
|
-
Args:
|
38
|
-
name (str): The name of the template to render.
|
39
|
-
data (Dict[str, Any]): The data to pass to the template.
|
40
|
-
|
41
|
-
Returns:
|
42
|
-
str: The rendered template.
|
43
|
-
"""
|
44
|
-
|
45
|
-
def blake3_hash(content: bytes) -> str:
|
46
|
-
"""Calculate the BLAKE3 hash of the given data.
|
47
|
-
|
48
|
-
Args:
|
49
|
-
content (bytes): The data to hash.
|
50
|
-
|
51
|
-
Returns:
|
52
|
-
str: The BLAKE3 hash of the data.
|
53
|
-
"""
|
fabricatio/_rust_instances.py
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
from fabricatio._rust import TemplateManager
|
2
|
-
from fabricatio.config import configs
|
3
|
-
|
4
|
-
template_manager = TemplateManager(
|
5
|
-
template_dirs=configs.templates.template_dir,
|
6
|
-
suffix=configs.templates.template_suffix,
|
7
|
-
active_loading=configs.templates.active_loading,
|
8
|
-
)
|
@@ -1,15 +0,0 @@
|
|
1
|
-
"""Actions that involve communication with the user."""
|
2
|
-
|
3
|
-
from fabricatio.models.action import Action
|
4
|
-
from fabricatio.models.task import Task
|
5
|
-
|
6
|
-
|
7
|
-
class Examining(Action):
|
8
|
-
"""Action that examines the input data."""
|
9
|
-
|
10
|
-
name: str = "talk"
|
11
|
-
output_key: str = "examine_pass"
|
12
|
-
|
13
|
-
async def _execute(self, exam_target: Task[str], to_examine: str, **_) -> bool:
|
14
|
-
"""Examine the input data."""
|
15
|
-
# TODO
|
@@ -1,23 +0,0 @@
|
|
1
|
-
"""Actions for transmitting tasks to targets."""
|
2
|
-
|
3
|
-
from typing import List
|
4
|
-
|
5
|
-
from fabricatio.journal import logger
|
6
|
-
from fabricatio.models.action import Action
|
7
|
-
from fabricatio.models.events import EventLike
|
8
|
-
from fabricatio.models.task import Task
|
9
|
-
|
10
|
-
|
11
|
-
class PublishTask(Action):
|
12
|
-
"""An action that publishes a task to a list of targets."""
|
13
|
-
|
14
|
-
name: str = "publish_task"
|
15
|
-
"""The name of the action."""
|
16
|
-
description: str = "Publish a task to a list of targets."
|
17
|
-
"""The description of the action."""
|
18
|
-
|
19
|
-
async def _execute(self, send_targets: List[EventLike], send_task: Task, **_) -> None:
|
20
|
-
"""Execute the action by sending the task to the specified targets."""
|
21
|
-
logger.info(f"Sending task {send_task.name} to {send_targets}")
|
22
|
-
for target in send_targets:
|
23
|
-
await send_task.move_to(target).publish()
|