fabricatio 0.2.6.dev1__cp312-cp312-win_amd64.whl → 0.2.7__cp312-cp312-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 +7 -24
- fabricatio/_rust.cp312-win_amd64.pyd +0 -0
- fabricatio/_rust.pyi +22 -0
- fabricatio/actions/article.py +168 -19
- fabricatio/actions/article_rag.py +35 -0
- fabricatio/actions/output.py +21 -6
- fabricatio/actions/rag.py +51 -3
- fabricatio/capabilities/correct.py +55 -11
- fabricatio/capabilities/rag.py +67 -16
- fabricatio/capabilities/rating.py +15 -6
- fabricatio/capabilities/review.py +7 -4
- fabricatio/capabilities/task.py +5 -5
- fabricatio/config.py +29 -21
- fabricatio/decorators.py +32 -0
- fabricatio/models/action.py +117 -43
- fabricatio/models/extra/article_base.py +378 -0
- fabricatio/models/extra/article_essence.py +226 -0
- fabricatio/models/extra/article_main.py +196 -0
- fabricatio/models/extra/article_outline.py +32 -0
- fabricatio/models/extra/article_proposal.py +35 -0
- fabricatio/models/generic.py +164 -14
- fabricatio/models/kwargs_types.py +51 -10
- fabricatio/models/role.py +30 -6
- fabricatio/models/tool.py +6 -2
- fabricatio/models/usages.py +94 -47
- fabricatio/models/utils.py +29 -2
- fabricatio/parser.py +2 -0
- fabricatio/workflows/articles.py +12 -1
- fabricatio-0.2.7.data/scripts/tdown.exe +0 -0
- fabricatio-0.2.7.dist-info/METADATA +181 -0
- fabricatio-0.2.7.dist-info/RECORD +47 -0
- {fabricatio-0.2.6.dev1.dist-info → fabricatio-0.2.7.dist-info}/WHEEL +1 -1
- fabricatio/models/extra.py +0 -171
- fabricatio-0.2.6.dev1.data/scripts/tdown.exe +0 -0
- fabricatio-0.2.6.dev1.dist-info/METADATA +0 -312
- fabricatio-0.2.6.dev1.dist-info/RECORD +0 -42
- {fabricatio-0.2.6.dev1.dist-info → fabricatio-0.2.7.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
fabricatio-0.2.7.dist-info/METADATA,sha256=pURYBzHBlC9kis-tB11uD9qVokoR9Kpj52synmR7sMs,5254
|
2
|
+
fabricatio-0.2.7.dist-info/WHEEL,sha256=jABKVkLC9kJr8mi_er5jOqpiQUjARSLXDUIIxDqsS50,96
|
3
|
+
fabricatio-0.2.7.dist-info/licenses/LICENSE,sha256=do7J7EiCGbq0QPbMAL_FqLYufXpHnCnXBOuqVPwSV8Y,1088
|
4
|
+
fabricatio/actions/article.py,sha256=W8MePeBrROpByxX48CKe4IwjRpm49-bnqM4V1SYThZk,8356
|
5
|
+
fabricatio/actions/article_rag.py,sha256=PiOFxI6VTmLXm3BK-01g_KH1mTE9uOtnA-CwUjt16AU,1456
|
6
|
+
fabricatio/actions/output.py,sha256=K7xsBH8MjXRH6JOy3ZO94KCQzX2jNrwPPK_rRXVkS0E,1161
|
7
|
+
fabricatio/actions/rag.py,sha256=QBdzEM8MloM_ahx5pTBZAETm9_631lTe_0ih_he_Iuo,2759
|
8
|
+
fabricatio/capabilities/correct.py,sha256=EM58d6Kt_XVpJFk9bkIbgBDA9LYTt6t5I0LPVuf_Fq8,6530
|
9
|
+
fabricatio/capabilities/propose.py,sha256=y3kge5g6bb8HYuV8e9h4MdqOMTlsfAIZpqE_cagWPTY,1593
|
10
|
+
fabricatio/capabilities/rag.py,sha256=XVvfH6rcog-moj1WCgwtR-l0-NdbFR6-fMQFLG7_asY,17690
|
11
|
+
fabricatio/capabilities/rating.py,sha256=yEPqL5_DqVMj_AH9cMvKsHdMnSbvm8dN6PaKHLsJUPQ,14904
|
12
|
+
fabricatio/capabilities/review.py,sha256=uc4WV9Xu-4rXAXZ-k-32HXAgm4WMLbDRfiZdRP7Nepg,11384
|
13
|
+
fabricatio/capabilities/task.py,sha256=vtS0YOe639vN8iTrkP2WK0AJVCr5N_JAaJuvRGyY2Fg,4639
|
14
|
+
fabricatio/config.py,sha256=hUv5XMzOkEw8cQjsVHTpPPix52IKwmxjBsZM6Px3xZI,16915
|
15
|
+
fabricatio/core.py,sha256=VQ_JKgUGIy2gZ8xsTBZCdr_IP7wC5aPg0_bsOmjQ588,6458
|
16
|
+
fabricatio/decorators.py,sha256=C0Gi7wcXC-0sWITqsSv3JdBGcgVJOlRvOt0FfO0aUsA,7554
|
17
|
+
fabricatio/fs/curd.py,sha256=N6l2MncjrFfnXBRtteRouXp5Rjy8EAKC_i29_G-zz98,4618
|
18
|
+
fabricatio/fs/readers.py,sha256=EZKN_AZdrp8DggJECP53QHw3uHeSDf-AwCAA_V7fNKU,1202
|
19
|
+
fabricatio/fs/__init__.py,sha256=PCf0s_9KDjVfNw7AfPoJzGt3jMq4gJOfbcT4pb0D0ZY,588
|
20
|
+
fabricatio/journal.py,sha256=stnEP88aUBA_GmU9gfTF2EZI8FS2OyMLGaMSTgK4QgA,476
|
21
|
+
fabricatio/models/action.py,sha256=UlflniS__MMrUXglu_U3PDFAtKEjVsKEix17AT9oP3M,8769
|
22
|
+
fabricatio/models/events.py,sha256=QvlnS8FEELg6KNabcJMeh2GV_y0ZBzKOPphcteKYWYU,4183
|
23
|
+
fabricatio/models/extra/article_base.py,sha256=kX32SvjUitK7fQr97joKyWlTpjqjrvsrWQVVqjggwkA,15371
|
24
|
+
fabricatio/models/extra/article_essence.py,sha256=DUESuK4CGgkRvIMoJCv4l8MNp5MawRYoNOtLCrFRPXY,9229
|
25
|
+
fabricatio/models/extra/article_main.py,sha256=XekZcXztjWdFT39lZ_Ny0zVGu56wt1oieeLd7aLPJo8,7400
|
26
|
+
fabricatio/models/extra/article_outline.py,sha256=pIsO5bOSV-SUeWWdhkfkVpcr9RPOHgYmsceHsrXs67M,1145
|
27
|
+
fabricatio/models/extra/article_proposal.py,sha256=p0NPzqg9x6t65DZqdF52Z1P0JwP6kwo2_eP-NsXgifU,1720
|
28
|
+
fabricatio/models/generic.py,sha256=tVMitdYI6gK30eWAIFvfXSRWliTzcfMKvuhaKFcZ_xw,19004
|
29
|
+
fabricatio/models/kwargs_types.py,sha256=chJ-rHaeBVRUPuORHuGR3DdNxxTUrotz0eflPEh4l4w,5474
|
30
|
+
fabricatio/models/role.py,sha256=mmQbJ6GKr2Gx3wtjEz8d-vYoXs09ffcEkT_eCXaDd3E,2782
|
31
|
+
fabricatio/models/task.py,sha256=8NaR7ojQWyM740EDTqt9stwHKdrD6axCRpLKo0QzS-I,10492
|
32
|
+
fabricatio/models/tool.py,sha256=kD0eB7OxO9geZOxO6JIKvCBeG-KOpRAkfRZqK_WGfW4,7105
|
33
|
+
fabricatio/models/usages.py,sha256=BSqTENSva8Flga3bPBfwuc1nHo5Z_29oYzar99NbjLM,31566
|
34
|
+
fabricatio/models/utils.py,sha256=yjxPZ6N7QGpGwkI_Vb28Ud3EhkdlB-tyfGRHAZMcGxs,5872
|
35
|
+
fabricatio/parser.py,sha256=9Jzw-yV6uKbFvf6sPna-XHdziVGVBZWvPctgX_6ODL8,6251
|
36
|
+
fabricatio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
37
|
+
fabricatio/toolboxes/arithmetic.py,sha256=WLqhY-Pikv11Y_0SGajwZx3WhsLNpHKf9drzAqOf_nY,1369
|
38
|
+
fabricatio/toolboxes/fs.py,sha256=l4L1CVxJmjw9Ld2XUpIlWfV0_Fu_2Og6d3E13I-S4aE,736
|
39
|
+
fabricatio/toolboxes/__init__.py,sha256=KBJi5OG_pExscdlM7Bnt_UF43j4I3Lv6G71kPVu4KQU,395
|
40
|
+
fabricatio/workflows/articles.py,sha256=G5HGRr-DHuYuEcfhFdFAuDvTTJ9aSU_UQ2yYXEjTMtM,1047
|
41
|
+
fabricatio/workflows/rag.py,sha256=-YYp2tlE9Vtfgpg6ROpu6QVO8j8yVSPa6yDzlN3qVxs,520
|
42
|
+
fabricatio/_rust.pyi,sha256=dGTGV7viu3YAGl1cRKIWrdHPc1hlwk3_hbaDaswxdVo,3831
|
43
|
+
fabricatio/_rust_instances.py,sha256=2GwF8aVfYNemRI2feBzH1CZfBGno-XJJE5imJokGEYw,314
|
44
|
+
fabricatio/__init__.py,sha256=SzBYsRhZeL77jLtfJEjmoHOSwHwUGyvMATX6xfndLDM,1135
|
45
|
+
fabricatio/_rust.cp312-win_amd64.pyd,sha256=KSrEUEqHJLRXmr2uwDgmVVxBu_oGHsN68uvH2hm4vDs,1835008
|
46
|
+
fabricatio-0.2.7.data/scripts/tdown.exe,sha256=6GgVuiuWQ_iaKcoswVvE8bS1pYvemvGfmKo0CZV2WmE,3399680
|
47
|
+
fabricatio-0.2.7.dist-info/RECORD,,
|
fabricatio/models/extra.py
DELETED
@@ -1,171 +0,0 @@
|
|
1
|
-
"""Extra models for built-in actions."""
|
2
|
-
|
3
|
-
from typing import List
|
4
|
-
|
5
|
-
from fabricatio.models.generic import Base, Display, FinalizedDumpAble, PrepareVectorization, ProposedAble
|
6
|
-
from pydantic import Field
|
7
|
-
|
8
|
-
|
9
|
-
class Equation(Base):
|
10
|
-
"""Structured representation of mathematical equations (including their physical or conceptual meanings)."""
|
11
|
-
|
12
|
-
description: str
|
13
|
-
"""A concise explanation of the equation's meaning, purpose, and relevance in the context of the research."""
|
14
|
-
|
15
|
-
latex_code: str
|
16
|
-
"""The LaTeX code used to represent the equation in a publication-ready format."""
|
17
|
-
|
18
|
-
|
19
|
-
class Figure(Base):
|
20
|
-
"""Structured representation of figures (including their academic significance and explanatory captions)."""
|
21
|
-
|
22
|
-
description: str
|
23
|
-
"""A detailed explanation of the figure's content and its role in conveying key insights."""
|
24
|
-
|
25
|
-
figure_caption: str
|
26
|
-
"""The caption accompanying the figure, summarizing its main points and academic value."""
|
27
|
-
|
28
|
-
figure_path: str
|
29
|
-
"""The file path to the figure"""
|
30
|
-
|
31
|
-
|
32
|
-
class Highlightings(Base):
|
33
|
-
"""Structured representation of highlighted elements in an academic paper (including equations, algorithms, figures, and tables)."""
|
34
|
-
|
35
|
-
# Academic Achievements Showcase
|
36
|
-
highlighted_equations: List[Equation] = Field(default_factory=list)
|
37
|
-
"""Core mathematical equations that represent breakthroughs in the field, accompanied by explanations of their physical or conceptual significance,Should always be in LaTeX format wrapped in $ or $$ signs."""
|
38
|
-
|
39
|
-
highlighted_algorithms: List[str] = Field(default_factory=list)
|
40
|
-
"""Pseudocode for key algorithms, annotated to highlight innovative components."""
|
41
|
-
|
42
|
-
highlighted_figures: List[Figure] = Field(default_factory=list)
|
43
|
-
"""Critical diagrams or illustrations, each accompanied by a caption explaining their academic importance."""
|
44
|
-
|
45
|
-
highlighted_tables: List[str] = Field(default_factory=list)
|
46
|
-
"""Important data tables, annotated to indicate statistical significance or other notable findings."""
|
47
|
-
|
48
|
-
|
49
|
-
class ArticleEssence(ProposedAble, Display, PrepareVectorization):
|
50
|
-
"""Structured representation of the core elements of an academic paper(providing a comprehensive digital profile of the paper's essential information)."""
|
51
|
-
|
52
|
-
# Basic Metadata
|
53
|
-
title: str = Field(...)
|
54
|
-
"""The full title of the paper, including any subtitles if applicable."""
|
55
|
-
|
56
|
-
authors: List[str]
|
57
|
-
"""A list of the paper's authors, typically in the order of contribution."""
|
58
|
-
|
59
|
-
keywords: List[str]
|
60
|
-
"""A list of keywords that summarize the paper's focus and facilitate indexing."""
|
61
|
-
|
62
|
-
publication_year: int
|
63
|
-
"""The year in which the paper was published."""
|
64
|
-
|
65
|
-
# Core Content Elements
|
66
|
-
highlightings: Highlightings = Field(default_factory=Highlightings)
|
67
|
-
"""A collection of highlighted elements in the paper, including equations, algorithms, figures, and tables."""
|
68
|
-
|
69
|
-
domain: List[str]
|
70
|
-
"""The research domains or fields addressed by the paper (e.g., ['Natural Language Processing', 'Computer Vision'])."""
|
71
|
-
|
72
|
-
abstract: str = Field(...)
|
73
|
-
"""A structured abstract that outlines the research problem, methodology, and conclusions in three distinct sections."""
|
74
|
-
|
75
|
-
core_contributions: List[str]
|
76
|
-
"""Key academic contributions that distinguish the paper from prior work in the field."""
|
77
|
-
|
78
|
-
technical_novelty: List[str]
|
79
|
-
"""Specific technical innovations introduced by the research, listed as individual points."""
|
80
|
-
|
81
|
-
# Academic Discussion Dimensions
|
82
|
-
research_problems: List[str]
|
83
|
-
"""A clearly defined research question or problem addressed by the study."""
|
84
|
-
|
85
|
-
limitations: List[str]
|
86
|
-
"""An analysis of the methodological or experimental limitations of the research."""
|
87
|
-
|
88
|
-
future_work: List[str]
|
89
|
-
"""Suggestions for potential directions or topics for follow-up studies."""
|
90
|
-
|
91
|
-
impact_analysis: List[str]
|
92
|
-
"""An assessment of the paper's potential influence on the development of the field."""
|
93
|
-
|
94
|
-
def _prepare_vectorization_inner(self) -> str:
|
95
|
-
return self.model_dump_json()
|
96
|
-
|
97
|
-
|
98
|
-
class ArticleProposal(ProposedAble, Display):
|
99
|
-
"""Structured representation of the proposal for an academic paper."""
|
100
|
-
|
101
|
-
title: str = Field(...)
|
102
|
-
"""The proposed title of the paper."""
|
103
|
-
|
104
|
-
focused_problem: List[str] = Field(default_factory=list)
|
105
|
-
"""The specific research problem or question that the paper aims to address."""
|
106
|
-
research_aim: List[str] = Field(default_factory=list)
|
107
|
-
"""The main objective or goal of the research, outlining what the study aims to achieve."""
|
108
|
-
research_methods: List[str] = Field(default_factory=list)
|
109
|
-
"""The methods used in the research, including the approach, techniques, and tools employed."""
|
110
|
-
|
111
|
-
|
112
|
-
class ArticleSubsectionOutline(Base):
|
113
|
-
"""Structured representation of the subsections of an academic paper."""
|
114
|
-
|
115
|
-
title: str = Field(...)
|
116
|
-
"""The title of the subsection."""
|
117
|
-
|
118
|
-
description: str = Field(...)
|
119
|
-
"""A brief description of the subsection's content should be, how it fits into the overall structure of the paper, and its significance in the context of the research."""
|
120
|
-
|
121
|
-
|
122
|
-
class ArticleSectionOutline(Base):
|
123
|
-
"""Structured representation of the sections of an academic paper."""
|
124
|
-
|
125
|
-
title: str = Field(...)
|
126
|
-
"""The title of the section."""
|
127
|
-
description: str = Field(...)
|
128
|
-
"""A brief description of the section's content should be, how it fits into the overall structure of the paper, and its significance in the context of the research."""
|
129
|
-
subsections: List[ArticleSubsectionOutline] = Field(default_factory=list)
|
130
|
-
"""The subsections of the section, outlining their content and significance."""
|
131
|
-
|
132
|
-
|
133
|
-
class ArticleChapterOutline(Base):
|
134
|
-
"""Structured representation of the chapters of an academic paper."""
|
135
|
-
|
136
|
-
title: str = Field(...)
|
137
|
-
"""The title of the chapter."""
|
138
|
-
description: str = Field(...)
|
139
|
-
"""A brief description of the chapter's content should be, how it fits into the overall structure of the paper, and its significance in the context of the research."""
|
140
|
-
sections: List[ArticleSectionOutline] = Field(default_factory=list)
|
141
|
-
"""The sections of the chapter, outlining their content and significance."""
|
142
|
-
|
143
|
-
|
144
|
-
class ArticleOutline(ProposedAble, Display, FinalizedDumpAble):
|
145
|
-
"""Structured representation of the outline for an academic paper."""
|
146
|
-
|
147
|
-
title: str = Field(...)
|
148
|
-
"""The proposed title of the paper."""
|
149
|
-
|
150
|
-
prospect: str = Field(...)
|
151
|
-
"""A brief description of the research problem or question that the paper aims to address manipulating methods or techniques"""
|
152
|
-
|
153
|
-
chapters: List[ArticleChapterOutline] = Field(default_factory=list)
|
154
|
-
"""The chapters of the paper, outlining their content and significance."""
|
155
|
-
|
156
|
-
def finalized_dump(self) -> str:
|
157
|
-
"""Finalized dump of the article outline.
|
158
|
-
|
159
|
-
Returns:
|
160
|
-
str: The finalized dump of the article outline.
|
161
|
-
"""
|
162
|
-
lines: List[str] = []
|
163
|
-
|
164
|
-
for chapter in self.chapters:
|
165
|
-
lines.append(f"= {chapter.title}")
|
166
|
-
for section in chapter.sections:
|
167
|
-
lines.append(f"== {section.title}")
|
168
|
-
for subsection in section.subsections:
|
169
|
-
lines.append(f"=== {subsection.title}")
|
170
|
-
|
171
|
-
return "\n\n".join(lines)
|
Binary file
|
@@ -1,312 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: fabricatio
|
3
|
-
Version: 0.2.6.dev1
|
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[rag] ; extra == 'full'
|
28
|
-
Provides-Extra: rag
|
29
|
-
Provides-Extra: full
|
30
|
-
License-File: LICENSE
|
31
|
-
Summary: A LLM multi-agent framework.
|
32
|
-
Keywords: ai,agents,multi-agent,llm,pyo3
|
33
|
-
Author-email: Whth <zettainspector@foxmail.com>
|
34
|
-
Requires-Python: >=3.12, <3.13
|
35
|
-
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
36
|
-
Project-URL: Homepage, https://github.com/Whth/fabricatio
|
37
|
-
Project-URL: Repository, https://github.com/Whth/fabricatio
|
38
|
-
Project-URL: Issues, https://github.com/Whth/fabricatio/issues
|
39
|
-
|
40
|
-
# Fabricatio
|
41
|
-
|
42
|
-

|
43
|
-

|
44
|
-

|
45
|
-
|
46
|
-
## Overview
|
47
|
-
|
48
|
-
Fabricatio is a Python library designed for building LLM (Large Language Model) applications using an event-based agent structure. It integrates Rust for performance-critical tasks, utilizes Handlebars for templating, and employs PyO3 for Python bindings.
|
49
|
-
|
50
|
-
## Features
|
51
|
-
|
52
|
-
- **Event-Based Architecture**: Utilizes an EventEmitter pattern for robust task management.
|
53
|
-
- **LLM Integration**: Supports interactions with large language models for intelligent task processing.
|
54
|
-
- **Templating Engine**: Uses Handlebars for dynamic content generation.
|
55
|
-
- **Toolboxes**: Provides predefined toolboxes for common operations like file manipulation and arithmetic.
|
56
|
-
- **Async Support**: Fully asynchronous for efficient execution.
|
57
|
-
- **Extensible**: Easy to extend with custom actions, workflows, and tools.
|
58
|
-
|
59
|
-
## Installation
|
60
|
-
|
61
|
-
### Using UV (Recommended)
|
62
|
-
|
63
|
-
To install Fabricatio using `uv` (a package manager for Python):
|
64
|
-
|
65
|
-
```bash
|
66
|
-
# Install uv if not already installed
|
67
|
-
pip install uv
|
68
|
-
|
69
|
-
# Clone the repository
|
70
|
-
git clone https://github.com/Whth/fabricatio.git
|
71
|
-
cd fabricatio
|
72
|
-
|
73
|
-
# Install the package in development mode with uv
|
74
|
-
uv --with-editable . maturin develop --uv -r
|
75
|
-
```
|
76
|
-
|
77
|
-
|
78
|
-
### Building Distribution
|
79
|
-
|
80
|
-
For production builds:
|
81
|
-
|
82
|
-
```bash
|
83
|
-
# Build distribution packages
|
84
|
-
make bdist
|
85
|
-
```
|
86
|
-
|
87
|
-
|
88
|
-
This will generate distribution files in the `dist` directory.
|
89
|
-
|
90
|
-
## Usage
|
91
|
-
|
92
|
-
### Basic Example
|
93
|
-
|
94
|
-
#### Simple Hello World Program
|
95
|
-
|
96
|
-
```python
|
97
|
-
import asyncio
|
98
|
-
from fabricatio import Action, Role, Task, logger, WorkFlow
|
99
|
-
from typing import Any
|
100
|
-
|
101
|
-
class Hello(Action):
|
102
|
-
name: str = "hello"
|
103
|
-
output_key: str = "task_output"
|
104
|
-
|
105
|
-
async def _execute(self, task_input: Task[str], **_) -> Any:
|
106
|
-
ret = "Hello fabricatio!"
|
107
|
-
logger.info("executing talk action")
|
108
|
-
return ret
|
109
|
-
|
110
|
-
async def main() -> None:
|
111
|
-
role = Role(
|
112
|
-
name="talker",
|
113
|
-
description="talker role",
|
114
|
-
registry={Task.pending_label: WorkFlow(name="talk", steps=(Hello,))}
|
115
|
-
)
|
116
|
-
|
117
|
-
task = Task(name="say hello", goals="say hello", description="say hello to the world")
|
118
|
-
result = await task.delegate()
|
119
|
-
logger.success(f"Result: {result}")
|
120
|
-
|
121
|
-
if __name__ == "__main__":
|
122
|
-
asyncio.run(main())
|
123
|
-
```
|
124
|
-
|
125
|
-
|
126
|
-
### Advanced Examples
|
127
|
-
|
128
|
-
#### Writing and Dumping Code
|
129
|
-
|
130
|
-
```python
|
131
|
-
import asyncio
|
132
|
-
from fabricatio import Action, Event, PythonCapture, Role, Task, ToolBox, WorkFlow, fs_toolbox, logger
|
133
|
-
|
134
|
-
|
135
|
-
class WriteCode(Action):
|
136
|
-
name: str = "write code"
|
137
|
-
output_key: str = "source_code"
|
138
|
-
|
139
|
-
async def _execute(self, task_input: Task[str], **_) -> str:
|
140
|
-
return await self.aask_validate(task_input.briefing, validator=PythonCapture.capture)
|
141
|
-
|
142
|
-
|
143
|
-
class DumpCode(Action):
|
144
|
-
name: str = "dump code"
|
145
|
-
description: str = "Dump code to file system"
|
146
|
-
toolboxes: set[ToolBox] = {fs_toolbox}
|
147
|
-
output_key: str = "task_output"
|
148
|
-
|
149
|
-
async def _execute(self, task_input: Task, source_code: str, **_) -> Any:
|
150
|
-
path = await self.handle_fin_grind(task_input, {"source_code": source_code})
|
151
|
-
return path[0] if path else None
|
152
|
-
|
153
|
-
|
154
|
-
async def main() -> None:
|
155
|
-
role = Role(
|
156
|
-
name="Coder",
|
157
|
-
description="A python coder who can write and document code",
|
158
|
-
registry={
|
159
|
-
Event.instantiate_from("coding.*").push("pending"): WorkFlow(
|
160
|
-
name="write code", steps=(WriteCode, DumpCode)
|
161
|
-
)
|
162
|
-
}
|
163
|
-
)
|
164
|
-
|
165
|
-
prompt = "write a Python CLI app which prints 'hello world' n times with detailed Google-style docstring. Write the source code to `cli.py`."
|
166
|
-
proposed_task = await role.propose_task(prompt)
|
167
|
-
path = await proposed_task.move_to("coding").delegate()
|
168
|
-
logger.success(f"Code Path: {path}")
|
169
|
-
|
170
|
-
|
171
|
-
if __name__ == "__main__":
|
172
|
-
asyncio.run(main())
|
173
|
-
```
|
174
|
-
|
175
|
-
|
176
|
-
### Template Management and Rendering
|
177
|
-
|
178
|
-
```python
|
179
|
-
from fabricatio._rust_instances import TEMPLATE_MANAGER
|
180
|
-
|
181
|
-
template_name = "claude-xml.hbs"
|
182
|
-
data = {
|
183
|
-
"absolute_code_path": "/path/to/project",
|
184
|
-
"source_tree": "source tree content",
|
185
|
-
"files": [{"path": "file1.py", "code": "print('Hello')"}],
|
186
|
-
}
|
187
|
-
|
188
|
-
rendered_template = TEMPLATE_MANAGER.render_template(template_name, data)
|
189
|
-
print(rendered_template)
|
190
|
-
```
|
191
|
-
|
192
|
-
|
193
|
-
### Handling Security Vulnerabilities
|
194
|
-
|
195
|
-
```python
|
196
|
-
from fabricatio.models.usages import ToolBoxUsage
|
197
|
-
from fabricatio.models.task import Task
|
198
|
-
|
199
|
-
toolbox_usage = ToolBoxUsage()
|
200
|
-
|
201
|
-
async def handle_security_vulnerabilities():
|
202
|
-
task = Task(
|
203
|
-
name="Security Check",
|
204
|
-
goals=["Identify security vulnerabilities"],
|
205
|
-
description="Perform a thorough security review on the project.",
|
206
|
-
dependencies=["./src/main.py"]
|
207
|
-
)
|
208
|
-
|
209
|
-
vulnerabilities = await toolbox_usage.gather_tools_fine_grind(task)
|
210
|
-
for vulnerability in vulnerabilities:
|
211
|
-
print(f"Found vulnerability: {vulnerability.name}")
|
212
|
-
```
|
213
|
-
|
214
|
-
|
215
|
-
### Managing CTF Challenges
|
216
|
-
|
217
|
-
```python
|
218
|
-
import asyncio
|
219
|
-
|
220
|
-
from fabricatio.models.usages import ToolBoxUsage
|
221
|
-
from fabricatio.models.task import Task
|
222
|
-
|
223
|
-
toolbox_usage = ToolBoxUsage()
|
224
|
-
|
225
|
-
async def solve_ctf_challenge(challenge_name: str, challenge_description: str, files: list[str]):
|
226
|
-
task = Task(
|
227
|
-
name=challenge_name,
|
228
|
-
goals=[f"Solve {challenge_name} challenge"],
|
229
|
-
description=challenge_description,
|
230
|
-
dependencies=files
|
231
|
-
)
|
232
|
-
|
233
|
-
solution = await toolbox_usage.gather_tools_fine_grind(task)
|
234
|
-
print(f"Challenge Solved: {solution}")
|
235
|
-
|
236
|
-
if __name__ == "__main__":
|
237
|
-
asyncio.run(
|
238
|
-
solve_ctf_challenge("Binary Exploitation", "CTF Binary Exploitation Challenge", ["./challenges/binary_exploit"]))
|
239
|
-
```
|
240
|
-
|
241
|
-
|
242
|
-
## Configuration
|
243
|
-
|
244
|
-
The configuration for Fabricatio is managed via environment variables or TOML files. The default configuration file (`config.toml`) can be overridden by specifying a custom path.
|
245
|
-
|
246
|
-
Example `config.toml`:
|
247
|
-
|
248
|
-
```toml
|
249
|
-
[llm]
|
250
|
-
api_endpoint = "https://api.openai.com"
|
251
|
-
api_key = "your_openai_api_key"
|
252
|
-
timeout = 300
|
253
|
-
max_retries = 3
|
254
|
-
model = "gpt-3.5-turbo"
|
255
|
-
temperature = 1.0
|
256
|
-
stop_sign = ["\n\n\n", "User:"]
|
257
|
-
top_p = 0.35
|
258
|
-
generation_count = 1
|
259
|
-
stream = false
|
260
|
-
max_tokens = 8192
|
261
|
-
```
|
262
|
-
|
263
|
-
|
264
|
-
## Development Setup
|
265
|
-
|
266
|
-
To set up a development environment for Fabricatio:
|
267
|
-
|
268
|
-
1. **Clone the Repository**:
|
269
|
-
```bash
|
270
|
-
git clone https://github.com/Whth/fabricatio.git
|
271
|
-
cd fabricatio
|
272
|
-
```
|
273
|
-
|
274
|
-
|
275
|
-
2. **Install Dependencies**:
|
276
|
-
```bash
|
277
|
-
uv --with-editable . maturin develop --uv -r
|
278
|
-
```
|
279
|
-
|
280
|
-
|
281
|
-
3. **Run Tests**:
|
282
|
-
```bash
|
283
|
-
make test
|
284
|
-
```
|
285
|
-
|
286
|
-
|
287
|
-
4. **Build Documentation**:
|
288
|
-
```bash
|
289
|
-
make docs
|
290
|
-
```
|
291
|
-
|
292
|
-
|
293
|
-
## Contributing
|
294
|
-
|
295
|
-
Contributions are welcome! Please follow these guidelines when contributing:
|
296
|
-
|
297
|
-
1. Fork the repository.
|
298
|
-
2. Create your feature branch (`git checkout -b feature/new-feature`).
|
299
|
-
3. Commit your changes (`git commit -am 'Add new feature'`).
|
300
|
-
4. Push to the branch (`git push origin feature/new-feature`).
|
301
|
-
5. Create a new Pull Request.
|
302
|
-
|
303
|
-
## License
|
304
|
-
|
305
|
-
Fabricatio is licensed under the MIT License. See [LICENSE](LICENSE) for more details.
|
306
|
-
|
307
|
-
## Acknowledgments
|
308
|
-
|
309
|
-
Special thanks to the contributors and maintainers of:
|
310
|
-
- [PyO3](https://github.com/PyO3/pyo3)
|
311
|
-
- [Maturin](https://github.com/PyO3/maturin)
|
312
|
-
- [Handlebars.rs](https://github.com/sunng87/handlebars-rust)
|
@@ -1,42 +0,0 @@
|
|
1
|
-
fabricatio-0.2.6.dev1.dist-info/METADATA,sha256=BSySyhuAwgYRJFDSx2zlSSpAICPoplPXW3G4tHd0JnA,8896
|
2
|
-
fabricatio-0.2.6.dev1.dist-info/WHEEL,sha256=tpW5AN9B-9qsM9WW2FXG2r193YXiqexDadpKp0A2daI,96
|
3
|
-
fabricatio-0.2.6.dev1.dist-info/licenses/LICENSE,sha256=do7J7EiCGbq0QPbMAL_FqLYufXpHnCnXBOuqVPwSV8Y,1088
|
4
|
-
fabricatio/actions/article.py,sha256=yzRwgc203vI3MW_oWyFybDxTz6kaBBvUgN2zOJJ9Amc,2825
|
5
|
-
fabricatio/actions/output.py,sha256=KSSLvEvXsA10ACN2mbqGo98QwKLVUAoMUJNKYk6HhGc,645
|
6
|
-
fabricatio/actions/rag.py,sha256=GpT7YlqOYznZyaT-6Y84_33HtZGT-5s71ZK8iroQA9g,813
|
7
|
-
fabricatio/capabilities/correct.py,sha256=QslmBYcpblSykZmjxr0vLgyfU0uGKOcwRxUYJZ9-jBc,4527
|
8
|
-
fabricatio/capabilities/propose.py,sha256=y3kge5g6bb8HYuV8e9h4MdqOMTlsfAIZpqE_cagWPTY,1593
|
9
|
-
fabricatio/capabilities/rag.py,sha256=OebdGps8LGniN_HkRAOuwZd1ZQsyQe3WrduNAmBSxLM,15773
|
10
|
-
fabricatio/capabilities/rating.py,sha256=R9otyZVE2E3kKxrOCTZMeesBCPbC-fSb7bXgZPMQzfU,14406
|
11
|
-
fabricatio/capabilities/review.py,sha256=XYzpSnFCT9HS2XytQT8HDgV4SjXehexoJgucZFMx6P8,11102
|
12
|
-
fabricatio/capabilities/task.py,sha256=nVsC8smZRM5kGnIDiQtgP9kiGkz5KB1S9NXhMvwY2CQ,4607
|
13
|
-
fabricatio/config.py,sha256=bpj8i0KT8HQ9ka2kX3lcILBWh4S5_PenCas9wu_Ueg0,16302
|
14
|
-
fabricatio/core.py,sha256=VQ_JKgUGIy2gZ8xsTBZCdr_IP7wC5aPg0_bsOmjQ588,6458
|
15
|
-
fabricatio/decorators.py,sha256=uzsP4tFKQNjDHBkofsjjoJA0IUAaYOtt6YVedoyOqlo,6551
|
16
|
-
fabricatio/fs/curd.py,sha256=N6l2MncjrFfnXBRtteRouXp5Rjy8EAKC_i29_G-zz98,4618
|
17
|
-
fabricatio/fs/readers.py,sha256=EZKN_AZdrp8DggJECP53QHw3uHeSDf-AwCAA_V7fNKU,1202
|
18
|
-
fabricatio/fs/__init__.py,sha256=PCf0s_9KDjVfNw7AfPoJzGt3jMq4gJOfbcT4pb0D0ZY,588
|
19
|
-
fabricatio/journal.py,sha256=stnEP88aUBA_GmU9gfTF2EZI8FS2OyMLGaMSTgK4QgA,476
|
20
|
-
fabricatio/models/action.py,sha256=25kaph3csV0VQtxVPQCyRAusgwp6E1R1g4KBs7H9T2c,6448
|
21
|
-
fabricatio/models/events.py,sha256=QvlnS8FEELg6KNabcJMeh2GV_y0ZBzKOPphcteKYWYU,4183
|
22
|
-
fabricatio/models/extra.py,sha256=O8ncZVsaNmlR5f8c_b2HJc-yVZQ2YhB6ddDbfT0Ysh4,7412
|
23
|
-
fabricatio/models/generic.py,sha256=IdPJMf3qxZFq8yqd6OuAYKfCM0wBlJkozgxvxQZVEEc,14025
|
24
|
-
fabricatio/models/kwargs_types.py,sha256=jTXgCti-3AyPJwea7g4FxBdsbIwD7jnusi0VhhEhSGo,4286
|
25
|
-
fabricatio/models/role.py,sha256=7S3HSjFLaSTZ5bzgTJLeZ3PpAQDEGBxPhou5Mp8ONpQ,1842
|
26
|
-
fabricatio/models/task.py,sha256=8NaR7ojQWyM740EDTqt9stwHKdrD6axCRpLKo0QzS-I,10492
|
27
|
-
fabricatio/models/tool.py,sha256=4b-v4WIC_LuLOKzzXL9bvKXr8vmGZ8O2uAFv5-1KRA0,7052
|
28
|
-
fabricatio/models/usages.py,sha256=hR4OU4sjQ2jKaH5_kkN83vG58n3kcKnt9osND0BYi0Q,28634
|
29
|
-
fabricatio/models/utils.py,sha256=1bCqeB6za7ecCAM3cU1raNWuN56732m45rXtlIlc3I4,5017
|
30
|
-
fabricatio/parser.py,sha256=SzyVzbKj5L_0IcI5Z5ILpopJxE-1hGhmomskTWdcc68,6194
|
31
|
-
fabricatio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
32
|
-
fabricatio/toolboxes/arithmetic.py,sha256=WLqhY-Pikv11Y_0SGajwZx3WhsLNpHKf9drzAqOf_nY,1369
|
33
|
-
fabricatio/toolboxes/fs.py,sha256=l4L1CVxJmjw9Ld2XUpIlWfV0_Fu_2Og6d3E13I-S4aE,736
|
34
|
-
fabricatio/toolboxes/__init__.py,sha256=KBJi5OG_pExscdlM7Bnt_UF43j4I3Lv6G71kPVu4KQU,395
|
35
|
-
fabricatio/workflows/articles.py,sha256=RebdC_BzSXC-xsck5I9ccC_XIgfhtoeM8FZuhtVDn3U,580
|
36
|
-
fabricatio/workflows/rag.py,sha256=-YYp2tlE9Vtfgpg6ROpu6QVO8j8yVSPa6yDzlN3qVxs,520
|
37
|
-
fabricatio/_rust.pyi,sha256=pI747rOciunGuQZDvfC3O0A6pLyOiaHSa3A5kHuQO0E,3169
|
38
|
-
fabricatio/_rust_instances.py,sha256=2GwF8aVfYNemRI2feBzH1CZfBGno-XJJE5imJokGEYw,314
|
39
|
-
fabricatio/__init__.py,sha256=wTPzKLGztMr7orV-KizHRXJFhPGncvAHE7BPeSmBVDU,1926
|
40
|
-
fabricatio/_rust.cp312-win_amd64.pyd,sha256=j7ToedGSthvqB4_o2rPN970MQxbmlgQ07zZ6JAKT0eI,1815552
|
41
|
-
fabricatio-0.2.6.dev1.data/scripts/tdown.exe,sha256=aq0eF5FWu3Dxz2_8_RDa-lR5HrgGL01nLFWkfcuKSSI,3395072
|
42
|
-
fabricatio-0.2.6.dev1.dist-info/RECORD,,
|
File without changes
|