fabricatio 0.3.15.dev4__cp313-cp313-win_amd64.whl → 0.4.0__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.
Files changed (58) hide show
  1. fabricatio/__init__.py +9 -8
  2. fabricatio/actions/output.py +21 -22
  3. fabricatio/actions/rules.py +83 -83
  4. fabricatio/rust.cp313-win_amd64.pyd +0 -0
  5. fabricatio/workflows/rag.py +2 -1
  6. fabricatio-0.4.0.data/scripts/tdown.exe +0 -0
  7. {fabricatio-0.3.15.dev4.dist-info → fabricatio-0.4.0.dist-info}/METADATA +18 -16
  8. fabricatio-0.4.0.dist-info/RECORD +18 -0
  9. fabricatio/actions/article.py +0 -415
  10. fabricatio/actions/article_rag.py +0 -407
  11. fabricatio/capabilities/__init__.py +0 -1
  12. fabricatio/capabilities/advanced_judge.py +0 -20
  13. fabricatio/capabilities/advanced_rag.py +0 -61
  14. fabricatio/capabilities/censor.py +0 -105
  15. fabricatio/capabilities/check.py +0 -212
  16. fabricatio/capabilities/correct.py +0 -228
  17. fabricatio/capabilities/extract.py +0 -74
  18. fabricatio/capabilities/persist.py +0 -103
  19. fabricatio/capabilities/propose.py +0 -65
  20. fabricatio/capabilities/rag.py +0 -264
  21. fabricatio/capabilities/rating.py +0 -404
  22. fabricatio/capabilities/review.py +0 -114
  23. fabricatio/capabilities/task.py +0 -113
  24. fabricatio/decorators.py +0 -253
  25. fabricatio/emitter.py +0 -177
  26. fabricatio/fs/__init__.py +0 -35
  27. fabricatio/fs/curd.py +0 -153
  28. fabricatio/fs/readers.py +0 -61
  29. fabricatio/journal.py +0 -12
  30. fabricatio/models/action.py +0 -263
  31. fabricatio/models/adv_kwargs_types.py +0 -63
  32. fabricatio/models/extra/__init__.py +0 -1
  33. fabricatio/models/extra/advanced_judge.py +0 -32
  34. fabricatio/models/extra/aricle_rag.py +0 -286
  35. fabricatio/models/extra/article_base.py +0 -486
  36. fabricatio/models/extra/article_essence.py +0 -101
  37. fabricatio/models/extra/article_main.py +0 -286
  38. fabricatio/models/extra/article_outline.py +0 -46
  39. fabricatio/models/extra/article_proposal.py +0 -52
  40. fabricatio/models/extra/patches.py +0 -20
  41. fabricatio/models/extra/problem.py +0 -165
  42. fabricatio/models/extra/rag.py +0 -98
  43. fabricatio/models/extra/rule.py +0 -52
  44. fabricatio/models/generic.py +0 -812
  45. fabricatio/models/kwargs_types.py +0 -121
  46. fabricatio/models/role.py +0 -99
  47. fabricatio/models/task.py +0 -310
  48. fabricatio/models/tool.py +0 -328
  49. fabricatio/models/usages.py +0 -791
  50. fabricatio/parser.py +0 -114
  51. fabricatio/rust.pyi +0 -846
  52. fabricatio/utils.py +0 -156
  53. fabricatio/workflows/articles.py +0 -24
  54. fabricatio-0.3.15.dev4.data/scripts/tdown.exe +0 -0
  55. fabricatio-0.3.15.dev4.data/scripts/ttm.exe +0 -0
  56. fabricatio-0.3.15.dev4.dist-info/RECORD +0 -64
  57. {fabricatio-0.3.15.dev4.dist-info → fabricatio-0.4.0.dist-info}/WHEEL +0 -0
  58. {fabricatio-0.3.15.dev4.dist-info → fabricatio-0.4.0.dist-info}/licenses/LICENSE +0 -0
