fabricatio 0.3.14.dev7__cp313-cp313-win_amd64.whl → 0.3.15.dev5__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.
fabricatio/rust.pyi CHANGED
@@ -12,9 +12,10 @@ Key Features:
12
12
  """
13
13
 
14
14
  from enum import StrEnum
15
- from pydantic import JsonValue
15
+ from pathlib import Path
16
16
  from typing import Any, Dict, List, Literal, Optional, Self, Tuple, Union, overload
17
17
 
18
+ from pydantic import JsonValue
18
19
 
19
20
  class TemplateManager:
20
21
  """Template rendering engine using Handlebars templates.
@@ -47,10 +48,8 @@ class TemplateManager:
47
48
 
48
49
  @overload
49
50
  def render_template(self, name: str, data: Dict[str, Any]) -> str: ...
50
-
51
51
  @overload
52
52
  def render_template(self, name: str, data: List[Dict[str, Any]]) -> List[str]: ...
53
-
54
53
  def render_template(self, name: str, data: Dict[str, Any] | List[Dict[str, Any]]) -> str | List[str]:
55
54
  """Render a template with context data.
56
55
 
@@ -67,10 +66,8 @@ class TemplateManager:
67
66
 
68
67
  @overload
69
68
  def render_template_raw(self, template: str, data: Dict[str, Any]) -> str: ...
70
-
71
69
  @overload
72
70
  def render_template_raw(self, template: str, data: List[Dict[str, Any]]) -> List[str]: ...
73
-
74
71
  def render_template_raw(self, template: str, data: Dict[str, Any] | List[Dict[str, Any]]) -> str | List[str]:
75
72
  """Render a template with context data.
76
73
 
@@ -82,7 +79,6 @@ class TemplateManager:
82
79
  Rendered template content as string or list of strings
83
80
  """
84
81
 
85
-
86
82
  class BibManager:
87
83
  """BibTeX bibliography manager for parsing and querying citation data."""
88
84
 
@@ -191,7 +187,6 @@ class BibManager:
191
187
  Field value if found, None otherwise
192
188
  """
193
189
 
194
-
195
190
  def blake3_hash(content: bytes) -> str:
196
191
  """Calculate the BLAKE3 cryptographic hash of data.
197
192
 
@@ -202,11 +197,9 @@ def blake3_hash(content: bytes) -> str:
202
197
  Hex-encoded BLAKE3 hash string
203
198
  """
204
199
 
205
-
206
200
  def detect_language(string: str) -> str:
207
201
  """Detect the language of a given string."""
208
202
 
209
-
210
203
  def split_word_bounds(string: str) -> List[str]:
211
204
  """Split the string into words based on word boundaries.
212
205
 
@@ -217,7 +210,6 @@ def split_word_bounds(string: str) -> List[str]:
217
210
  A list of words extracted from the string.
218
211
  """
219
212
 
220
-
221
213
  def split_sentence_bounds(string: str) -> List[str]:
222
214
  """Split the string into sentences based on sentence boundaries.
223
215
 
@@ -228,7 +220,6 @@ def split_sentence_bounds(string: str) -> List[str]:
228
220
  A list of sentences extracted from the string.
229
221
  """
230
222
 
231
-
232
223
  def split_into_chunks(string: str, max_chunk_size: int, max_overlapping_rate: float = 0.3) -> List[str]:
233
224
  """Split the string into chunks of a specified size.
234
225
 
@@ -241,7 +232,6 @@ def split_into_chunks(string: str, max_chunk_size: int, max_overlapping_rate: fl
241
232
  A list of chunks extracted from the string.
242
233
  """
243
234
 
244
-
245
235
  def word_count(string: str) -> int:
246
236
  """Count the number of words in the string.
247
237
 
@@ -252,67 +242,51 @@ def word_count(string: str) -> int:
252
242
  The number of words in the string.
253
243
  """
254
244
 
255
-
256
245
  def is_chinese(string: str) -> bool:
257
246
  """Check if the given string is in Chinese."""
258
247
 
259
-
260
248
  def is_english(string: str) -> bool:
261
249
  """Check if the given string is in English."""
262
250
 
