fabricatio 0.2.8.dev3__cp312-cp312-win_amd64.whl → 0.2.8.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.
@@ -7,10 +7,11 @@ from typing import Dict, List, Optional, Set, Tuple, Union, Unpack, overload
7
7
  from fabricatio._rust_instances import TEMPLATE_MANAGER
8
8
  from fabricatio.config import configs
9
9
  from fabricatio.journal import logger
10
- from fabricatio.models.kwargs_types import ValidateKwargs
10
+ from fabricatio.models.generic import Display
11
+ from fabricatio.models.kwargs_types import CompositeScoreKwargs, ValidateKwargs
11
12
  from fabricatio.models.usages import LLMUsage
12
13
  from fabricatio.parser import JsonCapture
13
- from fabricatio.utils import override_kwargs
14
+ from fabricatio.utils import ok, override_kwargs
14
15
  from more_itertools import flatten, windowed
15
16
  from pydantic import NonNegativeInt, PositiveInt
16
17
 
@@ -86,6 +87,7 @@ class Rating(LLMUsage):
86
87
  to_rate: str,
87
88
  topic: str,
88
89
  criteria: Set[str],
90
+ manual: Optional[Dict[str, str]],
89
91
  score_range: Tuple[float, float] = (0.0, 1.0),
90
92
  **kwargs: Unpack[ValidateKwargs],
91
93
  ) -> Dict[str, float]: ...
@@ -96,6 +98,7 @@ class Rating(LLMUsage):
96
98
  to_rate: List[str],
97
99
  topic: str,
98
100
  criteria: Set[str],
101
+ manual: Optional[Dict[str, str]],
99
102
  score_range: Tuple[float, float] = (0.0, 1.0),
100
103
  **kwargs: Unpack[ValidateKwargs],
101
104
  ) -> List[Dict[str, float]]: ...
@@ -105,6 +108,7 @@ class Rating(LLMUsage):
105
108
  to_rate: Union[str, List[str]],
106
109
  topic: str,
107
110
  criteria: Set[str],
111
+ manual: Optional[Dict[str, str]],
108
112
  score_range: Tuple[float, float] = (0.0, 1.0),
109
113
  **kwargs: Unpack[ValidateKwargs],
110
114
  ) -> Optional[Dict[str, float] | List[Dict[str, float]]]:
@@ -114,6 +118,7 @@ class Rating(LLMUsage):
114
118
  to_rate (Union[str, List[str]]): The string or sequence of strings to be rated.
115
119
  topic (str): The topic related to the task.
116
120
  criteria (Set[str]): A set of criteria for rating.
121
+ manual (Optional[Dict[str, str]]): A dictionary containing the rating criteria. If not provided, then this method will draft the criteria automatically.
117
122
  score_range (Tuple[float, float], optional): A tuple representing the valid score range. Defaults to (0.0, 1.0).
118
123
  **kwargs (Unpack[ValidateKwargs]): Additional keyword arguments for the LLM usage.
119
124
 
@@ -121,7 +126,11 @@ class Rating(LLMUsage):
121
126
  Union[Dict[str, float], List[Dict[str, float]]]: A dictionary with the ratings for each criterion if a single string is provided,
122
127
  or a list of dictionaries with the ratings for each criterion if a sequence of strings is provided.
