fabricatio 0.3.14.dev1__cp312-cp312-win_amd64.whl → 0.3.14.dev4__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 (47) hide show
  1. fabricatio/__init__.py +5 -6
  2. fabricatio/actions/article.py +31 -31
  3. fabricatio/actions/article_rag.py +58 -58
  4. fabricatio/actions/output.py +58 -24
  5. fabricatio/actions/rag.py +2 -3
  6. fabricatio/capabilities/advanced_judge.py +4 -7
  7. fabricatio/capabilities/advanced_rag.py +2 -1
  8. fabricatio/capabilities/censor.py +5 -4
  9. fabricatio/capabilities/check.py +27 -27
  10. fabricatio/capabilities/correct.py +22 -22
  11. fabricatio/capabilities/extract.py +33 -33
  12. fabricatio/capabilities/persist.py +103 -0
  13. fabricatio/capabilities/propose.py +2 -2
  14. fabricatio/capabilities/rag.py +37 -37
  15. fabricatio/capabilities/rating.py +66 -70
  16. fabricatio/capabilities/review.py +12 -11
  17. fabricatio/capabilities/task.py +19 -18
  18. fabricatio/decorators.py +9 -9
  19. fabricatio/{core.py → emitter.py} +17 -19
  20. fabricatio/journal.py +2 -1
  21. fabricatio/models/action.py +9 -11
  22. fabricatio/models/extra/aricle_rag.py +15 -12
  23. fabricatio/models/extra/article_base.py +4 -5
  24. fabricatio/models/extra/article_essence.py +2 -1
  25. fabricatio/models/extra/article_main.py +5 -4
  26. fabricatio/models/extra/article_outline.py +2 -1
  27. fabricatio/models/extra/article_proposal.py +1 -1
  28. fabricatio/models/extra/rag.py +2 -2
  29. fabricatio/models/extra/rule.py +2 -1
  30. fabricatio/models/generic.py +48 -131
  31. fabricatio/models/kwargs_types.py +1 -9
  32. fabricatio/models/role.py +14 -13
  33. fabricatio/models/task.py +3 -4
  34. fabricatio/models/tool.py +5 -6
  35. fabricatio/models/usages.py +137 -147
  36. fabricatio/parser.py +59 -99
  37. fabricatio/rust.cp312-win_amd64.pyd +0 -0
  38. fabricatio/rust.pyi +39 -59
  39. fabricatio/utils.py +6 -170
  40. fabricatio-0.3.14.dev4.data/scripts/tdown.exe +0 -0
  41. {fabricatio-0.3.14.dev1.data → fabricatio-0.3.14.dev4.data}/scripts/ttm.exe +0 -0
  42. {fabricatio-0.3.14.dev1.dist-info → fabricatio-0.3.14.dev4.dist-info}/METADATA +3 -7
  43. fabricatio-0.3.14.dev4.dist-info/RECORD +64 -0
  44. fabricatio-0.3.14.dev1.data/scripts/tdown.exe +0 -0
  45. fabricatio-0.3.14.dev1.dist-info/RECORD +0 -63
  46. {fabricatio-0.3.14.dev1.dist-info → fabricatio-0.3.14.dev4.dist-info}/WHEEL +0 -0
  47. {fabricatio-0.3.14.dev1.dist-info → fabricatio-0.3.14.dev4.dist-info}/licenses/LICENSE +0 -0
@@ -5,17 +5,16 @@ from itertools import groupby
5
5
  from pathlib import Path
6
6
  from typing import ClassVar, Dict, List, Optional, Self, Unpack
7
7
 
8
- from fabricatio.rust import BibManager, blake3_hash, split_into_chunks
9
- from more_itertools.more import first
10
- from more_itertools.recipes import flatten, unique
11
- from pydantic import Field
12
-
13
8
  from fabricatio.fs import safe_text_read
14
9
  from fabricatio.journal import logger
