fabricatio 0.2.6.dev7__cp312-cp312-manylinux_2_34_x86_64.whl → 0.2.7.dev0__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.cpython-312-x86_64-linux-gnu.so +0 -0
- fabricatio/actions/article.py +6 -3
- fabricatio/actions/rag.py +51 -3
- fabricatio/capabilities/correct.py +2 -2
- fabricatio/capabilities/rag.py +21 -6
- fabricatio/capabilities/review.py +2 -2
- fabricatio/capabilities/task.py +3 -3
- fabricatio/config.py +5 -3
- fabricatio/models/action.py +13 -1
- fabricatio/models/extra.py +111 -84
- fabricatio/models/tool.py +6 -2
- fabricatio/models/usages.py +5 -1
- fabricatio/models/utils.py +4 -0
- fabricatio-0.2.7.dev0.data/scripts/tdown +0 -0
- {fabricatio-0.2.6.dev7.dist-info → fabricatio-0.2.7.dev0.dist-info}/METADATA +1 -1
- {fabricatio-0.2.6.dev7.dist-info → fabricatio-0.2.7.dev0.dist-info}/RECORD +18 -18
- fabricatio-0.2.6.dev7.data/scripts/tdown +0 -0
- {fabricatio-0.2.6.dev7.dist-info → fabricatio-0.2.7.dev0.dist-info}/WHEEL +0 -0
- {fabricatio-0.2.6.dev7.dist-info → fabricatio-0.2.7.dev0.dist-info}/licenses/LICENSE +0 -0
Binary file
|
fabricatio/actions/article.py
CHANGED
@@ -24,10 +24,10 @@ class ExtractArticleEssence(Action):
|
|
24
24
|
output_key: str = "article_essence"
|
25
25
|
"""The key of the output data."""
|
26
26
|
|
27
|
-
async def _execute
|
27
|
+
async def _execute(
|
28
28
|
self,
|
29
29
|
task_input: Task,
|
30
|
-
reader: Callable[[
|
30
|
+
reader: Callable[[str], str] = lambda p: Path(p).read_text(encoding="utf-8"),
|
31
31
|
**_,
|
32
32
|
) -> Optional[List[ArticleEssence]]:
|
33
33
|
if not task_input.dependencies:
|
@@ -118,7 +118,7 @@ class CorrectOutline(Action):
|
|
118
118
|
article_proposal: ArticleProposal,
|
119
119
|
|
120
120
|
**_,
|
121
|
-
) ->
|
121
|
+
) -> ArticleOutline:
|
122
122
|
ret = None
|
123
123
|
while await confirm("Do you want to correct the outline?").ask_async():
|
124
124
|
rprint(article_outline.finalized_dump())
|
@@ -126,3 +126,6 @@ class CorrectOutline(Action):
|
|
126
126
|
...
|
127
127
|
ret = await self.correct_obj(article_outline, article_proposal.display(), topic=topic)
|
128
128
|
return ret or article_outline
|
129
|
+
|
130
|
+
|
131
|
+
|
fabricatio/actions/rag.py
CHANGED
@@ -3,8 +3,11 @@
|
|
3
3
|
from typing import List, Optional
|
4
4
|
|
5
5
|
from fabricatio.capabilities.rag import RAG
|
6
|
+
from fabricatio.journal import logger
|
6
7
|
from fabricatio.models.action import Action
|
7
8
|
from fabricatio.models.generic import PrepareVectorization
|
9
|
+
from fabricatio.models.task import Task
|
10
|
+
from questionary import text
|
8
11
|
|
9
12
|
|
10
13
|
class InjectToDB(Action, RAG):
|
@@ -13,13 +16,58 @@ class InjectToDB(Action, RAG):
|
|
13
16
|
output_key: str = "collection_name"
|
14
17
|
|
15
18
|
async def _execute[T: PrepareVectorization](
|
16
|
-
self, to_inject: T | List[T], collection_name:
|
19
|
+
self, to_inject: Optional[T] | List[Optional[T]], collection_name: str = "my_collection",override_inject:bool=False, **_
|
17
20
|
) -> Optional[str]:
|
18
21
|
if not isinstance(to_inject, list):
|
19
22
|
to_inject = [to_inject]
|
20
|
-
|
23
|
+
logger.info(f"Injecting {len(to_inject)} items into the collection '{collection_name}'")
|
24
|
+
if override_inject:
|
25
|
+
self.check_client().client.drop_collection(collection_name)
|
21
26
|
await self.view(collection_name, create=True).consume_string(
|
22
|
-
[
|
27
|
+
[
|
28
|
+
t.prepare_vectorization(self.embedding_max_sequence_length)
|
29
|
+
for t in to_inject
|
30
|
+
if isinstance(t, PrepareVectorization)
|
31
|
+
],
|
23
32
|
)
|
24
33
|
|
25
34
|
return collection_name
|
35
|
+
|
36
|
+
|
37
|
+
class RAGTalk(Action, RAG):
|
38
|
+
"""RAG-enabled conversational action that processes user questions based on a given task.
|
39
|
+
|
40
|
+
This action establishes an interactive conversation loop where it retrieves context-relevant
|
41
|
+
information to answer user queries according to the assigned task briefing.
|
42
|
+
|
43
|
+
Notes:
|
44
|
+
task_input: Task briefing that guides how to respond to user questions
|
45
|
+
collection_name: Name of the vector collection to use for retrieval (default: "my_collection")
|
46
|
+
|
47
|
+
Returns:
|
48
|
+
Number of conversation turns completed before termination
|
49
|
+
"""
|
50
|
+
|
51
|
+
output_key: str = "task_output"
|
52
|
+
|
53
|
+
async def _execute(self, task_input: Task[str], **kwargs) -> int:
|
54
|
+
collection_name = kwargs.get("collection_name", "my_collection")
|
55
|
+
counter = 0
|
56
|
+
|
57
|
+
self.view(collection_name, create=True)
|
58
|
+
|
59
|
+
try:
|
60
|
+
while True:
|
61
|
+
user_say = await text("User: ").ask_async()
|
62
|
+
if user_say is None:
|
63
|
+
break
|
64
|
+
gpt_say = await self.aask_retrieved(
|
65
|
+
user_say,
|
66
|
+
user_say,
|
67
|
+
extra_system_message=f"You have to answer to user obeying task assigned to you:\n{task_input.briefing}",
|
68
|
+
)
|
69
|
+
print(f"GPT: {gpt_say}") # noqa: T201
|
70
|
+
counter += 1
|
71
|
+
except KeyboardInterrupt:
|
72
|
+
logger.info(f"executed talk action {counter} times")
|
73
|
+
return counter
|
@@ -55,7 +55,7 @@ class Correct(Review):
|
|
55
55
|
if supervisor_check:
|
56
56
|
await review_res.supervisor_check()
|
57
57
|
if "default" in kwargs:
|
58
|
-
cast(ReviewKwargs[None], kwargs)["default"] = None
|
58
|
+
cast('ReviewKwargs[None]', kwargs)["default"] = None
|
59
59
|
return await self.propose(
|
60
60
|
obj.__class__,
|
61
61
|
TEMPLATE_MANAGER.render_template(
|
@@ -89,7 +89,7 @@ class Correct(Review):
|
|
89
89
|
await review_res.supervisor_check()
|
90
90
|
|
91
91
|
if "default" in kwargs:
|
92
|
-
cast(ReviewKwargs[None], kwargs)["default"] = None
|
92
|
+
cast('ReviewKwargs[None]', kwargs)["default"] = None
|
93
93
|
return await self.ageneric_string(
|
94
94
|
TEMPLATE_MANAGER.render_template(
|
95
95
|
configs.templates.correct_template, {"content": input_text, "review": review_res.display()}
|
fabricatio/capabilities/rag.py
CHANGED
@@ -63,10 +63,18 @@ class RAG(EmbeddingUsage):
|
|
63
63
|
uri=milvus_uri or ok(self.milvus_uri or configs.rag.milvus_uri).unicode_string(),
|
64
64
|
token=milvus_token
|
65
65
|
or (token.get_secret_value() if (token := (self.milvus_token or configs.rag.milvus_token)) else ""),
|
66
|
-
timeout=milvus_timeout or self.milvus_timeout,
|
66
|
+
timeout=milvus_timeout or self.milvus_timeout or configs.rag.milvus_timeout,
|
67
67
|
)
|
68
68
|
return self
|
69
69
|
|
70
|
+
def check_client(self, init: bool = True) -> Self:
|
71
|
+
"""Check if the client is initialized, and if not, initialize it."""
|
72
|
+
if self._client is None and init:
|
73
|
+
return self.init_client()
|
74
|
+
if self._client is None and not init:
|
75
|
+
raise RuntimeError("Client is not initialized. Have you called `self.init_client()`?")
|
76
|
+
return self
|
77
|
+
|
70
78
|
@overload
|
71
79
|
async def pack(
|
72
80
|
self, input_text: List[str], subject: Optional[str] = None, **kwargs: Unpack[EmbeddingKwargs]
|
@@ -111,8 +119,15 @@ class RAG(EmbeddingUsage):
|
|
111
119
|
create (bool): Whether to create the collection if it does not exist.
|
112
120
|
**kwargs (Unpack[CollectionConfigKwargs]): Additional keyword arguments for collection configuration.
|
113
121
|
"""
|
114
|
-
if create and collection_name and self.client.has_collection(collection_name):
|
115
|
-
kwargs["dimension"] =
|
122
|
+
if create and collection_name and not self.check_client().client.has_collection(collection_name):
|
123
|
+
kwargs["dimension"] = ok(
|
124
|
+
kwargs.get("dimension")
|
125
|
+
or self.milvus_dimensions
|
126
|
+
or configs.rag.milvus_dimensions
|
127
|
+
or self.embedding_dimensions
|
128
|
+
or configs.embedding.dimensions,
|
129
|
+
"`dimension` is not set at any level.",
|
130
|
+
)
|
116
131
|
self.client.create_collection(collection_name, auto_id=True, **kwargs)
|
117
132
|
logger.info(f"Creating collection {collection_name}")
|
118
133
|
|
@@ -158,7 +173,7 @@ class RAG(EmbeddingUsage):
|
|
158
173
|
else:
|
159
174
|
raise TypeError(f"Expected MilvusData or list of MilvusData, got {type(data)}")
|
160
175
|
c_name = collection_name or self.safe_target_collection
|
161
|
-
self.client.insert(c_name, prepared_data)
|
176
|
+
self.check_client().client.insert(c_name, prepared_data)
|
162
177
|
|
163
178
|
if flush:
|
164
179
|
logger.debug(f"Flushing collection {c_name}")
|
@@ -219,7 +234,7 @@ class RAG(EmbeddingUsage):
|
|
219
234
|
List[Dict[str, Any]] | List[Any]: The retrieved data.
|
220
235
|
"""
|
221
236
|
# Step 1: Search for vectors
|
222
|
-
search_results = self.client.search(
|
237
|
+
search_results = self.check_client().client.search(
|
223
238
|
collection_name or self.safe_target_collection,
|
224
239
|
vecs,
|
225
240
|
search_params={"radius": similarity_threshold},
|
@@ -260,7 +275,7 @@ class RAG(EmbeddingUsage):
|
|
260
275
|
if isinstance(query, str):
|
261
276
|
query = [query]
|
262
277
|
return cast(
|
263
|
-
List[str],
|
278
|
+
'List[str]',
|
264
279
|
await self.afetch_document(
|
265
280
|
vecs=(await self.vectorize(query)),
|
266
281
|
desired_fields="text",
|
@@ -121,7 +121,7 @@ class ReviewResult[T](ProposedAble, Display):
|
|
121
121
|
ReviewResult[K]: The current instance with updated reference type.
|
122
122
|
"""
|
123
123
|
self._ref = ref # pyright: ignore [reportAttributeAccessIssue]
|
124
|
-
return cast(ReviewResult[K], self)
|
124
|
+
return cast("ReviewResult[K]", self)
|
125
125
|
|
126
126
|
def deref(self) -> T:
|
127
127
|
"""Retrieve the referenced object that was reviewed.
|
@@ -200,7 +200,7 @@ class Review(GiveRating, Propose):
|
|
200
200
|
ReviewResult[Task[T]]: A review result containing identified problems and proposed solutions,
|
201
201
|
with a reference to the original task.
|
202
202
|
"""
|
203
|
-
return cast(ReviewResult[Task[T]], await self.review_obj(task, **kwargs))
|
203
|
+
return cast('ReviewResult[Task[T]]', await self.review_obj(task, **kwargs))
|
204
204
|
|
205
205
|
async def review_string(
|
206
206
|
self,
|
fabricatio/capabilities/task.py
CHANGED
@@ -23,7 +23,7 @@ class ProposeTask(WithBriefing, Propose):
|
|
23
23
|
self,
|
24
24
|
prompt: str,
|
25
25
|
**kwargs: Unpack[ValidateKwargs[Task[T]]],
|
26
|
-
) -> Task[T]:
|
26
|
+
) -> Optional[Task[T]]:
|
27
27
|
"""Asynchronously proposes a task based on a given prompt and parameters.
|
28
28
|
|
29
29
|
Parameters:
|
@@ -37,7 +37,7 @@ class ProposeTask(WithBriefing, Propose):
|
|
37
37
|
logger.error(err := f"{self.name}: Prompt must be provided.")
|
38
38
|
raise ValueError(err)
|
39
39
|
|
40
|
-
return await self.propose(Task, prompt, **self.prepend(cast(Dict[str, Any], kwargs)))
|
40
|
+
return await self.propose(Task, prompt, **self.prepend(cast('Dict[str, Any]', kwargs)))
|
41
41
|
|
42
42
|
|
43
43
|
class HandleTask(WithBriefing, ToolBoxUsage):
|
@@ -81,7 +81,7 @@ class HandleTask(WithBriefing, ToolBoxUsage):
|
|
81
81
|
return await self.aask_validate(
|
82
82
|
question=q,
|
83
83
|
validator=_validator,
|
84
|
-
**self.prepend(cast(Dict[str, Any], kwargs)),
|
84
|
+
**self.prepend(cast('Dict[str, Any]', kwargs)),
|
85
85
|
)
|
86
86
|
|
87
87
|
async def handle_fine_grind(
|
fabricatio/config.py
CHANGED
@@ -277,7 +277,7 @@ class RagConfig(BaseModel):
|
|
277
277
|
|
278
278
|
milvus_uri: Optional[HttpUrl] = Field(default=HttpUrl("http://localhost:19530"))
|
279
279
|
"""The URI of the Milvus server."""
|
280
|
-
milvus_timeout: Optional[PositiveFloat] = Field(default=
|
280
|
+
milvus_timeout: Optional[PositiveFloat] = Field(default=30.0)
|
281
281
|
"""The timeout of the Milvus server."""
|
282
282
|
milvus_token: Optional[SecretStr] = Field(default=None)
|
283
283
|
"""The token of the Milvus server."""
|
@@ -303,11 +303,13 @@ class RoutingConfig(BaseModel):
|
|
303
303
|
|
304
304
|
model_config = ConfigDict(use_attribute_docstrings=True)
|
305
305
|
|
306
|
-
|
306
|
+
max_parallel_requests: Optional[int] = 60
|
307
|
+
"""The maximum number of parallel requests. None means not checked."""
|
308
|
+
allowed_fails: Optional[int] = 3
|
307
309
|
"""The number of allowed fails before the routing is considered failed."""
|
308
310
|
retry_after: int = 15
|
309
311
|
"""The time in seconds to wait before retrying the routing after a fail."""
|
310
|
-
cooldown_time: Optional[int] =
|
312
|
+
cooldown_time: Optional[int] = 30
|
311
313
|
"""The time in seconds to wait before retrying the routing after a cooldown."""
|
312
314
|
|
313
315
|
|
fabricatio/models/action.py
CHANGED
@@ -48,7 +48,7 @@ class Action(HandleTask, ProposeTask, Correct):
|
|
48
48
|
self.description = self.description or self.__class__.__doc__ or ""
|
49
49
|
|
50
50
|
@abstractmethod
|
51
|
-
async def _execute(self, **cxt) -> Any:
|
51
|
+
async def _execute(self,*_, **cxt) -> Any: # noqa: ANN002
|
52
52
|
"""Execute the action logic with the provided context arguments.
|
53
53
|
|
54
54
|
This method must be implemented by subclasses to define the actual behavior.
|
@@ -216,3 +216,15 @@ class WorkFlow(WithBriefing, ToolBoxUsage):
|
|
216
216
|
"""
|
217
217
|
self.provide_tools_to(self._instances)
|
218
218
|
return self
|
219
|
+
|
220
|
+
def update_init_context(self, **kwargs) -> Self:
|
221
|
+
"""Update the initial context with additional key-value pairs.
|
222
|
+
|
223
|
+
Args:
|
224
|
+
**kwargs: Key-value pairs to add to the initial context.
|
225
|
+
|
226
|
+
Returns:
|
227
|
+
Self: The workflow instance for method chaining.
|
228
|
+
"""
|
229
|
+
self.extra_init_context.update(kwargs)
|
230
|
+
return self
|
fabricatio/models/extra.py
CHANGED
@@ -3,11 +3,12 @@
|
|
3
3
|
from typing import List, Self
|
4
4
|
|
5
5
|
from fabricatio.models.generic import Base, Display, FinalizedDumpAble, PrepareVectorization, ProposedAble
|
6
|
-
from pydantic import Field
|
7
|
-
|
8
6
|
|
9
7
|
# <editor-fold desc="ArticleEssence">
|
10
|
-
|
8
|
+
from pydantic import BaseModel, Field
|
9
|
+
|
10
|
+
|
11
|
+
class Equation(BaseModel):
|
11
12
|
"""Mathematical formalism specification for research contributions.
|
12
13
|
|
13
14
|
Encodes equations with dual representation: semantic meaning and typeset-ready notation.
|
@@ -15,93 +16,123 @@ class Equation(Base):
|
|
15
16
|
|
16
17
|
description: str
|
17
18
|
"""Equation significance structured in three elements:
|
18
|
-
1. Physical/conceptual meaning
|
19
|
-
2. Role in technical workflow
|
20
|
-
3. Relationship to paper's core contribution
|
21
|
-
Example:
|
19
|
+
1. Physical/conceptual meaning of the equation.
|
20
|
+
2. Role in technical workflow (e.g., derivation, optimization, or analysis).
|
21
|
+
3. Relationship to the paper's core contribution (e.g., theoretical foundation, empirical validation).
|
22
|
+
Example: "Defines constrained search space dimensionality reduction. Used in architecture optimization phase (Section 3.2). Enables 40% parameter reduction."
|
23
|
+
"""
|
22
24
|
|
23
25
|
latex_code: str
|
24
26
|
"""LaTeX representation following academic typesetting standards:
|
25
|
-
- Must use equation environment
|
26
|
-
- Multiline equations
|
27
|
-
-
|
28
|
-
Example:
|
27
|
+
- Must use equation environment (e.g., `equation`, `align`).
|
28
|
+
- Multiline equations must align at '=' using `&`.
|
29
|
+
- Include unit annotations where applicable.
|
30
|
+
Example: "\\begin{equation} \\mathcal{L}_{NAS} = \\alpha \\|\\theta\\|_2 + \\beta H(p) \\end{equation}"
|
31
|
+
"""
|
29
32
|
|
30
33
|
|
31
|
-
class Figure(
|
34
|
+
class Figure(BaseModel):
|
32
35
|
"""Visual component specification for technical communication.
|
33
36
|
|
34
|
-
Combines graphical assets with structured academic captioning.
|
37
|
+
Combines graphical assets with structured academic captioning.Extracted from the article provided
|
35
38
|
"""
|
36
39
|
|
37
40
|
description: str
|
38
41
|
"""Figure interpretation guide containing:
|
39
|
-
1. Key visual elements mapping
|
40
|
-
2. Data representation methodology
|
41
|
-
3. Connection to research findings
|
42
|
-
Example:
|
42
|
+
1. Key visual elements mapping (e.g., axes, legends, annotations).
|
43
|
+
2. Data representation methodology (e.g., visualization type, statistical measures).
|
44
|
+
3. Connection to research findings (e.g., supports hypothesis, demonstrates performance).
|
45
|
+
Example: "Architecture search space topology (left) vs. convergence curves (right). Demonstrates NAS efficiency gains through constrained search."
|
46
|
+
"""
|
43
47
|
|
44
48
|
figure_caption: str
|
45
49
|
"""Complete caption following Nature-style guidelines:
|
46
|
-
1. Brief overview statement (首句总结)
|
47
|
-
2. Technical detail layer
|
48
|
-
3. Result implication
|
49
|
-
Example:
|
50
|
+
1. Brief overview statement (首句总结).
|
51
|
+
2. Technical detail layer (e.g., data sources, experimental conditions).
|
52
|
+
3. Result implication (e.g., key insights, implications for future work).
|
53
|
+
Example: "Figure 3: Differentiable NAS framework. (a) Search space topology with constrained dimensions. (b) Training convergence across language pairs. Dashed lines indicate baseline methods."
|
54
|
+
"""
|
55
|
+
|
56
|
+
figure_serial_number: int
|
57
|
+
"""The Image serial number extracted from the Markdown article provided, the path usually in the form of ``, in this case the serial number is `1`"""
|
58
|
+
|
59
|
+
|
60
|
+
class Algorithm(BaseModel):
|
61
|
+
"""Algorithm specification for research contributions."""
|
62
|
+
|
63
|
+
title: str
|
64
|
+
"""Algorithm title with technical focus descriptor (e.g., 'Gradient Descent Optimization').
|
65
|
+
|
66
|
+
Tip: Do not attempt to translate the original element titles when generating JSON.
|
67
|
+
"""
|
68
|
+
|
69
|
+
description: str
|
70
|
+
"""Algorithm description with technical focus descriptor:
|
71
|
+
- Includes input/output specifications.
|
72
|
+
- Describes key steps and their purpose.
|
73
|
+
- Explains its role in the research workflow.
|
74
|
+
Example: "Proposed algorithm for neural architecture search. Inputs include search space constraints and training data. Outputs optimized architecture."
|
75
|
+
"""
|
76
|
+
|
50
77
|
|
51
|
-
|
52
|
-
"""
|
53
|
-
Strict validation requirements:
|
54
|
-
- Absolute path under /assets/figures/
|
55
|
-
- Naming convention: fig[chapter]-[section]_[description].pdf
|
56
|
-
Example: '/assets/figures/fig3-2_nas_convergence.pdf'"""
|
78
|
+
class Table(BaseModel):
|
79
|
+
"""Table specification for research contributions."""
|
57
80
|
|
81
|
+
title: str
|
82
|
+
"""Table title with technical focus descriptor (e.g., 'Comparison of Model Performance Metrics').
|
58
83
|
|
59
|
-
|
84
|
+
Tip: Do not attempt to translate the original element titles when generating JSON.
|
85
|
+
"""
|
86
|
+
|
87
|
+
description: str
|
88
|
+
"""Table description with technical focus descriptor:
|
89
|
+
- Includes data source and structure.
|
90
|
+
- Explains key columns/rows and their significance.
|
91
|
+
- Connects to research findings or hypotheses.
|
92
|
+
Example: "Performance metrics for different architectures. Columns represent accuracy, F1-score, and inference time. Highlights efficiency gains of proposed method."
|
93
|
+
"""
|
94
|
+
|
95
|
+
|
96
|
+
class Highlightings(BaseModel):
|
60
97
|
"""Technical showcase aggregator for research artifacts.
|
61
98
|
|
62
99
|
Curates core scientific components with machine-parseable annotations.
|
63
100
|
"""
|
64
101
|
|
65
|
-
highlighted_equations: List[Equation]
|
66
|
-
"""3-5 pivotal equations representing theoretical contributions
|
67
|
-
Each must
|
68
|
-
-
|
69
|
-
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
highlighted_algorithms: List[
|
74
|
-
"""
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
Example:
|
79
|
-
'Algorithm 1: Constrained NAS
|
80
|
-
1. Initialize search space with §3.1 constraints ※
|
81
|
-
2. While not converged:
|
82
|
-
a. Compute gradient ▽θ
|
83
|
-
b. Update architecture parameters...'"""
|
102
|
+
highlighted_equations: List[Equation]
|
103
|
+
"""3-5 pivotal equations representing theoretical contributions:
|
104
|
+
- Each equation must be wrapped in $$ for display math.
|
105
|
+
- Contain at least one novel operator/symbol.
|
106
|
+
- Be referenced in Methods/Results sections.
|
107
|
+
Example: Equation describing proposed loss function.
|
108
|
+
"""
|
109
|
+
|
110
|
+
highlighted_algorithms: List[Algorithm]
|
111
|
+
"""1-2 key algorithms demonstrating methodological contributions:
|
112
|
+
- Include pseudocode or step-by-step descriptions.
|
113
|
+
- Highlight innovation in computational approach.
|
114
|
+
Example: Algorithm for constrained search space exploration.
|
84
115
|
|
85
|
-
|
116
|
+
Tip: Do not attempt to translate the original element titles when generating JSON.
|
117
|
+
"""
|
118
|
+
|
119
|
+
highlighted_figures: List[Figure]
|
86
120
|
"""4-6 key figures demonstrating:
|
87
|
-
1. Framework overview (1 required)
|
88
|
-
2. Quantitative results (2-3 required)
|
89
|
-
3. Ablation studies (1 optional)
|
90
|
-
Each must appear in Results/Discussion chapters.
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
-
|
96
|
-
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
Ours & 32.4 & -41\\%† \\
|
103
|
-
\bottomrule
|
104
|
-
\\end{tabular}"""
|
121
|
+
1. Framework overview (1 required).
|
122
|
+
2. Quantitative results (2-3 required).
|
123
|
+
3. Ablation studies (1 optional).
|
124
|
+
Each must appear in Results/Discussion chapters.
|
125
|
+
Example: Figure showing architecture topology and convergence curves.
|
126
|
+
"""
|
127
|
+
|
128
|
+
highlighted_tables: List[Table]
|
129
|
+
"""2-3 key tables summarizing:
|
130
|
+
- Comparative analysis of methods.
|
131
|
+
- Empirical results supporting claims.
|
132
|
+
Example: Table comparing model performance across datasets.
|
133
|
+
|
134
|
+
Tip: Do not attempt to translate the original element titles when generating JSON.
|
135
|
+
"""
|
105
136
|
|
106
137
|
|
107
138
|
class ArticleEssence(ProposedAble, Display, PrepareVectorization):
|
@@ -111,28 +142,26 @@ class ArticleEssence(ProposedAble, Display, PrepareVectorization):
|
|
111
142
|
"""
|
112
143
|
|
113
144
|
title: str = Field(...)
|
114
|
-
"""
|
115
|
-
Must
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
145
|
+
"""Exact title of the original article without any modification.
|
146
|
+
Must be preserved precisely from the source material without:
|
147
|
+
- Translation
|
148
|
+
- Paraphrasing
|
149
|
+
- Adding/removing words
|
150
|
+
- Altering style or formatting
|
151
|
+
"""
|
120
152
|
|
121
153
|
authors: List[str]
|
122
|
-
"""
|
123
|
-
|
124
|
-
Superscripts mapping to affiliations.
|
125
|
-
Example: ['Yuanhao Zhou¹', 'Lei Chen²']"""
|
154
|
+
"""Original author names exactly as they appear in the source document. No translation or paraphrasing.
|
155
|
+
Extract complete list without any modifications or formatting changes."""
|
126
156
|
|
127
157
|
keywords: List[str]
|
128
|
-
"""
|
129
|
-
|
158
|
+
"""Original keywords exactly as they appear in the source document. No translation or paraphrasing.
|
159
|
+
Extract the complete set without modifying format or terminology."""
|
130
160
|
|
131
161
|
publication_year: int
|
132
|
-
"""Publication timestamp in ISO 8601 (YYYY format).
|
133
|
-
Constraint: 2017 ≤ year ≤ current_year"""
|
162
|
+
"""Publication timestamp in ISO 8601 (YYYY format)."""
|
134
163
|
|
135
|
-
highlightings: Highlightings
|
164
|
+
highlightings: Highlightings
|
136
165
|
"""Technical highlight reel containing:
|
137
166
|
- Core equations (Theory)
|
138
167
|
- Key algorithms (Implementation)
|
@@ -140,9 +169,7 @@ class ArticleEssence(ProposedAble, Display, PrepareVectorization):
|
|
140
169
|
- Benchmark tables (Evaluation)"""
|
141
170
|
|
142
171
|
domain: List[str]
|
143
|
-
"""
|
144
|
-
Exactly 2-3 categories required.
|
145
|
-
Example: ['Computing methodologies → Machine learning']"""
|
172
|
+
"""Domain tags for research focus."""
|
146
173
|
|
147
174
|
abstract: str = Field(...)
|
148
175
|
"""Three-paragraph structured abstract:
|
fabricatio/models/tool.py
CHANGED
@@ -136,7 +136,9 @@ class ToolExecutor(BaseModel):
|
|
136
136
|
|
137
137
|
def inject_tools[M: ModuleType](self, module: Optional[M] = None) -> M:
|
138
138
|
"""Inject the tools into the provided module or default."""
|
139
|
-
module = module or cast(
|
139
|
+
module = module or cast(
|
140
|
+
"M", module_from_spec(spec=ModuleSpec(name=configs.toolbox.tool_module_name, loader=None))
|
141
|
+
)
|
140
142
|
for tool in self.candidates:
|
141
143
|
logger.debug(f"Injecting tool: {tool.name}")
|
142
144
|
setattr(module, tool.name, tool.invoke)
|
@@ -144,7 +146,9 @@ class ToolExecutor(BaseModel):
|
|
144
146
|
|
145
147
|
def inject_data[M: ModuleType](self, module: Optional[M] = None) -> M:
|
146
148
|
"""Inject the data into the provided module or default."""
|
147
|
-
module = module or cast(
|
149
|
+
module = module or cast(
|
150
|
+
'M', module_from_spec(spec=ModuleSpec(name=configs.toolbox.data_module_name, loader=None))
|
151
|
+
)
|
148
152
|
for key, value in self.data.items():
|
149
153
|
logger.debug(f"Injecting data: {key}")
|
150
154
|
setattr(module, key, value)
|
fabricatio/models/usages.py
CHANGED
@@ -14,7 +14,7 @@ from fabricatio.models.task import Task
|
|
14
14
|
from fabricatio.models.tool import Tool, ToolBox
|
15
15
|
from fabricatio.models.utils import Messages, ok
|
16
16
|
from fabricatio.parser import GenericCapture, JsonCapture
|
17
|
-
from litellm import Router, stream_chunk_builder # pyright: ignore [reportPrivateImportUsage]
|
17
|
+
from litellm import RateLimitError, Router, stream_chunk_builder # pyright: ignore [reportPrivateImportUsage]
|
18
18
|
from litellm.types.router import Deployment, LiteLLM_Params, ModelInfo
|
19
19
|
from litellm.types.utils import (
|
20
20
|
Choices,
|
@@ -33,6 +33,7 @@ if configs.cache.enabled and configs.cache.type:
|
|
33
33
|
|
34
34
|
ROUTER = Router(
|
35
35
|
routing_strategy="usage-based-routing-v2",
|
36
|
+
default_max_parallel_requests=configs.routing.max_parallel_requests,
|
36
37
|
allowed_fails=configs.routing.allowed_fails,
|
37
38
|
retry_after=configs.routing.retry_after,
|
38
39
|
cooldown_time=configs.routing.cooldown_time,
|
@@ -305,6 +306,9 @@ class LLMUsage(ScopedConfig):
|
|
305
306
|
):
|
306
307
|
logger.debug(f"Successfully validated the co-response at {lap}th attempt.")
|
307
308
|
return validated
|
309
|
+
except RateLimitError as e:
|
310
|
+
logger.warning(f"Rate limit error: {e}")
|
311
|
+
continue
|
308
312
|
except Exception as e: # noqa: BLE001
|
309
313
|
logger.error(f"Error during validation: \n{e}")
|
310
314
|
break
|
fabricatio/models/utils.py
CHANGED
@@ -172,6 +172,10 @@ def override_kwargs[T](kwargs: Dict[str, T], **overrides) -> Dict[str, T]:
|
|
172
172
|
kwargs.update({k: v for k, v in overrides.items() if v is not None})
|
173
173
|
return kwargs
|
174
174
|
|
175
|
+
def fallback_kwargs[T](kwargs: Dict[str, T], **overrides) -> Dict[str, T]:
|
176
|
+
"""Fallback the values in kwargs with the provided overrides."""
|
177
|
+
kwargs.update({k: v for k, v in overrides.items() if k not in kwargs})
|
178
|
+
return kwargs
|
175
179
|
|
176
180
|
def ok[T](val: Optional[T], msg:str="Value is None") -> T:
|
177
181
|
"""Check if a value is None and raise a ValueError with the provided message if it is.
|
Binary file
|
@@ -1,18 +1,18 @@
|
|
1
|
-
fabricatio-0.2.
|
2
|
-
fabricatio-0.2.
|
3
|
-
fabricatio-0.2.
|
1
|
+
fabricatio-0.2.7.dev0.dist-info/METADATA,sha256=kbyPqlXHruO4h4035HRgwNcVuz2otPQAkunm_zj-MKc,13693
|
2
|
+
fabricatio-0.2.7.dev0.dist-info/WHEEL,sha256=7FgAcpQES0h1xhfN9Ugve9FTUilU6sRAr1WJ5ph2cuw,108
|
3
|
+
fabricatio-0.2.7.dev0.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=WxT4KBGGZTpqGPSPVwD5mkmhYBjxggZ7n-HKi-Hed4M,13619
|
7
|
-
fabricatio/models/tool.py,sha256=
|
7
|
+
fabricatio/models/tool.py,sha256=ifivEnYiEUtjeRxQkX8vjfyzn1m1acgfrsABbQqCsGs,6912
|
8
8
|
fabricatio/models/role.py,sha256=UgIfGdfIBu4cOug8Nm1a04JCEwjXR_MDZUQhumwMptk,2710
|
9
|
-
fabricatio/models/extra.py,sha256=
|
9
|
+
fabricatio/models/extra.py,sha256=uVVe5Xjv0sg0-HRaM4pCN3iwVZ8CwjdkjrKpp3QVYhc,27091
|
10
10
|
fabricatio/models/kwargs_types.py,sha256=rqhCG2QLj4iyZ5WnLU4IT0xPdzFWvgsz9g6qau3bD1E,4839
|
11
|
-
fabricatio/models/utils.py,sha256=
|
12
|
-
fabricatio/models/usages.py,sha256=
|
11
|
+
fabricatio/models/utils.py,sha256=E1Jz7oodbn09OkBspSpzCgKkv0AiuxyQElqCgHF7bVY,5718
|
12
|
+
fabricatio/models/usages.py,sha256=ALB9V0Gfli2T9LDZ_gdvdChXwj6ieDeuK6Qye6NPXgE,30368
|
13
13
|
fabricatio/models/events.py,sha256=UvOc6V3vfjKuvh7irDezJ8EGpsNo5yzLdq4xQexVonw,4063
|
14
14
|
fabricatio/models/task.py,sha256=-EnzpEyM6Z687gF1lPcmA2szEUw6dFpu3lOtseaz95o,10193
|
15
|
-
fabricatio/models/action.py,sha256=
|
15
|
+
fabricatio/models/action.py,sha256=Afm3f1eE_KthDcAIVunVa2R6sysvdxxBjPIj5WvfO08,8378
|
16
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
|
@@ -20,23 +20,23 @@ fabricatio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
20
|
fabricatio/fs/readers.py,sha256=5bLlpqcdhIwWfysh7gvfVv0PPPVAeDlTPGwNTio6j9M,1156
|
21
21
|
fabricatio/fs/curd.py,sha256=FuG75qco4dX8vhIK27gKz9rKUXbWHOFg5yK3nGLB25s,4469
|
22
22
|
fabricatio/fs/__init__.py,sha256=hTuYtzmvIGtbg7PTdoqLEQJ0E63hOzZltCIrLlDKaSE,559
|
23
|
-
fabricatio/config.py,sha256=
|
23
|
+
fabricatio/config.py,sha256=n5jU6j0SS8x3crJomwF8_6FI-UPGzEDsxL_zkxSZSkk,16352
|
24
24
|
fabricatio/journal.py,sha256=Op0wC-JlZumnAc_aDmYM4ljnSNLoKEEMfcIRbCF69ow,455
|
25
25
|
fabricatio/__init__.py,sha256=6EjK4SxbnvFxdO9ftkXD9rxSuoPEIITNzUkuMO9s3yU,1092
|
26
26
|
fabricatio/actions/output.py,sha256=wNyLNxjqBlms0hyxap8XUPgN53izipJrCOtpX6aluFQ,626
|
27
|
-
fabricatio/actions/rag.py,sha256=
|
28
|
-
fabricatio/actions/article.py,sha256=
|
27
|
+
fabricatio/actions/rag.py,sha256=Tsjn9IkO8OlKlhBBnk7J6qh9st61jzD6SUYClGhYs7I,2686
|
28
|
+
fabricatio/actions/article.py,sha256=f1r6LDiqGvotZzQOqFBYBQcm0zR7ElQzC6kurgrSuMM,4422
|
29
29
|
fabricatio/_rust_instances.py,sha256=bQmlhUCcxTmRgvw1SfzYzNNpgW_UCjmkYw5f-VPAyg8,304
|
30
30
|
fabricatio/workflows/articles.py,sha256=oHNV5kNKEcOKP55FA7I1SlxQRlk6N26cpem_QYu05g0,1021
|
31
31
|
fabricatio/workflows/rag.py,sha256=uOZXprD479fUhLA6sYvEM8RWcVcUZXXtP0xRbTMPdHE,509
|
32
32
|
fabricatio/parser.py,sha256=OV6bIAfLJ-GfaKoTeIOqS3X3GqCgyvzSJsgYMO3ogj4,6100
|
33
|
-
fabricatio/capabilities/correct.py,sha256=
|
34
|
-
fabricatio/capabilities/rag.py,sha256=
|
33
|
+
fabricatio/capabilities/correct.py,sha256=Nk1lppraLNDtA5qh-u82D_dUNUwKUqS4YsEbtNXioHo,5111
|
34
|
+
fabricatio/capabilities/rag.py,sha256=s7GbIG-i7uuJL1SerGr4tgonjl6s1k2HWWO5XyQsar8,16077
|
35
35
|
fabricatio/capabilities/rating.py,sha256=ZQrKKmmIgnN4zgNnG_GmWa5Nyxpk03JYW32RJ4R5vvQ,14067
|
36
|
-
fabricatio/capabilities/review.py,sha256=
|
36
|
+
fabricatio/capabilities/review.py,sha256=jX4VluU6pEefqT933AfkZdejxxABzLQrEkKMBm3vHA8,10828
|
37
37
|
fabricatio/capabilities/propose.py,sha256=4QvONVVUp1rs34Te2Rjams6NioEt6FhEAxDWiveQnSg,1544
|
38
|
-
fabricatio/capabilities/task.py,sha256=
|
38
|
+
fabricatio/capabilities/task.py,sha256=Y57GAsEuFZUxNuxEqOaZxeYOzQBAqvG_9kPbuPt7sLI,4510
|
39
39
|
fabricatio/_rust.pyi,sha256=1TvnaXK_QKM8Et05LkZ_vOGR4WISVd9X8lU6OTwFFaU,3376
|
40
|
-
fabricatio/_rust.cpython-312-x86_64-linux-gnu.so,sha256=
|
41
|
-
fabricatio-0.2.
|
42
|
-
fabricatio-0.2.
|
40
|
+
fabricatio/_rust.cpython-312-x86_64-linux-gnu.so,sha256=t1COw3bM_BmYYizdCwuFx_fq0PnhFPZO-zLJTJDkC40,1910320
|
41
|
+
fabricatio-0.2.7.dev0.data/scripts/tdown,sha256=Y3fBi2TPyjMz2tt8bXf8yB263OBAHob40owbzNsJZvM,4578912
|
42
|
+
fabricatio-0.2.7.dev0.dist-info/RECORD,,
|
Binary file
|
File without changes
|
File without changes
|