123
128
  """
124
- manual = await self.draft_rating_manual(topic, criteria, **kwargs) or dict(zip(criteria, criteria, strict=True))
129
+ manual = (
130
+ manual
131
+ or await self.draft_rating_manual(topic, criteria, **override_kwargs(kwargs, default=None))
132
+ or dict(zip(criteria, criteria, strict=True))
133
+ )
125
134
 
126
135
  return await self.rate_fine_grind(to_rate, manual, score_range, **kwargs)
127
136
 
@@ -309,7 +318,7 @@ class Rating(LLMUsage):
309
318
  validator=lambda resp: JsonCapture.validate_with(resp, target_type=float),
310
319
  **kwargs,
311
320
  )
312
- weights = [1]
321
+ weights = [1.0]
313
322
  for rw in relative_weights:
314
323
  weights.append(weights[-1] * rw)
315
324
  total = sum(weights)
@@ -319,27 +328,66 @@ class Rating(LLMUsage):
319
328
  self,
320
329
  topic: str,
321
330
  to_rate: List[str],
322
- reasons_count: PositiveInt = 2,
323
- criteria_count: PositiveInt = 5,
324
- **kwargs: Unpack[ValidateKwargs],
331
+ criteria: Optional[Set[str]] = None,
332
+ weights: Optional[Dict[str, float]] = None,
333
+ manual: Optional[Dict[str, str]] = None,
334
+ **kwargs: Unpack[ValidateKwargs[List[Dict[str, float]]]],
325
335
  ) -> List[float]:
326
336
  """Calculates the composite scores for a list of items based on a given topic and criteria.
327
337
 
328
338
  Args:
329
339
  topic (str): The topic for the rating.
330
340
  to_rate (List[str]): A list of strings to be rated.
331
- reasons_count (PositiveInt, optional): The number of reasons to extract from each pair of examples. Defaults to 2.
332
- criteria_count (PositiveInt, optional): The number of criteria to draft. Defaults to 5.
341
+ criteria (Optional[Set[str]]): A set of criteria for the rating. Defaults to None.
342
+ weights (Optional[Dict[str, float]]): A dictionary of rating weights for each criterion. Defaults to None.
343
+ manual (Optional[Dict[str, str]]): A dictionary of manual ratings for each item. Defaults to None.
333
344
  **kwargs (Unpack[ValidateKwargs]): Additional keyword arguments for the LLM usage.
334
345
 
335
346
  Returns:
336
347
  List[float]: A list of composite scores for the items.
