fabricatio 0.2.5.dev2__cp312-cp312-win_amd64.whl → 0.2.5.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.
- fabricatio/_rust.cp312-win_amd64.pyd +0 -0
- 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 +56 -13
- fabricatio/models/usages.py +48 -35
- fabricatio/toolboxes/fs.py +2 -0
- {fabricatio-0.2.5.dev2.data → fabricatio-0.2.5.dev4.data}/scripts/tdown.exe +0 -0
- {fabricatio-0.2.5.dev2.dist-info → fabricatio-0.2.5.dev4.dist-info}/METADATA +1 -1
- {fabricatio-0.2.5.dev2.dist-info → fabricatio-0.2.5.dev4.dist-info}/RECORD +18 -18
- {fabricatio-0.2.5.dev2.dist-info → fabricatio-0.2.5.dev4.dist-info}/WHEEL +0 -0
- {fabricatio-0.2.5.dev2.dist-info → fabricatio-0.2.5.dev4.dist-info}/licenses/LICENSE +0 -0
Binary file
|
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,63 @@ 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
|
-
|
54
|
-
|
77
|
+
# noinspection PyTypedDict
|
78
|
+
class GenerateKwargs[T](ValidateKwargs[T]):
|
79
|
+
"""Arguments for content generation operations.
|
80
|
+
|
81
|
+
Extends ValidateKwargs with parameters specific to text generation,
|
82
|
+
including system prompt configuration.
|
83
|
+
"""
|
55
84
|
|
56
85
|
system_message: NotRequired[str]
|
57
86
|
|
58
87
|
|
59
|
-
|
60
|
-
|
88
|
+
# noinspection PyTypedDict
|
89
|
+
class ReviewKwargs[T](GenerateKwargs[T]):
|
90
|
+
"""Arguments for content review operations.
|
91
|
+
|
92
|
+
Extends GenerateKwargs with parameters for evaluating content against
|
93
|
+
specific topics and review criteria.
|
94
|
+
"""
|
61
95
|
|
62
96
|
topic: str
|
63
97
|
criteria: NotRequired[Set[str]]
|
64
98
|
|
65
99
|
|
66
|
-
|
67
|
-
|
100
|
+
# noinspection PyTypedDict
|
101
|
+
class ChooseKwargs[T](GenerateKwargs[T]):
|
102
|
+
"""Arguments for selection operations.
|
103
|
+
|
104
|
+
Extends GenerateKwargs with parameters for selecting among options,
|
105
|
+
such as the number of items to choose.
|
106
|
+
"""
|
68
107
|
|
69
108
|
k: NotRequired[NonNegativeInt]
|
70
109
|
|
71
110
|
|
72
111
|
class CacheKwargs(TypedDict, total=False):
|
73
|
-
"""
|
112
|
+
"""Configuration parameters for the caching system.
|
113
|
+
|
114
|
+
These arguments control the behavior of various caching backends,
|
115
|
+
including in-memory, Redis, S3, and vector database caching options.
|
116
|
+
"""
|
74
117
|
|
75
118
|
mode: NotRequired[CacheMode] # when default_on cache is always on, when default_off cache is opt in
|
76
119
|
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,42 @@ 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
|
+
@overload
|
192
|
+
async def aask_validate[T](
|
193
|
+
self,
|
194
|
+
question: str,
|
195
|
+
validator: Callable[[str], T | None],
|
196
|
+
default: None = None,
|
197
|
+
max_validations: PositiveInt = 2,
|
198
|
+
system_message: str = "",
|
199
|
+
**kwargs: Unpack[LLMKwargs],
|
200
|
+
) -> Optional[T]: ...
|
201
|
+
|
202
|
+
async def aask_validate[T](
|
203
|
+
self,
|
204
|
+
question: str,
|
205
|
+
validator: Callable[[str], T | None],
|
206
|
+
default: Optional[T] = None,
|
207
|
+
max_validations: PositiveInt = 2,
|
208
|
+
system_message: str = "",
|
209
|
+
**kwargs: Unpack[LLMKwargs],
|
210
|
+
) -> Optional[T]:
|
187
211
|
"""Asynchronously asks a question and validates the response using a given validator.
|
188
212
|
|
189
213
|
Args:
|
190
214
|
question (str): The question to ask.
|
191
215
|
validator (Callable[[str], T | None]): A function to validate the response.
|
216
|
+
default (T | None): Default value to return if validation fails. Defaults to None.
|
192
217
|
max_validations (PositiveInt): Maximum number of validation attempts. Defaults to 2.
|
193
218
|
system_message (str): System message to include in the request. Defaults to an empty string.
|
194
219
|
**kwargs (Unpack[LLMKwargs]): Additional keyword arguments for the LLM usage.
|
@@ -196,8 +221,6 @@ class LLMUsage(ScopedConfig):
|
|
196
221
|
Returns:
|
197
222
|
T: The validated response.
|
198
223
|
|
199
|
-
Raises:
|
200
|
-
ValueError: If the response fails to validate after the maximum number of attempts.
|
201
224
|
"""
|
202
225
|
for i in range(max_validations):
|
203
226
|
if (
|
@@ -209,14 +232,17 @@ class LLMUsage(ScopedConfig):
|
|
209
232
|
) and (validated := validator(response)):
|
210
233
|
logger.debug(f"Successfully validated the response at {i}th attempt.")
|
211
234
|
return validated
|
212
|
-
|
213
|
-
|
235
|
+
kwargs["no_cache"] = True
|
236
|
+
logger.debug("Closed the cache for the next attempt")
|
237
|
+
if default is None:
|
238
|
+
logger.error(f"Failed to validate the response after {max_validations} attempts.")
|
239
|
+
return default
|
214
240
|
|
215
241
|
async def aask_validate_batch[T](
|
216
242
|
self,
|
217
243
|
questions: List[str],
|
218
244
|
validator: Callable[[str], T | None],
|
219
|
-
**kwargs: Unpack[GenerateKwargs],
|
245
|
+
**kwargs: Unpack[GenerateKwargs[T]],
|
220
246
|
) -> List[T]:
|
221
247
|
"""Asynchronously asks a batch of questions and validates the responses using a given validator.
|
222
248
|
|
@@ -233,7 +259,9 @@ class LLMUsage(ScopedConfig):
|
|
233
259
|
"""
|
234
260
|
return await gather(*[self.aask_validate(question, validator, **kwargs) for question in questions])
|
235
261
|
|
236
|
-
async def aliststr(
|
262
|
+
async def aliststr(
|
263
|
+
self, requirement: str, k: NonNegativeInt = 0, **kwargs: Unpack[GenerateKwargs[List[str]]]
|
264
|
+
) -> List[str]:
|
237
265
|
"""Asynchronously generates a list of strings based on a given requirement.
|
238
266
|
|
239
267
|
Args:
|
@@ -253,7 +281,7 @@ class LLMUsage(ScopedConfig):
|
|
253
281
|
**kwargs,
|
254
282
|
)
|
255
283
|
|
256
|
-
async def apathstr(self, requirement: str, **kwargs: Unpack[ChooseKwargs]) -> List[str]:
|
284
|
+
async def apathstr(self, requirement: str, **kwargs: Unpack[ChooseKwargs[List[str]]]) -> List[str]:
|
257
285
|
"""Asynchronously generates a list of strings based on a given requirement.
|
258
286
|
|
259
287
|
Args:
|
@@ -271,7 +299,7 @@ class LLMUsage(ScopedConfig):
|
|
271
299
|
**kwargs,
|
272
300
|
)
|
273
301
|
|
274
|
-
async def awhich_pathstr(self, requirement: str, **kwargs: Unpack[GenerateKwargs]) -> str:
|
302
|
+
async def awhich_pathstr(self, requirement: str, **kwargs: Unpack[GenerateKwargs[List[str]]]) -> str:
|
275
303
|
"""Asynchronously generates a single path string based on a given requirement.
|
276
304
|
|
277
305
|
Args:
|
@@ -294,7 +322,7 @@ class LLMUsage(ScopedConfig):
|
|
294
322
|
instruction: str,
|
295
323
|
choices: List[T],
|
296
324
|
k: NonNegativeInt = 0,
|
297
|
-
**kwargs: Unpack[GenerateKwargs],
|
325
|
+
**kwargs: Unpack[GenerateKwargs[List[T]]],
|
298
326
|
) -> List[T]:
|
299
327
|
"""Asynchronously executes a multi-choice decision-making process, generating a prompt based on the instruction and options, and validates the returned selection results.
|
300
328
|
|
@@ -345,7 +373,7 @@ class LLMUsage(ScopedConfig):
|
|
345
373
|
self,
|
346
374
|
instruction: str,
|
347
375
|
choices: List[T],
|
348
|
-
**kwargs: Unpack[GenerateKwargs],
|
376
|
+
**kwargs: Unpack[GenerateKwargs[List[T]]],
|
349
377
|
) -> T:
|
350
378
|
"""Asynchronously picks a single choice from a list of options using AI validation.
|
351
379
|
|
@@ -374,7 +402,7 @@ class LLMUsage(ScopedConfig):
|
|
374
402
|
prompt: str,
|
375
403
|
affirm_case: str = "",
|
376
404
|
deny_case: str = "",
|
377
|
-
**kwargs: Unpack[GenerateKwargs],
|
405
|
+
**kwargs: Unpack[GenerateKwargs[bool]],
|
378
406
|
) -> bool:
|
379
407
|
"""Asynchronously judges a prompt using AI validation.
|
380
408
|
|
@@ -489,17 +517,13 @@ class ToolBoxUsage(LLMUsage):
|
|
489
517
|
self,
|
490
518
|
task: Task,
|
491
519
|
system_message: str = "",
|
492
|
-
|
493
|
-
max_validations: PositiveInt = 2,
|
494
|
-
**kwargs: Unpack[LLMKwargs],
|
520
|
+
**kwargs: Unpack[ChooseKwargs[List[ToolBox]]],
|
495
521
|
) -> List[ToolBox]:
|
496
522
|
"""Asynchronously executes a multi-choice decision-making process to choose toolboxes.
|
497
523
|
|
498
524
|
Args:
|
499
525
|
task (Task): The task for which to choose toolboxes.
|
500
526
|
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
527
|
**kwargs (Unpack[LLMKwargs]): Additional keyword arguments for the LLM usage.
|
504
528
|
|
505
529
|
Returns:
|
@@ -511,8 +535,6 @@ class ToolBoxUsage(LLMUsage):
|
|
511
535
|
return await self.achoose(
|
512
536
|
instruction=task.briefing,
|
513
537
|
choices=list(self.toolboxes),
|
514
|
-
k=k,
|
515
|
-
max_validations=max_validations,
|
516
538
|
system_message=system_message,
|
517
539
|
**kwargs,
|
518
540
|
)
|
@@ -521,19 +543,13 @@ class ToolBoxUsage(LLMUsage):
|
|
521
543
|
self,
|
522
544
|
task: Task,
|
523
545
|
toolbox: ToolBox,
|
524
|
-
|
525
|
-
k: NonNegativeInt = 0,
|
526
|
-
max_validations: PositiveInt = 2,
|
527
|
-
**kwargs: Unpack[LLMKwargs],
|
546
|
+
**kwargs: Unpack[ChooseKwargs[List[Tool]]],
|
528
547
|
) -> List[Tool]:
|
529
548
|
"""Asynchronously executes a multi-choice decision-making process to choose tools.
|
530
549
|
|
531
550
|
Args:
|
532
551
|
task (Task): The task for which to choose tools.
|
533
552
|
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
553
|
**kwargs (Unpack[LLMKwargs]): Additional keyword arguments for the LLM usage.
|
538
554
|
|
539
555
|
Returns:
|
@@ -545,9 +561,6 @@ class ToolBoxUsage(LLMUsage):
|
|
545
561
|
return await self.achoose(
|
546
562
|
instruction=task.briefing,
|
547
563
|
choices=toolbox.tools,
|
548
|
-
k=k,
|
549
|
-
max_validations=max_validations,
|
550
|
-
system_message=system_message,
|
551
564
|
**kwargs,
|
552
565
|
)
|
553
566
|
|
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
|
)
|
Binary file
|
@@ -1,41 +1,41 @@
|
|
1
|
-
fabricatio-0.2.5.
|
2
|
-
fabricatio-0.2.5.
|
3
|
-
fabricatio-0.2.5.
|
1
|
+
fabricatio-0.2.5.dev4.dist-info/METADATA,sha256=qH-LvoH22Lf4rR2kk29GsYDKpDq1PLuD9m1HCet01rk,8861
|
2
|
+
fabricatio-0.2.5.dev4.dist-info/WHEEL,sha256=tpW5AN9B-9qsM9WW2FXG2r193YXiqexDadpKp0A2daI,96
|
3
|
+
fabricatio-0.2.5.dev4.dist-info/licenses/LICENSE,sha256=do7J7EiCGbq0QPbMAL_FqLYufXpHnCnXBOuqVPwSV8Y,1088
|
4
4
|
fabricatio/actions/article.py,sha256=PFO7QJw0SXryReA2kGJgd35NeIxCodpudNQxlXNg8xA,2785
|
5
5
|
fabricatio/actions/output.py,sha256=RWXulsfN_qrCFik0B6lGwXf6MMtgK3CaF1ENbK0l85o,684
|
6
6
|
fabricatio/actions/rag.py,sha256=lZfw9SZ8oxbWPK_bvWsEpVkWJbGP8HUnlNbxLh11Wdg,821
|
7
|
-
fabricatio/capabilities/propose.py,sha256=
|
7
|
+
fabricatio/capabilities/propose.py,sha256=Vs0kvs_F_MJiT0ySlIIbskyr4yFFpJgOCXM4GZpKtiA,1778
|
8
8
|
fabricatio/capabilities/rag.py,sha256=AQTtFPDluTByl5NXYZZIvAw2qFKpnulzxL7fmStJD0w,15547
|
9
|
-
fabricatio/capabilities/rating.py,sha256=
|
10
|
-
fabricatio/capabilities/review.py,sha256=
|
9
|
+
fabricatio/capabilities/rating.py,sha256=6EjMEBFghGAhKGtRe3UiusY3ytsGN_n2ZvHCwPa-910,14378
|
10
|
+
fabricatio/capabilities/review.py,sha256=DgqlMqqZ3UCAd-YRRFV9iFnSDz4m1auy9iuiSjXC4EU,9705
|
11
11
|
fabricatio/capabilities/task.py,sha256=s6FiC9Wg_l-qSa2LgsoKV9f6wXZN6Q_FlWn3XbSnrys,4618
|
12
12
|
fabricatio/config.py,sha256=N-H3eny1NSBmgtCNmSPaasIf4j4qya-bzYFTut80Q2E,14787
|
13
13
|
fabricatio/core.py,sha256=VQ_JKgUGIy2gZ8xsTBZCdr_IP7wC5aPg0_bsOmjQ588,6458
|
14
14
|
fabricatio/decorators.py,sha256=uzsP4tFKQNjDHBkofsjjoJA0IUAaYOtt6YVedoyOqlo,6551
|
15
|
-
fabricatio/fs/curd.py,sha256=
|
15
|
+
fabricatio/fs/curd.py,sha256=N6l2MncjrFfnXBRtteRouXp5Rjy8EAKC_i29_G-zz98,4618
|
16
16
|
fabricatio/fs/readers.py,sha256=Jw3NQ1AFMy_tZvGomTSu37kMojUoDeaZQS91w-xbNX0,1214
|
17
|
-
fabricatio/fs/__init__.py,sha256=
|
18
|
-
fabricatio/journal.py,sha256=
|
19
|
-
fabricatio/models/action.py,sha256=
|
17
|
+
fabricatio/fs/__init__.py,sha256=uk4yIlz43Yl2mQZ5QuoMstg0DaIQV9h6XXxU4SbdWpY,588
|
18
|
+
fabricatio/journal.py,sha256=2yo6R7aUq2czV7PgKM5owLvbZdimHMSxUYCMvI7Kp4M,779
|
19
|
+
fabricatio/models/action.py,sha256=XT7u3fDw7EdN___qsbUGGdhj8-RnNEpqbLbmST8SC-g,6443
|
20
20
|
fabricatio/models/events.py,sha256=pt-WkFhhA5SXmp6-3Vb_o_7I5xbKoTCJ22GAK7YYwpA,4101
|
21
21
|
fabricatio/models/extra.py,sha256=1vmtnE0n15ZSRVKmPmtChA34y0y-G07uTywXek_oGzs,7463
|
22
22
|
fabricatio/models/generic.py,sha256=wzFoZIUDrrk1eXEpjw2a-T48c9_dB7KTVUnYuMDstKo,12560
|
23
|
-
fabricatio/models/kwargs_types.py,sha256=
|
23
|
+
fabricatio/models/kwargs_types.py,sha256=8OvlMzK5glmzCX1lA0a-2lunT_W6oIhHRR0KZtjSdHY,5017
|
24
24
|
fabricatio/models/role.py,sha256=M9JVDmLLvJhY3G0hHMdcs1ywJ0eoAb6CLYbzhv-l_8s,1839
|
25
25
|
fabricatio/models/task.py,sha256=sbC0EAZC4rPL2GCJ9i9GlFcZUJ96g39SQ2QP8bbgdqs,10492
|
26
26
|
fabricatio/models/tool.py,sha256=JdpldDqlXZ0TZc9eh6IrdHB3FAldEPxsSxeSm4naJhA,7025
|
27
|
-
fabricatio/models/usages.py,sha256=
|
27
|
+
fabricatio/models/usages.py,sha256=u-MfB2B-oJp6rBnV8nN04O24evyzCkB_G5EAEHdBf6U,26779
|
28
28
|
fabricatio/models/utils.py,sha256=QI3bYrKBbzLbKvyzVrZXGcWq3trOOTE-hQAC_WNvjMg,4457
|
29
29
|
fabricatio/parser.py,sha256=qNYshYtuwbZHZG1kQKYYHZOzYhDO4DZJJYh2k4Imz3s,4911
|
30
30
|
fabricatio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
31
31
|
fabricatio/toolboxes/arithmetic.py,sha256=WLqhY-Pikv11Y_0SGajwZx3WhsLNpHKf9drzAqOf_nY,1369
|
32
|
-
fabricatio/toolboxes/fs.py,sha256=
|
32
|
+
fabricatio/toolboxes/fs.py,sha256=l4L1CVxJmjw9Ld2XUpIlWfV0_Fu_2Og6d3E13I-S4aE,736
|
33
33
|
fabricatio/toolboxes/__init__.py,sha256=KBJi5OG_pExscdlM7Bnt_UF43j4I3Lv6G71kPVu4KQU,395
|
34
34
|
fabricatio/workflows/articles.py,sha256=RebdC_BzSXC-xsck5I9ccC_XIgfhtoeM8FZuhtVDn3U,580
|
35
35
|
fabricatio/workflows/rag.py,sha256=-YYp2tlE9Vtfgpg6ROpu6QVO8j8yVSPa6yDzlN3qVxs,520
|
36
|
-
fabricatio/_rust.pyi,sha256=
|
37
|
-
fabricatio/_rust_instances.py,sha256=
|
36
|
+
fabricatio/_rust.pyi,sha256=pI747rOciunGuQZDvfC3O0A6pLyOiaHSa3A5kHuQO0E,3169
|
37
|
+
fabricatio/_rust_instances.py,sha256=RybIzB2kCoMeU_1kMm2JTz1ka8i524hAra66joDf--s,314
|
38
38
|
fabricatio/__init__.py,sha256=22KLRAVoJZUrK7gsDjU1NfiLCnZtV-qgx6TO2YMbuH8,1930
|
39
|
-
fabricatio/_rust.cp312-win_amd64.pyd,sha256=
|
40
|
-
fabricatio-0.2.5.
|
41
|
-
fabricatio-0.2.5.
|
39
|
+
fabricatio/_rust.cp312-win_amd64.pyd,sha256=tDlqCUS34WV9cNuXnd6OMsJGHuptnodQY3WAROnPF6o,1816064
|
40
|
+
fabricatio-0.2.5.dev4.data/scripts/tdown.exe,sha256=TUHa62i_6gpAYxQ1qImUl3araoORpKEAOscXPRF-DjQ,3395072
|
41
|
+
fabricatio-0.2.5.dev4.dist-info/RECORD,,
|
File without changes
|
File without changes
|