fabricatio 0.2.1.dev2__cp312-cp312-manylinux_2_34_x86_64.whl → 0.2.1.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/config.py CHANGED
@@ -163,6 +163,9 @@ class TemplateConfig(BaseModel):
163
163
  draft_rating_manual_template: str = Field(default="draft_rating_manual")
164
164
  """The name of the draft rating manual template which will be used to draft rating manual."""
165
165
 
166
+ draft_rating_dimensions_template: str = Field(default="draft_rating_dimensions")
167
+ """The name of the draft rating dimensions template which will be used to draft rating dimensions."""
168
+
166
169
 
167
170
  class MagikaConfig(BaseModel):
168
171
  """Magika configuration class."""
@@ -6,14 +6,14 @@ from asyncio import Queue
6
6
  from typing import Any, Dict, Self, Tuple, Type, Union, Unpack
7
7
 
8
8
  from fabricatio.journal import logger
9
- from fabricatio.models.advanced import HandleTask, ProposeTask
9
+ from fabricatio.models.advanced import GiveRating, HandleTask, ProposeTask
10
10
  from fabricatio.models.generic import WithBriefing
11
11
  from fabricatio.models.task import Task
12
12
  from fabricatio.models.usages import ToolBoxUsage
13
13
  from pydantic import Field, PrivateAttr
14
14
 
15
15
 
16
- class Action(HandleTask, ProposeTask):
16
+ class Action(HandleTask, ProposeTask, GiveRating):
17
17
  """Class that represents an action to be executed in a workflow."""
18
18
 
19
19
  personality: str = Field(default="")
@@ -13,7 +13,7 @@ from fabricatio.models.tool import Tool, ToolExecutor
13
13
  from fabricatio.models.usages import LLMUsage, ToolBoxUsage
14
14
  from fabricatio.parser import JsonCapture, PythonCapture
15
15
  from loguru import logger
16
- from pydantic import ValidationError
16
+ from pydantic import NonNegativeInt, ValidationError
17
17
 
18
18
 
19
19
  class ProposeTask(WithBriefing, LLMUsage):
@@ -242,3 +242,48 @@ class GiveRating(WithBriefing, LLMUsage):
242
242
  system_message=f"# your personal briefing: \n{self.briefing}",
243
243
  **kwargs,
244
244
  )
245
+
246
+ async def draft_rating_dimensions(
247
+ self,
248
+ topic: str,
249
+ dimensions_count: NonNegativeInt = 0,
250
+ examples: Optional[List[str]] = None,
251
+ **kwargs: Unpack[ValidateKwargs],
252
+ ) -> Set[str]:
253
+ """Drafts rating dimensions based on a topic.
254
+
255
+ Args:
256
+ topic: The topic for the rating dimensions.
257
+ dimensions_count: The number of dimensions to draft, 0 means no limit.
258
+ examples: A list of examples which is rated based on the rating dimensions.
259
+ **kwargs: Additional keyword arguments for the LLM usage.
260
+
261
+ Returns:
262
+ A set of rating dimensions.
263
+ """
264
+
265
+ def _validator(response: str) -> Set[str] | None:
266
+ if (
267
+ (json_data := JsonCapture.convert_with(response, orjson.loads)) is not None
268
+ and isinstance(json_data, list)
269
+ and all(isinstance(v, str) for v in json_data)
270
+ and (dimensions_count == 0 or len(json_data) == dimensions_count)
271
+ ):
272
+ return set(json_data)
273
+ return None
274
+
275
+ return await self.aask_validate(
276
+ question=(
277
+ template_manager.render_template(
278
+ configs.templates.draft_rating_dimensions_template,
279
+ {
280
+ "topic": topic,
281
+ "examples": examples,
282
+ "dimensions_count": dimensions_count,
283
+ },
284
+ )
285
+ ),
286
+ validator=_validator,
287
+ system_message=f"# your personal briefing: \n{self.briefing}",
288
+ **kwargs,
289
+ )
fabricatio/models/role.py CHANGED
@@ -5,14 +5,13 @@ from typing import Any, Self, Set
5
5
  from fabricatio.core import env
6
6
  from fabricatio.journal import logger
7
7
  from fabricatio.models.action import WorkFlow