337
348
  """
338
- criteria = await self.draft_rating_criteria_from_examples(
339
- topic, to_rate, reasons_count, criteria_count, **kwargs
349
+ criteria = ok(
350
+ criteria
351
+ or await self.draft_rating_criteria_from_examples(topic, to_rate, **override_kwargs(kwargs, default=None))
352
+ )
353
+ weights = ok(
354
+ weights or await self.drafting_rating_weights_klee(topic, criteria, **override_kwargs(kwargs, default=None))
340
355
  )
341
- weights = await self.drafting_rating_weights_klee(topic, criteria, **kwargs)
342
356
  logger.info(f"Criteria: {criteria}\nWeights: {weights}")
343
- ratings_seq = await self.rate(to_rate, topic, criteria, **kwargs)
357
+ ratings_seq = await self.rate(to_rate, topic, criteria, manual, **kwargs)
344
358
 
345
359
  return [sum(ratings[c] * weights[c] for c in criteria) for ratings in ratings_seq]
360
+
361
+ @overload
362
+ async def best(self, candidates: List[str], k: int=1, **kwargs: Unpack[CompositeScoreKwargs]) -> List[str]: ...
363
+ @overload
364
+ async def best[T: Display](
365
+ self, candidates: List[T], k: int=1, **kwargs: Unpack[CompositeScoreKwargs]
366
+ ) -> List[T]: ...
367
+
368
+ async def best[T: Display](
369
+ self, candidates: List[str] | List[T], k: int=1, **kwargs: Unpack[CompositeScoreKwargs]
370
+ ) -> Optional[List[str] | List[T]]:
371
+ """Choose the best candidates from the list of candidates based on the composite score.
372
+
373
+ Args:
374
+ k (int): The number of best candidates to choose.
375
+ candidates (List[str]): A list of candidates to choose from.
376
+ **kwargs (CompositeScoreKwargs): Additional keyword arguments for the composite score calculation.
377
+
378
+ Returns:
379
+ List[str]: The best candidates.
380
+ """
381
+ if (leng := len(candidates)) == 0:
382
+ logger.warning(f"No candidates, got {leng}, return None.")
383
+ return None
384
+
385
+ if leng == 1:
386
+ logger.warning(f"Only one candidate, got {leng}, return it.")
387
+ return candidates
388
+ logger.info(f"Choose best {k} from {leng} candidates.")
389
+
390
+ rating_seq = await self.composite_score(
391
+ to_rate=[c.display() if isinstance(c, Display) else c for c in candidates], **kwargs
392
+ )
393
+ return [a[0] for a in sorted(zip(candidates, rating_seq, strict=True), key=lambda x: x[1], reverse=True)[:k]] # pyright: ignore [reportReturnType]
fabricatio/config.py CHANGED
@@ -229,9 +229,6 @@ class TemplateConfig(BaseModel):
229
229
  generic_string_template: str = Field(default="generic_string")
230
230
  """The name of the generic string template which will be used to review a string."""
231
231
 
232
- correct_template: str = Field(default="correct")
233
- """The name of the correct template which will be used to correct a string."""
234
-
235
232
  co_validation_template: str = Field(default="co_validation")
236
233
  """The name of the co-validation template which will be used to co-validate a string."""
237
234
 
@@ -241,6 +238,15 @@ class TemplateConfig(BaseModel):
241
238
  check_string_template: str = Field(default="check_string")
242
239
  """The name of the check string template which will be used to check a string."""
243
240
 
241
+ ruleset_requirement_breakdown_template: str = Field(default="ruleset_requirement_breakdown")
242
+ """The name of the ruleset requirement breakdown template which will be used to breakdown a ruleset requirement."""
243
+
244
+ fix_troubled_obj_template: str = Field(default="fix_troubled_obj")
245
+ """The name of the fix troubled object template which will be used to fix a troubled object."""
246
+
247
+ fix_troubled_string_template: str = Field(default="fix_troubled_string")
248
+ """The name of the fix troubled string template which will be used to fix a troubled string."""
249
+
244
250
  class MagikaConfig(BaseModel):
245
251
  """Magika configuration class."""
246
252
 
@@ -9,16 +9,14 @@ from abc import abstractmethod
9
9
  from asyncio import Queue, create_task
10
10
  from typing import Any, Dict, Self, Tuple, Type, Union, final
11
11
 
12
- from fabricatio.capabilities.correct import Correct
13
- from fabricatio.capabilities.task import HandleTask, ProposeTask
14
12
  from fabricatio.journal import logger
15
13
  from fabricatio.models.generic import WithBriefing
16
14
  from fabricatio.models.task import Task
17
- from fabricatio.models.usages import ToolBoxUsage
15
+ from fabricatio.models.usages import LLMUsage, ToolBoxUsage
18
16
  from pydantic import Field, PrivateAttr
19
17
 
20
18
 
21
- class Action(WithBriefing, HandleTask, ProposeTask, Correct):
19
+ class Action(WithBriefing, LLMUsage):
22
20
  """Class that represents an action to be executed in a workflow.
23
21
 
24
22
  Actions are the atomic units of work in a workflow. Each action performs
@@ -97,7 +95,8 @@ class WorkFlow(WithBriefing, ToolBoxUsage):
97
95
  A workflow manages the execution of multiple actions in sequence, passing
98
96
  a shared context between them and handling task lifecycle events.
99
97
  """
100
- description:str =""
98
+
99
+ description: str = ""
101
100
  """The description of the workflow, which describes the workflow's purpose and requirements."""
102
101
 
103
102
  _context: Queue[Dict[str, Any]] = PrivateAttr(default_factory=lambda: Queue(maxsize=1))
@@ -0,0 +1,25 @@
1
+ """A module containing kwargs types for content correction and checking operations."""
2
+ from fabricatio.models.extra.problem import Improvement
3
+ from fabricatio.models.extra.rule import RuleSet
4
+ from fabricatio.models.generic import SketchedAble
5
+ from fabricatio.models.kwargs_types import ReferencedKwargs
6
+
7
+
8
+ class CorrectKwargs[T: SketchedAble](ReferencedKwargs[T], total=False):
9
+ """Arguments for content correction operations.
10
+
11
+ Extends GenerateKwargs with parameters for correcting content based on
12
+ specific criteria and templates.
13
+ """
14
+
15
+ improvement: Improvement
16
+
17
+
18
+ class CheckKwargs(ReferencedKwargs[Improvement], total=False):
19
+ """Arguments for content checking operations.
20
+
21
+ Extends GenerateKwargs with parameters for checking content against
22
+ specific criteria and templates.
23
+ """
24
+
25
+ ruleset: RuleSet
@@ -5,18 +5,21 @@ from typing import List
5
5
  from fabricatio.models.generic import Display, ProposedAble
