fabricatio 0.2.8.dev4__cp312-cp312-win_amd64.whl → 0.2.9.dev1__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.
Files changed (33) hide show
  1. fabricatio/__init__.py +4 -11
  2. fabricatio/actions/__init__.py +1 -0
  3. fabricatio/actions/article.py +3 -2
  4. fabricatio/actions/rag.py +2 -1
  5. fabricatio/actions/rules.py +39 -0
  6. fabricatio/capabilities/__init__.py +1 -0
  7. fabricatio/capabilities/censor.py +3 -0
  8. fabricatio/capabilities/check.py +6 -5
  9. fabricatio/capabilities/correct.py +1 -1
  10. fabricatio/capabilities/rag.py +5 -4
  11. fabricatio/capabilities/rating.py +4 -3
  12. fabricatio/capabilities/review.py +1 -1
  13. fabricatio/capabilities/task.py +2 -1
  14. fabricatio/config.py +2 -0
  15. fabricatio/models/action.py +10 -2
  16. fabricatio/models/extra/__init__.py +1 -0
  17. fabricatio/models/extra/patches.py +16 -3
  18. fabricatio/models/extra/rule.py +26 -7
  19. fabricatio/models/generic.py +272 -56
  20. fabricatio/models/task.py +1 -1
  21. fabricatio/models/tool.py +149 -14
  22. fabricatio/models/usages.py +39 -26
  23. fabricatio/rust.cp312-win_amd64.pyd +0 -0
  24. fabricatio/{_rust.pyi → rust.pyi} +3 -0
  25. fabricatio/{_rust_instances.py → rust_instances.py} +1 -1
  26. fabricatio/workflows/__init__.py +1 -0
  27. fabricatio-0.2.9.dev1.data/scripts/tdown.exe +0 -0
  28. {fabricatio-0.2.8.dev4.dist-info → fabricatio-0.2.9.dev1.dist-info}/METADATA +1 -1
  29. {fabricatio-0.2.8.dev4.dist-info → fabricatio-0.2.9.dev1.dist-info}/RECORD +31 -26
  30. fabricatio/_rust.cp312-win_amd64.pyd +0 -0
  31. fabricatio-0.2.8.dev4.data/scripts/tdown.exe +0 -0
  32. {fabricatio-0.2.8.dev4.dist-info → fabricatio-0.2.9.dev1.dist-info}/WHEEL +0 -0
  33. {fabricatio-0.2.8.dev4.dist-info → fabricatio-0.2.9.dev1.dist-info}/licenses/LICENSE +0 -0
@@ -1,18 +1,18 @@
1
- """This module defines generic classes for models in the Fabricatio library."""
1
+ """This module defines generic classes for models in the Fabricatio library, providing a foundation for various model functionalities."""
2
2
 
3
3
  from abc import ABC, abstractmethod
4
4
  from datetime import datetime
5
5
  from pathlib import Path
6
- from typing import Any, Callable, Dict, Iterable, List, Optional, Self, Union, final, overload
6
+ from typing import Any, Callable, Dict, Iterable, List, Optional, Self, Type, Union, final, overload
7
7
 
8
8
  import orjson
9
9
  import rtoml
10
- from fabricatio._rust import blake3_hash
11
- from fabricatio._rust_instances import TEMPLATE_MANAGER
12
10
  from fabricatio.config import configs
13
11
  from fabricatio.fs.readers import MAGIKA, safe_text_read
14
12
  from fabricatio.journal import logger
15
13
  from fabricatio.parser import JsonCapture
14
+ from fabricatio.rust import blake3_hash
15
+ from fabricatio.rust_instances import TEMPLATE_MANAGER
16
16
  from fabricatio.utils import ok
17
17
  from litellm.utils import token_counter
