fabricatio 0.2.11.dev2__cp312-cp312-manylinux_2_34_x86_64.whl → 0.2.11.dev3__cp312-cp312-manylinux_2_34_x86_64.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/actions/article.py +20 -4
- fabricatio/actions/article_rag.py +6 -4
- fabricatio/models/action.py +14 -7
- fabricatio/models/task.py +13 -1
- fabricatio/models/usages.py +1 -1
- fabricatio/utils.py +4 -4
- {fabricatio-0.2.11.dev2.dist-info → fabricatio-0.2.11.dev3.dist-info}/METADATA +4 -2
- {fabricatio-0.2.11.dev2.dist-info → fabricatio-0.2.11.dev3.dist-info}/RECORD +11 -11
- {fabricatio-0.2.11.dev2.data → fabricatio-0.2.11.dev3.data}/scripts/tdown +0 -0
- {fabricatio-0.2.11.dev2.dist-info → fabricatio-0.2.11.dev3.dist-info}/WHEEL +0 -0
- {fabricatio-0.2.11.dev2.dist-info → fabricatio-0.2.11.dev3.dist-info}/licenses/LICENSE +0 -0
fabricatio/actions/article.py
CHANGED
@@ -149,10 +149,10 @@ class GenerateInitialOutline(Action, Extract):
|
|
149
149
|
async def _execute(
|
150
150
|
self,
|
151
151
|
article_proposal: ArticleProposal,
|
152
|
+
supervisor: Optional[bool] = None,
|
152
153
|
**_,
|
153
154
|
) -> Optional[ArticleOutline]:
|
154
|
-
|
155
|
-
f"{(article_proposal.as_prompt())}\n"
|
155
|
+
req = (
|
156
156
|
f"Design each chapter of a proper and academic and ready for release manner.\n"
|
157
157
|
f"You Must make sure every chapter have sections, and every section have subsections.\n"
|
158
158
|
f"Make the chapter and sections and subsections bing divided into a specific enough article component.\n"
|
@@ -160,14 +160,16 @@ class GenerateInitialOutline(Action, Extract):
|
|
160
160
|
f"Note that you SHALL use `{article_proposal.language}` as written language",
|
161
161
|
)
|
162
162
|
|
163
|
-
|
163
|
+
raw_outline = await self.aask(f"{(article_proposal.as_prompt())}\n{req}")
|
164
|
+
|
165
|
+
if supervisor or (supervisor is None and self.supervisor):
|
164
166
|
from questionary import confirm, text
|
165
167
|
|
166
168
|
r_print(raw_outline)
|
167
169
|
while not await confirm("Accept this version and continue?", default=True).ask_async():
|
168
170
|
imp = await text("Enter the improvement:").ask_async()
|
169
171
|
raw_outline = await self.aask(
|
170
|
-
f"{article_proposal.as_prompt()}\n{wrapp_in_block(raw_outline, 'Previous ArticleOutline')}\n{imp}"
|
172
|
+
f"{article_proposal.as_prompt()}\n{wrapp_in_block(raw_outline, 'Previous ArticleOutline')}\n{req}\n{wrapp_in_block(imp, title='Improvement')}"
|
171
173
|
)
|
172
174
|
r_print(raw_outline)
|
173
175
|
|
@@ -177,6 +179,20 @@ class GenerateInitialOutline(Action, Extract):
|
|
177
179
|
).update_ref(article_proposal)
|
178
180
|
|
179
181
|
|
182
|
+
class ExtractOutlineFromRaw(Action, Extract):
|
183
|
+
"""Extract the outline from the raw outline."""
|
184
|
+
|
185
|
+
output_key: str = "article_outline_from_raw"
|
186
|
+
|
187
|
+
async def _execute(self, article_outline_raw_path: str | Path, **cxt) -> ArticleOutline:
|
188
|
+
logger.info(f"Extracting outline from raw: {Path(article_outline_raw_path).as_posix()}")
|
189
|
+
|
190
|
+
return ok(
|
191
|
+
await self.extract(ArticleOutline, safe_text_read(article_outline_raw_path)),
|
192
|
+
"Could not extract the outline from raw.",
|
193
|
+
)
|
194
|
+
|
195
|
+
|
180
196
|
class FixIntrospectedErrors(Action, Censor):
|
181
197
|
"""Fix introspected errors in the article outline."""
|
182
198
|
|
@@ -56,13 +56,13 @@ class WriteArticleContentRAG(Action, RAG, Extract):
|
|
56
56
|
async def _execute(
|
57
57
|
self,
|
58
58
|
article_outline: ArticleOutline,
|
59
|
-
writing_ruleset: RuleSet,
|
60
59
|
collection_name: str = "article_chunks",
|
60
|
+
supervisor: Optional[bool] = None,
|
61
61
|
**cxt,
|
62
62
|
) -> Article:
|
63
63
|
article = Article.from_outline(article_outline).update_ref(article_outline)
|
64
64
|
|
65
|
-
if self.supervisor:
|
65
|
+
if supervisor or (supervisor is None and self.supervisor):
|
66
66
|
await gather(
|
67
67
|
*[
|
68
68
|
self._supervisor_inner(article, article_outline, chap, sec, subsec)
|
@@ -98,9 +98,10 @@ class WriteArticleContentRAG(Action, RAG, Extract):
|
|
98
98
|
|
99
99
|
raw = await self.write_raw(article, article_outline, chap, sec, subsec, cm)
|
100
100
|
r_print(raw)
|
101
|
+
|
101
102
|
while not await confirm("Accept this version and continue?").ask_async():
|
102
103
|
if await confirm("Search for more refs?").ask_async():
|
103
|
-
new_refs = await self.search_database(article, article_outline, chap, sec, subsec)
|
104
|
+
new_refs = await self.search_database(article, article_outline, chap, sec, subsec, supervisor=True)
|
104
105
|
cm.add_chunks(await ask_retain([r.chunk for r in new_refs], new_refs))
|
105
106
|
|
106
107
|
instruction = await text("Enter the instructions to improve").ask_async()
|
@@ -185,6 +186,7 @@ class WriteArticleContentRAG(Action, RAG, Extract):
|
|
185
186
|
sec: ArticleSection,
|
186
187
|
subsec: ArticleSubsection,
|
187
188
|
extra_instruction: str = "",
|
189
|
+
supervisor: bool = False,
|
188
190
|
) -> List[ArticleChunk]:
|
189
191
|
"""Search database for related references."""
|
190
192
|
ref_q = ok(
|
@@ -199,7 +201,7 @@ class WriteArticleContentRAG(Action, RAG, Extract):
|
|
199
201
|
"Failed to refine query.",
|
200
202
|
)
|
201
203
|
|
202
|
-
if
|
204
|
+
if supervisor:
|
203
205
|
ref_q = await ask_retain(ref_q)
|
204
206
|
|
205
207
|
return await self.aretrieve(
|
fabricatio/models/action.py
CHANGED
@@ -18,6 +18,7 @@ from fabricatio.journal import logger
|
|
18
18
|
from fabricatio.models.generic import WithBriefing
|
19
19
|
from fabricatio.models.task import Task
|
20
20
|
from fabricatio.models.usages import LLMUsage, ToolBoxUsage
|
21
|
+
from fabricatio.utils import override_kwargs
|
21
22
|
from pydantic import Field, PrivateAttr
|
22
23
|
|
23
24
|
OUTPUT_KEY = "task_output"
|
@@ -55,7 +56,7 @@ class Action(WithBriefing, LLMUsage):
|
|
55
56
|
self.description = self.description or self.__class__.__doc__ or ""
|
56
57
|
|
57
58
|
@abstractmethod
|
58
|
-
async def _execute(self, *_:Any, **cxt) -> Any:
|
59
|
+
async def _execute(self, *_: Any, **cxt) -> Any:
|
59
60
|
"""Implement the core logic of the action.
|
60
61
|
|
61
62
|
Args:
|
@@ -95,11 +96,12 @@ class Action(WithBriefing, LLMUsage):
|
|
95
96
|
return f"## Your personality: \n{self.personality}\n# The action you are going to perform: \n{super().briefing}"
|
96
97
|
return f"# The action you are going to perform: \n{super().briefing}"
|
97
98
|
|
98
|
-
def to_task_output(self)->Self:
|
99
|
+
def to_task_output(self) -> Self:
|
99
100
|
"""Set the output key to OUTPUT_KEY and return the action instance."""
|
100
|
-
self.output_key=OUTPUT_KEY
|
101
|
+
self.output_key = OUTPUT_KEY
|
101
102
|
return self
|
102
103
|
|
104
|
+
|
103
105
|
class WorkFlow(WithBriefing, ToolBoxUsage):
|
104
106
|
"""Manages sequences of actions to fulfill tasks.
|
105
107
|
|
@@ -177,7 +179,7 @@ class WorkFlow(WithBriefing, ToolBoxUsage):
|
|
177
179
|
current_action = None
|
178
180
|
try:
|
179
181
|
# Process each action in sequence
|
180
|
-
for i,step in enumerate(self._instances):
|
182
|
+
for i, step in enumerate(self._instances):
|
181
183
|
current_action = step.name
|
182
184
|
logger.info(f"Executing step [{i}] >> {current_action}")
|
183
185
|
|
@@ -227,8 +229,13 @@ class WorkFlow(WithBriefing, ToolBoxUsage):
|
|
227
229
|
- Any extra_init_context values
|
228
230
|
"""
|
229
231
|
logger.debug(f"Initializing context for workflow: {self.name}")
|
230
|
-
|
231
|
-
|
232
|
+
ctx = override_kwargs(self.extra_init_context, **task.extra_init_context)
|
233
|
+
if self.task_input_key in ctx:
|
234
|
+
raise ValueError(
|
235
|
+
f"Task input key: `{self.task_input_key}`, which is reserved, is already set in the init context"
|
236
|
+
)
|
237
|
+
|
238
|
+
await self._context.put({self.task_input_key: task, **ctx})
|
232
239
|
|
233
240
|
def steps_fallback_to_self(self) -> Self:
|
234
241
|
"""Configure all steps to use this workflow's configuration as fallback.
|
@@ -245,7 +252,7 @@ class WorkFlow(WithBriefing, ToolBoxUsage):
|
|
245
252
|
Returns:
|
246
253
|
Self: The workflow instance for method chaining.
|
247
254
|
"""
|
248
|
-
self.provide_tools_to(i for i in self._instances if isinstance(i,ToolBoxUsage))
|
255
|
+
self.provide_tools_to(i for i in self._instances if isinstance(i, ToolBoxUsage))
|
249
256
|
return self
|
250
257
|
|
251
258
|
def update_init_context(self, /, **kwargs) -> Self:
|
fabricatio/models/task.py
CHANGED
@@ -4,7 +4,7 @@ It includes methods to manage the task's lifecycle, such as starting, finishing,
|
|
4
4
|
"""
|
5
5
|
|
6
6
|
from asyncio import Queue
|
7
|
-
from typing import Any, List, Optional, Self
|
7
|
+
from typing import Any, Dict, List, Optional, Self
|
8
8
|
|
9
9
|
from fabricatio.config import configs
|
10
10
|
from fabricatio.constants import TaskStatus
|
@@ -50,6 +50,18 @@ class Task[T](WithBriefing, ProposedAble, WithDependency):
|
|
50
50
|
|
51
51
|
_namespace: Event = PrivateAttr(default_factory=Event)
|
52
52
|
"""The namespace of the task as an event, which is generated from the namespace list."""
|
53
|
+
_extra_init_context: Dict = PrivateAttr(default_factory=dict)
|
54
|
+
"""Extra initialization context for the task, which is designed to override the one of the Workflow."""
|
55
|
+
|
56
|
+
@property
|
57
|
+
def extra_init_context(self) -> Dict:
|
58
|
+
"""Extra initialization context for the task, which is designed to override the one of the Workflow."""
|
59
|
+
return self._extra_init_context
|
60
|
+
|
61
|
+
def update_init_context(self, /, **kwargs) -> Self:
|
62
|
+
"""Update the extra initialization context for the task."""
|
63
|
+
self.extra_init_context.update(kwargs)
|
64
|
+
return self
|
53
65
|
|
54
66
|
def model_post_init(self, __context: Any) -> None:
|
55
67
|
"""Initialize the task with a namespace event."""
|
fabricatio/models/usages.py
CHANGED
@@ -31,7 +31,7 @@ from pydantic import BaseModel, ConfigDict, Field, NonNegativeInt, PositiveInt
|
|
31
31
|
|
32
32
|
if configs.cache.enabled and configs.cache.type:
|
33
33
|
litellm.enable_cache(type=configs.cache.type, **configs.cache.params)
|
34
|
-
logger.
|
34
|
+
logger.debug(f"{configs.cache.type.name} Cache enabled")
|
35
35
|
|
36
36
|
ROUTER = Router(
|
37
37
|
routing_strategy="usage-based-routing-v2",
|
fabricatio/utils.py
CHANGED
@@ -54,14 +54,14 @@ async def ask_retain[V](candidates: List[str], value_mapping: Optional[List[V]]
|
|
54
54
|
def override_kwargs(kwargs: Mapping[str, Any], **overrides) -> Dict[str, Any]:
|
55
55
|
"""Override the values in kwargs with the provided overrides."""
|
56
56
|
new_kwargs = dict(kwargs.items())
|
57
|
-
new_kwargs.update(
|
57
|
+
new_kwargs.update(overrides)
|
58
58
|
return new_kwargs
|
59
59
|
|
60
60
|
|
61
|
-
def fallback_kwargs(kwargs: Mapping[str, Any], **
|
62
|
-
"""Fallback the values in kwargs with the provided
|
61
|
+
def fallback_kwargs(kwargs: Mapping[str, Any], **fallbacks) -> Dict[str, Any]:
|
62
|
+
"""Fallback the values in kwargs with the provided fallbacks."""
|
63
63
|
new_kwargs = dict(kwargs.items())
|
64
|
-
new_kwargs.update({k: v for k, v in
|
64
|
+
new_kwargs.update({k: v for k, v in fallbacks.items() if k not in new_kwargs})
|
65
65
|
return new_kwargs
|
66
66
|
|
67
67
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: fabricatio
|
3
|
-
Version: 0.2.11.
|
3
|
+
Version: 0.2.11.dev3
|
4
4
|
Classifier: License :: OSI Approved :: MIT License
|
5
5
|
Classifier: Programming Language :: Rust
|
6
6
|
Classifier: Programming Language :: Python :: 3.12
|
@@ -20,18 +20,20 @@ Requires-Dist: pydantic-settings>=2.7.1
|
|
20
20
|
Requires-Dist: pymitter>=1.0.0
|
21
21
|
Requires-Dist: rich>=13.9.4
|
22
22
|
Requires-Dist: ujson>=5.10.0
|
23
|
-
Requires-Dist: fabricatio[calc,ftd,plot,qa,rag] ; extra == 'full'
|
23
|
+
Requires-Dist: fabricatio[calc,ftd,plot,qa,rag,cli] ; extra == 'full'
|
24
24
|
Requires-Dist: pymilvus>=2.5.4 ; extra == 'rag'
|
25
25
|
Requires-Dist: sympy>=1.13.3 ; extra == 'calc'
|
26
26
|
Requires-Dist: matplotlib>=3.10.1 ; extra == 'plot'
|
27
27
|
Requires-Dist: questionary>=2.1.0 ; extra == 'qa'
|
28
28
|
Requires-Dist: magika>=0.6.1 ; extra == 'ftd'
|
29
|
+
Requires-Dist: typer-slim[standard]>=0.15.2 ; extra == 'cli'
|
29
30
|
Provides-Extra: full
|
30
31
|
Provides-Extra: rag
|
31
32
|
Provides-Extra: calc
|
32
33
|
Provides-Extra: plot
|
33
34
|
Provides-Extra: qa
|
34
35
|
Provides-Extra: ftd
|
36
|
+
Provides-Extra: cli
|
35
37
|
License-File: LICENSE
|
36
38
|
Summary: A LLM multi-agent framework.
|
37
39
|
Keywords: ai,agents,multi-agent,llm,pyo3
|
@@ -1,6 +1,6 @@
|
|
1
|
-
fabricatio-0.2.11.
|
2
|
-
fabricatio-0.2.11.
|
3
|
-
fabricatio-0.2.11.
|
1
|
+
fabricatio-0.2.11.dev3.dist-info/METADATA,sha256=xdi73tDlxylje7XHzZ0RtsCrEJ4biCZm06ML_qDR3EQ,5120
|
2
|
+
fabricatio-0.2.11.dev3.dist-info/WHEEL,sha256=7FgAcpQES0h1xhfN9Ugve9FTUilU6sRAr1WJ5ph2cuw,108
|
3
|
+
fabricatio-0.2.11.dev3.dist-info/licenses/LICENSE,sha256=yDZaTLnOi03bi3Dk6f5IjhLUc5old2yOsihHWU0z-i0,1067
|
4
4
|
fabricatio/decorators.py,sha256=iuFCTtZ4VXwxJpM_z-CtrEpTaVZsv_eBFe5mOhe4wlo,8715
|
5
5
|
fabricatio/constants.py,sha256=JxtaKGTf0IQhM-MNCHtr6x85Ejg8FWYcie-Z_RupCBg,557
|
6
6
|
fabricatio/core.py,sha256=MaEKZ6DDmbdScAY-7F1gwGA6fr7ADX6Mz5rNVi2msFA,6277
|
@@ -21,10 +21,10 @@ fabricatio/models/extra/aricle_rag.py,sha256=2y9XBgCwi_9ZyMYEF2i3eKZO4oYEj4YgGtR
|
|
21
21
|
fabricatio/models/extra/article_base.py,sha256=K15Nw98DgLWZs-8CFrgJqE2r1GgpzFIuF_ftRHbB7yE,12516
|
22
22
|
fabricatio/models/extra/patches.py,sha256=_ghmnlvTZQq7UJyaH77mTZE9abjvxRJ2mgWHUbezUls,977
|
23
23
|
fabricatio/models/adv_kwargs_types.py,sha256=659KMMuvdVq1xJxavLbUAMWxPOAz0RP9bNaZm3hyz-4,1890
|
24
|
-
fabricatio/models/usages.py,sha256=
|
24
|
+
fabricatio/models/usages.py,sha256=FVRhh_AulXlJF9uUmJzKEdiLz-di0rAiaQm4snYEid0,32571
|
25
25
|
fabricatio/models/events.py,sha256=-9Xy8kcZug1tYwxmt3GpXtCkNfZUMSFvAH5HdZoRJTI,4030
|
26
|
-
fabricatio/models/task.py,sha256=
|
27
|
-
fabricatio/models/action.py,sha256=
|
26
|
+
fabricatio/models/task.py,sha256=O4v5T3HuzYblGeeqNzTDOCbulhGovR6olV2ojD0FJvk,10785
|
27
|
+
fabricatio/models/action.py,sha256=JPLp7VjX09FjaTxSeda4Zsywb1XU2lvdvPcWY70DtzQ,9841
|
28
28
|
fabricatio/toolboxes/fs.py,sha256=OQMdeokYxSNVrCZJAweJ0cYiK4k2QuEiNdIbS5IHIV8,705
|
29
29
|
fabricatio/toolboxes/__init__.py,sha256=dYm_Gd8XolSU_h4wnkA09dlaLDK146eeFz0CUgPZ8_c,380
|
30
30
|
fabricatio/toolboxes/arithmetic.py,sha256=sSTPkKI6-mb278DwQKFO9jKyzc9kCx45xNH7V6bGBpE,1307
|
@@ -34,16 +34,16 @@ fabricatio/fs/curd.py,sha256=QqwnyLdVALNnerYGXf6a0irqoPSNE9_GJV9bJ33kbl0,4610
|
|
34
34
|
fabricatio/fs/__init__.py,sha256=abIYGDiX5bZ9vSHfro1-OtogzD_3vuR71FZMvZt8820,750
|
35
35
|
fabricatio/rust_instances.py,sha256=i5fIt6XkE8UwUU4JarmPt50AZs8aJW6efaypSLGLl0I,303
|
36
36
|
fabricatio/config.py,sha256=NbZu1AnHzR2VFOvzuBP5TSb9Jo3k17ODVuhL1jmT4-c,17559
|
37
|
-
fabricatio/utils.py,sha256=
|
37
|
+
fabricatio/utils.py,sha256=BbH69s0TaJgy2idq5-5WEO5jgny1jQy7piG7B4YPuWc,2990
|
38
38
|
fabricatio/journal.py,sha256=Op0wC-JlZumnAc_aDmYM4ljnSNLoKEEMfcIRbCF69ow,455
|
39
39
|
fabricatio/rust.pyi,sha256=EEZTQquqkHZ1G29YUPICwb9SJBzKgCB1B0ILuFNUoR0,10143
|
40
40
|
fabricatio/__init__.py,sha256=OXoMMHJKHEB_vN97_34U4I5QpAKL9xnVQEVcBCvwBCg,986
|
41
41
|
fabricatio/actions/fs.py,sha256=nlTmk-tYDW158nz_fzlsNfuYJwj7j4BHn_MFY5hxdqs,934
|
42
42
|
fabricatio/actions/output.py,sha256=XudogHKTp-9qqB7fvqRRjtcKee3I-vZ0WepMeEE7qsI,6805
|
43
|
-
fabricatio/actions/article_rag.py,sha256=
|
43
|
+
fabricatio/actions/article_rag.py,sha256=gHRkrR9OaNEu71gJF3YsUt3c5Tr0y5e946xzoxOuNRk,13992
|
44
44
|
fabricatio/actions/rag.py,sha256=-bA7KkZEFfWEanAPHzYwRHG7zRlTZcNDI7HL3n-lDuE,3496
|
45
45
|
fabricatio/actions/__init__.py,sha256=ZMa1LeM5BNeqp-J-D32W-f5bD53-kdXGyt0zuueJofM,47
|
46
|
-
fabricatio/actions/article.py,sha256=
|
46
|
+
fabricatio/actions/article.py,sha256=syUjEyKppdT72Xd1LSXKR3Djo1aybRPeFRHRzifNhm0,10632
|
47
47
|
fabricatio/actions/rules.py,sha256=07ILsiwR250AUcKLPHTUPpWD_mPhPCfWKSkEAKcPv3A,3557
|
48
48
|
fabricatio/workflows/articles.py,sha256=ZDV5nqUKRo1GOuuKWeSV7ZI32FYZU7WiTrD4YDuCeEo,945
|
49
49
|
fabricatio/workflows/rag.py,sha256=uOZXprD479fUhLA6sYvEM8RWcVcUZXXtP0xRbTMPdHE,509
|
@@ -61,5 +61,5 @@ fabricatio/capabilities/propose.py,sha256=vOJvmmnMBHUQB6N1AmZNFw42jf7Bl2mBRNlBK1
|
|
61
61
|
fabricatio/capabilities/task.py,sha256=_BAQonNy5JH3JxhLmPGfn0nDvn_ENKXyOdql8EVXRLE,4362
|
62
62
|
fabricatio/capabilities/extract.py,sha256=b4_Tuc9O6Pe71y4Tj-JHMb4simdhduVR-rcfD9yW8RA,2425
|
63
63
|
fabricatio/rust.cpython-312-x86_64-linux-gnu.so,sha256=RMc1j9N5smoAD9ffKxSFOinOa3O2p7UlIf4y4n9F7lM,4435800
|
64
|
-
fabricatio-0.2.11.
|
65
|
-
fabricatio-0.2.11.
|
64
|
+
fabricatio-0.2.11.dev3.data/scripts/tdown,sha256=bb3sOe5zM95YbGfmmxLTz4ZK3o-SFFAJ6Mdu6clF5Q8,4585440
|
65
|
+
fabricatio-0.2.11.dev3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|