fabricatio/__init__.py CHANGED
@@ -1,12 +1,14 @@
1
1
  """Fabricatio is a Python library for building llm app using event-based agent structure."""
2
2
 
3
- from fabricatio import actions, capabilities, fs, models, parser, toolboxes, utils, workflows
4
- from fabricatio.journal import logger
5
- from fabricatio.models.action import Action, WorkFlow
6
- from fabricatio.models.role import Role
7
- from fabricatio.models.task import Task
8
- from fabricatio.models.tool import ToolBox
9
- from fabricatio.rust import CONFIG, TEMPLATE_MANAGER, Event
3
+ from fabricatio_core import fs, models, parser, utils
4
+ from fabricatio_core.journal import logger
5
+ from fabricatio_core.models.action import Action, WorkFlow
6
+ from fabricatio_core.models.role import Role
7
+ from fabricatio_core.models.task import Task
8
+ from fabricatio_core.models.tool import ToolBox
9
+ from fabricatio_core.rust import CONFIG, TEMPLATE_MANAGER, Event
10
+
11
+ from fabricatio import actions, toolboxes, workflows
10
12
 
11
13
  __all__ = [
12
14
  "CONFIG",
@@ -18,7 +20,6 @@ __all__ = [
18
20
  "ToolBox",
19
21
  "WorkFlow",
20
22
  "actions",
21
- "capabilities",
22
23
  "fs",
23
24
  "logger",
24
25
  "models",
@@ -3,11 +3,10 @@
3
3
  from pathlib import Path
4
4
  from typing import Any, Iterable, List, Mapping, Optional, Self, Sequence, Type
5
5
 
6
- from fabricatio.capabilities.persist import PersistentAble
7
6
  from fabricatio.fs import dump_text
8
7
  from fabricatio.journal import logger
9
8
  from fabricatio.models.action import Action
10
- from fabricatio.models.generic import FinalizedDumpAble, FromMapping, FromSequence
9
+ from fabricatio.models.generic import FinalizedDumpAble, FromMapping, FromSequence, PersistentAble
11
10
  from fabricatio.models.task import Task
12
11
  from fabricatio.models.usages import LLMUsage
13
12
  from fabricatio.rust import TEMPLATE_MANAGER
@@ -21,11 +20,11 @@ class DumpFinalizedOutput(Action, LLMUsage):
21
20
  dump_path: Optional[str] = None
22
21
 
23
22
  async def _execute(
24
- self,
25
- to_dump: FinalizedDumpAble,
26
- task_input: Optional[Task] = None,
27
- dump_path: Optional[str | Path] = None,
28
- **_,
23
+ self,
24
+ to_dump: FinalizedDumpAble,
25
+ task_input: Optional[Task] = None,
26
+ dump_path: Optional[str | Path] = None,
27
+ **_,
29
28
  ) -> str:
30
29
  dump_path = Path(
31
30
  dump_path
@@ -52,11 +51,11 @@ class RenderedDump(Action, LLMUsage):
52
51
  """The template name to render the data."""
53
52
 
54
53
  async def _execute(
55
- self,
56
- to_dump: FinalizedDumpAble,
57
- task_input: Optional[Task] = None,
58
- dump_path: Optional[str | Path] = None,
59
- **_,
54
+ self,
55
+ to_dump: FinalizedDumpAble,
56
+ task_input: Optional[Task] = None,
57
+ dump_path: Optional[str | Path] = None,
58
+ **_,
60
59
  ) -> str:
61
60
  dump_path = Path(
62
61
  dump_path
@@ -91,10 +90,10 @@ class PersistentAll(Action, LLMUsage):
91
90
  """Whether to remove the existing dir before dumping."""
92
91
 
93
92
  async def _execute(
94
- self,
95
- task_input: Optional[Task] = None,
96
- persist_dir: Optional[str | Path] = None,
97
- **cxt,
93
+ self,
94
+ task_input: Optional[Task] = None,
95
+ persist_dir: Optional[str | Path] = None,
96
+ **cxt,
98
97
  ) -> int:
99
98
  persist_dir = Path(
100
99
  persist_dir
@@ -124,7 +123,7 @@ class PersistentAll(Action, LLMUsage):
124
123
  v.persist(final_dir)
125
124
  count += 1
126
125
  if isinstance(v, Iterable) and any(
127
- persistent_ables := (pers for pers in v if isinstance(pers, PersistentAble))
126
+ persistent_ables := (pers for pers in v if isinstance(pers, PersistentAble))
128
127
  ):
129
128
  logger.info(f"Persisting collection {k} to {final_dir}")
130
129
  final_dir.mkdir(parents=True, exist_ok=True)
@@ -174,11 +173,11 @@ class RetrieveFromLatest[T: PersistentAble](RetrieveFromPersistent[T], FromMappi
174
173
 
175
174
  @classmethod
176
175
  def from_mapping(
177
- cls,
178
- mapping: Mapping[str, str | Path],
179
- *,
180
- retrieve_cls: Type[T],
181
- **kwargs,
176
+ cls,
177
+ mapping: Mapping[str, str | Path],
178
+ *,
179
+ retrieve_cls: Type[T],
180
+ **kwargs,
182
181
  ) -> List["RetrieveFromLatest[T]"]:
183
182
  """Create a list of `RetrieveFromLatest` from the mapping."""
184
183
  return [
@@ -1,83 +1,83 @@
1
- """A module containing the DraftRuleSet action."""
2
-
3
- from typing import Any, List, Mapping, Optional, Self, Tuple
4
-
5
- from fabricatio.capabilities.check import Check
6
- from fabricatio.journal import logger
7
- from fabricatio.models.action import Action
8
- from fabricatio.models.extra.rule import RuleSet
9
- from fabricatio.models.generic import FromMapping
10
- from fabricatio.utils import ok
11
-
12
-
13
- class DraftRuleSet(Action, Check, FromMapping):
14
- """Action to draft a ruleset based on a given requirement description."""
15
-
16
- output_key: str = "drafted_ruleset"
17
- """The key used to store the drafted ruleset in the context dictionary."""
18
-
19
- ruleset_requirement: Optional[str] = None
20
- """The natural language description of the desired ruleset characteristics."""
21
- rule_count: int = 0
22
- """The number of rules to generate in the ruleset (0 for no restriction)."""
23
-
24
- async def _execute(
25
- self,
26
- ruleset_requirement: Optional[str] = None,
27
- **_,
28
- ) -> Optional[RuleSet]:
29
- """Draft a ruleset based on the requirement description.
30
-
31
- Args:
32
- ruleset_requirement (str): Natural language description of desired ruleset characteristics
33
- rule_count (int): Number of rules to generate (0 for no restriction)
34
- **kwargs: Validation parameters for rule generation
35
-
36
- Returns:
37
- Optional[RuleSet]: Drafted ruleset object or None if generation fails
38
- """
39
- ruleset = await self.draft_ruleset(
40
- ruleset_requirement=ok(ruleset_requirement or self.ruleset_requirement, "No ruleset requirement provided"),
41
- rule_count=self.rule_count,
42
- )
43
- if ruleset:
44
- logger.info(f"Drafted Ruleset length: {len(ruleset.rules)}\n{ruleset.display()}")
45
- else:
46
- logger.warning(f"Drafting Rule Failed for:\n{ruleset_requirement}")
47
- return ruleset
48
-
49
- @classmethod
50
- def from_mapping(cls, mapping: Mapping[str, Tuple[int, str]], **kwargs) -> List[Self]:
51
- """Create a list of DraftRuleSet actions from a mapping of output keys to tuples of rule counts and requirements."""
52
- return [cls(ruleset_requirement=r, rule_count=c, output_key=k, **kwargs) for k, (c, r) in mapping.items()]
53
-
54
-
55
- class GatherRuleset(Action, FromMapping):
56
- """Action to gather a ruleset from a given requirement description."""
57
-
58
- output_key: str = "gathered_ruleset"
59
- """The key used to store the drafted ruleset in the context dictionary."""
60
-
61
- to_gather: List[str]
62
- """the cxt name of RuleSet to gather"""
63
-
64
- @classmethod
65
- def from_mapping(cls, mapping: Mapping[str, List[str]], **kwargs: Any) -> List[Self]:
66
- """Create a list of GatherRuleset actions from a mapping of output keys to tuples of rule counts and requirements."""
67
- return [cls(to_gather=t, output_key=k, **kwargs) for k, t in mapping.items()]
68
-
69
- async def _execute(self, **cxt) -> RuleSet:
70
- logger.info(f"Gathering Ruleset from {self.to_gather}")
71
- # Fix for not_found
72
- not_found = next((t for t in self.to_gather if t not in cxt), None)
73
- if not_found:
74
- raise ValueError(
75
- f"Not all required keys found in context: {self.to_gather}|`{not_found}` not found in context."
76
- )
77
-
78
- # Fix for invalid RuleSet check
79
- invalid = next((t for t in self.to_gather if not isinstance(cxt[t], RuleSet)), None)
80
- if invalid is not None:
81
- raise TypeError(f"Invalid RuleSet instance for key `{invalid}`")
82
-
83
- return RuleSet.gather(*[cxt[t] for t in self.to_gather])
1
+ """A module containing the DraftRuleSet action."""
2
+
3
+ from typing import Any, List, Mapping, Optional, Self, Tuple
4
+
5
+ from fabricatio.capabilities.check import Check
6
+ from fabricatio.journal import logger
7
+ from fabricatio.models.action import Action
8
+ from fabricatio.models.extra.rule import RuleSet
9
+ from fabricatio.models.generic import FromMapping
10
+ from fabricatio.utils import ok
11
+
12
+
13
+ class DraftRuleSet(Action, Check, FromMapping):
14
+ """Action to draft a ruleset based on a given requirement description."""
15
+
16
+ output_key: str = "drafted_ruleset"
17
+ """The key used to store the drafted ruleset in the context dictionary."""
18
+
19
+ ruleset_requirement: Optional[str] = None
20
+ """The natural language description of the desired ruleset characteristics."""
21
+ rule_count: int = 0
22
+ """The number of rules to generate in the ruleset (0 for no restriction)."""
23
+
24
+ async def _execute(
25
+ self,
26
+ ruleset_requirement: Optional[str] = None,
27
+ **_,
28
+ ) -> Optional[RuleSet]:
29
+ """Draft a ruleset based on the requirement description.
30
+
31
+ Args:
32
+ ruleset_requirement (str): Natural language description of desired ruleset characteristics
33
+ rule_count (int): Number of rules to generate (0 for no restriction)
34
+ **kwargs: Validation parameters for rule generation
35
+
36
+ Returns:
37
+ Optional[RuleSet]: Drafted ruleset object or None if generation fails
38
+ """
39
+ ruleset = await self.draft_ruleset(
40
+ ruleset_requirement=ok(ruleset_requirement or self.ruleset_requirement, "No ruleset requirement provided"),
41
+ rule_count=self.rule_count,
42
+ )
43
+ if ruleset:
44
+ logger.info(f"Drafted Ruleset length: {len(ruleset.rules)}\n{ruleset.display()}")
45
+ else:
46
+ logger.warning(f"Drafting Rule Failed for:\n{ruleset_requirement}")
47
+ return ruleset
48
+
49
+ @classmethod
50
+ def from_mapping(cls, mapping: Mapping[str, Tuple[int, str]], **kwargs) -> List[Self]:
51
+ """Create a list of DraftRuleSet actions from a mapping of output keys to tuples of rule counts and requirements."""
52
+ return [cls(ruleset_requirement=r, rule_count=c, output_key=k, **kwargs) for k, (c, r) in mapping.items()]
53
+
54
+
55
+ class GatherRuleset(Action, FromMapping):
56
+ """Action to gather a ruleset from a given requirement description."""
57
+
58
+ output_key: str = "gathered_ruleset"
59
+ """The key used to store the drafted ruleset in the context dictionary."""
60
+
61
+ to_gather: List[str]
62
+ """the cxt name of RuleSet to gather"""
63
+
64
+ @classmethod
65
+ def from_mapping(cls, mapping: Mapping[str, List[str]], **kwargs: Any) -> List[Self]:
66
+ """Create a list of GatherRuleset actions from a mapping of output keys to tuples of rule counts and requirements."""
67
+ return [cls(to_gather=t, output_key=k, **kwargs) for k, t in mapping.items()]
68
+
69
+ async def _execute(self, **cxt) -> RuleSet:
70
+ logger.info(f"Gathering Ruleset from {self.to_gather}")
71
+ # Fix for not_found
72
+ not_found = next((t for t in self.to_gather if t not in cxt), None)
73
+ if not_found:
74
+ raise ValueError(
75
+ f"Not all required keys found in context: {self.to_gather}|`{not_found}` not found in context."
76
+ )
77
+
78
+ # Fix for invalid RuleSet check
79
+ invalid = next((t for t in self.to_gather if not isinstance(cxt[t], RuleSet)), None)
80
+ if invalid is not None:
81
+ raise TypeError(f"Invalid RuleSet instance for key `{invalid}`")
82
+
83
+ return RuleSet.gather(*[cxt[t] for t in self.to_gather])
Binary file
@@ -1,8 +1,9 @@
1
1
  """The workflow for extracting the essence of an article and storing it in the database."""
2
2
 
3
+ from fabricatio_core.models.action import WorkFlow
4
+
3
5
  from fabricatio.actions.article import ExtractArticleEssence
4
6
  from fabricatio.actions.rag import InjectToDB
5
- from fabricatio.models.action import WorkFlow
6
7
 
7
8
  StoreArticle = WorkFlow(
8
9
  name="Extract Article Essence",
Binary file
@@ -1,33 +1,32 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fabricatio
3
- Version: 0.3.15.dev4
3
+ Version: 0.4.0
4
4
  Classifier: License :: OSI Approved :: MIT License
5
5
  Classifier: Programming Language :: Rust
6
6
  Classifier: Programming Language :: Python :: 3.12
7
+ Classifier: Programming Language :: Python :: 3.13
7
8
  Classifier: Programming Language :: Python :: Implementation :: CPython
8
9
  Classifier: Framework :: AsyncIO
9
10
  Classifier: Framework :: Pydantic :: 2
10
11
  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'
12
+ Requires-Dist: fabricatio-core
13
+ Requires-Dist: fabricatio-capabilities
14
+ Requires-Dist: fabricatio[ftd,qa,rag,cli,typst,rule,judge] ; extra == 'full'
15
+ Requires-Dist: fabricatio-rag ; extra == 'rag'
16
+ Requires-Dist: fabricatio-judge ; extra == 'judge'
17
+ Requires-Dist: fabricatio-rule ; extra == 'rule'
23
18
  Requires-Dist: questionary>=2.1.0 ; extra == 'qa'
24
19
  Requires-Dist: magika>=0.6.1 ; extra == 'ftd'
25
20
  Requires-Dist: typer-slim[standard]>=0.15.2 ; extra == 'cli'
21
+ Requires-Dist: fabricatio-typst ; extra == 'typst'
26
22
  Provides-Extra: full
27
23
  Provides-Extra: rag
24
+ Provides-Extra: judge
25
+ Provides-Extra: rule
28
26
  Provides-Extra: qa
29
27
  Provides-Extra: ftd
30
28
  Provides-Extra: cli
29
+ Provides-Extra: typst
31
30
  License-File: LICENSE
32
31
  Summary: A LLM multi-agent framework.
33
32
  Keywords: ai,agents,multi-agent,llm,pyo3
@@ -65,8 +64,11 @@ pip install uv
65
64
  git clone https://github.com/Whth/fabricatio.git
66
65
  cd fabricatio
67
66
 
68
- # Install the package in development mode with uv
69
- uv --with-editable . maturin develop --uv -r
67
+ # Install the package in development mode with uvx
68
+ uvx --with-editable . maturin develop --uv -r
69
+
70
+ # Or, with make
71
+ make dev
70
72
  ```
71
73
 
72
74
  ### Building Distribution
@@ -153,7 +155,7 @@ max_tokens = 8192
153
155
  ```
154
156
  2. **Install Dependencies**:
155
157
  ```bash
156
- uv --with-editable . maturin develop --uv -r
158
+ make dev
157
159
  ```
158
160
  3. **Run Tests**:
159
161
  ```bash
@@ -0,0 +1,18 @@
1
+ fabricatio-0.4.0.data/scripts/tdown.exe,sha256=wJB4uqkaC7lj5SdJTbsBoa6Cz-Bl_WC-jnZeabGwfic,3378176
2
+ fabricatio-0.4.0.dist-info/METADATA,sha256=f0SYcL4jgeWa4X3giEG6zJZ6qXActgZQ0ynZuJXO2ds,5189
3
+ fabricatio-0.4.0.dist-info/WHEEL,sha256=Fk195VgSS-LCRRJAxz6O39eu2NdDhBCq3h9q4zoTguY,96
4
+ fabricatio-0.4.0.dist-info/licenses/LICENSE,sha256=do7J7EiCGbq0QPbMAL_FqLYufXpHnCnXBOuqVPwSV8Y,1088
5
+ fabricatio/__init__.py,sha256=9YbjjPgR_-rvuXt86oNLXZodDm3zltnMNmhP-1pESvE,786
6
+ fabricatio/actions/__init__.py,sha256=wVENCFtpVb1rLFxoOFJt9-8smLWXuJV7IwA8P3EfFz4,48
7
+ fabricatio/actions/fs.py,sha256=gJR14U4ln35nt8Z7OWLVAZpqGaLnED-r1Yi-lX22tkI,959
8
+ fabricatio/actions/output.py,sha256=nYKCUkNyAVziJmKS_Hdxnb015CrHRFdLJuQJlkEyB1s,9971
9
+ fabricatio/actions/rag.py,sha256=vgCzIfbSd3_vL3QxB12PY4h12V9Pe3sZRsWme0KC6X8,3583
10
+ fabricatio/actions/rules.py,sha256=07ILsiwR250AUcKLPHTUPpWD_mPhPCfWKSkEAKcPv3A,3557
11
+ fabricatio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ fabricatio/rust.cp313-win_amd64.pyd,sha256=L-c7Su6i5T4fqbGfJU8pqQW5Vx4kaDM1gvidnlFmp9g,176128
13
+ fabricatio/toolboxes/__init__.py,sha256=KBJi5OG_pExscdlM7Bnt_UF43j4I3Lv6G71kPVu4KQU,395
14
+ fabricatio/toolboxes/arithmetic.py,sha256=WLqhY-Pikv11Y_0SGajwZx3WhsLNpHKf9drzAqOf_nY,1369
15
+ fabricatio/toolboxes/fs.py,sha256=l4L1CVxJmjw9Ld2XUpIlWfV0_Fu_2Og6d3E13I-S4aE,736
16
+ fabricatio/workflows/__init__.py,sha256=5ScFSTA-bvhCesj3U9Mnmi6Law6N1fmh5UKyh58L3u8,51
17
+ fabricatio/workflows/rag.py,sha256=O8qCLhZTJTEj72R7W6Nq3WFg2I42arzQJkIGaeDdpss,527
18
+ fabricatio-0.4.0.dist-info/RECORD,,