18
18
  from pydantic import (
@@ -30,13 +30,19 @@ from pydantic.json_schema import GenerateJsonSchema, JsonSchemaValue
30
30
 
31
31
 
32
32
  class Base(BaseModel):
33
- """Base class for all models with Pydantic configuration."""
33
+ """Base class for all models with Pydantic configuration.
34
+
35
+ This class sets up the basic Pydantic configuration for all models in the Fabricatio library.
36
+ """
34
37
 
35
38
  model_config = ConfigDict(use_attribute_docstrings=True)
36
39
 
37
40
 
38
41
  class Display(Base):
39
- """Class that provides a method to display the model in a formatted JSON string."""
42
+ """Class that provides a method to display the model in a formatted JSON string.
43
+
44
+ This class includes methods to display the model in both formatted and compact JSON strings.
45
+ """
40
46
 
41
47
  def display(self) -> str:
42
48
  """Display the model in a formatted JSON string.
@@ -56,26 +62,46 @@ class Display(Base):
56
62
 
57
63
  @staticmethod
58
64
  def seq_display(seq: Iterable["Display"], compact: bool = False) -> str:
59
- """Display a sequence of Display objects in a formatted JSON string."""
65
+ """Display a sequence of Display objects in a formatted JSON string.
66
+
67
+ Args:
68
+ seq (Iterable[Display]): The sequence of Display objects to display.
69
+ compact (bool): Whether to display the sequence in a compact format. Defaults to False.
70
+
71
+ Returns:
72
+ str: The formatted JSON string of the sequence.
73
+ """
60
74
  return "\n".join(d.compact() if compact else d.display() for d in seq)
61
75
 
62
76
 
63
77
  class Named(Base):
64
- """Class that includes a name attribute."""
78
+ """Class that includes a name attribute.
79
+
80
+ This class adds a name attribute to models, which is intended to be a unique identifier.
81
+ """
65
82
 
66
- name: str = Field(frozen=True)
67
- """The name of the object."""
83
+ name: str
84
+ """The name of this object,briefly and conclusively."""
68
85
 
69
86
 
70
87
  class Described(Base):
71
- """Class that includes a description attribute."""
88
+ """Class that includes a description attribute.
72
89
 
73
- description: str = Field(frozen=True)
74
- """The description of the object."""
90
+ This class adds a description attribute to models, providing additional context or information.
91
+ """
92
+
93
+ description: str
94
+ """A comprehensive description of this object, including its purpose, scope, and context.
95
+ This should clearly explain what this object is about, why it exists, and in what situations
96
+ it applies. The description should be detailed enough to provide full understanding of
97
+ this object's intent and application."""
75
98
 
76
99
 
77
100
  class AsPrompt(Base):
78
- """Class that provides a method to generate a prompt from the model."""
101
+ """Class that provides a method to generate a prompt from the model.
102
+
103
+ This class includes a method to generate a prompt based on the model's attributes.
104
+ """
79
105
 
80
106
  @final
81
107
  def as_prompt(self) -> str:
@@ -90,31 +116,53 @@ class AsPrompt(Base):
90
116
  )
91
117
 
92
118
  @abstractmethod
93
- def _as_prompt_inner(self) -> Dict[str, str]: ...
119
+ def _as_prompt_inner(self) -> Dict[str, str]:
120
+ """Generate the inner part of the prompt.
121
+
122
+ This method should be implemented by subclasses to provide the specific data for the prompt.
123
+
124
+ Returns:
125
+ Dict[str, str]: The data for the prompt.
126
+ """
94
127
 
95
128
 
96
129
  class WithRef[T](Base):
97
- """Class that provides a reference to another object."""
130
+ """Class that provides a reference to another object.
131
+
132
+ This class manages a reference to another object, allowing for easy access and updates.
133
+ """
98
134
 
99
135
  _reference: Optional[T] = PrivateAttr(None)
100
136
 
101
137
  @property
102
138
  def referenced(self) -> T:
103
- """Get the referenced object."""
139
+ """Get the referenced object.
140
+
141
+ Returns:
142
+ T: The referenced object.
143
+
144
+ Raises:
145
+ ValueError: If the reference is not set.
146
+ """
104
147
  return ok(
105
- self._reference, f"`{self.__class__.__name__}`' s `_reference` field is None. Have you called `update_ref`?"
148
+ self._reference, f"`{self.__class__.__name__}`'s `_reference` field is None. Have you called `update_ref`?"
106
149
  )
107
150
 
108
151
  @overload
109
152
  def update_ref[S: WithRef](self: S, reference: T) -> S: ...
110
-
111
153
  @overload
112
154
  def update_ref[S: WithRef](self: S, reference: "WithRef[T]") -> S: ...
113
-
114
155
  @overload
115
156
  def update_ref[S: WithRef](self: S, reference: None = None) -> S: ...
116
157
  def update_ref[S: WithRef](self: S, reference: Union[T, "WithRef[T]", None] = None) -> S: # noqa: PYI019
117
- """Update the reference of the object."""
158
+ """Update the reference of the object.
159
+
160
+ Args:
161
+ reference (Union[T, WithRef[T], None]): The new reference to set.
162
+
163
+ Returns:
164
+ S: The current instance with the updated reference.
165
+ """
118
166
  if isinstance(reference, self.__class__):