263
-
264
251
  def is_japanese(string: str) -> bool:
265
252
  """Check if the given string is in Japanese."""
266
253
 
267
-
268
254
  def is_korean(string: str) -> bool:
269
255
  """Check if the given string is in Korean."""
270
256
 
271
-
272
257
  def is_arabic(string: str) -> bool:
273
258
  """Check if the given string is in Arabic."""
274
259
 
275
-
276
260
  def is_russian(string: str) -> bool:
277
261
  """Check if the given string is in Russian."""
278
262
 
279
-
280
263
  def is_german(string: str) -> bool:
281
264
  """Check if the given string is in German."""
282
265
 
283
-
284
266
  def is_french(string: str) -> bool:
285
267
  """Check if the given string is in French."""
286
268
 
287
-
288
269
  def is_hindi(string: str) -> bool:
289
270
  """Check if the given string is in Hindi."""
290
271
 
291
-
292
272
  def is_italian(string: str) -> bool:
293
273
  """Check if the given string is in Italian."""
294
274
 
295
-
296
275
  def is_dutch(string: str) -> bool:
297
276
  """Check if the given string is in Dutch."""
298
277
 
299
-
300
278
  def is_portuguese(string: str) -> bool:
301
279
  """Check if the given string is in Portuguese."""
302
280
 
303
-
304
281
  def is_swedish(string: str) -> bool:
305
282
  """Check if the given string is in Swedish."""
306
283
 
307
-
308
284
  def is_turkish(string: str) -> bool:
309
285
  """Check if the given string is in Turkish."""
310
286
 
311
-
312
287
  def is_vietnamese(string: str) -> bool:
313
288
  """Check if the given string is in Vietnamese."""
314
289
 
315
-
316
290
  def tex_to_typst(string: str) -> str:
317
291
  """Convert TeX to Typst.
318
292
 
@@ -323,7 +297,6 @@ def tex_to_typst(string: str) -> str:
323
297
  The converted Typst string.
324
298
  """
325
299
 
326
-
327
300
  def convert_all_tex_math(string: str) -> str:
328
301
  r"""Unified function to convert all supported TeX math expressions in a string to Typst format.
329
302
 
@@ -336,7 +309,6 @@ def convert_all_tex_math(string: str) -> str:
336
309
  The string with TeX math expressions converted to Typst format.
337
310
  """
338
311
 
339
-
340
312
  def fix_misplaced_labels(string: str) -> str:
341
313
  """A func to fix labels in a string.
342
314
 
@@ -347,7 +319,6 @@ def fix_misplaced_labels(string: str) -> str:
347
319
  The fixed string with labels properly placed.
348
320
  """
349
321
 
350
-
351
322
  def comment(string: str) -> str:
352
323
  r"""Add comment to the string.
353
324
 
@@ -358,7 +329,6 @@ def comment(string: str) -> str:
358
329
  The string with each line prefixed by '// '.
359
330
  """
360
331
 
361
-
362
332
  def uncomment(string: str) -> str:
363
333
  """Remove comment from the string.
364
334
 
@@ -369,6 +339,15 @@ def uncomment(string: str) -> str:
369
339
  The string with comments (lines starting with '// ' or '//') removed.
370
340
  """
371
341
 
342
+ def strip_comment(string: str) -> str:
343
+ """Remove leading and trailing comment lines from a multi-line string.
344
+
345
+ Args:
346
+ string: Input string that may have comment lines at start and/or end
347
+
348
+ Returns:
349
+ str: A new string with leading and trailing comment lines removed
350
+ """
372
351
 
373
352
  def split_out_metadata(string: str) -> Tuple[Optional[JsonValue], str]:
374
353
  """Split out metadata from a string.
@@ -380,7 +359,6 @@ def split_out_metadata(string: str) -> Tuple[Optional[JsonValue], str]:
380
359
  A tuple containing the metadata as a Python object (if parseable) and the remaining string.
381
360
  """
382
361
 
383
-
384
362
  def to_metadata(data: JsonValue) -> str:
385
363
  """Convert a Python object to a YAML string.
386
364
 
@@ -391,7 +369,6 @@ def to_metadata(data: JsonValue) -> str:
391
369
  The YAML string representation of the input data.
392
370
  """