8
- from fabricatio.models.advanced import ProposeTask
8
+ from fabricatio.models.advanced import GiveRating, HandleTask, ProposeTask
9
9
  from fabricatio.models.events import Event
10
10
  from fabricatio.models.tool import ToolBox
11
- from fabricatio.models.usages import ToolBoxUsage
12
11
  from pydantic import Field
13
12
 
14
13
 
15
- class Role(ProposeTask, ToolBoxUsage):
14
+ class Role(ProposeTask, HandleTask, GiveRating):
16
15
  """Class that represents a role with a registry of events and workflows."""
17
16
 
18
17
  registry: dict[Event | str, WorkFlow] = Field(...)
fabricatio/models/task.py CHANGED
@@ -57,6 +57,9 @@ class Task[T](WithBriefing, WithJsonExample, WithDependency):
57
57
  namespace: List[str] = Field(default_factory=list)
58
58
  """The namespace of the task, a list of namespace segment, as string."""
59
59
 
60
+ dependencies: List[str] = Field(default_factory=list)
61
+ """A list of file paths, These file are needed to read or write to meet a specific requirement of this task."""
62
+
60
63
  _output: Queue = PrivateAttr(default_factory=lambda: Queue(maxsize=1))
61
64
  """The output queue of the task."""
62
65
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fabricatio
3
- Version: 0.2.1.dev2
3
+ Version: 0.2.1.dev3
4
4
  Classifier: License :: OSI Approved :: MIT License
5
5
  Classifier: Programming Language :: Rust
6
6
  Classifier: Programming Language :: Python :: 3.12
@@ -1,6 +1,6 @@
1
- fabricatio-0.2.1.dev2.dist-info/METADATA,sha256=VmxaVD6VdtZZigoDpY9_LUiSb9ePANneUvy2dlv6X5w,11972
2
- fabricatio-0.2.1.dev2.dist-info/WHEEL,sha256=RIvmwLDYujv60MYBx2jxyP4vdn1DD7X0kBgz1TQvZuc,108
3
- fabricatio-0.2.1.dev2.dist-info/licenses/LICENSE,sha256=yDZaTLnOi03bi3Dk6f5IjhLUc5old2yOsihHWU0z-i0,1067
1
+ fabricatio-0.2.1.dev3.dist-info/METADATA,sha256=HKe_w2CDh9Def3QfL-Hc5PFor_oplxEQZXKZ34E1h3E,11972
2
+ fabricatio-0.2.1.dev3.dist-info/WHEEL,sha256=RIvmwLDYujv60MYBx2jxyP4vdn1DD7X0kBgz1TQvZuc,108
3
+ fabricatio-0.2.1.dev3.dist-info/licenses/LICENSE,sha256=yDZaTLnOi03bi3Dk6f5IjhLUc5old2yOsihHWU0z-i0,1067
4
4
  fabricatio/fs/__init__.py,sha256=bYE9r8uR0dtknzbg_YaGv_6Wwa27ntkQt0Tl7Kb3HFI,117
5
5
  fabricatio/fs/readers.py,sha256=lqMrM5Nt3l6QJmPDoBno2PSaN2BbFwfUjBqaghrbK3A,1002
6
6
  fabricatio/fs/curd.py,sha256=g74Pc2WPSkPlCXX0cWj2jyiDYTfkLwpwM480eyCkmc8,3851
@@ -10,19 +10,19 @@ fabricatio/toolboxes/task.py,sha256=9J3W-48CCEUh5PFz0XEC47Hv23Ugn1BEg-J_woQE1UA,
10
10
  fabricatio/toolboxes/arithmetic.py,sha256=sSTPkKI6-mb278DwQKFO9jKyzc9kCx45xNH7V6bGBpE,1307
11
11
  fabricatio/__init__.py,sha256=h0FgwSAdI2yhxYiuQi46uFvzqkK5LfJLt5XsHZ9rWIo,1063
12
12
  fabricatio/core.py,sha256=apwXgI94DCWpGujGlsmXsTZQvJOQMB9llmuUo7ohd-4,5771
13
- fabricatio/config.py,sha256=w8VxjFd8dHIdCZW_c0KZkL-mnoi6FKbqJr3neHqqD7o,10357
13
+ fabricatio/config.py,sha256=M8VinyP4crwRYFcaTKekeOEOY4H03FbutpdfIU72moc,10549
14
14
  fabricatio/decorators.py,sha256=cJHsxxbnMhc4SzPl4454CPLuDP3H0qbTrzV_U2rLPrs,6372