119
167
  self._reference = reference.referenced
120
168
  else:
@@ -122,14 +170,24 @@ class WithRef[T](Base):
122
170
  return self
123
171
 
124
172
  def derive[S: WithRef](self: S, reference: Any) -> S: # noqa: PYI019
125
- """Derive a new object from the current object."""
173
+ """Derive a new object from the current object.
174
+
175
+ Args:
176
+ reference (Any): The reference for the new object.
177
+
178
+ Returns:
179
+ S: A new instance derived from the current object with the provided reference.
180
+ """
126
181
  new = self.model_copy()
127
182
  new._reference = reference
128
183
  return new
129
184
 
130
185
 
131
186
  class PersistentAble(Base):
132
- """Class that provides a method to persist the object."""
187
+ """Class that provides a method to persist the object.
188
+
189
+ This class includes methods to persist the object to a file or directory.
190
+ """
133
191
 
134
192
  def persist(self, path: str | Path) -> Self:
135
193
  """Persist the object to a file or directory.
@@ -174,19 +232,47 @@ class PersistentAble(Base):
174
232
  return cls.model_validate_json(safe_text_read(path))
175
233
 
176
234
 
235
+ class Language(Base):
236
+ """Class that provides a language attribute."""
237
+
238
+ language: str
239
+ """The written language of this object, which should be aligned to the original requirement
240
+ For example if the requirement is in Chinese, the language should be set to `zh`, if the requirement is in English, the language should be set to `en` and etc."""
241
+
242
+
177
243
  class ModelHash(Base):
178
- """Class that provides a hash value for the object."""
244
+ """Class that provides a hash value for the object.
245
+
246
+ This class includes a method to calculate a hash value for the object based on its JSON representation.
247
+ """
179
248
 
180
249
  def __hash__(self) -> int:
181
- """Calculates a hash value for the ArticleBase object based on its model_dump_json representation."""
250
+ """Calculates a hash value for the object based on its model_dump_json representation.
251
+
252
+ Returns:
253
+ int: The hash value of the object.
254
+ """
182
255
  return hash(self.model_dump_json())
183
256
 
184
257
 
185
258
  class UpdateFrom(Base):
186
- """Class that provides a method to update the object from another object."""
259
+ """Class that provides a method to update the object from another object.
260
+
261
+ This class includes methods to update the current object with the attributes of another object.
262
+ """
187
263
 
188
264
  def update_pre_check(self, other: Self) -> Self:
189
- """Pre-check for updating the object from another object."""
265
+ """Pre-check for updating the object from another object.
266
+
267
+ Args:
268
+ other (Self): The other object to update from.
269
+
270
+ Returns:
271
+ Self: The current instance after pre-check.
272
+
273
+ Raises:
274
+ TypeError: If the other object is not of the same type.
275
+ """
190
276
  if not isinstance(other, self.__class__):
191
277
  raise TypeError(f"Cannot update from a non-{self.__class__.__name__} instance.")
192
278
 
@@ -194,16 +280,35 @@ class UpdateFrom(Base):
194
280
 
195
281
  @abstractmethod
196
282
  def update_from_inner(self, other: Self) -> Self:
197
- """Updates the current instance with the attributes of another instance."""
283
+ """Updates the current instance with the attributes of another instance.
284
+
285
+ This method should be implemented by subclasses to provide the specific update logic.
286
+
287
+ Args:
288
+ other (Self): The other instance to update from.
289
+
290
+ Returns:
291
+ Self: The current instance with updated attributes.
292
+ """
198
293
 
199
294
  @final
200
295
  def update_from(self, other: Self) -> Self:
201
- """Updates the current instance with the attributes of another instance."""
296
+ """Updates the current instance with the attributes of another instance.
297
+
298
+ Args:
299
+ other (Self): The other instance to update from.
300
+
301
+ Returns:
302
+ Self: The current instance with updated attributes.
303
+ """
202
304
  return self.update_pre_check(other).update_from_inner(other)
203
305
 
204
306
 
205
307
  class ResolveUpdateConflict(Base):
206
- """Class that provides a method to update the object from another object."""
308
+ """Class that provides a method to update the object from another object.
309
+
310
+ This class includes a method to resolve conflicts when updating the object from another object.
311
+ """
207
312
 
208
313
  @abstractmethod
209
314
  def resolve_update_conflict(self, other: Self) -> str:
@@ -218,7 +323,10 @@ class ResolveUpdateConflict(Base):
218
323
 
219
324
 
220
325
  class Introspect(Base):
221
- """Class that provides a method to introspect the object."""
326
+ """Class that provides a method to introspect the object.
327
+
328
+ This class includes a method to perform internal introspection of the object.
329
+ """
222
330
 
223
331
  @abstractmethod
224
332
  def introspect(self) -> str:
@@ -230,7 +338,10 @@ class Introspect(Base):
230
338
 
231
339
 
232
340
  class WithBriefing(Named, Described):
233
- """Class that provides a briefing based on the name and description."""
341
+ """Class that provides a briefing based on the name and description.
342
+
343
+ This class combines the name and description attributes to provide a brief summary of the object.
344
+ """
234
345
 
235
346
  @property
236
347
  def briefing(self) -> str:
@@ -243,15 +354,29 @@ class WithBriefing(Named, Described):
243
354
 
244
355
 
245
356
  class UnsortGenerate(GenerateJsonSchema):
246
- """Class that provides a reverse JSON schema of the model."""
357
+ """Class that provides a reverse JSON schema of the model.
358
+
359
+ This class overrides the sorting behavior of the JSON schema generation to maintain the original order.
360
+ """
247
361
 
248
362
  def sort(self, value: JsonSchemaValue, parent_key: str | None = None) -> JsonSchemaValue:
249
- """Not sort."""
363
+ """Not sort.
364
+
365
+ Args:
366
+ value (JsonSchemaValue): The JSON schema value to sort.
367
+ parent_key (str | None): The parent key of the JSON schema value.
368
+
369
+ Returns:
370
+ JsonSchemaValue: The JSON schema value without sorting.
371
+ """
250
372
  return value
251
373
 
252
374
 
253
375
  class WithFormatedJsonSchema(Base):
254
- """Class that provides a formatted JSON schema of the model."""
376
+ """Class that provides a formatted JSON schema of the model.
377
+
378
+ This class includes a method to generate a formatted JSON schema of the model.
379
+ """
255
380
 
256
381
  @classmethod
257
382
  def formated_json_schema(cls) -> str:
@@ -267,25 +392,26 @@ class WithFormatedJsonSchema(Base):
267
392
 
268
393
 
269
394
  class CreateJsonObjPrompt(WithFormatedJsonSchema):
270
- """Class that provides a prompt for creating a JSON object."""
395
+ """Class that provides a prompt for creating a JSON object.
396
+
397
+ This class includes a method to create a prompt for creating a JSON object based on the model's schema and a requirement.
398
+ """
271
399
 
272
400
  @classmethod
273
401
  @overload
274
402
  def create_json_prompt(cls, requirement: List[str]) -> List[str]: ...
275
-
276
403
  @classmethod
277
404
  @overload
278
405
  def create_json_prompt(cls, requirement: str) -> str: ...
279
-
280
406
  @classmethod
281
407
  def create_json_prompt(cls, requirement: str | List[str]) -> str | List[str]:
282
408
  """Create the prompt for creating a JSON object with given requirement.