393
371
 
394
-
395
372
  def replace_thesis_body(string: str, wrapper: str, new_body: str) -> Optional[str]:
396
373
  """Replace content between wrapper strings.
397
374
 
@@ -405,7 +382,6 @@ def replace_thesis_body(string: str, wrapper: str, new_body: str) -> Optional[st
405
382
 
406
383
  """
407
384
 
408
-
409
385
  def extract_body(string: str, wrapper: str) -> Optional[str]:
410
386
  """Extract the content between two occurrences of a wrapper string.
411
387
 
@@ -417,7 +393,6 @@ def extract_body(string: str, wrapper: str) -> Optional[str]:
417
393
  The content between the first two occurrences of the wrapper string if found, otherwise None.
418
394
  """
419
395
 
420
-
421
396
  class LLMConfig:
422
397
  """LLM configuration structure.
423
398
 
@@ -469,7 +444,6 @@ class LLMConfig:
469
444
  frequency_penalty: Optional[float]
470
445
  """Penalizes new tokens based on their frequency in text so far (-2.0-2.0)."""
471
446
 
472
-
473
447
  class EmbeddingConfig:
474
448
  """Embedding configuration structure."""
475
449
 
@@ -494,7 +468,6 @@ class EmbeddingConfig:
494
468
  api_key: Optional[SecretStr]
495
469
  """The API key."""
496
470
 
497
-
498
471
  class RagConfig:
499
472
  """RAG (Retrieval Augmented Generation) configuration structure."""
500
473
 
@@ -510,18 +483,16 @@ class RagConfig:
510
483
  milvus_dimensions: Optional[int]
511
484
  """The dimensions for Milvus vectors."""
512
485
 
513
-
514
486
  class DebugConfig:
515
487
  """Debug configuration structure."""
516
488
 
517
489
  log_level: Optional[str]
518
490
  """The logging level to use."""
519
491
 
520
-
521
492
  class TemplateManagerConfig:
522
493
  """Template manager configuration structure."""
523
494
 
524
- template_dir: List[str]
495
+ template_dir: List[Path]
525
496
  """The directories containing the templates."""
526
497
 
527
498
  active_loading: Optional[bool]
@@ -530,10 +501,12 @@ class TemplateManagerConfig:
530
501
  template_suffix: Optional[str]
531
502
  """The suffix of the templates."""
532
503
 
533
-
534
504
  class TemplateConfig:
535
505
  """Template configuration structure."""
536
506
 
507
+ research_content_summary_template: str
508
+ """The name of the research content summary template which will be used to generate a summary of research content."""
509
+
537
510
  create_json_obj_template: str
538
511
  """The name of the create json object template which will be used to create a json object."""
539
512
 
@@ -615,7 +588,6 @@ class TemplateConfig:
615
588
  chap_summary_template: str
616
589
  """The name of the chap summary template which will be used to generate a chapter summary."""
617
590
 
618
-
619
591
  class RoutingConfig:
620
592
  """Routing configuration structure for controlling request dispatching behavior."""
621
593
 
@@ -631,7 +603,6 @@ class RoutingConfig:
631
603
  cooldown_time: Optional[int]
632
604
  """Time to cooldown a deployment after failure in seconds."""
633
605
 
634
-
635
606
  class GeneralConfig:
636
607
  """General configuration structure for application-wide settings."""
637
608
 
@@ -641,7 +612,6 @@ class GeneralConfig:
641
612
  use_json_repair: bool
642
613
  """Whether to automatically repair malformed JSON."""
643
614
 
644
-
645
615
  class ToolBoxConfig:
646
616
  """Configuration for toolbox functionality."""
647
617
 
@@ -651,7 +621,6 @@ class ToolBoxConfig:
651
621
  data_module_name: str
652
622
  """The name of the module containing the data."""
653
623
 
654
-
655
624
  class PymitterConfig:
656
625
  """Pymitter configuration structure for controlling event emission and listener behavior."""
657
626
 
@@ -664,7 +633,6 @@ class PymitterConfig:
664
633
  max_listeners: int
665
634
  """The maximum number of listeners per event. -1 means unlimited."""
666
635
 
667
-
668
636
  class Config:
669
637
  """Configuration structure containing all system components."""
670
638
 
@@ -698,22 +666,17 @@ class Config:
698
666
  pymitter: PymitterConfig
699
667
  """Pymitter configuration."""
700
668
 
701
-
702
669
  CONFIG: Config
703
670
 
704
-
705
671
  class SecretStr:
706
672
  """A string that should not be exposed."""
707
673
 
708
674
  def __init__(self, source: str) -> None: ...
709
-
710
675
  def get_secret_value(self) -> str:
711
676
  """Expose the secret string."""
712
677
 
713
-
714
678
  TEMPLATE_MANAGER: TemplateManager
715
679
 
716
-
717
680
  class Event:
718
681
  """Event class that represents a hierarchical event with segments.