6
6
 
7
7
 
8
- class JudgeMent(ProposedAble,Display):
8
+ class JudgeMent(ProposedAble, Display):
9
9
  """Represents a judgment result containing supporting/denying evidence and final verdict.
10
10
 
11
11
  The class stores both affirmative and denies evidence, truth and reasons lists along with the final boolean judgment.
12
12
  """
13
+
14
+ issue_to_judge: str
15
+ """The issue to be judged"""
16
+
13
17
  deny_evidence: List[str]
14
18
  """List of clues supporting the denial."""
15
19
 
16
20
  affirm_evidence: List[str]
17
21
  """List of clues supporting the affirmation."""
18
22
 
19
-
20
23
  final_judgement: bool
21
24
  """The final judgment made according to all extracted clues."""
22
25
 
@@ -15,6 +15,7 @@ from fabricatio.models.generic import (
15
15
  PersistentAble,
16
16
  ProposedUpdateAble,
17
17
  ResolveUpdateConflict,
18
+ SequencePatch,
18
19
  )
19
20
 
20
21
 
@@ -29,7 +30,7 @@ class ReferringType(StrEnum):
29
30
  type RefKey = Tuple[str, Optional[str], Optional[str]]
30
31
 
31
32
 
32
- class ArticleRef(CensoredAble, Display, ProposedUpdateAble):
33
+ class ArticleRef(CensoredAble, ProposedUpdateAble):
33
34
  """Reference to a specific chapter, section or subsection within the article. You SHALL not refer to an article component that is external and not present within our own article.
34
35
 
35
36
  Examples:
@@ -120,25 +121,7 @@ class ArticleMetaData(CensoredAble, Display):
120
121
  """Do not add any prefix or suffix to the title. should not contain special characters."""
121
122
 
122
123
 
123
- class Patch[T](ProposedUpdateAble, Display):
124
- """Base class for patches."""
125
-
126
- tweaked: List[T]
127
- """Tweaked content list"""
128
-
129
- def update_from_inner(self, other: Self) -> Self:
130
- """Updates the current instance with the attributes of another instance."""
131
- self.tweaked.clear()
132
- self.tweaked.extend(other.tweaked)
133
- return self
134
-
135
- @classmethod
136
- def default(cls) -> Self:
137
- """Defaults to empty list."""
138
- return cls(tweaked=[])
139
-
140
-
141
- class ArticleRefPatch(Patch[ArticleRef]):
124
+ class ArticleRefSequencePatch(SequencePatch[ArticleRef]):
142
125
  """Patch for article refs."""
143
126
 
144
127
 
@@ -8,14 +8,13 @@ from fabricatio.models.extra.article_base import (
8
8
  ArticleBase,
9
9
  ArticleOutlineBase,
10
10
  ChapterBase,
11
- Patch,
12
11
  SectionBase,
13
12
  SubSectionBase,
14
13
  )
15
14
  from fabricatio.models.extra.article_outline import (
16
15
  ArticleOutline,
17
16
  )
18
- from fabricatio.models.generic import CensoredAble, Display, PersistentAble, WithRef
17
+ from fabricatio.models.generic import CensoredAble, Display, PersistentAble, SequencePatch, WithRef
19
18
  from fabricatio.utils import ok
20
19
 
21
20
 
@@ -32,7 +31,7 @@ class Paragraph(CensoredAble):
32
31
  """The actual content of the paragraph, represented as a string."""
33
32
 
34
33
 
35
- class ArticleParagraphPatch(Patch[Paragraph]):
34
+ class ArticleParagraphSequencePatch(SequencePatch[Paragraph]):
36
35
  """Patch for `Paragraph` list of `ArticleSubsection`."""
37
36
 
38
37
 
@@ -0,0 +1,7 @@
1
+ """A patch class for updating the description and name of a `WithBriefing` object."""
2
+
3
+ from fabricatio.models.generic import Patch, WithBriefing
4
+
5
+
6
+ class BriefingPatch[T:WithBriefing](Patch[T], WithBriefing):
7
+ """Patch class for updating the description and name of a `WithBriefing` object."""
@@ -1,14 +1,16 @@
1
1
  """A class representing a problem-solution pair identified during a review process."""
2
2
 
3
- from typing import List, Literal, Self
3
+ from itertools import chain
4
+ from typing import List, Literal, Optional, Self
4
5
 
5
- from fabricatio.models.generic import Display, ProposedAble, ProposedUpdateAble, WithBriefing
6
+ from fabricatio.journal import logger
7
+ from fabricatio.models.generic import SketchedAble, WithBriefing
6
8
  from fabricatio.utils import ask_edit
7
9
  from questionary import Choice, checkbox, text
8
10
  from rich import print as r_print
9
11
 
10
12
 
11
- class Problem(ProposedAble, WithBriefing, Display):
13
+ class Problem(SketchedAble, WithBriefing):
12
14
  """Represents a problem identified during review."""
13
15
 
14
16
  description: str
@@ -27,11 +29,14 @@ class Problem(ProposedAble, WithBriefing, Display):
27
29
  """Recommended solution or action."""
28
30
 
29
31
 
30
- class Solution(ProposedAble, WithBriefing, Display):
32
+ class Solution(SketchedAble, WithBriefing):
31
33
  """Represents a proposed solution to a problem."""
32
34
 
33
- operation: str
34
- """Description or identifier of the operation."""
35
+ description: str
36
+ """Description of the solution, including a detailed description of the execution steps, and the mechanics, principle or fact."""
37
+
38
+ execute_steps: List[str]
39
+ """A list of steps to execute to implement the solution, which is expected to be able to finally solve the corresponding problem."""
35
40
 
36
41
  feasibility: Literal["low", "medium", "high"]
37
42
  """Feasibility level of the solution."""
@@ -40,7 +45,7 @@ class Solution(ProposedAble, WithBriefing, Display):
40
45
  """Impact level of the solution."""
41
46
 
42
47
 
43
- class ProblemSolutions(ProposedUpdateAble):
48
+ class ProblemSolutions(SketchedAble):
44
49
  """Represents a problem-solution pair identified during a review process."""
45
50
 
46
51
  problem: Problem
@@ -78,10 +83,26 @@ class ProblemSolutions(ProposedUpdateAble):
78
83
  self.solutions = [Solution.model_validate_strings(s) for s in string_seq]
79
84
  return self
80
85
 
86
+ def decided(self) -> bool:
87
+ """Check if the improvement is decided."""
88
+ return len(self.solutions) == 1
89
+
90
+ def final_solution(self) -> Optional[Solution]:
91
+ """Get the final solution."""
92
+ if not self.decided():
93
+ logger.error(
94
+ f"There is more than one solution for problem {self.problem.name}, please decide which solution is eventually adopted."
95
+ )
96
+ return None
97
+ return self.solutions[0]
98
+
81
99
 
82
- class Improvement(ProposedAble, Display):
100
+ class Improvement(SketchedAble):
83
101
  """A class representing an improvement suggestion."""
84
102
 
103
+ focused_on: str
104
+ """The focused on topic of the improvement"""
105
+
85
106
  problem_solutions: List[ProblemSolutions]
86
107
  """Collection of problems identified during review along with their potential solutions."""
87
108
 
@@ -118,3 +139,15 @@ class Improvement(ProposedAble, Display):
118
139
  await to_exam.edit_solutions()
119
140
 
120
141
  return self
142
+
143
+ def decided(self) -> bool:
144
+ """Check if the improvement is decided."""
145
+ return all(ps.decided() for ps in self.problem_solutions)
146
+
147
+ @classmethod
148
+ def gather(cls, *improvements: Self) -> Self:
149
+ """Gather multiple improvements into a single instance."""
150
+ return cls(
151
+ focused_on="\n".join(imp.focused_on for imp in improvements),
152
+ problem_solutions=list(chain(*(imp.problem_solutions for imp in improvements))),
153
+ )
@@ -2,7 +2,7 @@
2
2
 
3
3
  from typing import List
4
4
 
5
- from fabricatio.models.generic import Described, Display, PersistentAble, ProposedAble, WithBriefing
5
+ from fabricatio.models.generic import Display, PersistentAble, ProposedAble, WithBriefing
6
6
 
7
7
 
8
8
  class Rule(WithBriefing,ProposedAble,Display):
@@ -14,10 +14,8 @@ class Rule(WithBriefing,ProposedAble,Display):
14
14
  """Examples of how to comply with the rule."""
15
15
 
16
16
 
17
- class RuleSet(ProposedAble, Display, PersistentAble, Described):
17
+ class RuleSet(ProposedAble, Display, PersistentAble, WithBriefing):
18
18
  """Represents a collection of rules and guidelines for a particular topic."""
19
19
 
20
- title: str
21
- """The title of the rule set."""
22
20
  rules: List[Rule]
23
21
  """The rules and guidelines contained in the rule set."""
@@ -54,6 +54,11 @@ class Display(Base):
54
54
  """
