fabricatio 0.3.15.dev5__cp313-cp313-win_amd64.whl → 0.4.0__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.
Files changed (56) hide show
  1. fabricatio/__init__.py +9 -8
  2. fabricatio/actions/rules.py +83 -83
  3. fabricatio/rust.cp313-win_amd64.pyd +0 -0
  4. fabricatio/workflows/rag.py +2 -1
  5. fabricatio-0.4.0.data/scripts/tdown.exe +0 -0
  6. {fabricatio-0.3.15.dev5.dist-info → fabricatio-0.4.0.dist-info}/METADATA +17 -16
  7. fabricatio-0.4.0.dist-info/RECORD +18 -0
  8. fabricatio/actions/article.py +0 -415
  9. fabricatio/actions/article_rag.py +0 -407
  10. fabricatio/capabilities/__init__.py +0 -1
  11. fabricatio/capabilities/advanced_judge.py +0 -20
  12. fabricatio/capabilities/advanced_rag.py +0 -61
  13. fabricatio/capabilities/censor.py +0 -105
  14. fabricatio/capabilities/check.py +0 -212
  15. fabricatio/capabilities/correct.py +0 -228
  16. fabricatio/capabilities/extract.py +0 -74
  17. fabricatio/capabilities/propose.py +0 -65
  18. fabricatio/capabilities/rag.py +0 -264
  19. fabricatio/capabilities/rating.py +0 -404
  20. fabricatio/capabilities/review.py +0 -114
  21. fabricatio/capabilities/task.py +0 -113
  22. fabricatio/decorators.py +0 -253
  23. fabricatio/emitter.py +0 -177
  24. fabricatio/fs/__init__.py +0 -35
  25. fabricatio/fs/curd.py +0 -153
  26. fabricatio/fs/readers.py +0 -61
  27. fabricatio/journal.py +0 -12
  28. fabricatio/models/action.py +0 -263
  29. fabricatio/models/adv_kwargs_types.py +0 -63
  30. fabricatio/models/extra/__init__.py +0 -1
  31. fabricatio/models/extra/advanced_judge.py +0 -32
  32. fabricatio/models/extra/aricle_rag.py +0 -286
  33. fabricatio/models/extra/article_base.py +0 -488
  34. fabricatio/models/extra/article_essence.py +0 -98
  35. fabricatio/models/extra/article_main.py +0 -285
  36. fabricatio/models/extra/article_outline.py +0 -45
  37. fabricatio/models/extra/article_proposal.py +0 -52
  38. fabricatio/models/extra/patches.py +0 -20
  39. fabricatio/models/extra/problem.py +0 -165
  40. fabricatio/models/extra/rag.py +0 -98
  41. fabricatio/models/extra/rule.py +0 -51
  42. fabricatio/models/generic.py +0 -904
  43. fabricatio/models/kwargs_types.py +0 -121
  44. fabricatio/models/role.py +0 -156
  45. fabricatio/models/task.py +0 -310
  46. fabricatio/models/tool.py +0 -328
  47. fabricatio/models/usages.py +0 -791
  48. fabricatio/parser.py +0 -114
  49. fabricatio/rust.pyi +0 -846
  50. fabricatio/utils.py +0 -156
  51. fabricatio/workflows/articles.py +0 -24
  52. fabricatio-0.3.15.dev5.data/scripts/tdown.exe +0 -0
  53. fabricatio-0.3.15.dev5.data/scripts/ttm.exe +0 -0
  54. fabricatio-0.3.15.dev5.dist-info/RECORD +0 -63
  55. {fabricatio-0.3.15.dev5.dist-info → fabricatio-0.4.0.dist-info}/WHEEL +0 -0
  56. {fabricatio-0.3.15.dev5.dist-info → fabricatio-0.4.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,212 +0,0 @@
1
- """A class that provides the capability to check strings and objects against rules and guidelines."""
2
-
3
- from abc import ABC
4
- from asyncio import gather
5
- from typing import List, Optional, Unpack
6
-
7
- from fabricatio.capabilities.advanced_judge import AdvancedJudge
8
- from fabricatio.capabilities.propose import Propose
9
- from fabricatio.journal import logger
10
- from fabricatio.models.extra.patches import RuleSetMetadata
11
- from fabricatio.models.extra.problem import Improvement
12
- from fabricatio.models.extra.rule import Rule, RuleSet
13
- from fabricatio.models.generic import Display, WithBriefing
14
- from fabricatio.models.kwargs_types import ValidateKwargs
15
- from fabricatio.rust import CONFIG, TEMPLATE_MANAGER, detect_language
16
- from fabricatio.utils import override_kwargs
17
-
18
-
19
- class Check(AdvancedJudge, Propose, ABC):
20
- """Class for validating strings/objects against predefined rules and guidelines.
21
-
22
- This capability combines rule-based judgment and proposal generation to provide
23
- structured validation results with actionable improvement suggestions.
24
- """
25
-
26
- async def draft_ruleset(
27
- self, ruleset_requirement: str, rule_count: int = 0, **kwargs: Unpack[ValidateKwargs[Rule]]
28
- ) -> Optional[RuleSet]:
29
- """Generate rule set based on requirement description.
30
-
31
- Args:
32
- ruleset_requirement (str): Natural language description of desired ruleset characteristics
33
- rule_count (int): Number of rules to generate (0 for default count)
34
- **kwargs: Validation parameters for rule generation
35
-
36
- Returns:
37
- Optional[RuleSet]: Validated ruleset object or None if generation fails
38
-
39
- Notes:
40
- - Requires valid template configuration in configs.templates
41
- - Returns None if any step in rule generation fails
42
- - Uses `alist_str` for requirement breakdown and iterative rule proposal
43
- """
44
- rule_reqs = (
45
- await self.alist_str(
46
- TEMPLATE_MANAGER.render_template(
47
- CONFIG.templates.ruleset_requirement_breakdown_template,
48
- {"ruleset_requirement": ruleset_requirement},
49
- ),
50
- rule_count,
51
- **override_kwargs(kwargs, default=None),
52
- )
53
- if rule_count > 1
54
- else [ruleset_requirement]
55
- )
56
-
57
- if rule_reqs is None:
58
- return None
59
-
60
- rules = await self.propose(
61
- Rule,
62
- [
63
- TEMPLATE_MANAGER.render_template(CONFIG.templates.rule_requirement_template, {"rule_requirement": r})
64
- for r in rule_reqs
65
- ],
66
- **kwargs,
67
- )
68
- if any(r for r in rules if r is None):
69
- return None
70
-
71
- ruleset_patch = await self.propose(
72
- RuleSetMetadata,
73
- f"{ruleset_requirement}\n\nYou should use `{detect_language(ruleset_requirement)}`!",
74
- **override_kwargs(kwargs, default=None),
75
- )
76
-
77
- if ruleset_patch is None:
78
- return None
79
-
80
- return RuleSet(rules=rules, **ruleset_patch.as_kwargs())
81
-
82
- async def check_string_against_rule(
83
- self,
84
- input_text: str,
85
- rule: Rule,
86
- reference: str = "",
87
- **kwargs: Unpack[ValidateKwargs[Improvement]],
88
- ) -> Optional[Improvement]:
89
- """Validate text against specific rule.
90
-
91
- Args:
92
- input_text (str): Text content to validate
93
- rule (Rule): Rule instance for validation
94
- reference (str): Reference text for comparison (default: "")
95
- **kwargs: Configuration for validation process
96
-
97
- Returns:
98
- Optional[Improvement]: Suggested improvement if violation detected
99
-
100
- Notes:
101
- - Uses `evidently_judge` to determine violation presence
102
- - Renders template using `check_string_template` for proposal
103
- - Proposes Improvement only when violation is confirmed
104
- """
105
- if judge := await self.evidently_judge(
106
- f"# Content to exam\n{input_text}\n\n# Rule Must to follow\n{rule.display()}\nDoes `Content to exam` provided above violate the `{rule.name}` provided above?"
107
- f"should I take some measure to fix that violation? true for I do need, false for I don't need.",
108
- **override_kwargs(kwargs, default=None),
109
- ):
110
- logger.info(f"Rule `{rule.name}` violated: \n{judge.display()}")
111
- return await self.propose(
112
- Improvement,
113
- TEMPLATE_MANAGER.render_template(
114
- CONFIG.templates.check_string_template,
115
- {"to_check": input_text, "rule": rule.display(), "judge": judge.display(), "reference": reference},
116
- ),
117
- **kwargs,
118
- )
119
- return None
120
-
121
- async def check_obj_against_rule[M: (Display, WithBriefing)](
122
- self,
123
- obj: M,
124
- rule: Rule,
125
- reference: str = "",
126
- **kwargs: Unpack[ValidateKwargs[Improvement]],
127
- ) -> Optional[Improvement]:
128
- """Validate object against rule using text representation.
129
-
130
- Args:
131
- obj (M): Object implementing Display/WithBriefing interface
132
- rule (Rule): Validation rule
133
- reference (str): Reference text for comparison (default: "")
134
- **kwargs: Validation configuration parameters
135
-
136
- Returns:
137
- Optional[Improvement]: Improvement suggestion if issues found
138
-
139
- Notes:
140
- - Requires obj to implement display() or briefing property
141
- - Raises TypeError for incompatible object types
142
- - Converts object to text before string validation
143
- """
144
- if isinstance(obj, Display):
145
- input_text = obj.display()
146
- elif isinstance(obj, WithBriefing):
147
- input_text = obj.briefing
148
- else:
149
- raise TypeError("obj must be either Display or WithBriefing")
150
-
151
- return await self.check_string_against_rule(input_text, rule, reference, **kwargs)
152
-
153
- async def check_string(
154
- self,
155
- input_text: str,
156
- ruleset: RuleSet,
157
- reference: str = "",
158
- **kwargs: Unpack[ValidateKwargs[Improvement]],
159
- ) -> Optional[List[Improvement]]:
160
- """Validate text against full ruleset.
161
-
162
- Args:
163
- input_text (str): Text content to validate
164
- ruleset (RuleSet): Collection of validation rules
165
- reference (str): Reference text for comparison
166
- **kwargs: Validation configuration parameters
167
-
168
- Returns:
169
- Optional[Improvement]: First detected improvement
170
-
171
- Notes:
172
- - Checks rules sequentially and returns first violation
173
- - Halts validation after first successful improvement proposal
174
- - Maintains rule execution order from ruleset.rules list
175
- """
176
- imp_seq = await gather(
177
- *[self.check_string_against_rule(input_text, rule, reference, **kwargs) for rule in ruleset.rules]
178
- )
179
- if imp_seq is None:
180
- logger.warning(f"Generation failed for string check against `{ruleset.name}`")
181
- return None
182
- return [imp for imp in imp_seq if imp]
183
-
184
- async def check_obj[M: (Display, WithBriefing)](
185
- self,
186
- obj: M,
187
- ruleset: RuleSet,
188
- reference: str = "",
189
- **kwargs: Unpack[ValidateKwargs[Improvement]],
190
- ) -> Optional[List[Improvement]]:
191
- """Validate object against full ruleset.
192
-
193
- Args:
194
- obj (M): Object implementing Display/WithBriefing interface
195
- ruleset (RuleSet): Collection of validation rules
196
- reference (str): Reference text for comparison (default: "")
197
- **kwargs: Validation configuration parameters
198
-
199
- Returns:
200
- Optional[Improvement]: First detected improvement
201
-
202
- Notes:
203
- - Uses check_obj_against_rule for individual rule checks
204
- - Maintains same early termination behavior as check_string
205
- - Validates object through text conversion mechanism
206
- """
207
- imp_seq = await gather(*[self.check_obj_against_rule(obj, rule, reference, **kwargs) for rule in ruleset.rules])
208
-
209
- if imp_seq is None:
210
- logger.warning(f"Generation Failed for `{obj.__class__.__name__}` against Ruleset `{ruleset.name}`")
211
- return None
212
- return [i for i in imp_seq if i]
@@ -1,228 +0,0 @@
1
- """A module containing the Correct capability for reviewing, validating, and improving objects."""
2
-
3
- from abc import ABC
4
- from asyncio import gather
5
- from typing import Optional, Type, Unpack, cast
6
-
7
- from fabricatio.capabilities.propose import Propose
8
- from fabricatio.capabilities.rating import Rating
9
- from fabricatio.journal import logger
10
- from fabricatio.models.adv_kwargs_types import CorrectKwargs
11
- from fabricatio.models.extra.problem import Improvement, ProblemSolutions
12
- from fabricatio.models.generic import ProposedUpdateAble, SketchedAble
13
- from fabricatio.models.kwargs_types import (
14
- BestKwargs,
15
- ValidateKwargs,
16
- )
17
- from fabricatio.rust import CONFIG, TEMPLATE_MANAGER
18
- from fabricatio.utils import fallback_kwargs, ok, override_kwargs
19
-
20
-
21
- class Correct(Rating, Propose, ABC):
22
- """A class that provides the capability to correct objects."""
23
-
24
- async def decide_solution(
25
- self, problem_solutions: ProblemSolutions, **kwargs: Unpack[BestKwargs]
26
- ) -> ProblemSolutions:
27
- """Decide the best solution from a list of problem solutions.
28
-
29
- Args:
30
- problem_solutions (ProblemSolutions): The problem solutions to evaluate.
31
- **kwargs (Unpack[BestKwargs]): Additional keyword arguments for the decision process.
32
-
33
- Returns:
34
- ProblemSolutions: The problem solutions with the best solution selected.
35
- """
36
- if (leng := len(problem_solutions.solutions)) == 0:
37
- logger.error(f"No solutions found in ProblemSolutions, Skip: `{problem_solutions.problem.name}`")
38
- if leng > 1:
39
- logger.info(f"{leng} solutions found in Problem `{problem_solutions.problem.name}`, select the best.")
40
- problem_solutions.solutions = await self.best(problem_solutions.solutions, **kwargs)
41
- return problem_solutions
42
-
43
- async def decide_improvement(self, improvement: Improvement, **kwargs: Unpack[BestKwargs]) -> Improvement:
44
- """Decide the best solution for each problem solution in an improvement.
45
-
46
- Args:
47
- improvement (Improvement): The improvement containing problem solutions to evaluate.
48
- **kwargs (Unpack[BestKwargs]): Additional keyword arguments for the decision process.
49
-
50
- Returns:
51
- Improvement: The improvement with the best solutions selected for each problem solution.
52
- """
53
- if leng := len(improvement.problem_solutions):
54
- logger.debug(f"{leng} problem_solutions found in Improvement, decide solution for each of them.")
55
- await gather(
56
- *[
57
- self.decide_solution(
58
- ps,
59
- **fallback_kwargs(
60
- kwargs, topic=f"which solution is better to deal this problem {ps.problem.description}\n\n"
61
- ),
62
- )
63
- for ps in improvement.problem_solutions
64
- ],
65
- )
66
- if any(not (violated := ps).decided() for ps in improvement.problem_solutions):
67
- logger.error(f"Some problem_solutions are not decided: {violated}")
68
- else:
69
- logger.success(f"All problem_solutions are decided '{improvement.focused_on}'")
70
- else:
71
- logger.error(f"No problem_solutions found in Improvement, Skip: {improvement}")
72
- return improvement
73
-
74
- async def fix_troubled_obj[M: SketchedAble](
75
- self,
76
- obj: M,
77
- problem_solutions: ProblemSolutions,
78
- reference: str = "",
79
- **kwargs: Unpack[ValidateKwargs[M]],
80
- ) -> Optional[M]:
81
- """Fix a troubled object based on problem solutions.
82
-
83
- Args:
84
- obj (M): The object to be fixed.
85
- problem_solutions (ProblemSolutions): The problem solutions to apply.
86
- reference (str): A reference or contextual information for the object.
87
- **kwargs (Unpack[ValidateKwargs[M]]): Additional keyword arguments for the validation process.
88
-
89
- Returns:
90
- Optional[M]: The fixed object, or None if fixing fails.
91
- """
92
- return await self.propose(
93
- cast("Type[M]", obj.__class__),
94
- TEMPLATE_MANAGER.render_template(
95
- CONFIG.templates.fix_troubled_obj_template,
96
- {
97
- "problem": problem_solutions.problem.display(),
98
- "solution": ok(
99
- problem_solutions.final_solution(),
100
- f"{len(problem_solutions.solutions)} solution Found for `{problem_solutions.problem.name}`.",
101
- ).display(),
102
- "reference": reference,
103
- },
104
- ),
105
- **kwargs,
106
- )
107
-
108
- async def fix_troubled_string(
109
- self,
110
- input_text: str,
111
- problem_solutions: ProblemSolutions,
112
- reference: str = "",
113
- **kwargs: Unpack[ValidateKwargs[str]],
114
- ) -> Optional[str]:
115
- """Fix a troubled string based on problem solutions.
116
-
117
- Args:
118
- input_text (str): The string to be fixed.
119
- problem_solutions (ProblemSolutions): The problem solutions to apply.
120
- reference (str): A reference or contextual information for the string.
121
- **kwargs (Unpack[ValidateKwargs[str]]): Additional keyword arguments for the validation process.
122
-
123
- Returns:
124
- Optional[str]: The fixed string, or None if fixing fails.
125
- """
126
- return await self.ageneric_string(
127
- TEMPLATE_MANAGER.render_template(
128
- CONFIG.templates.fix_troubled_string_template,
129
- {
130
- "problem": problem_solutions.problem.display(),
131
- "solution": ok(
132
- problem_solutions.final_solution(),
133
- f"No solution found for problem: {problem_solutions.problem}",
134
- ).display(),
135
- "reference": reference,
136
- "string_to_fix": input_text,
137
- },
138
- ),
139
- **kwargs,
140
- )
141
-
142
- async def correct_obj[M: SketchedAble](
143
- self,
144
- obj: M,
145
- improvement: Improvement,
146
- reference: str = "",
147
- **kwargs: Unpack[ValidateKwargs[M]],
148
- ) -> Optional[M]:
149
- """Review and correct an object based on defined criteria and templates.
150
-
151
- This method first conducts a review of the given object, then uses the review results
152
- to generate a corrected version of the object using appropriate templates.
153
-
154
- Args:
155
- obj (M): The object to be reviewed and corrected. Must implement ProposedAble.
156
- improvement (Improvement): The improvement object containing the review results.
157
- reference (str): A reference or contextual information for the object.
158
- **kwargs (Unpack[ValidateKwargs[M]]): Review configuration parameters including criteria and review options.
159
-
160
- Returns:
161
- Optional[M]: A corrected version of the input object, or None if correction fails.
162
-
163
- Raises:
164
- TypeError: If the provided object doesn't implement Display or WithBriefing interfaces.
165
- """
166
- if not improvement.decided():
167
- logger.info(f"Improvement {improvement.focused_on} not decided, start deciding...")
168
- improvement = await self.decide_improvement(improvement, **override_kwargs(kwargs, default=None))
169
-
170
- total = len(improvement.problem_solutions)
171
- for idx, ps in enumerate(improvement.problem_solutions):
172
- logger.info(f"[{idx + 1}/{total}] Fixing {obj.__class__.__name__} for problem `{ps.problem.name}`")
173
- fixed_obj = await self.fix_troubled_obj(obj, ps, reference, **kwargs)
174
- if fixed_obj is None:
175
- logger.error(f"[{idx + 1}/{total}] Failed to fix problem `{ps.problem.name}`")
176
- return None
177
- obj = fixed_obj
178
- return obj
179
-
180
- async def correct_string(
181
- self, input_text: str, improvement: Improvement, reference: str = "", **kwargs: Unpack[ValidateKwargs[str]]
182
- ) -> Optional[str]:
183
- """Review and correct a string based on defined criteria and templates.
184
-
185
- This method first conducts a review of the given string, then uses the review results
186
- to generate a corrected version of the string using appropriate templates.
187
-
188
- Args:
189
- input_text (str): The string to be reviewed and corrected.
190
- improvement (Improvement): The improvement object containing the review results.
191
- reference (str): A reference or contextual information for the string.
192
- **kwargs (Unpack[ValidateKwargs[str]]): Review configuration parameters including criteria and review options.
193
-
194
- Returns:
195
- Optional[str]: A corrected version of the input string, or None if correction fails.
196
- """
197
- if not improvement.decided():
198
- logger.info(f"Improvement {improvement.focused_on} not decided, start deciding...")
199
-
200
- improvement = await self.decide_improvement(improvement, **override_kwargs(kwargs, default=None))
201
-
202
- for ps in improvement.problem_solutions:
203
- fixed_string = await self.fix_troubled_string(input_text, ps, reference, **kwargs)
204
- if fixed_string is None:
205
- logger.error(
206
- f"Failed to fix troubling string when deal with problem: {ps.problem}",
207
- )
208
- return None
209
- input_text = fixed_string
210
- return input_text
211
-
212
- async def correct_obj_inplace[M: ProposedUpdateAble](
213
- self, obj: M, **kwargs: Unpack[CorrectKwargs[M]]
214
- ) -> Optional[M]:
215
- """Correct an object in place based on defined criteria and templates.
216
-
217
- Args:
218
- obj (M): The object to be corrected.
219
- **kwargs (Unpack[CorrectKwargs[M]]): Additional keyword arguments for the correction process.
220
-
221
- Returns:
222
- Optional[M]: The corrected object, or None if correction fails.
223
- """
224
- corrected_obj = await self.correct_obj(obj, **kwargs)
225
- if corrected_obj is None:
226
- return corrected_obj
227
- obj.update_from(corrected_obj)
228
- return obj
@@ -1,74 +0,0 @@
1
- """A module that provide capabilities for extracting information from a given source to a model."""
2
-
3
- from abc import ABC
4
- from typing import List, Optional, Type, Unpack, overload
5
-
6
- from fabricatio import TEMPLATE_MANAGER
7
- from fabricatio.capabilities.propose import Propose
8
- from fabricatio.models.generic import ProposedAble
9
- from fabricatio.models.kwargs_types import ValidateKwargs
10
- from fabricatio.rust import CONFIG
11
-
12
-
13
- class Extract(Propose, ABC):
14
- """A class that extract information from a given source to a model."""
15
-
16
- @overload
17
- async def extract[M: ProposedAble](
18
- self,
19
- cls: Type[M],
20
- source: str,
21
- extract_requirement: Optional[str] = None,
22
- align_language: bool = True,
23
- **kwargs: Unpack[ValidateKwargs[M]],
24
- ) -> M: ...
25
-
26
- @overload
27
- async def extract[M: ProposedAble](
28
- self,
29
- cls: Type[M],
30
- source: str,
31
- extract_requirement: Optional[str] = None,
32
- align_language: bool = True,
33
- **kwargs: Unpack[ValidateKwargs[None]],
34
- ) -> Optional[M]: ...
35
-
36
- @overload
37
- async def extract[M: ProposedAble](
38
- self,
39
- cls: Type[M],
40
- source: List[str],
41
- extract_requirement: Optional[str] = None,
42
- align_language: bool = True,
43
- **kwargs: Unpack[ValidateKwargs[M]],
44
- ) -> List[M]: ...
45
-
46
- @overload
47
- async def extract[M: ProposedAble](
48
- self,
49
- cls: Type[M],
50
- source: List[str],
51
- extract_requirement: Optional[str] = None,
52
- align_language: bool = True,
53
- **kwargs: Unpack[ValidateKwargs[None]],
54
- ) -> List[Optional[M]]: ...
55
-
56
- async def extract[M: ProposedAble](
57
- self,
58
- cls: Type[M],
59
- source: List[str] | str,
60
- extract_requirement: Optional[str] = None,
61
- align_language: bool = True,
62
- **kwargs: Unpack[ValidateKwargs[Optional[M]]],
63
- ) -> M | List[M] | Optional[M] | List[Optional[M]]:
64
- """Extract information from a given source to a model."""
65
- return await self.propose(
66
- cls,
67
- prompt=TEMPLATE_MANAGER.render_template(
68
- CONFIG.templates.extract_template,
69
- [{"source": s, "extract_requirement": extract_requirement} for s in source]
70
- if isinstance(source, list)
71
- else {"source": source, "extract_requirement": extract_requirement, "align_language": align_language},
72
- ),
73
- **kwargs,
74
- )
@@ -1,65 +0,0 @@
1
- """A module for the task capabilities of the Fabricatio library."""
2
- from abc import ABC
3
- from typing import List, Optional, Type, Unpack, overload
4
-
5
- from fabricatio.models.generic import ProposedAble
6
- from fabricatio.models.kwargs_types import ValidateKwargs
7
- from fabricatio.models.usages import LLMUsage
8
-
9
-
10
- class Propose(LLMUsage,ABC):
11
- """A class that proposes an Obj based on a prompt."""
12
-
13
- @overload
14
- async def propose[M: ProposedAble](
15
- self,
16
- cls: Type[M],
17
- prompt: List[str],
18
- **kwargs: Unpack[ValidateKwargs[None]],
19
- ) -> List[Optional[M]]: ...
20
-
21
- @overload
22
- async def propose[M: ProposedAble](
23
- self,
24
- cls: Type[M],
25
- prompt: List[str],
26
- **kwargs: Unpack[ValidateKwargs[M]],
27
- ) -> List[M]: ...
28
-
29
- @overload
30
- async def propose[M: ProposedAble](
31
- self,
32
- cls: Type[M],
33
- prompt: str,
34
- **kwargs: Unpack[ValidateKwargs[None]],
35
- ) -> Optional[M]: ...
36
- @overload
37
- async def propose[M: ProposedAble](
38
- self,
39
- cls: Type[M],
40
- prompt: str,
41
- **kwargs: Unpack[ValidateKwargs[M]],
42
- ) -> M: ...
43
-
44
- async def propose[M: ProposedAble](
45
- self,
46
- cls: Type[M],
47
- prompt: List[str] | str,
48
- **kwargs: Unpack[ValidateKwargs[Optional[M]]],
49
- ) -> Optional[M] | List[Optional[M]] | M | List[M]:
50
- """Asynchronously proposes a task based on a given prompt and parameters.
51
-
52
- Parameters:
53
- cls: The class type of the task to be proposed.
54
- prompt: The prompt text for proposing a task, which is a string that must be provided.
55
- **kwargs: The keyword arguments for the LLM (Large Language Model) usage.
56
-
57
- Returns:
58
- A Task object based on the proposal result.
59
- """
60
- return await self.aask_validate(
61
- question=cls.create_json_prompt(prompt),
62
- validator=cls.instantiate_from_string,
63
- **kwargs,
64
- )
65
-