719
682
 
@@ -825,12 +788,9 @@ class Event:
825
788
  """
826
789
 
827
790
  def __hash__(self) -> int: ...
828
-
829
791
  def __eq__(self, other: object) -> bool: ...
830
-
831
792
  def __ne__(self, other: object) -> bool: ...
832
793
 
833
-
834
794
  class TaskStatus(StrEnum, str):
835
795
  """Enumeration of possible task statuses."""
836
796
 
@@ -849,7 +809,6 @@ class TaskStatus(StrEnum, str):
849
809
  Cancelled: TaskStatus
850
810
  """Task has been cancelled."""
851
811
 
852
-
853
812
  class TEIClient:
854
813
  """Client for TEI reranking service.
855
814
 
@@ -865,11 +824,11 @@ class TEIClient:
865
824
  """
866
825
 
867
826
  async def arerank(
868
- self,
869
- query: str,
870
- texts: List[str],
871
- truncate: bool = False,
872
- truncation_direction: Literal["Left", "Right"] = "Left",
827
+ self,
828
+ query: str,
829
+ texts: List[str],
830
+ truncate: bool = False,
831
+ truncation_direction: Literal["Left", "Right"] = "Left",
873
832
  ) -> List[Tuple[int, float]]:
874
833
  """Rerank texts based on relevance to query.
875
834
 