55
55
  return self.model_dump_json()
56
56
 
57
+ @staticmethod
58
+ def seq_display(seq: Iterable["Display"], compact: bool = False) -> str:
59
+ """Display a sequence of Display objects in a formatted JSON string."""
60
+ return "\n".join(d.compact() if compact else d.display() for d in seq)
61
+
57
62
 
58
63
  class Named(Base):
59
64
  """Class that includes a name attribute."""
@@ -136,7 +141,7 @@ class PersistentAble(Base):
136
141
  Self: The current instance of the object.
137
142
  """
138
143
  p = Path(path)
139
- out = rtoml.dumps(self.model_dump())
144
+ out = self.model_dump_json()
140
145
 
141
146
  # Generate a timestamp in the format YYYYMMDD_HHMMSS
142
147
  timestamp = datetime.now().strftime("%Y%m%d")
@@ -166,7 +171,7 @@ class PersistentAble(Base):
166
171
  Returns:
167
172
  Self: The current instance of the object.
168
173
  """
169
- return cls.model_validate(rtoml.load(path))
174
+ return cls.model_validate_json(safe_text_read(path))
170
175
 
171
176
 
172
177
  class ModelHash(Base):
@@ -309,14 +314,20 @@ class InstantiateFromString(Base):
309
314
  Returns:
310
315
  Self | None: The instance of the class or None if the string is not valid.
311
316
  """
312
- return JsonCapture.convert_with(string, cls.model_validate_json)
317
+ obj = JsonCapture.convert_with(string, cls.model_validate_json)
318
+ logger.debug(f"Instantiate `{cls.__name__}` from string, {'Failed' if obj is None else 'Success'}.")
319
+ return obj
313
320
 
314
321
 
315
322
  class ProposedAble(CreateJsonObjPrompt, InstantiateFromString):
316
323
  """Class that provides a method to propose a JSON object based on the requirement."""
317
324
 
318
325
 
319
- class ProposedUpdateAble(ProposedAble, UpdateFrom, ABC):
326
+ class SketchedAble(ProposedAble, Display):
327
+ """Class that provides a method to scratch the object."""
328
+
329
+
330
+ class ProposedUpdateAble(SketchedAble, UpdateFrom, ABC):
320
331
  """Make the obj can be updated from the proposed obj in place."""
321
332
 
322
333
 
@@ -344,8 +355,6 @@ class FinalizedDumpAble(Base):
344
355
  return self
345
356
 
346
357
 
347
- class CensoredAble(ProposedAble, FinalizedDumpAble):
348
- """Class that provides a method to censor the object."""
349
358
 
350
359
 
351
360
  class WithDependency(Base):
@@ -567,3 +576,33 @@ class ScopedConfig(Base):
567
576
  if (attr := getattr(self, attr_name)) is not None and getattr(other, attr_name) is None:
568
577
  setattr(other, attr_name, attr)
569
578
  return self
579
+
580
+
581
+ class Patch[T](ProposedAble):
582
+ """Base class for patches."""
583
+
584
+ def apply(self, other: T) -> T:
585
+ """Apply the patch to another instance."""
586
+ for field in self.__class__.model_fields:
587
+ if not hasattr(other, field):
588
+ raise ValueError(f"{field} not found in {other}, are you applying to the wrong type?")
589
+ setattr(other, field, getattr(self, field))
590
+ return other
591
+
592
+
593
+ class SequencePatch[T](ProposedUpdateAble):
594
+ """Base class for patches."""
595
+
596
+ tweaked: List[T]
597
+ """Tweaked content list"""
598
+
599
+ def update_from_inner(self, other: Self) -> Self:
600
+ """Updates the current instance with the attributes of another instance."""
601
+ self.tweaked.clear()
602
+ self.tweaked.extend(other.tweaked)
603
+ return self
604
+
605
+ @classmethod
606
+ def default(cls) -> Self:
607
+ """Defaults to empty list."""
608
+ return cls(tweaked=[])
@@ -1,7 +1,7 @@
1
1
  """This module contains the types for the keyword arguments of the methods in the models module."""
2
2
 
3
3
  from importlib.util import find_spec
4
- from typing import Any, Dict, Required, TypedDict
4
+ from typing import Any, Dict, List, Optional, Required, TypedDict
5
5
 
6
6
  from litellm.caching.caching import CacheMode
7
7
  from litellm.types.caching import CachingSupportedCallTypes
@@ -95,11 +95,30 @@ class ValidateKwargs[T](GenerateKwargs, total=False):
95
95
  such as limiting the number of validation attempts.
96
96
  """