283
409
 
284
410
  Args:
285
- requirement (str): The requirement for the JSON object.
411
+ requirement (str | List[str]): The requirement for the JSON object.
286
412
 
287
413
  Returns:
288
- str: The prompt for creating a JSON object with given requirement.
414
+ str | List[str]: The prompt for creating a JSON object with given requirement.
289
415
  """
290
416
  if isinstance(requirement, str):
291
417
  return TEMPLATE_MANAGER.render_template(
@@ -302,7 +428,10 @@ class CreateJsonObjPrompt(WithFormatedJsonSchema):
302
428
 
303
429
 
304
430
  class InstantiateFromString(Base):
305
- """Class that provides a method to instantiate the class from a string."""
431
+ """Class that provides a method to instantiate the class from a string.
432
+
433
+ This class includes a method to instantiate the class from a JSON string representation.
434
+ """
306
435
 
307
436
  @classmethod
308
437
  def instantiate_from_string(cls, string: str) -> Self | None:
@@ -320,19 +449,31 @@ class InstantiateFromString(Base):
320
449
 
321
450
 
322
451
  class ProposedAble(CreateJsonObjPrompt, InstantiateFromString):
323
- """Class that provides a method to propose a JSON object based on the requirement."""
452
+ """Class that provides a method to propose a JSON object based on the requirement.
453
+
454
+ This class combines the functionality to create a prompt for a JSON object and instantiate it from a string.
455
+ """
324
456
 
325
457
 
326
458
  class SketchedAble(ProposedAble, Display):
327
- """Class that provides a method to scratch the object."""
459
+ """Class that provides a method to scratch the object.
460
+
461
+ This class combines the functionality to propose a JSON object, instantiate it from a string, and display it.
462
+ """
328
463
 
329
464
 
330
465
  class ProposedUpdateAble(SketchedAble, UpdateFrom, ABC):
331
- """Make the obj can be updated from the proposed obj in place."""
466
+ """Make the obj can be updated from the proposed obj in place.
467
+
468
+ This class provides the ability to update an object in place from a proposed object.
469
+ """
332
470
 
333
471
 
334
472
  class FinalizedDumpAble(Base):
335
- """Class that provides a method to finalize the dump of the object."""
473
+ """Class that provides a method to finalize the dump of the object.
474
+
475
+ This class includes methods to finalize the JSON representation of the object and dump it to a file.
476
+ """
336
477
 
337
478
  def finalized_dump(self) -> str:
338
479
  """Finalize the dump of the object.