@@ -1,9 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fabricatio
3
- Version: 0.3.14.dev7
3
+ Version: 0.3.15.dev5
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
@@ -185,4 +186,5 @@ Special thanks to the contributors and maintainers of:
185
186
  - [PyO3](https://github.com/PyO3/pyo3)
186
187
  - [Maturin](https://github.com/PyO3/maturin)
187
188
  - [Handlebars.rs](https://github.com/sunng87/handlebars-rust)
189
+ - [LiteLLM](https://github.com/BerriAI/litellm)
188
190
 
@@ -1,14 +1,14 @@
1
- fabricatio-0.3.14.dev7.data/scripts/tdown.exe,sha256=lHV09r-4UOiWlzHyfYV6iq1iXdXP8FbwtMwjGiPKaqU,3450880
2
- fabricatio-0.3.14.dev7.data/scripts/ttm.exe,sha256=JYT1OR7umACb3xXHjQZ9JzoILYX-atkSZ-ENFBo4Gcw,2561536
3
- fabricatio-0.3.14.dev7.dist-info/METADATA,sha256=btu_bPIYHocy_FeY8gF0BZ1qx60Td8eujW1SGyEQOr8,5116
4
- fabricatio-0.3.14.dev7.dist-info/WHEEL,sha256=aR9tSjQsZDIcSIX9Ihx1Vyf9toUnjsKopg6qQPYNdi8,96
5
- fabricatio-0.3.14.dev7.dist-info/licenses/LICENSE,sha256=do7J7EiCGbq0QPbMAL_FqLYufXpHnCnXBOuqVPwSV8Y,1088
1
+ fabricatio-0.3.15.dev5.data/scripts/tdown.exe,sha256=b9847TDX6VyRzfZOITsYgOcrpWw8vi_2vjIRqlp8f2k,3452416
2
+ fabricatio-0.3.15.dev5.data/scripts/ttm.exe,sha256=XjZq6x3Qi_g1aqeC-CcFXRkIjF8gR82ctcFKlv-HfO8,2556416
3
+ fabricatio-0.3.15.dev5.dist-info/METADATA,sha256=TBhqN2F5lbHd6fEgM-IwJecibnD_J2veBU6DmwM-Qa8,5216
4
+ fabricatio-0.3.15.dev5.dist-info/WHEEL,sha256=Fk195VgSS-LCRRJAxz6O39eu2NdDhBCq3h9q4zoTguY,96
5
+ fabricatio-0.3.15.dev5.dist-info/licenses/LICENSE,sha256=do7J7EiCGbq0QPbMAL_FqLYufXpHnCnXBOuqVPwSV8Y,1088
6
6
  fabricatio/__init__.py,sha256=w7ObFg6ud4pQuC1DhVyQI9x9dtp05QrcJAEk643iJmc,761
7
7
  fabricatio/actions/__init__.py,sha256=wVENCFtpVb1rLFxoOFJt9-8smLWXuJV7IwA8P3EfFz4,48
8
- fabricatio/actions/article.py,sha256=TPS2fOqCymKv2hK2c_WmMRMKNBkvN8M91QkB9ar8-bg,12507
9
- fabricatio/actions/article_rag.py,sha256=81668J2A_v00ODc01T-4FBEAtla6SB55VwSDO7DuRR4,18213
8
+ fabricatio/actions/article.py,sha256=pKJ8DBHeb3MIUdz-y-Xtk-7XAIyDAGQf3b135w1Moxo,17110
9
+ fabricatio/actions/article_rag.py,sha256=ohS1CRtYuv2rJNgoIsBl2yv-PuuoypA3y223rUUyDBg,17989
10
10
  fabricatio/actions/fs.py,sha256=gJR14U4ln35nt8Z7OWLVAZpqGaLnED-r1Yi-lX22tkI,959
11
- fabricatio/actions/output.py,sha256=jZL72D5uFobKNiVFapnVxBcjSNqGEThYNlCUKQvZwz8,9935
11
+ fabricatio/actions/output.py,sha256=nYKCUkNyAVziJmKS_Hdxnb015CrHRFdLJuQJlkEyB1s,9971
12
12
  fabricatio/actions/rag.py,sha256=vgCzIfbSd3_vL3QxB12PY4h12V9Pe3sZRsWme0KC6X8,3583
13
13
  fabricatio/actions/rules.py,sha256=dkvCgNDjt2KSO1VgPRsxT4YBmIIMeetZb5tiz-slYkU,3640
14
14
  fabricatio/capabilities/__init__.py,sha256=v1cHRHIJ2gxyqMLNCs6ERVcCakSasZNYzmMI4lqAcls,57
@@ -18,13 +18,12 @@ fabricatio/capabilities/censor.py,sha256=e0tHll4J_-TT8-Vn1OZ1innVZbJfx55oyGtDoEI
18
18
  fabricatio/capabilities/check.py,sha256=6IC6F0IhYVpSf9pJ8r9lq40l_FF3qf-iJcTRWwpnkdg,8591
19
19
  fabricatio/capabilities/correct.py,sha256=-JR8ZUAtagmNXepVyY679MBUyFCZwtKPjv8dANJMZiE,10403
20
20
  fabricatio/capabilities/extract.py,sha256=E7CLZflWzJ6C6DVLEWysYZ_48g_-F93gZJVU56k2-XA,2523
21
- fabricatio/capabilities/persist.py,sha256=9XnKoeZ62YjXVDpYnkbDFf62B_Mz46WVsq1dTr2Wvvc,3421
22
21
  fabricatio/capabilities/propose.py,sha256=v8OiUHc8GU7Jg1zAUghYhrI-AKgmBeUvQMo22ZAOddw,2030
23
22
  fabricatio/capabilities/rag.py,sha256=lwFrC96tL3uJ4keJ6n46vrvrdF6bARg1Yn6y6pQn7VQ,11194
24
23
  fabricatio/capabilities/rating.py,sha256=cm-s2YJMYcS36mR9b7XNwRQ1x0h0uWxLHCapoAORv8I,17815
25
24
  fabricatio/capabilities/review.py,sha256=l06BYcQzPi7VKmWdplj9L6WvZEscZqW1Wx9OhR-UnNw,5061
26
25
  fabricatio/capabilities/task.py,sha256=-b92cGi7b3B30kOSS-90_H6BjA0VF_cjc1BzPbO5MkI,4401
27
- fabricatio/decorators.py,sha256=OohwKgc5dUjybv70D-J2lA0C9zjUuq8-gzU5O8JPl8w,8962
26
+ fabricatio/decorators.py,sha256=FmUDSr6RFtRnIXZ2OWYmbxCgTM1lsHKuyw4jTFgJbDo,9094
28
27
  fabricatio/emitter.py,sha256=n4vH6E7lcT57qVve_3hUAdfvj0mQUDkWu6iU5aNztB8,6341
29
28
  fabricatio/fs/__init__.py,sha256=USoMI_HcIr3Yc77_JQYYsXrsplYPXtFTaNB9YgFfC4s,713
30
29
  fabricatio/fs/curd.py,sha256=652nHulbJ3gwt0Z3nywtPMmjhEyglDvEfc3p7ieJNNA,4777
@@ -34,26 +33,26 @@ fabricatio/models/action.py,sha256=RhjHaEJILiCZux5hzxSZVt_7Evcu3TnFHNuJN8rzgq8,1
34
33
  fabricatio/models/adv_kwargs_types.py,sha256=IBV3ZcsNLvvEjO_2hBpYg_wLSpNKaMx6Ndam3qXJCw8,2097
35
34
  fabricatio/models/extra/__init__.py,sha256=XlYnS_2B9nhLhtQkjE7rvvfPmAAtXVdNi9bSDAR-Ge8,54
36
35
  fabricatio/models/extra/advanced_judge.py,sha256=INUl_41C8jkausDekkjnEmTwNfLCJ23TwFjq2cM23Cw,1092
37
- fabricatio/models/extra/aricle_rag.py,sha256=K2ceihjIJFfkE82ykNH8hwTLDbXfFRZAXhz1NkdVZSA,12011
38
- fabricatio/models/extra/article_base.py,sha256=1azdvRfT9lKiPT3xVTlP26FfzJOTwMlueJQDee3TgOU,16783
39
- fabricatio/models/extra/article_essence.py,sha256=z3Qz6xVsB9k-K-c4Y2CoKzxZrXaUd4oyt2Mb6hGDYdg,2793
40
- fabricatio/models/extra/article_main.py,sha256=7fH_pVjIDtaz4Gw885FU1m29puKgm3nHoowrVeWdMIE,11106
41
- fabricatio/models/extra/article_outline.py,sha256=P0T-1DGCzoNmQ3iQVwSmOul0nwS6qLgr0FF8jDdD7F0,1673
42
- fabricatio/models/extra/article_proposal.py,sha256=OQIKoJkmJv0ogYVk7eGK_TOtANVYcBPA_HeV1nuG0Vo,1909
36
+ fabricatio/models/extra/aricle_rag.py,sha256=wg7EaxDW3ScOoYHPc-e9HXzllNgaJemNFmrAuF_mgzI,12009
37
+ fabricatio/models/extra/article_base.py,sha256=OI55jmjKDscJNlzSBZRxx0xBj3Z1FHxDg-nb4tKSxMs,18882
38
+ fabricatio/models/extra/article_essence.py,sha256=CFmoP5emEL9TptIFP1gKO9Ec8AA_6uxkeI__8XokdPU,2745
39
+ fabricatio/models/extra/article_main.py,sha256=s_jnwZzliwTz_LvvI7mGhW_nOu7pn2pOf8UOi45o5OM,11263
40
+ fabricatio/models/extra/article_outline.py,sha256=mw7eOuKMJgns4bihjcjOEIpAy38i0g-x6T6Vx3J0T5A,1629
41
+ fabricatio/models/extra/article_proposal.py,sha256=NbyjW-7UiFPtnVD9nte75re4xL2pD4qL29PpNV4Cg_M,1870
43
42
  fabricatio/models/extra/patches.py,sha256=_WNCxtYzzsVfUxI16vu4IqsLahLYRHdbQN9er9tqhC0,997
44
43
  fabricatio/models/extra/problem.py,sha256=8tTU-3giFHOi5j7NJsvH__JJyYcaGrcfsRnkzQNm0Ew,7216
45
44
  fabricatio/models/extra/rag.py,sha256=C7ptZCuGJmT8WikjpF9KhZ0Bw-VicdB-s8EqEAgMLKE,3967
46
- fabricatio/models/extra/rule.py,sha256=WKahNiaIp8s_l2r_FG21F_PP3_hgNm4hfSVCSFyfoBE,2669
47
- fabricatio/models/generic.py,sha256=OJrYClooL2XnyalWTyyLgorycA1d_JNW8VqOYNDJdXc,27873
45
+ fabricatio/models/extra/rule.py,sha256=KQQELVhCLUXhEZ35jU3WGYqKHuCYEAkn0p6pxAE-hOU,2625
46
+ fabricatio/models/generic.py,sha256=ERUrwjOnLjR3zm1uXHPi-YrRQGSHqsgjtr5PHNcqEHU,30996
48
47
  fabricatio/models/kwargs_types.py,sha256=Ik8-Oi_NmwfkvC9B8K4NsoZc_vSWV85xKCSthA1Xv_k,3403
49
- fabricatio/models/role.py,sha256=b3zg96YKDsMBqa7SIe9LQHc-IVs2fGWqoQeRQYQIl4o,3856
48
+ fabricatio/models/role.py,sha256=p8yE9dc8xW6zxd-_tk3sjU_e1oabX6rNYsiGAMmZS44,7493
50
49
  fabricatio/models/task.py,sha256=XZ1l1P-iS02ZF9P8cXv8gEfJKBa17PFPNJ1SbhyhT4Q,11033
51
50
  fabricatio/models/tool.py,sha256=q2wDtZAebWMZlsFifgmJq8N3XvAhVNMb0aUIKkdruGc,12419
52
51
  fabricatio/models/usages.py,sha256=q2jLqa0vJ7ho9ZUkC-2uPuFpK8uClBLIS6TEEYHUotY,33041
53
52
  fabricatio/parser.py,sha256=dYFri9pDlsiwVpEJ-a5jmVU2nFuKN3uBHC8VsVpdEm8,4642
54
53
  fabricatio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
- fabricatio/rust.cp313-win_amd64.pyd,sha256=fMFlamARxZ3hNaXJGCkFN6C2BYuPgZI1poi3QE9JIys,7830016
56
- fabricatio/rust.pyi,sha256=PK9KfYSUto6nZ2KaCmF5sEVWCNizdtgOLhJhc1E7w20,25962
54
+ fabricatio/rust.cp313-win_amd64.pyd,sha256=J3SXmYBCP-UcfXxSdxMFWNwg7FkboBiEruVxYP6Gal4,7813632
55
+ fabricatio/rust.pyi,sha256=gACnTKrPEU15AC3c_HfcNNzLcMa6VTdC8SoGRgm0Qdw,26337
57
56
  fabricatio/toolboxes/__init__.py,sha256=KBJi5OG_pExscdlM7Bnt_UF43j4I3Lv6G71kPVu4KQU,395
58
57
  fabricatio/toolboxes/arithmetic.py,sha256=WLqhY-Pikv11Y_0SGajwZx3WhsLNpHKf9drzAqOf_nY,1369
59
58
  fabricatio/toolboxes/fs.py,sha256=l4L1CVxJmjw9Ld2XUpIlWfV0_Fu_2Og6d3E13I-S4aE,736
@@ -61,4 +60,4 @@ fabricatio/utils.py,sha256=WYhFB4tHk6jKmjZgAsYhRmg1ZvBjn4X2y4n7yz25HjE,5454
61
60
  fabricatio/workflows/__init__.py,sha256=5ScFSTA-bvhCesj3U9Mnmi6Law6N1fmh5UKyh58L3u8,51
62
61
  fabricatio/workflows/articles.py,sha256=ObYTFUqLUk_CzdmmnX6S7APfxcGmPFqnFr9pdjU7Z4Y,969
63
62
  fabricatio/workflows/rag.py,sha256=-YYp2tlE9Vtfgpg6ROpu6QVO8j8yVSPa6yDzlN3qVxs,520
64
- fabricatio-0.3.14.dev7.dist-info/RECORD,,
63
+ fabricatio-0.3.15.dev5.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: maturin (1.8.4)
2
+ Generator: maturin (1.8.6)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp313-cp313-win_amd64
@@ -1,103 +0,0 @@
1
- """Persistence capabilities for model instances."""
2
-
3
- from abc import ABC
4
- from datetime import datetime
5
- from pathlib import Path
6
- from typing import Optional, Self
7
-
8
- from loguru import logger
9
-
10
- from fabricatio.fs import safe_text_read
11
- from fabricatio.models.generic import Base
12
- from fabricatio.rust import blake3_hash
13
-
14
-
15
- class PersistentAble(Base, ABC):
16
- """Class providing file persistence capabilities.
17
-
18
- Enables saving model instances to disk with timestamped filenames and loading from persisted files.
19
- Implements basic versioning through filename hashing and timestamping.
20
- """
21
-
22
- def persist(self, path: str | Path) -> Self:
23
- """Save model instance to disk with versioned filename.
24
-
25
- Args:
26
- path (str | Path): Target directory or file path. If directory, filename is auto-generated.
27
-
28
- Returns:
29
- Self: Current instance for method chaining
30
-
31
- Notes:
32
- - Filename format: <ClassName>_<YYYYMMDD_HHMMSS>_<6-char_hash>.json
33
- - Hash generated from JSON content ensures uniqueness
34
- """
35
- p = Path(path)
36
- out = self.model_dump_json(indent=1, by_alias=True)
37
-
38
- # Generate a timestamp in the format YYYYMMDD_HHMMSS
39
- timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
40
-
41
- # Generate the hash
42
- file_hash = blake3_hash(out.encode())[:6]
43
-
44
- # Construct the file name with timestamp and hash
45
- file_name = f"{self.__class__.__name__}_{timestamp}_{file_hash}.json"
46
-
47
- if p.is_dir():
48
- p.joinpath(file_name).write_text(out, encoding="utf-8")
49
- else:
50
- p.mkdir(exist_ok=True, parents=True)
51
- p.write_text(out, encoding="utf-8")
52
-
53
- logger.info(f"Persisted `{self.__class__.__name__}` to {p.as_posix()}")
54
- return self
55
-
56
- @classmethod
57
- def from_latest_persistent(cls, dir_path: str | Path) -> Optional[Self]:
58
- """Load most recent persisted instance from directory.
59
-
60
- Args:
61
- dir_path (str | Path): Directory containing persisted files
62
-
63
- Returns:
64
- Self: Most recently modified instance
65
-
66
- Raises:
67
- NotADirectoryError: If path is not a valid directory
68
- FileNotFoundError: If no matching files found
69
- """
70
- dir_path = Path(dir_path)
71
- if not dir_path.is_dir():
72
- return None
73
-
74
- pattern = f"{cls.__name__}_*.json"
75
- files = list(dir_path.glob(pattern))
76
-
77
- if not files:
78
- return None
79
-
80
- def _get_timestamp(file_path: Path) -> datetime:
81
- stem = file_path.stem
82
- parts = stem.split("_")
83
- return datetime.strptime(f"{parts[1]}_{parts[2]}", "%Y%m%d_%H%M%S")
84
-
85
- files.sort(key=lambda f: _get_timestamp(f), reverse=True)
86
-
87
- return cls.from_persistent(files.pop(0))
88
-
89
- @classmethod
90
- def from_persistent(cls, path: str | Path) -> Self:
91
- """Load an instance from a specific persisted file.
92
-
93
- Args:
94
- path (str | Path): Path to the JSON file.
95
-
96
- Returns:
97
- Self: The loaded instance from the file.
98
-
99
- Raises:
100
- FileNotFoundError: If the specified file does not exist.
101
- ValueError: If the file content is invalid for the model.
102
- """
103
- return cls.model_validate_json(safe_text_read(path))
Binary file