15
10
  from fabricatio.models.extra.rag import MilvusDataBase
16
11
  from fabricatio.models.generic import AsPrompt
17
12
  from fabricatio.models.kwargs_types import ChunkKwargs
13
+ from fabricatio.rust import BibManager, blake3_hash, split_into_chunks
18
14
  from fabricatio.utils import ok, wrapp_in_block
15
+ from more_itertools.more import first
16
+ from more_itertools.recipes import flatten, unique
17
+ from pydantic import Field
19
18
 
20
19
 
21
20
  class ArticleChunk(MilvusDataBase):
@@ -56,6 +55,7 @@ class ArticleChunk(MilvusDataBase):
56
55
 
57
56
  @property
58
57
  def reference_header(self) -> str:
58
+ """Get the reference header."""
59
59
  return f"[[{ok(self._cite_number, 'You need to update cite number first.')}]] reference `{self.article_title}` from {self.as_auther_seq()}"
60
60
 
61
61
  @property
@@ -68,7 +68,7 @@ class ArticleChunk(MilvusDataBase):
68
68
 
69
69
  @classmethod
70
70
  def from_file[P: str | Path](
71
- cls, path: P | List[P], bib_mgr: BibManager, **kwargs: Unpack[ChunkKwargs]
71
+ cls, path: P | List[P], bib_mgr: BibManager, **kwargs: Unpack[ChunkKwargs]
72
72
  ) -> List[Self]:
73
73
  """Load the article chunks from the file."""
74
74
  if isinstance(path, list):
@@ -85,9 +85,9 @@ class ArticleChunk(MilvusDataBase):
85
85
  title_seg = path.stem.split(" - ").pop()
86
86
 
87
87
  key = (
88
- bib_mgr.get_cite_key_by_title(title_seg)
89
- or bib_mgr.get_cite_key_by_title_fuzzy(title_seg)
90
- or bib_mgr.get_cite_key_fuzzy(path.stem)
88
+ bib_mgr.get_cite_key_by_title(title_seg)
89
+ or bib_mgr.get_cite_key_by_title_fuzzy(title_seg)
90
+ or bib_mgr.get_cite_key_fuzzy(path.stem)
91
91
  )
92
92
  if key is None:
93
93
  logger.warning(f"no cite key found for {path.as_posix()}, skip.")
@@ -179,7 +179,7 @@ class CitationManager(AsPrompt):
179
179
  """Separator for abbreviated citation numbers."""
180
180
 
181
181
  def update_chunks(
182
- self, article_chunks: List[ArticleChunk], set_cite_number: bool = True, dedup: bool = True
182
+ self, article_chunks: List[ArticleChunk], set_cite_number: bool = True, dedup: bool = True
183
183
  ) -> Self:
184
184
  """Update article chunks."""
185
185
  self.article_chunks.clear()
@@ -218,8 +218,9 @@ class CitationManager(AsPrompt):
218
218
  def _as_prompt_inner(self) -> Dict[str, str]:
219
219
  """Generate prompt inner representation."""
220
220
  seg = []
221
- for k, g in groupby(self.article_chunks, key=lambda a: a.bibtex_cite_key):
222
- g = list(g)
221
+ for k, g_iter in groupby(self.article_chunks, key=lambda a: a.bibtex_cite_key):
222
+ g = list(g_iter)
223
+
223
224
  logger.debug(f"Group [{k}]: {len(g)}")
224
225
  seg.append(wrapp_in_block("\n\n".join(a.chunk for a in g), first(g).reference_header))
225
226
  return {"References": "\n".join(seg)}
@@ -277,5 +278,7 @@ class CitationManager(AsPrompt):
277
278
  return "".join(a.as_typst_cite() for a in chunk_seq.values())
278
279
 
279
280
  def as_milvus_filter_expr(self, blacklist: bool = True) -> str:
281
+ """Asynchronously fetches documents from a Milvus database based on input vectors."""
280
282
  if blacklist:
281
283
  return " and ".join(f'bibtex_cite_key != "{a.bibtex_cite_key}"' for a in self.article_chunks)
284
+ return " or ".join(f'bibtex_cite_key == "{a.bibtex_cite_key}"' for a in self.article_chunks)
@@ -5,9 +5,7 @@ from enum import StrEnum
5
5
  from pathlib import Path
6
6
  from typing import ClassVar, Generator, List, Optional, Self, Tuple, Type
7
7
 
8
- from fabricatio.rust import extract_body, inplace_update, split_out_metadata, to_metadata, word_count
9
- from pydantic import Field
10
-
8
+ from fabricatio.capabilities.persist import PersistentAble
11
9
  from fabricatio.fs import dump_text, safe_text_read
12
10
  from fabricatio.fs.readers import extract_sections
13
11
  from fabricatio.journal import logger
@@ -18,13 +16,14 @@ from fabricatio.models.generic import (
18
16
  Introspect,
19
17
  Language,
20
18
  ModelHash,
21
- PersistentAble,
22
19
  ProposedUpdateAble,
23
20
  SketchedAble,
24
21
  Titled,
25
22
  WordCount,
26
23
  )
24
+ from fabricatio.rust import extract_body, inplace_update, split_out_metadata, to_metadata, word_count
27
25
  from fabricatio.utils import fallback_kwargs, ok
26
+ from pydantic import Field
28
27
 
29
28
  ARTICLE_WRAPPER = "// =-=-=-=-=-=-=-=-=-="
30
29
 
@@ -276,7 +275,7 @@ class ArticleBase[T: ChapterBase](FinalizedDumpAble, AsPrompt, FromTypstCode, To
276
275
  )
277
276
 
278
277
  def iter_dfs_rev(
279
- self,
278
+ self,
280
279
  ) -> Generator[ArticleOutlineBase, None, None]:
281
280
  """Performs a depth-first search (DFS) through the article structure in reverse order.
282
281
 
@@ -2,8 +2,9 @@
2
2
 
3
3
  from typing import List
4
4
 
5
+ from fabricatio.capabilities.persist import PersistentAble
5
6
  from fabricatio.models.extra.rag import MilvusDataBase
6
- from fabricatio.models.generic import PersistentAble, SketchedAble
7
+ from fabricatio.models.generic import SketchedAble
7
8
  from pydantic import BaseModel
8
9
 
9
10
 
@@ -11,6 +11,7 @@ from fabricatio.rust import (
11
11
  )
12
12
  from pydantic import Field, NonNegativeInt
13
13
 
14
+ from fabricatio.capabilities.persist import PersistentAble
14
15
  from fabricatio.decorators import precheck_package
15
16
  from fabricatio.journal import logger
16
17
  from fabricatio.models.extra.article_base import (
@@ -25,9 +26,9 @@ from fabricatio.models.extra.article_outline import (
25
26
  ArticleSectionOutline,
26
27
  ArticleSubsectionOutline,
27
28
  )
28
- from fabricatio.models.generic import Described, PersistentAble, SequencePatch, SketchedAble, WithRef, WordCount
29
+ from fabricatio.models.generic import Described, SequencePatch, SketchedAble, WithRef, WordCount
29
30
 
30
- PARAGRAPH_SEP = "\n\n// - - -\n\n"
31
+ PARAGRAPH_SEP = "// - - -"
31
32
 
32
33
 
33
34
  class Paragraph(SketchedAble, WordCount, Described):
@@ -50,7 +51,7 @@ class Paragraph(SketchedAble, WordCount, Described):
50
51
  @classmethod
51
52
  def from_content(cls, content: str) -> Self:
52
53
  """Create a Paragraph object from the given content."""
53
- return cls(elaboration="", aims=[], expected_word_count=word_count(content), content=content)
54
+ return cls(elaboration="", aims=[], expected_word_count=word_count(content), content=content.strip())
54
55
 
55
56
  @property
56
57
  def exact_wordcount(self) -> int:
@@ -103,7 +104,7 @@ class ArticleSubsection(SubSectionBase):
103
104
  Returns:
104
105
  str: Typst code snippet for rendering.
105
106
  """