@@ -355,10 +496,11 @@ class FinalizedDumpAble(Base):
355
496
  return self
356
497
 
357
498
 
358
-
359
-
360
499
  class WithDependency(Base):
361
- """Class that manages file dependencies."""
500
+ """Class that manages file dependencies.
501
+
502
+ This class includes methods to manage file dependencies required for reading or writing.
503
+ """
362
504
 
363
505
  dependencies: List[str] = Field(default_factory=list)
364
506
  """The file dependencies which is needed to read or write to meet a specific requirement, a list of file paths."""
@@ -446,7 +588,10 @@ class WithDependency(Base):
446
588
 
447
589
 
448
590
  class Vectorizable(Base):
449
- """Class that prepares the vectorization of the model."""
591
+ """Class that prepares the vectorization of the model.
592
+
593
+ This class includes methods to prepare the model for vectorization, ensuring it fits within a specified token length.
594
+ """
450
595
 
451
596
  def _prepare_vectorization_inner(self) -> str:
452
597
  return rtoml.dumps(self.model_dump())
@@ -455,20 +600,29 @@ class Vectorizable(Base):
455
600
  def prepare_vectorization(self, max_length: Optional[int] = None) -> str:
456
601
  """Prepare the vectorization of the model.
457
602
 
603
+ Args:
604
+ max_length (Optional[int]): The maximum token length for the vectorization. Defaults to the configuration.
605
+
458
606
  Returns:
459
607
  str: The prepared vectorization of the model.
608
+
609
+ Raises:
610
+ ValueError: If the chunk exceeds the maximum sequence length.
460
611
  """
461
612
  max_length = max_length or configs.embedding.max_sequence_length
462
613
  chunk = self._prepare_vectorization_inner()
463
614
  if max_length and (length := token_counter(text=chunk)) > max_length:
464
- logger.error(err := f"Chunk exceeds maximum sequence length {max_length}, got {length},see {chunk}")
615
+ logger.error(err := f"Chunk exceeds maximum sequence length {max_length}, got {length}, see {chunk}")
465
616
  raise ValueError(err)
466
617
 
467
618
  return chunk
468
619
 
469
620
 
470
621
  class ScopedConfig(Base):
471
- """Class that manages a scoped configuration."""
622
+ """Class that manages a scoped configuration.
623
+
624
+ This class includes attributes and methods to manage configuration settings scoped to the instance.
625
+ """
472
626
 
473
627
  llm_api_endpoint: Optional[HttpUrl] = None
474
628
  """The OpenAI API endpoint."""
@@ -526,15 +680,19 @@ class ScopedConfig(Base):
526
680
 
527
681
  embedding_dimensions: Optional[PositiveInt] = None
528
682
  """The dimensions of the embedding."""
683
+
529
684
  embedding_caching: Optional[bool] = False
530
685
  """Whether to cache the embedding result."""
531
686
 
532
687
  milvus_uri: Optional[HttpUrl] = Field(default=None)
533
688
  """The URI of the Milvus server."""
689
+
534
690
  milvus_token: Optional[SecretStr] = Field(default=None)
535
691
  """The token for the Milvus server."""
692
+
536
693
  milvus_timeout: Optional[PositiveFloat] = Field(default=None)
537
694
  """The timeout for the Milvus server."""