97
97
 
98
- default: T
98
+ default: Optional[T]
99
99
  max_validations: int
100
100
  co_extractor: GenerateKwargs
101
101
 
102
102
 
103
+ class CompositeScoreKwargs(ValidateKwargs[List[Dict[str, float]]], total=False):
104
+ """Arguments for composite score generation operations.
105
+
106
+ Extends GenerateKwargs with parameters for generating composite scores
107
+ based on specific criteria and weights.
108
+ """
109
+
110
+ topic: str
111
+ criteria: set[str]
112
+ weights: Dict[str, float]
113
+ manual: Dict[str, str]
114
+
115
+
116
+ class BestKwargs(CompositeScoreKwargs, total=False):
117
+ """Arguments for choose top-k operations."""
118
+
119
+ k: int
120
+
121
+
103
122
  class ReviewInnerKwargs[T](ValidateKwargs[T], total=False):
104
123
  """Arguments for content review operations."""
105
124
 
@@ -118,22 +137,9 @@ class ReviewKwargs[T](ReviewInnerKwargs[T], total=False):
118
137
  topic: Required[str]
119
138
 
120
139
 
121
- class CorrectKwargs[T](ReviewKwargs[T], total=False):
122
- """Arguments for content correction operations.
123
-
124
- Extends GenerateKwargs with parameters for correcting content based on
125
- specific criteria and templates.
126
- """
127
-
128
- reference: str
129
- supervisor_check: bool
130
-
131
-
132
- class CensoredCorrectKwargs[T](ReviewInnerKwargs[T], total=False):
133
- """Arguments for content censorship operations."""
134
-
140
+ class ReferencedKwargs[T](ValidateKwargs[T], total=False):
141
+ """Arguments for content review operations."""
135
142
  reference: str
136
- supervisor_check: bool
137
143
 
138
144
 
139
145
  # noinspection PyTypedDict