106
- return super().to_typst_code() + PARAGRAPH_SEP.join(p.content for p in self.paragraphs)
107
+ return super().to_typst_code() + f"\n\n{PARAGRAPH_SEP}\n\n".join(p.content for p in self.paragraphs)
107
108
 
108
109
  @classmethod
109
110
  def from_typst_code(cls, title: str, body: str, **kwargs) -> Self:
@@ -2,6 +2,7 @@
2
2
 
3
3
  from typing import ClassVar, Dict, Type
4
4
 
5
+ from fabricatio.capabilities.persist import PersistentAble
5
6
  from fabricatio.models.extra.article_base import (
6
7
  ArticleBase,
7
8
  ChapterBase,
@@ -9,7 +10,7 @@ from fabricatio.models.extra.article_base import (
9
10
  SubSectionBase,
10
11
  )
11
12
  from fabricatio.models.extra.article_proposal import ArticleProposal
12
- from fabricatio.models.generic import PersistentAble, WithRef
13
+ from fabricatio.models.generic import WithRef
13
14
 
14
15
 
15
16
  class ArticleSubsectionOutline(SubSectionBase):
@@ -2,11 +2,11 @@
2
2
 
3
3
  from typing import Dict, List
4
4
 
5
+ from fabricatio.capabilities.persist import PersistentAble
5
6
  from fabricatio.models.generic import (
6
7
  AsPrompt,
7
8
  Described,
8
9
  Language,
9
- PersistentAble,
10
10
  SketchedAble,
11
11
  Titled,
12
12
  WithRef,
@@ -5,7 +5,7 @@ from functools import partial
5
5
  from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Self, Sequence, Set
6
6
 
7
7
  from fabricatio.decorators import precheck_package
8
- from fabricatio.models.generic import Vectorizable
8
+ from fabricatio.models.generic import Base, Vectorizable
9
9
  from fabricatio.utils import ok
10
10
  from pydantic import JsonValue
11
11
 
@@ -18,7 +18,7 @@ if TYPE_CHECKING:
18
18
  from pymilvus import CollectionSchema
19
19
 
20
20
 
21
- class MilvusDataBase(Vectorizable, ABC):
21
+ class MilvusDataBase(Base, Vectorizable, ABC):
22
22
  """A base class for Milvus data."""
23
23
 
24
24
  primary_field_name: ClassVar[str] = "id"
@@ -10,7 +10,8 @@ complex rule management systems.
10
10
 
11
11
  from typing import List, Self, Tuple, Unpack
12
12
 
13
- from fabricatio.models.generic import Language, PersistentAble, SketchedAble, WithBriefing
13
+ from fabricatio.capabilities.persist import PersistentAble
14
+ from fabricatio.models.generic import Language, SketchedAble, WithBriefing
14
15
  from more_itertools import flatten
15
16
 
16
17
 
@@ -1,12 +1,15 @@
1
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
- from datetime import datetime
5
4
  from pathlib import Path
6
- from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Self, Type, Union, final, overload
5
+ from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Self, Sequence, Type, Union, final, overload
7
6
 
8
7
  import ujson
8
+ from fabricatio.fs import dump_text
9
+ from fabricatio.fs.readers import safe_text_read
10
+ from fabricatio.journal import logger
9
11
  from fabricatio.rust import CONFIG, TEMPLATE_MANAGER, blake3_hash, detect_language
12
+ from fabricatio.utils import ok
10
13
  from pydantic import (
11
14
  BaseModel,
12
15
  ConfigDict,
@@ -19,13 +22,8 @@ from pydantic import (
19
22
  )
20
23
  from pydantic.json_schema import GenerateJsonSchema, JsonSchemaValue
21
24
 
22
- from fabricatio.fs import dump_text
23
- from fabricatio.fs.readers import safe_text_read
24
- from fabricatio.journal import logger
25
- from fabricatio.utils import ok
26
25
 
27
-
28
- class Base(BaseModel):
26
+ class Base(BaseModel, ABC):
29
27
  """Base class for all models with Pydantic configuration.
30
28
 
31
29
  This class sets up the basic Pydantic configuration for all models in the Fabricatio library.
@@ -36,7 +34,7 @@ class Base(BaseModel):
36
34
  model_config = ConfigDict(use_attribute_docstrings=True)
37
35
 
38
36
 
39
- class Display(Base):
37
+ class Display(Base, ABC):
40
38
  """Class that provides formatted JSON representation utilities.
41
39
 
42
40
  Provides methods to generate both pretty-printed and compact JSON representations of the model.
@@ -71,13 +69,13 @@ class Display(Base):
71
69
  str: Combined display output with boundary markers
72
70
  """
73
71
  return (
74
- "--- Start of Extra Info Sequence ---"
75
- + "\n".join(d.compact() if compact else d.display() for d in seq)
76
- + "--- End of Extra Info Sequence ---"
72
+ "--- Start of Extra Info Sequence ---"
73
+ + "\n".join(d.compact() if compact else d.display() for d in seq)
74
+ + "--- End of Extra Info Sequence ---"
77
75
  )
78
76
 
79
77
 
80
- class Named(Base):
78
+ class Named(Base, ABC):
81
79
  """Class that includes a name attribute.
82
80
 
83
81
  This class adds a name attribute to models, which is intended to be a unique identifier.
@@ -87,7 +85,7 @@ class Named(Base):
87
85
  """The name of this object,briefly and conclusively."""
88
86
 
89
87
 
90
- class Described(Base):
88
+ class Described(Base, ABC):
91
89
  """Class that includes a description attribute.
92
90
 
93
91
  This class adds a description attribute to models, providing additional context or information.
@@ -100,19 +98,24 @@ class Described(Base):
100
98
  this object's intent and application."""
101
99
 
102
100
 
103
- class Titled(Base):
101
+ class Titled(Base, ABC):
104
102
  """Class that includes a title attribute."""
105
103
 
106
104
  title: str
107
105
  """The title of this object, make it professional and concise.No prefixed heading number should be included."""
108
106
 
109
107
 
110
- class WordCount(Base):
108
+ class WordCount(Base, ABC):
111
109
  """Class that includes a word count attribute."""
112
110
 
113
111
  expected_word_count: int
114
112
  """Expected word count of this research component."""
115
113
 
114
+ @property
115
+ def exact_word_count(self) -> int:
116
+ """Get the exact word count of this research component."""
117
+ raise NotImplementedError(f"`expected_word_count` is not implemented for {self.__class__.__name__}")
118
+
116
119
 
117
120
  class FromMapping:
118
121
  """Class that provides a method to generate a list of objects from a mapping."""
@@ -123,6 +126,15 @@ class FromMapping:
123
126
  """Generate a list of objects from a mapping."""
124
127
 
125
128
 
129
+ class FromSequence:
130
+ """Class that provides a method to generate a list of objects from a sequence."""
131
+
132
+ @classmethod
133
+ @abstractmethod
134
+ def from_sequence[S](cls: S, sequence: Sequence[Any], **kwargs: Any) -> List[S]:
135
+ """Generate a list of objects from a sequence."""
136
+
137
+
126
138
  class AsPrompt:
127
139
  """Class that provides a method to generate a prompt from the model.
128
140
 
@@ -152,7 +164,7 @@ class AsPrompt:
152
164
  """
153
165
 
154
166
 
155
- class WithRef[T](Base):
167
+ class WithRef[T](Base, ABC):
156
168
  """Class that provides a reference to another object.
157
169
 
158
170
  This class manages a reference to another object, allowing for easy access and updates.
@@ -175,16 +187,13 @@ class WithRef[T](Base):
175
187
  )
176
188
 
177
189
  @overload
178
- def update_ref[S: WithRef](self: S, reference: T) -> S:
179
- ...
190
+ def update_ref[S: WithRef](self: S, reference: T) -> S: ...
180
191
 
181
192
  @overload
182
- def update_ref[S: WithRef](self: S, reference: "WithRef[T]") -> S:
183
- ...
193
+ def update_ref[S: WithRef](self: S, reference: "WithRef[T]") -> S: ...
184
194
 
185
195
  @overload
186
- def update_ref[S: WithRef](self: S, reference: None = None) -> S:
187
- ...
196
+ def update_ref[S: WithRef](self: S, reference: None = None) -> S: ...
188
197
 
189
198
  def update_ref[S: WithRef](self: S, reference: Union[T, "WithRef[T]", None] = None) -> S:
190
199
  """Update the reference of the object.
@@ -202,97 +211,6 @@ class WithRef[T](Base):
202
211
  return self
203
212
 
204
213
 
205
- class PersistentAble(Base):
206
- """Class providing file persistence capabilities.
207
-
208
- Enables saving model instances to disk with timestamped filenames and loading from persisted files.
209
- Implements basic versioning through filename hashing and timestamping.
210
- """
211
-
212
- def persist(self, path: str | Path) -> Self:
213
- """Save model instance to disk with versioned filename.
214
-
215
- Args:
216
- path (str | Path): Target directory or file path. If directory, filename is auto-generated.
217
-
218
- Returns:
219
- Self: Current instance for method chaining
220
-
221
- Notes:
222
- - Filename format: <ClassName>_<YYYYMMDD_HHMMSS>_<6-char_hash>.json
223
- - Hash generated from JSON content ensures uniqueness
224
- """
225
- p = Path(path)
226
- out = self.model_dump_json(indent=1, by_alias=True)
227
-
228
- # Generate a timestamp in the format YYYYMMDD_HHMMSS
229
- timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
230
-
231
- # Generate the hash
232
- file_hash = blake3_hash(out.encode())[:6]
233
-
234
- # Construct the file name with timestamp and hash
235
- file_name = f"{self.__class__.__name__}_{timestamp}_{file_hash}.json"
236
-
237
- if p.is_dir():
238
- p.joinpath(file_name).write_text(out, encoding="utf-8")
239
- else:
240
- p.mkdir(exist_ok=True, parents=True)
241
- p.write_text(out, encoding="utf-8")
242
-
243
- logger.info(f"Persisted `{self.__class__.__name__}` to {p.as_posix()}")
244
- return self
245
-
246
- @classmethod
247
- def from_latest_persistent(cls, dir_path: str | Path) -> Optional[Self]:
248
- """Load most recent persisted instance from directory.
249
-
250
- Args:
251
- dir_path (str | Path): Directory containing persisted files
252
-
253
- Returns:
254
- Self: Most recently modified instance
255
-
256
- Raises:
257
- NotADirectoryError: If path is not a valid directory
258
- FileNotFoundError: If no matching files found
259
- """
260
- dir_path = Path(dir_path)
261
- if not dir_path.is_dir():
262
- return None
263
-
264
- pattern = f"{cls.__name__}_*.json"
265
- files = list(dir_path.glob(pattern))
266
-
267
- if not files:
268
- return None
269
-
270
- def _get_timestamp(file_path: Path) -> datetime:
271
- stem = file_path.stem
272
- parts = stem.split("_")
273
- return datetime.strptime(f"{parts[1]}_{parts[2]}", "%Y%m%d_%H%M%S")
274
-
275
- files.sort(key=lambda f: _get_timestamp(f), reverse=True)
276
-
277
- return cls.from_persistent(files.pop(0))
278
-
279
- @classmethod
280
- def from_persistent(cls, path: str | Path) -> Self:
281
- """Load an instance from a specific persisted file.
282
-
283
- Args:
284
- path (str | Path): Path to the JSON file.
285
-
286
- Returns:
287
- Self: The loaded instance from the file.
288
-
289
- Raises:
290
- FileNotFoundError: If the specified file does not exist.
291
- ValueError: If the file content is invalid for the model.
292
- """
293
- return cls.model_validate_json(safe_text_read(path))
294
-
295
-
296
214
  class Language:
297
215
  """Class that provides a language attribute."""
298
216
 
@@ -308,7 +226,7 @@ class Language:
308
226
  raise RuntimeError(f"Cannot determine language! class that not support language: {self.__class__.__name__}")
309
227
 
310
228
 
311
- class ModelHash(Base):
229
+ class ModelHash(Base, ABC):
312
230
  """Class that provides a hash value for the object.
313
231
 
314
232
  This class includes a method to calculate a hash value for the object based on its JSON representation.
@@ -323,7 +241,7 @@ class ModelHash(Base):
323
241
  return hash(self.model_dump_json())
324
242
 
325
243
 
326
- class UpdateFrom:
244
+ class UpdateFrom(ABC):
327
245
  """Class that provides a method to update the object from another object.
328
246
 
329
247
  This class includes methods to update the current object with the attributes of another object.
@@ -372,7 +290,7 @@ class UpdateFrom:
372
290
  return self.update_pre_check(other).update_from_inner(other)
373
291
 
374
292
 
375
- class Introspect:
293
+ class Introspect(ABC):
376
294
  """Class that provides a method to introspect the object.
377
295
 
378
296
  This class includes a method to perform internal introspection of the object.
@@ -387,7 +305,7 @@ class Introspect:
387
305
  """
388
306
 
389
307
 
390
- class WithBriefing(Named, Described):
308
+ class WithBriefing(Named, Described, ABC):
391
309
  """Class that provides a briefing based on the name and description.
392
310
 
393
311
  This class combines the name and description attributes to provide a brief summary of the object.
@@ -422,7 +340,7 @@ class UnsortGenerate(GenerateJsonSchema):
422
340
  return value
423
341
 
424
342
 
425
- class WithFormatedJsonSchema(Base):
343
+ class WithFormatedJsonSchema(Base, ABC):
426
344
  """Class that provides a formatted JSON schema of the model.
427
345
 
428
346
  This class includes a method to generate a formatted JSON schema of the model.
@@ -440,7 +358,7 @@ class WithFormatedJsonSchema(Base):
440
358
  )
441
359
 
442
360
 
443
- class CreateJsonObjPrompt(WithFormatedJsonSchema):
361
+ class CreateJsonObjPrompt(WithFormatedJsonSchema, ABC):
444
362
  """Class that provides a prompt for creating a JSON object.
445
363
 
446
364
  This class includes a method to create a prompt for creating a JSON object based on the model's schema and a requirement.
@@ -478,7 +396,7 @@ class CreateJsonObjPrompt(WithFormatedJsonSchema):
478
396
  ]
479
397
 
480
398
 
481
- class InstantiateFromString(Base):
399
+ class InstantiateFromString(Base, ABC):
482
400
  """Class that provides a method to instantiate the class from a string.
483
401
 
484
402
  This class includes a method to instantiate the class from a JSON string representation.
@@ -501,14 +419,14 @@ class InstantiateFromString(Base):
501
419
  return obj
502
420
 
503
421
 
504
- class ProposedAble(CreateJsonObjPrompt, InstantiateFromString):
422
+ class ProposedAble(CreateJsonObjPrompt, InstantiateFromString, ABC):
505
423
  """Class that provides a method to propose a JSON object based on the requirement.
506
424
 
507
425
  This class combines the functionality to create a prompt for a JSON object and instantiate it from a string.
508
426
  """
509
427
 
510
428
 
511
- class SketchedAble(ProposedAble, Display):
429
+ class SketchedAble(ProposedAble, Display, ABC):
512
430
  """Class that provides a method to scratch the object.
513
431
 
514
432
  This class combines the functionality to propose a JSON object, instantiate it from a string, and display it.
@@ -522,7 +440,7 @@ class ProposedUpdateAble(SketchedAble, UpdateFrom, ABC):
522
440
  """
523
441
 
524
442
 
525
- class FinalizedDumpAble(Base):
443
+ class FinalizedDumpAble(Base, ABC):
526
444
  """Class that provides a method to finalize the dump of the object.
527
445
 
528
446
  This class includes methods to finalize the JSON representation of the object and dump it to a file.
@@ -549,7 +467,7 @@ class FinalizedDumpAble(Base):
549
467
  return self
550
468
 
551
469
 
552
- class WithDependency(Base):
470
+ class WithDependency(Base, ABC):
553
471
  """Class that manages file dependencies.
554
472
 
555
473
  This class includes methods to manage file dependencies required for reading or writing.
@@ -642,7 +560,7 @@ class WithDependency(Base):
642
560
  )
643
561
 
644
562
 
645
- class Vectorizable:
563
+ class Vectorizable(ABC):
646
564
  """Class that prepares the vectorization of the model.
647
565
 
648
566
  This class includes methods to prepare the model for vectorization, ensuring it fits within a specified token length.
@@ -675,7 +593,7 @@ class Vectorizable:
675
593
  return chunk
676
594
 
677
595
 
678
- class ScopedConfig(Base):
596
+ class ScopedConfig(Base, ABC):
679
597
  """Configuration holder with hierarchical fallback mechanism.
680
598
 
681
599
  Manages LLM, embedding, and vector database configurations with fallback logic.
@@ -808,7 +726,7 @@ class ScopedConfig(Base):
808
726
  return self
809
727
 
810
728
 
811
- class Patch[T](ProposedAble):
729
+ class Patch[T](ProposedAble, ABC):
812
730
  """Base class for patches.
813
731
 
814
732
  This class provides a base implementation for patches that can be applied to other objects.
@@ -855,15 +773,14 @@ class Patch[T](ProposedAble):
855
773
  # copy the desc info of each corresponding fields from `ref_cls`
856
774
  for field_name in [f for f in cls.model_fields if f in ref_cls.model_fields]:
857
775
  my_schema["properties"][field_name]["description"] = (
858
- ref_cls.model_fields[field_name].description or my_schema["properties"][field_name][
859
- "description"]
776
+ ref_cls.model_fields[field_name].description or my_schema["properties"][field_name]["description"]
860
777
  )
861
778
  my_schema["description"] = ref_cls.__doc__
862
779
 
863
780
  return ujson.dumps(my_schema, indent=2, ensure_ascii=False, sort_keys=False)
864
781
 
865
782
 
866
- class SequencePatch[T](ProposedUpdateAble):
783
+ class SequencePatch[T](ProposedUpdateAble, ABC):
867
784
  """Base class for patches.
868
785
 
869
786
  This class provides a base implementation for patches that can be applied to sequences of objects.
@@ -1,6 +1,6 @@
1
1
  """This module contains the types for the keyword arguments of the methods in the models module."""
2
2
 
3
- from typing import Dict, List, Literal, NotRequired, Optional, Required, TypedDict
3
+ from typing import Dict, List, NotRequired, Optional, Required, TypedDict
4
4
 
5
5
 
6
6
  class ChunkKwargs(TypedDict):
@@ -119,11 +119,3 @@ class ChooseKwargs[T](ValidateKwargs[T], total=False):
119
119
  """
120
120
 
121
121
  k: int
122
-
123
-
124
- class RerankOptions(TypedDict, total=False):
125
- """Optional keyword arguments for the rerank method."""
126
-
127
- raw_scores: bool
128
- truncate: bool
129
- truncation_direction: Literal["Left", "Right"]