15
15
  fabricatio/journal.py,sha256=bzxZay48ZWI0VIkkDXm4Wc_Cc9lBQYa2VGx3Hxy_PtA,753
16
16
  fabricatio/models/generic.py,sha256=4j6DRNkHLNhx8U6aijf0Cz9HSahtEPQBh22i6d_PGTs,4981
17
17
  fabricatio/models/kwargs_types.py,sha256=9LbvozHzlBijGjefWQEZZO4BrwcXjRcgtsRn_L4A768,993
18
- fabricatio/models/action.py,sha256=Kjq0ozqgPjHK0tP61k0yhrSZBxzE9m68MJCWZUUgh1c,5513
19
- fabricatio/models/task.py,sha256=0HXaf8Ig47UeMBN7n3iUp0oyOvN6-DlKxQForHnt8RI,8981
20
- fabricatio/models/role.py,sha256=TT_SxC1M8IawVA72BRI3h3KrK3XMb88UV7F897PuKyU,1754
18
+ fabricatio/models/action.py,sha256=ks7gWEMUT0p6Yrv8QAMj6x7lfOqaJt5xp_sc52ssh7I,5537
19
+ fabricatio/models/task.py,sha256=X2-Nivi_lG5j5u-I_ZqAY1mmDVCfHxQZK4-pQd0f5UM,9156
20
+ fabricatio/models/role.py,sha256=5hc11wF9hdiNHAhv3BirsbGPd-2GloaKZuJNnvs7g1s,1738
21
21
  fabricatio/models/tool.py,sha256=wgNXtobDSWZTVmIrSSaS5oyxhSUYWXhS0S2o9acE2ls,6800
22
22
  fabricatio/models/events.py,sha256=TkMSJYSzRgurbfY2knWIc8gYw7rmaWqB7KeYzy5jeWU,2637
23
23
  fabricatio/models/utils.py,sha256=u-eR_v-o0BSFSmCprP3mOyAO-WOyg_P68jjzLjyit_w,2457
24
24
  fabricatio/models/usages.py,sha256=xpUF6luEiQUyAvjc6xBdXwA5gZHGckPsT-g-49McwIg,25185
25
- fabricatio/models/advanced.py,sha256=l_T9ETDU3ttb-KgVGpGQA1DHmqWIYA70KI-9pocz5Do,9460
25
+ fabricatio/models/advanced.py,sha256=WCgz0RuWtS_GW1v7kvArL8VoBT3NMSLvKe924A0O7uQ,11131
26
26
  fabricatio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  fabricatio/_rust_instances.py,sha256=JAtO-vL8ihvduf1SHLNf0w7ZSVGCJeIv6zZ9Ekyy1hY,271
28
28
  fabricatio/actions/__init__.py,sha256=eLa_5ACZ-FqdrLtOfCHk5nQBxzhIs1kgMIXWmkm2P8Y,110
@@ -31,5 +31,5 @@ fabricatio/actions/transmission.py,sha256=WM-kssiqzTLZuZSiqbRvBaC2qynd9kjrKXya4f
31
31
  fabricatio/_rust.pyi,sha256=clhcURuiB9zlFo4m3VyoWQ8Xs4tvg6KNHXpF-ok9h4o,1703
32
32
  fabricatio/parser.py,sha256=Q4laV79Svggl09UKa3lAw6NYPuDz1sP2F-6U4tsSvQw,3429
33
33
  fabricatio/_rust.cpython-312-x86_64-linux-gnu.so,sha256=wyOQQQjki23ZQn48Lpv9_7NtIrbYBqX7MIS1z6NR6LY,1340176
34
- fabricatio-0.2.1.dev2.data/scripts/tdown,sha256=R0aC5Ur-Z8wjsaa8m2S2Q88Pa-5on2f8gnWpSrNV1SA,4571336
35
- fabricatio-0.2.1.dev2.dist-info/RECORD,,
34
+ fabricatio-0.2.1.dev3.data/scripts/tdown,sha256=R0aC5Ur-Z8wjsaa8m2S2Q88Pa-5on2f8gnWpSrNV1SA,4571336
35
+ fabricatio-0.2.1.dev3.dist-info/RECORD,,