695
+
538
696
  milvus_dimensions: Optional[PositiveInt] = Field(default=None)
539
697
  """The dimensions of the Milvus server."""
540
698
 
@@ -579,30 +737,88 @@ class ScopedConfig(Base):
579
737
 
580
738
 
581
739
  class Patch[T](ProposedAble):
582
- """Base class for patches."""
740
+ """Base class for patches.
741
+
742
+ This class provides a base implementation for patches that can be applied to other objects.
743
+ """
583
744
 
584
745
  def apply(self, other: T) -> T:
585
- """Apply the patch to another instance."""
746
+ """Apply the patch to another instance.
747
+
748
+ Args:
749
+ other (T): The instance to apply the patch to.
750
+
751
+ Returns:
752
+ T: The instance with the patch applied.
753
+
754
+ Raises:
755
+ ValueError: If a field in the patch is not found in the target instance.
756
+ """
586
757
  for field in self.__class__.model_fields:
587
758
  if not hasattr(other, field):
588
759
  raise ValueError(f"{field} not found in {other}, are you applying to the wrong type?")
589
760
  setattr(other, field, getattr(self, field))
590
761
  return other
591
762
 
763
+ def as_kwargs(self) -> Dict[str, Any]:
764
+ """Get the kwargs of the patch."""
765
+ return self.model_dump()
766
+
767
+ @staticmethod
768
+ def ref_cls() -> Optional[Type[BaseModel]]:
769
+ """Get the reference class of the model."""
770
+ return None
771
+
772
+ @classmethod
773
+ def formated_json_schema(cls) -> str:
774
+ """Get the JSON schema of the model in a formatted string.
775
+
776
+ Returns:
777
+ str: The JSON schema of the model in a formatted string.
778
+ """
779
+ my_schema = cls.model_json_schema(schema_generator=UnsortGenerate)
780
+ if (ref_cls := cls.ref_cls()) is not None:
781
+ # copy the desc info of each corresponding fields from `ref_cls`
782
+ for field_name, field_info in cls.model_fields.items():
783
+ if (ref_field := getattr(ref_cls, field_name, None)) is not None:
784
+ if (desc := ref_field.field_info.description) is not None:
785
+ my_schema["properties"][field_name]["description"] = desc
786
+ if (example := ref_field.field_info.examples) is not None:
787
+ my_schema["properties"][field_name]["examples"] = example
788
+
789
+ return orjson.dumps(
790
+ my_schema,
791
+ option=orjson.OPT_INDENT_2,
792
+ ).decode()
793
+
592
794
 
593
795
  class SequencePatch[T](ProposedUpdateAble):
594
- """Base class for patches."""
796
+ """Base class for patches.
797
+
798
+ This class provides a base implementation for patches that can be applied to sequences of objects.
799
+ """
595
800
 
596
801
  tweaked: List[T]
597
802
  """Tweaked content list"""
598
803
 
599
804
  def update_from_inner(self, other: Self) -> Self:
600
- """Updates the current instance with the attributes of another instance."""
805
+ """Updates the current instance with the attributes of another instance.
806
+
807
+ Args:
808
+ other (Self): The other instance to update from.
809
+
810
+ Returns:
811
+ Self: The current instance with updated attributes.
812
+ """
601
813
  self.tweaked.clear()
602
814
  self.tweaked.extend(other.tweaked)
603
815
  return self
604
816
 
605
817
  @classmethod
606
818
  def default(cls) -> Self:
607
- """Defaults to empty list."""
819
+ """Defaults to empty list.
820
+
821
+ Returns:
822
+ Self: A new instance with an empty list of tweaks.
823
+ """
608
824
  return cls(tweaked=[])
fabricatio/models/task.py CHANGED
@@ -6,13 +6,13 @@ It includes methods to manage the task's lifecycle, such as starting, finishing,
6
6
  from asyncio import Queue
7
7
  from typing import Any, List, Optional, Self
8
8
 
9
- from fabricatio._rust_instances import TEMPLATE_MANAGER
10
9
  from fabricatio.config import configs
11
10
  from fabricatio.core import env
12
11
  from fabricatio.journal import logger
13
12
  from fabricatio.models.events import Event, EventLike
14
13
  from fabricatio.models.generic import ProposedAble, WithBriefing, WithDependency
15
14
  from fabricatio.models.utils import TaskStatus
15
+ from fabricatio.rust_instances import TEMPLATE_MANAGER
16
16
  from pydantic import Field, PrivateAttr
17
17
 
18
18