fabricatio 0.2.1.dev2__cp312-cp312-win_amd64.whl → 0.2.1.dev3__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.
Binary file
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,23 +1,23 @@
1
- fabricatio-0.2.1.dev2.dist-info/METADATA,sha256=jNZzL0ClVEXeLkJFlLjaTo9sRHoG27EISI0JmMOqqaE,12351
2
- fabricatio-0.2.1.dev2.dist-info/WHEEL,sha256=tpW5AN9B-9qsM9WW2FXG2r193YXiqexDadpKp0A2daI,96
3
- fabricatio-0.2.1.dev2.dist-info/licenses/LICENSE,sha256=do7J7EiCGbq0QPbMAL_FqLYufXpHnCnXBOuqVPwSV8Y,1088
1
+ fabricatio-0.2.1.dev3.dist-info/METADATA,sha256=OwlHmlzaQ2C89QQVzGZUKNkNHKb6rAjeAFRShKYSfkM,12351
2
+ fabricatio-0.2.1.dev3.dist-info/WHEEL,sha256=tpW5AN9B-9qsM9WW2FXG2r193YXiqexDadpKp0A2daI,96
3
+ fabricatio-0.2.1.dev3.dist-info/licenses/LICENSE,sha256=do7J7EiCGbq0QPbMAL_FqLYufXpHnCnXBOuqVPwSV8Y,1088
4
4
  fabricatio/actions/communication.py,sha256=NZxIIncKgJSDyBrqNebUtH_haqtxHa8ld2TZxT3CMdU,429
5
5
  fabricatio/actions/transmission.py,sha256=xpvKqbXqgpi1BWy-vUUvmd8NZ1GhRNfsYUBp-l2jLyk,862
6
6
  fabricatio/actions/__init__.py,sha256=eFmFVPQvtNgFynIXBVr3eP-vWQDWCPng60YY5LXvZgg,115
7
- fabricatio/config.py,sha256=hDYLpxn3ZrRjoSEGXGfC8s0URpebZyLHD45jU1UJOVo,10627
7
+ fabricatio/config.py,sha256=qHPChDvzoclDLuaykHr8qlJq1zE3RjU6jObSNe11C1Y,10822
8
8
  fabricatio/core.py,sha256=yQK2ZrbPYDJOaNDp0Bky3muTkB-ZaQ1ld_Qfflm2dY0,5938
9
9
  fabricatio/decorators.py,sha256=uzsP4tFKQNjDHBkofsjjoJA0IUAaYOtt6YVedoyOqlo,6551
10
10
  fabricatio/fs/curd.py,sha256=faMstgGUiQ4k2AW3OXfvvWWTldTtKXco7QINYaMjmyA,3981
11
11
  fabricatio/fs/readers.py,sha256=Pz1-cdZYtmqr032dsroImlkFXAd0kCYY_9qVpD4UrG4,1045
12
12
  fabricatio/fs/__init__.py,sha256=lWcKYg0v3mv2LnnSegOQaTtlVDODU0vtw_s6iKU5IqQ,122
13
13
  fabricatio/journal.py,sha256=siqimKF0M_QaaOCMxtjr_BJVNyUIAQWILzE9Q4T6-7c,781
14
- fabricatio/models/action.py,sha256=1V3upL79e3ekyGXA4bSY70N60yeL0aWak7ZPBVsFE3A,5652
15
- fabricatio/models/advanced.py,sha256=YknnBR89nFosHjbD9moyXm8vWx4uD57zUgtvRfKALLc,9704
14
+ fabricatio/models/action.py,sha256=VenovcZyR_ibwEy5Jpr4EaNP1L0hRqAjW0IhQNLdpNE,5676
15
+ fabricatio/models/advanced.py,sha256=xVzHqoO1glNdCqflKZF5FGkK5GQmfIMZpT_07zQi9KM,11420
16
16
  fabricatio/models/events.py,sha256=mrihNEFgQ5o7qFWja1z_qX8dnaTLwPBoJdVlzxQV5oM,2719
17
17
  fabricatio/models/generic.py,sha256=WEjZ96rTyBjaBjkM6e8E4Pg_Naot4xWRvGJteqBiCCI,5133
18
18
  fabricatio/models/kwargs_types.py,sha256=sVEkaeujQDNnQzTlisnjjVjrqS2g_wa4ROVbD86nHCE,1024
19
- fabricatio/models/role.py,sha256=RPdOcjmM6KNyH310Vx4524JQG94P5sXl_3doSrRpiKQ,1802
20
- fabricatio/models/task.py,sha256=hogTBx74IAKfKDWghhWFR7i-LVQAn7L9PQM5tyOA5Rk,9257
19
+ fabricatio/models/role.py,sha256=h_0NIKvPbmRam4jsZOCGOMaje4gy5jYjTMpM39oTaYI,1785
20
+ fabricatio/models/task.py,sha256=It4pUoaNIIC4Jw66KOG07Vp0bumCJZQo61KnR7HoGzM,9435
21
21
  fabricatio/models/tool.py,sha256=WTFnpF6xZ1nJbmIOonLsGQcM-kkDCeZiAFqyil9xg2U,6988
22
22
  fabricatio/models/usages.py,sha256=6qoh9w1xeC-olkQjiH1oZYgqxohp0GX4dwOmSrhMn0E,25756
23
23
  fabricatio/models/utils.py,sha256=i_kpcQpct04mQFk1nbcVGV-pl1YThWu4Qk3wbewzKkc,2535
@@ -30,6 +30,6 @@ fabricatio/toolboxes/__init__.py,sha256=b13KmASO8q5fBLwew964fn9oH86ER5g-S1PgA4fZ
30
30
  fabricatio/_rust.pyi,sha256=0wCqtwWkVxxoqprvk8T27T8QYKIAKHS7xgsmdMNjQKc,1756
31
31
  fabricatio/_rust_instances.py,sha256=dl0-yZ4UvT5g20tQgnPJpmqtkjFGXNG_YK4eLfi_ugQ,279
32
32
  fabricatio/__init__.py,sha256=opIrN8lGyT-h2If4Qez0bRuWBa3uIT9GsM9CZy7_XJ0,1100
33
- fabricatio/_rust.cp312-win_amd64.pyd,sha256=apS92eztfWPO-xRlnon15y0Pq7qPT1nRn652Pd2RBRw,1261056
34
- fabricatio-0.2.1.dev2.data/scripts/tdown.exe,sha256=f7ZxXFNyP5_SiScZWZcdWE0FJbTX7l4AAKZov5XpDHk,3397120
35
- fabricatio-0.2.1.dev2.dist-info/RECORD,,
33
+ fabricatio/_rust.cp312-win_amd64.pyd,sha256=p9QIx4phvmlr_ae1700OGjD1tVJRvkRCe9mWy_T4Z4U,1261056
34
+ fabricatio-0.2.1.dev3.data/scripts/tdown.exe,sha256=-jC9BrzFlXOyBsw3O3T4XTMqirtLGPXPtOE1gE4uh3M,3397120
35
+ fabricatio-0.2.1.dev3.dist-info/RECORD,,