fabricatio 0.2.5.dev2__cp312-cp312-manylinux_2_34_x86_64.whl → 0.2.5.dev3__cp312-cp312-manylinux_2_34_x86_64.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 +1 -1
- fabricatio/_rust_instances.py +0 -1
- fabricatio/capabilities/propose.py +3 -3
- fabricatio/capabilities/rating.py +15 -1
- fabricatio/capabilities/review.py +30 -4
- fabricatio/fs/__init__.py +2 -0
- fabricatio/fs/curd.py +13 -0
- fabricatio/journal.py +0 -1
- fabricatio/models/action.py +3 -4
- fabricatio/models/kwargs_types.py +50 -10
- fabricatio/models/usages.py +38 -35
- fabricatio/toolboxes/fs.py +2 -0
- {fabricatio-0.2.5.dev2.dist-info → fabricatio-0.2.5.dev3.dist-info}/METADATA +1 -1
- {fabricatio-0.2.5.dev2.dist-info → fabricatio-0.2.5.dev3.dist-info}/RECORD +17 -17
- {fabricatio-0.2.5.dev2.data → fabricatio-0.2.5.dev3.data}/scripts/tdown +0 -0
- {fabricatio-0.2.5.dev2.dist-info → fabricatio-0.2.5.dev3.dist-info}/WHEEL +0 -0
- {fabricatio-0.2.5.dev2.dist-info → fabricatio-0.2.5.dev3.dist-info}/licenses/LICENSE +0 -0
fabricatio/_rust.pyi
CHANGED
fabricatio/_rust_instances.py
CHANGED
@@ -15,7 +15,7 @@ class Propose[M: ProposedAble](LLMUsage):
|
|
15
15
|
self,
|
16
16
|
cls: Type[M],
|
17
17
|
prompt: List[str],
|
18
|
-
**kwargs: Unpack[GenerateKwargs],
|
18
|
+
**kwargs: Unpack[GenerateKwargs[M]],
|
19
19
|
) -> List[M]: ...
|
20
20
|
|
21
21
|
@overload
|
@@ -23,14 +23,14 @@ class Propose[M: ProposedAble](LLMUsage):
|
|
23
23
|
self,
|
24
24
|
cls: Type[M],
|
25
25
|
prompt: str,
|
26
|
-
**kwargs: Unpack[GenerateKwargs],
|
26
|
+
**kwargs: Unpack[GenerateKwargs[M]],
|
27
27
|
) -> M: ...
|
28
28
|
|
29
29
|
async def propose(
|
30
30
|
self,
|
31
31
|
cls: Type[M],
|
32
32
|
prompt: List[str] | str,
|
33
|
-
**kwargs: Unpack[GenerateKwargs],
|
33
|
+
**kwargs: Unpack[GenerateKwargs[M]],
|
34
34
|
) -> List[M] | M:
|
35
35
|
"""Asynchronously proposes a task based on a given prompt and parameters.
|
36
36
|
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
from asyncio import gather
|
4
4
|
from itertools import permutations
|
5
|
+
from random import sample
|
5
6
|
from typing import Dict, List, Set, Tuple, Union, Unpack, overload
|
6
7
|
|
7
8
|
from fabricatio._rust_instances import template_manager
|
@@ -16,7 +17,11 @@ from pydantic import NonNegativeInt, PositiveInt
|
|
16
17
|
|
17
18
|
|
18
19
|
class GiveRating(WithBriefing, LLMUsage):
|
19
|
-
"""A class that provides functionality to rate tasks based on a rating manual and score range.
|
20
|
+
"""A class that provides functionality to rate tasks based on a rating manual and score range.
|
21
|
+
|
22
|
+
References:
|
23
|
+
Lu X, Li J, Takeuchi K, et al. AHP-powered LLM reasoning for multi-criteria evaluation of open-ended responses[A/OL]. arXiv, 2024. DOI: 10.48550/arXiv.2410.01246.
|
24
|
+
"""
|
20
25
|
|
21
26
|
async def rate_fine_grind(
|
22
27
|
self,
|
@@ -187,6 +192,7 @@ class GiveRating(WithBriefing, LLMUsage):
|
|
187
192
|
self,
|
188
193
|
topic: str,
|
189
194
|
examples: List[str],
|
195
|
+
m: NonNegativeInt = 0,
|
190
196
|
reasons_count: PositiveInt = 2,
|
191
197
|
criteria_count: PositiveInt = 5,
|
192
198
|
**kwargs: Unpack[ValidateKwargs],
|
@@ -199,13 +205,21 @@ class GiveRating(WithBriefing, LLMUsage):
|
|
199
205
|
Parameters:
|
200
206
|
topic (str): The subject topic for the rating criteria.
|
201
207
|
examples (List[str]): A list of example texts to analyze.
|
208
|
+
m (NonNegativeInt, optional): The number of examples to sample from the provided list. Defaults to 0 (no sampling).
|
202
209
|
reasons_count (PositiveInt, optional): The number of reasons to extract from each pair of examples. Defaults to 2.
|
203
210
|
criteria_count (PositiveInt, optional): The final number of rating criteria to draft. Defaults to 5.
|
204
211
|
**kwargs (Unpack[ValidateKwargs]): Additional keyword arguments for validation.
|
205
212
|
|
206
213
|
Returns:
|
207
214
|
Set[str]: A set of drafted rating criteria.
|
215
|
+
|
216
|
+
Warnings:
|
217
|
+
Since this function uses pairwise comparisons, it may not be suitable for large lists of examples.
|
218
|
+
For that reason, consider using a smaller list of examples or setting `m` to a non-zero value smaller than the length of the examples.
|
208
219
|
"""
|
220
|
+
if m:
|
221
|
+
examples = sample(examples, m)
|
222
|
+
|
209
223
|
kwargs = GenerateKwargs(system_message=f"# your personal briefing: \n{self.briefing}", **kwargs)
|
210
224
|
# extract reasons from the comparison of ordered pairs of extracted from examples
|
211
225
|
reasons = flatten(
|
@@ -11,6 +11,7 @@ from fabricatio.models.kwargs_types import GenerateKwargs, ReviewKwargs
|
|
11
11
|
from fabricatio.models.task import Task
|
12
12
|
from pydantic import PrivateAttr
|
13
13
|
from questionary import Choice, checkbox
|
14
|
+
from rich import print
|
14
15
|
|
15
16
|
|
16
17
|
class ProblemSolutions(Base):
|
@@ -78,6 +79,18 @@ class ReviewResult[T](ProposedAble, Display):
|
|
78
79
|
_ref: T = PrivateAttr(None)
|
79
80
|
"""Reference to the original object that was reviewed."""
|
80
81
|
|
82
|
+
def update_topic(self, topic: str) -> Self:
|
83
|
+
"""Update the review topic.
|
84
|
+
|
85
|
+
Args:
|
86
|
+
topic (str): The new topic to be associated with this review.
|
87
|
+
|
88
|
+
Returns:
|
89
|
+
Self: The current instance with updated review topic.
|
90
|
+
"""
|
91
|
+
self.review_topic = topic
|
92
|
+
return self
|
93
|
+
|
81
94
|
def update_ref[K](self, ref: K) -> "ReviewResult[K]":
|
82
95
|
"""Update the reference to the reviewed object.
|
83
96
|
|
@@ -111,9 +124,18 @@ class ReviewResult[T](ProposedAble, Display):
|
|
111
124
|
Returns:
|
112
125
|
Self: The current instance with filtered problems and solutions.
|
113
126
|
"""
|
127
|
+
if isinstance(self._ref, str):
|
128
|
+
display = self._ref
|
129
|
+
elif isinstance(self._ref, WithBriefing):
|
130
|
+
display = self._ref.briefing
|
131
|
+
elif isinstance(self._ref, Display):
|
132
|
+
display = self._ref.display()
|
133
|
+
else:
|
134
|
+
raise TypeError(f"Unsupported type for review: {type(self._ref)}")
|
114
135
|
# Choose the problems to retain
|
136
|
+
print(display)
|
115
137
|
chosen_ones: List[ProblemSolutions] = await checkbox(
|
116
|
-
f"Please choose the problems you want to retain
|
138
|
+
f"Please choose the problems you want to retain.(Default: retain all)\n\t`{self.review_topic}`",
|
117
139
|
choices=[Choice(p.problem, p, checked=True) for p in self.problem_solutions],
|
118
140
|
).ask_async()
|
119
141
|
if not check_solutions:
|
@@ -124,7 +146,7 @@ class ReviewResult[T](ProposedAble, Display):
|
|
124
146
|
for to_exam in chosen_ones:
|
125
147
|
to_exam.update_solutions(
|
126
148
|
await checkbox(
|
127
|
-
f"Please choose the solutions you want to retain
|
149
|
+
f"Please choose the solutions you want to retain.(Default: retain all)\n\t`{to_exam.problem}`",
|
128
150
|
choices=[Choice(s, s, checked=True) for s in to_exam.solutions],
|
129
151
|
).ask_async()
|
130
152
|
)
|
@@ -159,7 +181,11 @@ class Review(GiveRating, Propose):
|
|
159
181
|
return await self.review_obj(task, **kwargs)
|
160
182
|
|
161
183
|
async def review_string(
|
162
|
-
self,
|
184
|
+
self,
|
185
|
+
text: str,
|
186
|
+
topic: str,
|
187
|
+
criteria: Optional[Set[str]] = None,
|
188
|
+
**kwargs: Unpack[GenerateKwargs[ReviewResult[str]]],
|
163
189
|
) -> ReviewResult[str]:
|
164
190
|
"""Review a string based on specified topic and criteria.
|
165
191
|
|
@@ -186,7 +212,7 @@ class Review(GiveRating, Propose):
|
|
186
212
|
),
|
187
213
|
**kwargs,
|
188
214
|
)
|
189
|
-
return res.update_ref(text)
|
215
|
+
return res.update_ref(text).update_topic(topic)
|
190
216
|
|
191
217
|
async def review_obj[M: (Display, WithBriefing)](self, obj: M, **kwargs: Unpack[ReviewKwargs]) -> ReviewResult[M]:
|
192
218
|
"""Review an object that implements Display or WithBriefing interface.
|
fabricatio/fs/__init__.py
CHANGED
@@ -7,6 +7,7 @@ from fabricatio.fs.curd import (
|
|
7
7
|
delete_directory,
|
8
8
|
delete_file,
|
9
9
|
dump_text,
|
10
|
+
gather_files,
|
10
11
|
move_file,
|
11
12
|
tree,
|
12
13
|
)
|
@@ -19,6 +20,7 @@ __all__ = [
|
|
19
20
|
"delete_directory",
|
20
21
|
"delete_file",
|
21
22
|
"dump_text",
|
23
|
+
"gather_files",
|
22
24
|
"magika",
|
23
25
|
"move_file",
|
24
26
|
"safe_json_read",
|
fabricatio/fs/curd.py
CHANGED
@@ -134,3 +134,16 @@ def absolute_path(path: str | Path | PathLike) -> str:
|
|
134
134
|
str: The absolute path of the file or directory.
|
135
135
|
"""
|
136
136
|
return Path(path).expanduser().resolve().as_posix()
|
137
|
+
|
138
|
+
|
139
|
+
def gather_files(directory: str | Path | PathLike, extension: str) -> list[str]:
|
140
|
+
"""Gather all files with a specific extension in a directory.
|
141
|
+
|
142
|
+
Args:
|
143
|
+
directory (str, Path, PathLike): The directory to search in.
|
144
|
+
extension (str): The file extension to look for.
|
145
|
+
|
146
|
+
Returns:
|
147
|
+
list[str]: A list of file paths with the specified extension.
|
148
|
+
"""
|
149
|
+
return [file.as_posix() for file in Path(directory).rglob(f"*.{extension}")]
|
fabricatio/journal.py
CHANGED
fabricatio/models/action.py
CHANGED
@@ -122,17 +122,16 @@ class WorkFlow(WithBriefing, ToolBoxUsage):
|
|
122
122
|
current_action = None
|
123
123
|
try:
|
124
124
|
for step in self._instances:
|
125
|
-
logger.debug(f"Executing step: {step.name}")
|
125
|
+
logger.debug(f"Executing step: {(current_action := step.name)}")
|
126
126
|
act_task = create_task(step.act(await self._context.get()))
|
127
127
|
if task.is_cancelled():
|
128
128
|
act_task.cancel(f"Cancelled by task: {task.name}")
|
129
129
|
break
|
130
130
|
modified_ctx = await act_task
|
131
131
|
await self._context.put(modified_ctx)
|
132
|
-
current_action = step.name
|
133
132
|
logger.info(f"Finished executing workflow: {self.name}")
|
134
|
-
|
135
|
-
if self.task_output_key not in final_ctx:
|
133
|
+
|
134
|
+
if self.task_output_key not in (final_ctx := await self._context.get()):
|
136
135
|
logger.warning(
|
137
136
|
f"Task output key: {self.task_output_key} not found in the context, None will be returned. You can check if `Action.output_key` is set the same as `WorkFlow.task_output_key`."
|
138
137
|
)
|
@@ -8,14 +8,21 @@ from pydantic import NonNegativeFloat, NonNegativeInt, PositiveInt
|
|
8
8
|
|
9
9
|
|
10
10
|
class CollectionSimpleConfigKwargs(TypedDict):
|
11
|
-
"""
|
11
|
+
"""Configuration parameters for a vector collection.
|
12
|
+
|
13
|
+
These arguments are typically used when configuring connections to vector databases.
|
14
|
+
"""
|
12
15
|
|
13
16
|
dimension: NotRequired[int]
|
14
17
|
timeout: NotRequired[float]
|
15
18
|
|
16
19
|
|
17
20
|
class FetchKwargs(TypedDict):
|
18
|
-
"""
|
21
|
+
"""Arguments for fetching data from vector collections.
|
22
|
+
|
23
|
+
Controls how data is retrieved from vector databases, including filtering
|
24
|
+
and result limiting parameters.
|
25
|
+
"""
|
19
26
|
|
20
27
|
collection_name: NotRequired[str]
|
21
28
|
similarity_threshold: NotRequired[float]
|
@@ -23,7 +30,11 @@ class FetchKwargs(TypedDict):
|
|
23
30
|
|
24
31
|
|
25
32
|
class EmbeddingKwargs(TypedDict):
|
26
|
-
"""
|
33
|
+
"""Configuration parameters for text embedding operations.
|
34
|
+
|
35
|
+
These settings control the behavior of embedding models that convert text
|
36
|
+
to vector representations.
|
37
|
+
"""
|
27
38
|
|
28
39
|
model: NotRequired[str]
|
29
40
|
dimensions: NotRequired[int]
|
@@ -32,7 +43,11 @@ class EmbeddingKwargs(TypedDict):
|
|
32
43
|
|
33
44
|
|
34
45
|
class LLMKwargs(TypedDict):
|
35
|
-
"""
|
46
|
+
"""Configuration parameters for language model inference.
|
47
|
+
|
48
|
+
These arguments control the behavior of large language model calls,
|
49
|
+
including generation parameters and caching options.
|
50
|
+
"""
|
36
51
|
|
37
52
|
model: NotRequired[str]
|
38
53
|
temperature: NotRequired[NonNegativeFloat]
|
@@ -42,35 +57,60 @@ class LLMKwargs(TypedDict):
|
|
42
57
|
stream: NotRequired[bool]
|
43
58
|
timeout: NotRequired[PositiveInt]
|
44
59
|
max_retries: NotRequired[PositiveInt]
|
60
|
+
no_cache: NotRequired[bool] # If use cache in this call
|
61
|
+
no_store: NotRequired[bool] # If store the response of this call to cache
|
62
|
+
cache_ttl: NotRequired[int] # how long the stored cache is alive, in seconds
|
63
|
+
s_maxage: NotRequired[int] # max accepted age of cached response, in seconds
|
64
|
+
|
45
65
|
|
66
|
+
class ValidateKwargs[T](LLMKwargs):
|
67
|
+
"""Arguments for content validation operations.
|
46
68
|
|
47
|
-
|
48
|
-
|
69
|
+
Extends LLMKwargs with additional parameters specific to validation tasks,
|
70
|
+
such as limiting the number of validation attempts.
|
71
|
+
"""
|
49
72
|
|
73
|
+
default: NotRequired[T]
|
50
74
|
max_validations: NotRequired[PositiveInt]
|
51
75
|
|
52
76
|
|
53
77
|
class GenerateKwargs(ValidateKwargs):
|
54
|
-
"""
|
78
|
+
"""Arguments for content generation operations.
|
79
|
+
|
80
|
+
Extends ValidateKwargs with parameters specific to text generation,
|
81
|
+
including system prompt configuration.
|
82
|
+
"""
|
55
83
|
|
56
84
|
system_message: NotRequired[str]
|
57
85
|
|
58
86
|
|
59
87
|
class ReviewKwargs(GenerateKwargs):
|
60
|
-
"""
|
88
|
+
"""Arguments for content review operations.
|
89
|
+
|
90
|
+
Extends GenerateKwargs with parameters for evaluating content against
|
91
|
+
specific topics and review criteria.
|
92
|
+
"""
|
61
93
|
|
62
94
|
topic: str
|
63
95
|
criteria: NotRequired[Set[str]]
|
64
96
|
|
65
97
|
|
66
98
|
class ChooseKwargs(GenerateKwargs):
|
67
|
-
"""
|
99
|
+
"""Arguments for selection operations.
|
100
|
+
|
101
|
+
Extends GenerateKwargs with parameters for selecting among options,
|
102
|
+
such as the number of items to choose.
|
103
|
+
"""
|
68
104
|
|
69
105
|
k: NotRequired[NonNegativeInt]
|
70
106
|
|
71
107
|
|
72
108
|
class CacheKwargs(TypedDict, total=False):
|
73
|
-
"""
|
109
|
+
"""Configuration parameters for the caching system.
|
110
|
+
|
111
|
+
These arguments control the behavior of various caching backends,
|
112
|
+
including in-memory, Redis, S3, and vector database caching options.
|
113
|
+
"""
|
74
114
|
|
75
115
|
mode: NotRequired[CacheMode] # when default_on cache is always on, when default_off cache is opt in
|
76
116
|
host: NotRequired[str]
|
fabricatio/models/usages.py
CHANGED
@@ -26,12 +26,8 @@ from more_itertools import duplicates_everseen
|
|
26
26
|
from pydantic import Field, NonNegativeInt, PositiveInt
|
27
27
|
|
28
28
|
if configs.cache.enabled:
|
29
|
-
|
30
|
-
|
31
|
-
if configs.cache.type is None:
|
32
|
-
Cache(**configs.cache.params)
|
33
|
-
else:
|
34
|
-
Cache(type=configs.cache.type, **configs.cache.params)
|
29
|
+
litellm.enable_cache(type=configs.cache.type, **configs.cache.params)
|
30
|
+
logger.success(f"{configs.cache.type.name} Cache enabled")
|
35
31
|
|
36
32
|
|
37
33
|
class LLMUsage(ScopedConfig):
|
@@ -71,6 +67,12 @@ class LLMUsage(ScopedConfig):
|
|
71
67
|
max_retries=kwargs.get("max_retries") or self.llm_max_retries or configs.llm.max_retries,
|
72
68
|
api_key=(self.llm_api_key or configs.llm.api_key).get_secret_value(),
|
73
69
|
base_url=(self.llm_api_endpoint or configs.llm.api_endpoint).unicode_string(),
|
70
|
+
cache={
|
71
|
+
"no-cache": kwargs.get("no_cache"),
|
72
|
+
"no-store": kwargs.get("no_store"),
|
73
|
+
"cache-ttl": kwargs.get("cache_ttl"),
|
74
|
+
"s-maxage": kwargs.get("s_maxage"),
|
75
|
+
},
|
74
76
|
)
|
75
77
|
|
76
78
|
async def ainvoke(
|
@@ -176,19 +178,32 @@ class LLMUsage(ScopedConfig):
|
|
176
178
|
case _:
|
177
179
|
raise RuntimeError("Should not reach here.")
|
178
180
|
|
181
|
+
@overload
|
179
182
|
async def aask_validate[T](
|
180
183
|
self,
|
181
184
|
question: str,
|
182
185
|
validator: Callable[[str], T | None],
|
186
|
+
default: T,
|
183
187
|
max_validations: PositiveInt = 2,
|
184
188
|
system_message: str = "",
|
185
189
|
**kwargs: Unpack[LLMKwargs],
|
186
|
-
) -> T:
|
190
|
+
) -> T: ...
|
191
|
+
|
192
|
+
async def aask_validate[T](
|
193
|
+
self,
|
194
|
+
question: str,
|
195
|
+
validator: Callable[[str], T | None],
|
196
|
+
default: Optional[T] = None,
|
197
|
+
max_validations: PositiveInt = 2,
|
198
|
+
system_message: str = "",
|
199
|
+
**kwargs: Unpack[LLMKwargs],
|
200
|
+
) -> Optional[T]:
|
187
201
|
"""Asynchronously asks a question and validates the response using a given validator.
|
188
202
|
|
189
203
|
Args:
|
190
204
|
question (str): The question to ask.
|
191
205
|
validator (Callable[[str], T | None]): A function to validate the response.
|
206
|
+
default (T | None): Default value to return if validation fails. Defaults to None.
|
192
207
|
max_validations (PositiveInt): Maximum number of validation attempts. Defaults to 2.
|
193
208
|
system_message (str): System message to include in the request. Defaults to an empty string.
|
194
209
|
**kwargs (Unpack[LLMKwargs]): Additional keyword arguments for the LLM usage.
|
@@ -196,8 +211,6 @@ class LLMUsage(ScopedConfig):
|
|
196
211
|
Returns:
|
197
212
|
T: The validated response.
|
198
213
|
|
199
|
-
Raises:
|
200
|
-
ValueError: If the response fails to validate after the maximum number of attempts.
|
201
214
|
"""
|
202
215
|
for i in range(max_validations):
|
203
216
|
if (
|
@@ -209,14 +222,17 @@ class LLMUsage(ScopedConfig):
|
|
209
222
|
) and (validated := validator(response)):
|
210
223
|
logger.debug(f"Successfully validated the response at {i}th attempt.")
|
211
224
|
return validated
|
212
|
-
|
213
|
-
|
225
|
+
kwargs["no_cache"] = True
|
226
|
+
logger.debug("Closed the cache for the next attempt")
|
227
|
+
if default is None:
|
228
|
+
logger.error(f"Failed to validate the response after {max_validations} attempts.")
|
229
|
+
return default
|
214
230
|
|
215
231
|
async def aask_validate_batch[T](
|
216
232
|
self,
|
217
233
|
questions: List[str],
|
218
234
|
validator: Callable[[str], T | None],
|
219
|
-
**kwargs: Unpack[GenerateKwargs],
|
235
|
+
**kwargs: Unpack[GenerateKwargs[T]],
|
220
236
|
) -> List[T]:
|
221
237
|
"""Asynchronously asks a batch of questions and validates the responses using a given validator.
|
222
238
|
|
@@ -233,7 +249,9 @@ class LLMUsage(ScopedConfig):
|
|
233
249
|
"""
|
234
250
|
return await gather(*[self.aask_validate(question, validator, **kwargs) for question in questions])
|
235
251
|
|
236
|
-
async def aliststr(
|
252
|
+
async def aliststr(
|
253
|
+
self, requirement: str, k: NonNegativeInt = 0, **kwargs: Unpack[GenerateKwargs[List[str]]]
|
254
|
+
) -> List[str]:
|
237
255
|
"""Asynchronously generates a list of strings based on a given requirement.
|
238
256
|
|
239
257
|
Args:
|
@@ -253,7 +271,7 @@ class LLMUsage(ScopedConfig):
|
|
253
271
|
**kwargs,
|
254
272
|
)
|
255
273
|
|
256
|
-
async def apathstr(self, requirement: str, **kwargs: Unpack[ChooseKwargs]) -> List[str]:
|
274
|
+
async def apathstr(self, requirement: str, **kwargs: Unpack[ChooseKwargs[List[str]]]) -> List[str]:
|
257
275
|
"""Asynchronously generates a list of strings based on a given requirement.
|
258
276
|
|
259
277
|
Args:
|
@@ -271,7 +289,7 @@ class LLMUsage(ScopedConfig):
|
|
271
289
|
**kwargs,
|
272
290
|
)
|
273
291
|
|
274
|
-
async def awhich_pathstr(self, requirement: str, **kwargs: Unpack[GenerateKwargs]) -> str:
|
292
|
+
async def awhich_pathstr(self, requirement: str, **kwargs: Unpack[GenerateKwargs[List[str]]]) -> str:
|
275
293
|
"""Asynchronously generates a single path string based on a given requirement.
|
276
294
|
|
277
295
|
Args:
|
@@ -294,7 +312,7 @@ class LLMUsage(ScopedConfig):
|
|
294
312
|
instruction: str,
|
295
313
|
choices: List[T],
|
296
314
|
k: NonNegativeInt = 0,
|
297
|
-
**kwargs: Unpack[GenerateKwargs],
|
315
|
+
**kwargs: Unpack[GenerateKwargs[List[T]]],
|
298
316
|
) -> List[T]:
|
299
317
|
"""Asynchronously executes a multi-choice decision-making process, generating a prompt based on the instruction and options, and validates the returned selection results.
|
300
318
|
|
@@ -345,7 +363,7 @@ class LLMUsage(ScopedConfig):
|
|
345
363
|
self,
|
346
364
|
instruction: str,
|
347
365
|
choices: List[T],
|
348
|
-
**kwargs: Unpack[GenerateKwargs],
|
366
|
+
**kwargs: Unpack[GenerateKwargs[List[T]]],
|
349
367
|
) -> T:
|
350
368
|
"""Asynchronously picks a single choice from a list of options using AI validation.
|
351
369
|
|
@@ -374,7 +392,7 @@ class LLMUsage(ScopedConfig):
|
|
374
392
|
prompt: str,
|
375
393
|
affirm_case: str = "",
|
376
394
|
deny_case: str = "",
|
377
|
-
**kwargs: Unpack[GenerateKwargs],
|
395
|
+
**kwargs: Unpack[GenerateKwargs[bool]],
|
378
396
|
) -> bool:
|
379
397
|
"""Asynchronously judges a prompt using AI validation.
|
380
398
|
|
@@ -489,17 +507,13 @@ class ToolBoxUsage(LLMUsage):
|
|
489
507
|
self,
|
490
508
|
task: Task,
|
491
509
|
system_message: str = "",
|
492
|
-
|
493
|
-
max_validations: PositiveInt = 2,
|
494
|
-
**kwargs: Unpack[LLMKwargs],
|
510
|
+
**kwargs: Unpack[ChooseKwargs[List[ToolBox]]],
|
495
511
|
) -> List[ToolBox]:
|
496
512
|
"""Asynchronously executes a multi-choice decision-making process to choose toolboxes.
|
497
513
|
|
498
514
|
Args:
|
499
515
|
task (Task): The task for which to choose toolboxes.
|
500
516
|
system_message (str): Custom system-level prompt, defaults to an empty string.
|
501
|
-
k (NonNegativeInt): The number of toolboxes to select, 0 means infinite. Defaults to 0.
|
502
|
-
max_validations (PositiveInt): Maximum number of validation failures, default is 2.
|
503
517
|
**kwargs (Unpack[LLMKwargs]): Additional keyword arguments for the LLM usage.
|
504
518
|
|
505
519
|
Returns:
|
@@ -511,8 +525,6 @@ class ToolBoxUsage(LLMUsage):
|
|
511
525
|
return await self.achoose(
|
512
526
|
instruction=task.briefing,
|
513
527
|
choices=list(self.toolboxes),
|
514
|
-
k=k,
|
515
|
-
max_validations=max_validations,
|
516
528
|
system_message=system_message,
|
517
529
|
**kwargs,
|
518
530
|
)
|
@@ -521,19 +533,13 @@ class ToolBoxUsage(LLMUsage):
|
|
521
533
|
self,
|
522
534
|
task: Task,
|
523
535
|
toolbox: ToolBox,
|
524
|
-
|
525
|
-
k: NonNegativeInt = 0,
|
526
|
-
max_validations: PositiveInt = 2,
|
527
|
-
**kwargs: Unpack[LLMKwargs],
|
536
|
+
**kwargs: Unpack[ChooseKwargs[List[Tool]]],
|
528
537
|
) -> List[Tool]:
|
529
538
|
"""Asynchronously executes a multi-choice decision-making process to choose tools.
|
530
539
|
|
531
540
|
Args:
|
532
541
|
task (Task): The task for which to choose tools.
|
533
542
|
toolbox (ToolBox): The toolbox from which to choose tools.
|
534
|
-
system_message (str): Custom system-level prompt, defaults to an empty string.
|
535
|
-
k (NonNegativeInt): The number of tools to select, 0 means infinite. Defaults to 0.
|
536
|
-
max_validations (PositiveInt): Maximum number of validation failures, default is 2.
|
537
543
|
**kwargs (Unpack[LLMKwargs]): Additional keyword arguments for the LLM usage.
|
538
544
|
|
539
545
|
Returns:
|
@@ -545,9 +551,6 @@ class ToolBoxUsage(LLMUsage):
|
|
545
551
|
return await self.achoose(
|
546
552
|
instruction=task.briefing,
|
547
553
|
choices=toolbox.tools,
|
548
|
-
k=k,
|
549
|
-
max_validations=max_validations,
|
550
|
-
system_message=system_message,
|
551
554
|
**kwargs,
|
552
555
|
)
|
553
556
|
|
fabricatio/toolboxes/fs.py
CHANGED
@@ -7,6 +7,7 @@ from fabricatio.fs import (
|
|
7
7
|
delete_directory,
|
8
8
|
delete_file,
|
9
9
|
dump_text,
|
10
|
+
gather_files,
|
10
11
|
move_file,
|
11
12
|
safe_json_read,
|
12
13
|
safe_text_read,
|
@@ -26,4 +27,5 @@ fs_toolbox = (
|
|
26
27
|
.add_tool(absolute_path)
|
27
28
|
.add_tool(safe_text_read)
|
28
29
|
.add_tool(safe_json_read)
|
30
|
+
.add_tool(gather_files)
|
29
31
|
)
|
@@ -1,41 +1,41 @@
|
|
1
|
-
fabricatio-0.2.5.
|
2
|
-
fabricatio-0.2.5.
|
3
|
-
fabricatio-0.2.5.
|
1
|
+
fabricatio-0.2.5.dev3.dist-info/METADATA,sha256=MKx81GhYa4Kl5fyAn1CtYrdf_nWPZt-sq86I_iteWXE,8589
|
2
|
+
fabricatio-0.2.5.dev3.dist-info/WHEEL,sha256=RIvmwLDYujv60MYBx2jxyP4vdn1DD7X0kBgz1TQvZuc,108
|
3
|
+
fabricatio-0.2.5.dev3.dist-info/licenses/LICENSE,sha256=yDZaTLnOi03bi3Dk6f5IjhLUc5old2yOsihHWU0z-i0,1067
|
4
4
|
fabricatio/decorators.py,sha256=cJHsxxbnMhc4SzPl4454CPLuDP3H0qbTrzV_U2rLPrs,6372
|
5
5
|
fabricatio/core.py,sha256=MaEKZ6DDmbdScAY-7F1gwGA6fr7ADX6Mz5rNVi2msFA,6277
|
6
6
|
fabricatio/models/generic.py,sha256=dP5rNf13Yo-Zy0WpmunsDYOxNbJF3RpFcVBTrYaHnvc,12197
|
7
7
|
fabricatio/models/tool.py,sha256=m7gFo8nXywGj7J3zOfPC_wPUgcTY-76ZwAmHlQLWkb8,6836
|
8
8
|
fabricatio/models/role.py,sha256=Xd-TYNefcY9FGeINAI8Q5sCu2pgBXl0l9XKxN0r4rZ0,1791
|
9
9
|
fabricatio/models/extra.py,sha256=svUxjM9iPtXCpNJwxYdkvRtvORsze8Fcz4Oql-46huQ,7295
|
10
|
-
fabricatio/models/kwargs_types.py,sha256=
|
10
|
+
fabricatio/models/kwargs_types.py,sha256=3K7c72NYnqQ7aEs6tTninVb2670bNqiKdfUT7uzLjas,4769
|
11
11
|
fabricatio/models/utils.py,sha256=vahILaesw50ofFft-wZ9kZ_Qogqi6vIOISWczvwVXxk,4311
|
12
|
-
fabricatio/models/usages.py,sha256=
|
12
|
+
fabricatio/models/usages.py,sha256=TBADSlnY70ewfXri3FbIPaD_jzgZz4dwMNEMJtWirxw,25845
|
13
13
|
fabricatio/models/events.py,sha256=sBCKeNoYc4TFDoke-jhFEyA11RcdGu-wdF5ynAuVOMM,3983
|
14
14
|
fabricatio/models/task.py,sha256=BdBfCtxzgDzqHE0eP65liUGRmddAtKhim6optodzEcQ,10193
|
15
|
-
fabricatio/models/action.py,sha256=
|
16
|
-
fabricatio/toolboxes/fs.py,sha256=
|
15
|
+
fabricatio/models/action.py,sha256=xAzNbkRMh8-6V-P9VwOgbc_hoFLcsXe7w0vcdSxmqhU,6285
|
16
|
+
fabricatio/toolboxes/fs.py,sha256=OQMdeokYxSNVrCZJAweJ0cYiK4k2QuEiNdIbS5IHIV8,705
|
17
17
|
fabricatio/toolboxes/__init__.py,sha256=dYm_Gd8XolSU_h4wnkA09dlaLDK146eeFz0CUgPZ8_c,380
|
18
18
|
fabricatio/toolboxes/arithmetic.py,sha256=sSTPkKI6-mb278DwQKFO9jKyzc9kCx45xNH7V6bGBpE,1307
|
19
19
|
fabricatio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
20
20
|
fabricatio/fs/readers.py,sha256=JNjTaHpH0ljXxJ7SREJYL5gU8bbCe3lDEaVCmna1rww,1168
|
21
|
-
fabricatio/fs/curd.py,sha256=
|
22
|
-
fabricatio/fs/__init__.py,sha256=
|
21
|
+
fabricatio/fs/curd.py,sha256=FuG75qco4dX8vhIK27gKz9rKUXbWHOFg5yK3nGLB25s,4469
|
22
|
+
fabricatio/fs/__init__.py,sha256=iNYphupcebrXEKLG2MgLliEUlh_G6xmupqfVrUwGT9E,559
|
23
23
|
fabricatio/config.py,sha256=tByDnt0HOthTOdEYK4KJwUqT74gJSVjUUxNOtc9Sa58,14422
|
24
|
-
fabricatio/journal.py,sha256=
|
24
|
+
fabricatio/journal.py,sha256=HbqgbSMckpr8vNxNAR1k4EbRtpzVZDnWzvu9at0hhrc,752
|
25
25
|
fabricatio/__init__.py,sha256=kr86hyEDgUbxl1KmWTJqmW1R-aeC8Hd4KFp-2HFr0LM,1870
|
26
26
|
fabricatio/actions/output.py,sha256=0sKfU8C9y326IcgZMLeEoZZH3iMpgFGOLGoi9wYZz1U,663
|
27
27
|
fabricatio/actions/rag.py,sha256=tP1uKLq7mo19YhsJzFbGYryrcMx6xcvBc3n_Wzh0hjg,796
|
28
28
|
fabricatio/actions/article.py,sha256=-WKVYu1HrQOL5nyBraCvRG2bfbkTa_ylH_PyFSI6iLs,2704
|
29
|
-
fabricatio/_rust_instances.py,sha256=
|
29
|
+
fabricatio/_rust_instances.py,sha256=CdvEQquLgXJ4slqYlqAYyBIzo3hiAmx1M98PIP2ajww,304
|
30
30
|
fabricatio/workflows/articles.py,sha256=utvKDBFEJbcM76729-H2AvgMCNcsX1NquqMpHqGZq8E,565
|
31
31
|
fabricatio/workflows/rag.py,sha256=uOZXprD479fUhLA6sYvEM8RWcVcUZXXtP0xRbTMPdHE,509
|
32
32
|
fabricatio/parser.py,sha256=S-4p1mjvJZEgnQW6WKdkmE68MzqqWXGSiLbADdhE-W4,4791
|
33
33
|
fabricatio/capabilities/rag.py,sha256=mGUWaVsLbA1vNe0LRdAOeUlR4WMc6mwuOQ0vhPG8m74,15181
|
34
|
-
fabricatio/capabilities/rating.py,sha256=
|
35
|
-
fabricatio/capabilities/review.py,sha256=
|
36
|
-
fabricatio/capabilities/propose.py,sha256=
|
34
|
+
fabricatio/capabilities/rating.py,sha256=_F8-t60W4EFHW62gPOFgys4oqAoXAVk442oz91P0z0c,14044
|
35
|
+
fabricatio/capabilities/review.py,sha256=PoJZrPGq8FvqLjQELuWv1CCMcJMusuv6KZTl7Wv6_zE,9463
|
36
|
+
fabricatio/capabilities/propose.py,sha256=fuQzwx6OBymEbHbHDDPoT4sqFRso8u6Kk7NXKS5DFVc,1723
|
37
37
|
fabricatio/capabilities/task.py,sha256=BISAFbMgBI4udW0otE3-iyq0RXc05YN_30N0yI5qLxQ,4504
|
38
|
-
fabricatio/_rust.pyi,sha256=
|
38
|
+
fabricatio/_rust.pyi,sha256=xXSaL7llihyFIyr9_k6e5RRJVNYk2jM-jrrheNvvaIA,3067
|
39
39
|
fabricatio/_rust.cpython-312-x86_64-linux-gnu.so,sha256=X-d8ziGuBqQEtJXheq6NTFAsxotGLiy2it6rteu9Cic,1898944
|
40
|
-
fabricatio-0.2.5.
|
41
|
-
fabricatio-0.2.5.
|
40
|
+
fabricatio-0.2.5.dev3.data/scripts/tdown,sha256=MsmVZJr1r5g1VXyayAS7DEtHgLj0O8a2YbGNf1u6SDw,4571832
|
41
|
+
fabricatio-0.2.5.dev3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|