fabricatio 0.2.12.dev2__cp312-cp312-manylinux_2_34_x86_64.whl → 0.2.13.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/actions/article_rag.py +6 -0
- fabricatio/capabilities/advanced_rag.py +9 -6
- fabricatio/models/extra/article_base.py +51 -38
- fabricatio/models/extra/article_main.py +40 -49
- fabricatio/models/extra/article_outline.py +41 -3
- fabricatio/rust.cpython-312-x86_64-linux-gnu.so +0 -0
- fabricatio/rust.pyi +31 -3
- fabricatio-0.2.13.dev0.data/scripts/tdown +0 -0
- fabricatio-0.2.13.dev0.data/scripts/ttm +0 -0
- {fabricatio-0.2.12.dev2.dist-info → fabricatio-0.2.13.dev0.dist-info}/METADATA +1 -1
- {fabricatio-0.2.12.dev2.dist-info → fabricatio-0.2.13.dev0.dist-info}/RECORD +13 -12
- fabricatio-0.2.12.dev2.data/scripts/tdown +0 -0
- {fabricatio-0.2.12.dev2.dist-info → fabricatio-0.2.13.dev0.dist-info}/WHEEL +0 -0
- {fabricatio-0.2.12.dev2.dist-info → fabricatio-0.2.13.dev0.dist-info}/licenses/LICENSE +0 -0
@@ -20,6 +20,7 @@ from fabricatio.models.extra.article_main import Article, ArticleChapter, Articl
|
|
20
20
|
from fabricatio.models.extra.article_outline import ArticleOutline
|
21
21
|
from fabricatio.models.extra.rule import RuleSet
|
22
22
|
from fabricatio.models.kwargs_types import ChooseKwargs, LLMKwargs
|
23
|
+
from fabricatio.rust import convert_to_block_formula, convert_to_inline_formula
|
23
24
|
from fabricatio.utils import ask_retain, ok
|
24
25
|
|
25
26
|
TYPST_CITE_USAGE = (
|
@@ -162,6 +163,7 @@ class WriteArticleContentRAG(Action, RAG, Extract):
|
|
162
163
|
)
|
163
164
|
for p in new_subsec.paragraphs:
|
164
165
|
p.content = cm.apply(p.content)
|
166
|
+
p.description = cm.apply(p.description)
|
165
167
|
subsec.update_from(new_subsec)
|
166
168
|
logger.debug(f"{subsec.title}:rpl\n{subsec.display()}")
|
167
169
|
return subsec
|
@@ -286,6 +288,10 @@ class ArticleConsultRAG(Action, AdvancedRAG):
|
|
286
288
|
while (req := await text("User: ").ask_async()) is not None:
|
287
289
|
if await confirm("Empty the cm?").ask_async():
|
288
290
|
cm.empty()
|
291
|
+
|
292
|
+
req = convert_to_block_formula(req)
|
293
|
+
req = convert_to_inline_formula(req)
|
294
|
+
|
289
295
|
await self.clued_search(
|
290
296
|
req,
|
291
297
|
cm,
|
@@ -11,11 +11,12 @@ from fabricatio.models.kwargs_types import ChooseKwargs
|
|
11
11
|
|
12
12
|
class AdvancedRAG(RAG):
|
13
13
|
"""A class representing the Advanced RAG (Retrieval Augmented Generation) model."""
|
14
|
+
|
14
15
|
async def clued_search(
|
15
16
|
self,
|
16
17
|
requirement: str,
|
17
18
|
cm: CitationManager,
|
18
|
-
max_capacity=40,
|
19
|
+
max_capacity: int = 40,
|
19
20
|
max_round: int = 3,
|
20
21
|
expand_multiplier: float = 1.4,
|
21
22
|
base_accepted: int = 12,
|
@@ -23,28 +24,30 @@ class AdvancedRAG(RAG):
|
|
23
24
|
**kwargs: Unpack[FetchKwargs],
|
24
25
|
) -> CitationManager:
|
25
26
|
"""Asynchronously performs a clued search based on a given requirement and citation manager."""
|
26
|
-
if max_round
|
27
|
+
if max_round <= 0:
|
28
|
+
raise ValueError("max_round should be greater than 0")
|
29
|
+
if max_round == 1:
|
27
30
|
logger.warning(
|
28
31
|
"max_round should be greater than 1, otherwise it behaves nothing different from the `self.aretrieve`"
|
29
32
|
)
|
30
33
|
|
31
34
|
refinery_kwargs = refinery_kwargs or {}
|
32
35
|
|
33
|
-
for i in range(max_round + 1
|
34
|
-
logger.info(f"Round [{i
|
36
|
+
for i in range(1, max_round + 1):
|
37
|
+
logger.info(f"Round [{i}/{max_round}] search started.")
|
35
38
|
ref_q = await self.arefined_query(
|
36
39
|
f"{cm.as_prompt()}\n\nAbove is the retrieved references in the {i - 1}th RAG, now we need to perform the {i}th RAG."
|
37
40
|
f"\n\n{requirement}",
|
38
41
|
**refinery_kwargs,
|
39
42
|
)
|
40
43
|
if ref_q is None:
|
41
|
-
logger.error(f"At round [{i
|
44
|
+
logger.error(f"At round [{i}/{max_round}] search, failed to refine the query, exit.")
|
42
45
|
return cm
|
43
46
|
refs = await self.aretrieve(ref_q, ArticleChunk, base_accepted, **kwargs)
|
44
47
|
|
45
48
|
if (max_capacity := max_capacity - len(refs)) < 0:
|
46
49
|
cm.add_chunks(refs[0:max_capacity])
|
47
|
-
logger.debug(f"At round [{i
|
50
|
+
logger.debug(f"At round [{i}/{max_round}] search, the capacity is not enough, exit.")
|
48
51
|
return cm
|
49
52
|
|
50
53
|
cm.add_chunks(refs)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"""A foundation for hierarchical document components with dependency tracking."""
|
2
2
|
|
3
|
-
from abc import ABC
|
3
|
+
from abc import ABC
|
4
4
|
from enum import StrEnum
|
5
5
|
from typing import Generator, List, Optional, Self, Tuple
|
6
6
|
|
@@ -18,7 +18,8 @@ from fabricatio.models.generic import (
|
|
18
18
|
Titled,
|
19
19
|
WordCount,
|
20
20
|
)
|
21
|
-
from fabricatio.rust import
|
21
|
+
from fabricatio.rust import split_out_metadata, to_metadata, word_count
|
22
|
+
from fabricatio.utils import fallback_kwargs
|
22
23
|
from pydantic import Field
|
23
24
|
|
24
25
|
|
@@ -49,21 +50,46 @@ class ArticleMetaData(SketchedAble, Described, WordCount, Titled, Language):
|
|
49
50
|
@property
|
50
51
|
def typst_metadata_comment(self) -> str:
|
51
52
|
"""Generates a comment for the metadata of the article component."""
|
52
|
-
return
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
return to_metadata(self.model_dump(include={"description", "aims", "expected_word_count"}, by_alias=True))
|
54
|
+
|
55
|
+
|
56
|
+
class FromTypstCode(ArticleMetaData):
|
57
|
+
"""Base class for article components that can be created from a Typst code snippet."""
|
58
|
+
|
59
|
+
@classmethod
|
60
|
+
def from_typst_code(cls, title: str, body: str, **kwargs) -> Self:
|
61
|
+
"""Converts a Typst code snippet into an article component."""
|
62
|
+
data, body = split_out_metadata(body)
|
63
|
+
|
64
|
+
return cls(
|
65
|
+
heading=title,
|
66
|
+
**fallback_kwargs(
|
67
|
+
data or {},
|
68
|
+
elaboration="",
|
69
|
+
expected_word_count=word_count(body),
|
70
|
+
aims=[],
|
71
|
+
),
|
72
|
+
**kwargs,
|
57
73
|
)
|
58
74
|
|
59
75
|
|
76
|
+
class ToTypstCode(ArticleMetaData):
|
77
|
+
"""Base class for article components that can be converted to a Typst code snippet."""
|
78
|
+
|
79
|
+
def to_typst_code(self) -> str:
|
80
|
+
"""Converts the component into a Typst code snippet for rendering."""
|
81
|
+
return f"{self.title}\n{self.typst_metadata_comment}\n"
|
82
|
+
|
83
|
+
|
60
84
|
class ArticleOutlineBase(
|
61
|
-
ArticleMetaData,
|
62
85
|
ResolveUpdateConflict,
|
63
86
|
ProposedUpdateAble,
|
64
87
|
PersistentAble,
|
65
88
|
ModelHash,
|
66
89
|
Introspect,
|
90
|
+
FromTypstCode,
|
91
|
+
ToTypstCode,
|
92
|
+
ABC,
|
67
93
|
):
|
68
94
|
"""Base class for article outlines."""
|
69
95
|
|
@@ -89,17 +115,13 @@ class ArticleOutlineBase(
|
|
89
115
|
"""Updates the current instance with the attributes of another instance."""
|
90
116
|
return self.update_metadata(other)
|
91
117
|
|
92
|
-
@abstractmethod
|
93
|
-
def to_typst_code(self) -> str:
|
94
|
-
"""Converts the component into a Typst code snippet for rendering."""
|
95
|
-
|
96
118
|
|
97
119
|
class SubSectionBase(ArticleOutlineBase):
|
98
120
|
"""Base class for article sections and subsections."""
|
99
121
|
|
100
122
|
def to_typst_code(self) -> str:
|
101
123
|
"""Converts the component into a Typst code snippet for rendering."""
|
102
|
-
return f"=== {
|
124
|
+
return f"=== {super().to_typst_code()}"
|
103
125
|
|
104
126
|
def introspect(self) -> str:
|
105
127
|
"""Introspects the article subsection outline."""
|
@@ -124,9 +146,7 @@ class SectionBase[T: SubSectionBase](ArticleOutlineBase):
|
|
124
146
|
Returns:
|
125
147
|
str: The formatted Typst code snippet.
|
126
148
|
"""
|
127
|
-
return f"== {
|
128
|
-
subsec.to_typst_code() for subsec in self.subsections
|
129
|
-
)
|
149
|
+
return f"== {super().to_typst_code()}" + "\n\n".join(subsec.to_typst_code() for subsec in self.subsections)
|
130
150
|
|
131
151
|
def resolve_update_conflict(self, other: Self) -> str:
|
132
152
|
"""Resolve update errors in the article outline."""
|
@@ -169,9 +189,7 @@ class ChapterBase[T: SectionBase](ArticleOutlineBase):
|
|
169
189
|
|
170
190
|
def to_typst_code(self) -> str:
|
171
191
|
"""Converts the chapter into a Typst formatted code snippet for rendering."""
|
172
|
-
return f"= {
|
173
|
-
sec.to_typst_code() for sec in self.sections
|
174
|
-
)
|
192
|
+
return f"= {super().to_typst_code()}" + "\n\n".join(sec.to_typst_code() for sec in self.sections)
|
175
193
|
|
176
194
|
def resolve_update_conflict(self, other: Self) -> str:
|
177
195
|
"""Resolve update errors in the article outline."""
|
@@ -203,12 +221,13 @@ class ChapterBase[T: SectionBase](ArticleOutlineBase):
|
|
203
221
|
return ""
|
204
222
|
|
205
223
|
|
206
|
-
class ArticleBase[T: ChapterBase](FinalizedDumpAble, AsPrompt,
|
224
|
+
class ArticleBase[T: ChapterBase](FinalizedDumpAble, AsPrompt, FromTypstCode, ToTypstCode, ABC):
|
207
225
|
"""Base class for article outlines."""
|
208
226
|
|
209
|
-
|
210
|
-
|
211
|
-
|
227
|
+
description: str = Field(
|
228
|
+
alias="elaboration",
|
229
|
+
)
|
230
|
+
"""The abstract of this article, which serves as a concise summary of an academic article, encapsulating its core purpose, methodologies, key results,
|
212
231
|
and conclusions while enabling readers to rapidly assess the relevance and significance of the study.
|
213
232
|
Functioning as the article's distilled essence, it succinctly articulates the research problem, objectives,
|
214
233
|
and scope, providing a roadmap for the full text while also facilitating database indexing, literature reviews,
|
@@ -293,6 +312,10 @@ class ArticleBase[T: ChapterBase](FinalizedDumpAble, AsPrompt, WordCount, Descri
|
|
293
312
|
for _, _, subsec in self.iter_subsections():
|
294
313
|
yield subsec.title
|
295
314
|
|
315
|
+
def to_typst_code(self) -> str:
|
316
|
+
"""Generates the Typst code representation of the article."""
|
317
|
+
return f"// #{super().to_typst_code()}\n\n" + "\n\n".join(a.to_typst_code() for a in self.chapters)
|
318
|
+
|
296
319
|
def finalized_dump(self) -> str:
|
297
320
|
"""Generates standardized hierarchical markup for academic publishing systems.
|
298
321
|
|
@@ -313,26 +336,16 @@ class ArticleBase[T: ChapterBase](FinalizedDumpAble, AsPrompt, WordCount, Descri
|
|
313
336
|
=== Implementation Details
|
314
337
|
== Evaluation Protocol
|
315
338
|
"""
|
316
|
-
return (
|
317
|
-
comment(
|
318
|
-
f"Title:{self.title}\n"
|
319
|
-
+ (f"Desc:\n{self.description}\n" if self.description else "")
|
320
|
-
+ f"Word Count:{self.expected_word_count}"
|
321
|
-
if self.expected_word_count
|
322
|
-
else ""
|
323
|
-
)
|
324
|
-
+ "\n\n"
|
325
|
-
+ "\n\n".join(a.to_typst_code() for a in self.chapters)
|
326
|
-
)
|
339
|
+
return self.to_typst_code()
|
327
340
|
|
328
|
-
def avg_chap_wordcount[S](self: S) -> S:
|
341
|
+
def avg_chap_wordcount[S: "ArticleBase"](self: S) -> S:
|
329
342
|
"""Set all chap have same word count sum up to be `self.expected_word_count`."""
|
330
343
|
avg = int(self.expected_word_count / len(self.chapters))
|
331
344
|
for c in self.chapters:
|
332
345
|
c.expected_word_count = avg
|
333
346
|
return self
|
334
347
|
|
335
|
-
def avg_sec_wordcount[S](self: S) -> S:
|
348
|
+
def avg_sec_wordcount[S: "ArticleBase"](self: S) -> S:
|
336
349
|
"""Set all sec have same word count sum up to be `self.expected_word_count`."""
|
337
350
|
for c in self.chapters:
|
338
351
|
avg = int(c.expected_word_count / len(c.sections))
|
@@ -340,7 +353,7 @@ class ArticleBase[T: ChapterBase](FinalizedDumpAble, AsPrompt, WordCount, Descri
|
|
340
353
|
s.expected_word_count = avg
|
341
354
|
return self
|
342
355
|
|
343
|
-
def avg_subsec_wordcount[S](self: S) -> S:
|
356
|
+
def avg_subsec_wordcount[S: "ArticleBase"](self: S) -> S:
|
344
357
|
"""Set all subsec have same word count sum up to be `self.expected_word_count`."""
|
345
358
|
for _, s in self.iter_sections():
|
346
359
|
avg = int(s.expected_word_count / len(s.subsections))
|
@@ -348,6 +361,6 @@ class ArticleBase[T: ChapterBase](FinalizedDumpAble, AsPrompt, WordCount, Descri
|
|
348
361
|
ss.expected_word_count = avg
|
349
362
|
return self
|
350
363
|
|
351
|
-
def avg_wordcount_recursive[S](self:S) -> S:
|
364
|
+
def avg_wordcount_recursive[S: "ArticleBase"](self: S) -> S:
|
352
365
|
"""Set all chap, sec, subsec have same word count sum up to be `self.expected_word_count`."""
|
353
366
|
return self.avg_chap_wordcount().avg_sec_wordcount().avg_subsec_wordcount()
|
@@ -18,11 +18,16 @@ from fabricatio.models.extra.article_outline import (
|
|
18
18
|
ArticleSubsectionOutline,
|
19
19
|
)
|
20
20
|
from fabricatio.models.generic import Described, PersistentAble, SequencePatch, SketchedAble, WithRef, WordCount
|
21
|
-
from fabricatio.rust import
|
22
|
-
|
21
|
+
from fabricatio.rust import (
|
22
|
+
convert_all_block_tex,
|
23
|
+
convert_all_inline_tex,
|
24
|
+
fix_misplaced_labels,
|
25
|
+
split_out_metadata,
|
26
|
+
word_count,
|
27
|
+
)
|
23
28
|
from pydantic import Field, NonNegativeInt
|
24
29
|
|
25
|
-
PARAGRAPH_SEP = "// - -
|
30
|
+
PARAGRAPH_SEP = "\n\n// - - -\n\n"
|
26
31
|
|
27
32
|
|
28
33
|
class Paragraph(SketchedAble, WordCount, Described):
|
@@ -93,17 +98,17 @@ class ArticleSubsection(SubSectionBase):
|
|
93
98
|
Returns:
|
94
99
|
str: Typst code snippet for rendering.
|
95
100
|
"""
|
96
|
-
return super().to_typst_code() +
|
101
|
+
return super().to_typst_code() + PARAGRAPH_SEP.join(p.content for p in self.paragraphs)
|
97
102
|
|
98
103
|
@classmethod
|
99
|
-
def from_typst_code(cls, title: str, body: str) -> Self:
|
104
|
+
def from_typst_code(cls, title: str, body: str, **kwargs) -> Self:
|
100
105
|
"""Creates an Article object from the given Typst code."""
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
106
|
+
_, para_body = split_out_metadata(body)
|
107
|
+
|
108
|
+
return super().from_typst_code(
|
109
|
+
title,
|
110
|
+
body,
|
111
|
+
paragraphs=[Paragraph.from_content(p) for p in para_body.split(PARAGRAPH_SEP)],
|
107
112
|
)
|
108
113
|
|
109
114
|
|
@@ -111,16 +116,14 @@ class ArticleSection(SectionBase[ArticleSubsection]):
|
|
111
116
|
"""Atomic argumentative unit with high-level specificity."""
|
112
117
|
|
113
118
|
@classmethod
|
114
|
-
def from_typst_code(cls, title: str, body: str) -> Self:
|
119
|
+
def from_typst_code(cls, title: str, body: str, **kwargs) -> Self:
|
115
120
|
"""Creates an Article object from the given Typst code."""
|
116
|
-
return
|
121
|
+
return super().from_typst_code(
|
122
|
+
title,
|
123
|
+
body,
|
117
124
|
subsections=[
|
118
125
|
ArticleSubsection.from_typst_code(*pack) for pack in extract_sections(body, level=3, section_char="=")
|
119
126
|
],
|
120
|
-
heading=title,
|
121
|
-
elaboration="",
|
122
|
-
expected_word_count=word_count(body),
|
123
|
-
aims=[],
|
124
127
|
)
|
125
128
|
|
126
129
|
|
@@ -128,21 +131,18 @@ class ArticleChapter(ChapterBase[ArticleSection]):
|
|
128
131
|
"""Thematic progression implementing research function."""
|
129
132
|
|
130
133
|
@classmethod
|
131
|
-
def from_typst_code(cls, title: str, body: str) -> Self:
|
134
|
+
def from_typst_code(cls, title: str, body: str, **kwargs) -> Self:
|
132
135
|
"""Creates an Article object from the given Typst code."""
|
133
|
-
return
|
136
|
+
return super().from_typst_code(
|
137
|
+
title,
|
138
|
+
body,
|
134
139
|
sections=[
|
135
140
|
ArticleSection.from_typst_code(*pack) for pack in extract_sections(body, level=2, section_char="=")
|
136
141
|
],
|
137
|
-
heading=title,
|
138
|
-
elaboration="",
|
139
|
-
expected_word_count=word_count(body),
|
140
|
-
aims=[],
|
141
142
|
)
|
142
143
|
|
143
144
|
|
144
145
|
class Article(
|
145
|
-
SketchedAble,
|
146
146
|
WithRef[ArticleOutline],
|
147
147
|
PersistentAble,
|
148
148
|
ArticleBase[ArticleChapter],
|
@@ -161,25 +161,20 @@ class Article(
|
|
161
161
|
"Original Article": self.display(),
|
162
162
|
}
|
163
163
|
|
164
|
-
def convert_tex(self) -> Self:
|
164
|
+
def convert_tex(self, paragraphs: bool = True, descriptions: bool = True) -> Self:
|
165
165
|
"""Convert tex to typst code."""
|
166
|
-
|
167
|
-
for
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
p.content.replace(r" \( ", "$")
|
179
|
-
.replace(r" \) ", "$")
|
180
|
-
.replace("\\[\n", "$$\n")
|
181
|
-
.replace("\n\\]", "\n$$")
|
182
|
-
)
|
166
|
+
if descriptions:
|
167
|
+
for a in self.iter_dfs():
|
168
|
+
a.description = fix_misplaced_labels(a.description)
|
169
|
+
a.description = convert_all_inline_tex(a.description)
|
170
|
+
a.description = convert_all_block_tex(a.description)
|
171
|
+
|
172
|
+
if paragraphs:
|
173
|
+
for _, _, subsec in self.iter_subsections():
|
174
|
+
for p in subsec.paragraphs:
|
175
|
+
p.content = fix_misplaced_labels(p.content)
|
176
|
+
p.content = convert_all_inline_tex(p.content)
|
177
|
+
p.content = convert_all_block_tex(p.content)
|
183
178
|
return self
|
184
179
|
|
185
180
|
@override
|
@@ -269,16 +264,12 @@ class Article(
|
|
269
264
|
@classmethod
|
270
265
|
def from_typst_code(cls, title: str, body: str, **kwargs) -> Self:
|
271
266
|
"""Generates an article from the given Typst code."""
|
272
|
-
return
|
267
|
+
return super().from_typst_code(
|
268
|
+
title,
|
269
|
+
body,
|
273
270
|
chapters=[
|
274
271
|
ArticleChapter.from_typst_code(*pack) for pack in extract_sections(body, level=1, section_char="=")
|
275
272
|
],
|
276
|
-
heading=title,
|
277
|
-
**fallback_kwargs(
|
278
|
-
kwargs,
|
279
|
-
expected_word_count=word_count(body),
|
280
|
-
abstract="",
|
281
|
-
),
|
282
273
|
)
|
283
274
|
|
284
275
|
@classmethod
|
@@ -1,7 +1,8 @@
|
|
1
1
|
"""A module containing the ArticleOutline class, which represents the outline of an academic paper."""
|
2
2
|
|
3
|
-
from typing import Dict
|
3
|
+
from typing import Dict, Self
|
4
4
|
|
5
|
+
from fabricatio.fs.readers import extract_sections
|
5
6
|
from fabricatio.models.extra.article_base import (
|
6
7
|
ArticleBase,
|
7
8
|
ChapterBase,
|
@@ -9,7 +10,7 @@ from fabricatio.models.extra.article_base import (
|
|
9
10
|
SubSectionBase,
|
10
11
|
)
|
11
12
|
from fabricatio.models.extra.article_proposal import ArticleProposal
|
12
|
-
from fabricatio.models.generic import PersistentAble,
|
13
|
+
from fabricatio.models.generic import PersistentAble, WithRef
|
13
14
|
|
14
15
|
|
15
16
|
class ArticleSubsectionOutline(SubSectionBase):
|
@@ -18,14 +19,39 @@ class ArticleSubsectionOutline(SubSectionBase):
|
|
18
19
|
|
19
20
|
class ArticleSectionOutline(SectionBase[ArticleSubsectionOutline]):
|
20
21
|
"""A slightly more detailed research component specification for academic paper generation, Must contain subsections."""
|
22
|
+
@classmethod
|
23
|
+
def from_typst_code(cls, title: str, body: str, **kwargs) -> Self:
|
24
|
+
"""Parse the given Typst code into an ArticleSectionOutline instance."""
|
25
|
+
return super().from_typst_code(
|
26
|
+
title,
|
27
|
+
body,
|
28
|
+
subsections=[
|
29
|
+
ArticleSubsectionOutline.from_typst_code(*pack)
|
30
|
+
for pack in extract_sections(body, level=3, section_char="=")
|
31
|
+
],
|
32
|
+
)
|
33
|
+
|
21
34
|
|
22
35
|
|
23
36
|
class ArticleChapterOutline(ChapterBase[ArticleSectionOutline]):
|
24
37
|
"""Macro-structural unit implementing standard academic paper organization. Must contain sections."""
|
25
38
|
|
39
|
+
@classmethod
|
40
|
+
def from_typst_code(cls, title: str, body: str, **kwargs) -> Self:
|
41
|
+
"""Parse the given Typst code into an ArticleChapterOutline instance."""
|
42
|
+
return super().from_typst_code(
|
43
|
+
title,
|
44
|
+
body,
|
45
|
+
sections=[
|
46
|
+
ArticleSectionOutline.from_typst_code(*pack)
|
47
|
+
for pack in extract_sections(body, level=2, section_char="=")
|
48
|
+
],
|
49
|
+
|
50
|
+
)
|
51
|
+
|
52
|
+
|
26
53
|
|
27
54
|
class ArticleOutline(
|
28
|
-
SketchedAble,
|
29
55
|
WithRef[ArticleProposal],
|
30
56
|
PersistentAble,
|
31
57
|
ArticleBase[ArticleChapterOutline],
|
@@ -38,3 +64,15 @@ class ArticleOutline(
|
|
38
64
|
"Original Article Proposal": self.referenced.display(),
|
39
65
|
"Original Article Outline": self.display(),
|
40
66
|
}
|
67
|
+
|
68
|
+
@classmethod
|
69
|
+
def from_typst_code(cls, title: str, body: str, **kwargs) -> Self:
|
70
|
+
"""Parse the given Typst code into an ArticleOutline instance."""
|
71
|
+
return super().from_typst_code(
|
72
|
+
title,
|
73
|
+
body,
|
74
|
+
chapters=[
|
75
|
+
ArticleChapterOutline.from_typst_code(*pack)
|
76
|
+
for pack in extract_sections(body, level=1, section_char="=")
|
77
|
+
],
|
78
|
+
)
|
Binary file
|
fabricatio/rust.pyi
CHANGED
@@ -12,7 +12,9 @@ Key Features:
|
|
12
12
|
"""
|
13
13
|
|
14
14
|
from pathlib import Path
|
15
|
-
from typing import Any, Dict, List, Optional, overload
|
15
|
+
from typing import Any, Dict, List, Optional, Tuple, overload
|
16
|
+
|
17
|
+
from pydantic import JsonValue
|
16
18
|
|
17
19
|
class TemplateManager:
|
18
20
|
"""Template rendering engine using Handlebars templates.
|
@@ -325,11 +327,11 @@ def convert_all_block_tex(string: str) -> str:
|
|
325
327
|
The converted string with block TeX code replaced.
|
326
328
|
"""
|
327
329
|
|
328
|
-
def fix_misplaced_labels(
|
330
|
+
def fix_misplaced_labels(string: str) -> str:
|
329
331
|
"""A func to fix labels in a string.
|
330
332
|
|
331
333
|
Args:
|
332
|
-
|
334
|
+
string: The input string containing misplaced labels.
|
333
335
|
|
334
336
|
Returns:
|
335
337
|
The fixed string with labels properly placed.
|
@@ -354,3 +356,29 @@ def uncomment(string: str) -> str:
|
|
354
356
|
Returns:
|
355
357
|
The string with comments (lines starting with '// ' or '//') removed.
|
356
358
|
"""
|
359
|
+
|
360
|
+
def split_out_metadata(string: str) -> Tuple[Optional[JsonValue], str]:
|
361
|
+
"""Split out metadata from a string.
|
362
|
+
|
363
|
+
Args:
|
364
|
+
string: The input string containing metadata.
|
365
|
+
|
366
|
+
Returns:
|
367
|
+
A tuple containing the metadata as a Python object (if parseable) and the remaining string.
|
368
|
+
"""
|
369
|
+
|
370
|
+
def to_metadata(data: JsonValue) -> str:
|
371
|
+
"""Convert a Python object to a YAML string.
|
372
|
+
|
373
|
+
Args:
|
374
|
+
data: The Python object to be converted to YAML.
|
375
|
+
|
376
|
+
Returns:
|
377
|
+
The YAML string representation of the input data.
|
378
|
+
"""
|
379
|
+
|
380
|
+
def convert_to_inline_formula(string: str) -> str:
|
381
|
+
r"""Convert `$...$` to inline formula `\(...\)` and trim spaces."""
|
382
|
+
|
383
|
+
def convert_to_block_formula(string: str) -> str:
|
384
|
+
r"""Convert `$$...$$` to block formula `\[...\]` and trim spaces."""
|
Binary file
|
Binary file
|
@@ -1,6 +1,6 @@
|
|
1
|
-
fabricatio-0.2.
|
2
|
-
fabricatio-0.2.
|
3
|
-
fabricatio-0.2.
|
1
|
+
fabricatio-0.2.13.dev0.dist-info/METADATA,sha256=Spzd95aTVAVcyTqZFNv0zJOA02o-rpSGFmJFlZvuA2o,5120
|
2
|
+
fabricatio-0.2.13.dev0.dist-info/WHEEL,sha256=7FgAcpQES0h1xhfN9Ugve9FTUilU6sRAr1WJ5ph2cuw,108
|
3
|
+
fabricatio-0.2.13.dev0.dist-info/licenses/LICENSE,sha256=yDZaTLnOi03bi3Dk6f5IjhLUc5old2yOsihHWU0z-i0,1067
|
4
4
|
fabricatio/decorators.py,sha256=iuFCTtZ4VXwxJpM_z-CtrEpTaVZsv_eBFe5mOhe4wlo,8715
|
5
5
|
fabricatio/constants.py,sha256=JxtaKGTf0IQhM-MNCHtr6x85Ejg8FWYcie-Z_RupCBg,557
|
6
6
|
fabricatio/core.py,sha256=MaEKZ6DDmbdScAY-7F1gwGA6fr7ADX6Mz5rNVi2msFA,6277
|
@@ -10,15 +10,15 @@ fabricatio/models/role.py,sha256=5SJ1Vm6H3FwOVEk5Z-4GBJWABI3OKAKwkz5t170osi8,285
|
|
10
10
|
fabricatio/models/kwargs_types.py,sha256=aI844DNQXLbSBC3P0bZQLJpuJxwwF66WTDbbYQTftaE,4618
|
11
11
|
fabricatio/models/extra/article_proposal.py,sha256=4G2qLkMxtK54G1ANgPW0G3w4Pahxgk2lhGPU5KMxuzw,1818
|
12
12
|
fabricatio/models/extra/advanced_judge.py,sha256=CKPP4Lseb_Ey8Y7i2V9HJfB-mZgCknFdqq7Zo41o6s4,1060
|
13
|
-
fabricatio/models/extra/article_main.py,sha256=
|
13
|
+
fabricatio/models/extra/article_main.py,sha256=HxqmMleOId2EXPAGBZIYyR1ufwUnll0ASFkHSRKN0qI,11290
|
14
14
|
fabricatio/models/extra/problem.py,sha256=1Sd8hsThQK6pXMXhErRhP1ft58z4PvqeB8AV8VcXiaI,7051
|
15
15
|
fabricatio/models/extra/article_essence.py,sha256=zUfZ2_bX3h__RaVPwJlxQ-tkFyfSV8SdX8DsmFX6v_w,2649
|
16
16
|
fabricatio/models/extra/rag.py,sha256=RWv_YJhDX6UL4t3sRtQt-LYMtxN-K-t931nmyiJXkKM,3857
|
17
|
-
fabricatio/models/extra/article_outline.py,sha256=
|
17
|
+
fabricatio/models/extra/article_outline.py,sha256=B_qMldX_vxPZ52uvCp124R4vVYFFYPjUjLJc0-_lGog,2715
|
18
18
|
fabricatio/models/extra/__init__.py,sha256=0R9eZsCNu6OV-Xtf15H7FrqhfHTFBFf3fBrcd7ChsJ0,53
|
19
19
|
fabricatio/models/extra/rule.py,sha256=b756_XmWeDoJ1qOFEGy6ZfP8O7rBjOZs4XvfZvWKXXI,2574
|
20
20
|
fabricatio/models/extra/aricle_rag.py,sha256=-w1fxs5PrsLTYPmNtUhWSeucQ9evnasUB75aMlzutL0,10722
|
21
|
-
fabricatio/models/extra/article_base.py,sha256=
|
21
|
+
fabricatio/models/extra/article_base.py,sha256=fiwhy5TuNi9hPB12zfjCAThymcCSoZ66vxsklCYymng,14150
|
22
22
|
fabricatio/models/extra/patches.py,sha256=_ghmnlvTZQq7UJyaH77mTZE9abjvxRJ2mgWHUbezUls,977
|
23
23
|
fabricatio/models/adv_kwargs_types.py,sha256=659KMMuvdVq1xJxavLbUAMWxPOAz0RP9bNaZm3hyz-4,1890
|
24
24
|
fabricatio/models/usages.py,sha256=FVRhh_AulXlJF9uUmJzKEdiLz-di0rAiaQm4snYEid0,32571
|
@@ -36,11 +36,11 @@ fabricatio/rust_instances.py,sha256=i5fIt6XkE8UwUU4JarmPt50AZs8aJW6efaypSLGLl0I,
|
|
36
36
|
fabricatio/config.py,sha256=Zc2UG1Jf8u0XfwHR7yrApgynzdX_uC6jInMw8PDm64o,17526
|
37
37
|
fabricatio/utils.py,sha256=DZDOsJN1FxTVqq-i1fAJZdLfDYxyVoMAJFQURuYt1rY,3004
|
38
38
|
fabricatio/journal.py,sha256=Op0wC-JlZumnAc_aDmYM4ljnSNLoKEEMfcIRbCF69ow,455
|
39
|
-
fabricatio/rust.pyi,sha256=
|
39
|
+
fabricatio/rust.pyi,sha256=9GXuLBMTmRfea9PUBZgycYACly02kCaGzDb1YGgg0g8,11207
|
40
40
|
fabricatio/__init__.py,sha256=OXoMMHJKHEB_vN97_34U4I5QpAKL9xnVQEVcBCvwBCg,986
|
41
41
|
fabricatio/actions/fs.py,sha256=nlTmk-tYDW158nz_fzlsNfuYJwj7j4BHn_MFY5hxdqs,934
|
42
42
|
fabricatio/actions/output.py,sha256=lTvMgXzY-fwA_kNrivdFZkk3kT8DMpjBSIWLyav2B1k,8089
|
43
|
-
fabricatio/actions/article_rag.py,sha256=
|
43
|
+
fabricatio/actions/article_rag.py,sha256=CndhcKrYLIEuwKakU4CaLrpNsiRfT3GxuQoxhRpEE_c,18528
|
44
44
|
fabricatio/actions/rag.py,sha256=-bA7KkZEFfWEanAPHzYwRHG7zRlTZcNDI7HL3n-lDuE,3496
|
45
45
|
fabricatio/actions/__init__.py,sha256=ZMa1LeM5BNeqp-J-D32W-f5bD53-kdXGyt0zuueJofM,47
|
46
46
|
fabricatio/actions/article.py,sha256=syUjEyKppdT72Xd1LSXKR3Djo1aybRPeFRHRzifNhm0,10632
|
@@ -52,7 +52,7 @@ fabricatio/parser.py,sha256=rMXd9Lo5TjxUkI0rocYigF9d1kC0rSySenuMW8uqXm8,6483
|
|
52
52
|
fabricatio/capabilities/censor.py,sha256=j6vyjKpR1CfLzC-XrOZSZePjJz3jsoM104gqqsWwi1Q,4615
|
53
53
|
fabricatio/capabilities/advanced_judge.py,sha256=bvb8fYoiKoGlBwMZVMflVE9R2MoS1VtmZAo65jMJFew,683
|
54
54
|
fabricatio/capabilities/check.py,sha256=TLtkUIR6tX73qR_V5TkXpdmplrmqFt4dZj32PBy81H0,8409
|
55
|
-
fabricatio/capabilities/advanced_rag.py,sha256=
|
55
|
+
fabricatio/capabilities/advanced_rag.py,sha256=y1XMENFdGGr0AcXZHgloRM9jX2yJpPEM-q0Y9Z-EI1k,2320
|
56
56
|
fabricatio/capabilities/correct.py,sha256=Et3Ud-oLZlwTVSy2XyT5UX2shT_OJ9j4HWP9b5Hntvk,10192
|
57
57
|
fabricatio/capabilities/rag.py,sha256=f7d3y6ZmjkbGZL_KyK9d-DAFE-yJFBck-NBrTPTVF8c,9387
|
58
58
|
fabricatio/capabilities/__init__.py,sha256=skaJ43CqAQaZMH-mCRzF4Fps3x99P2SwJ8vSM9pInX8,56
|
@@ -61,6 +61,7 @@ fabricatio/capabilities/review.py,sha256=EPL8IlxSKO0XStBkXdW7FJMbPztDQMv9w7tHgu6
|
|
61
61
|
fabricatio/capabilities/propose.py,sha256=vOJvmmnMBHUQB6N1AmZNFw42jf7Bl2mBRNlBK15TpNI,1942
|
62
62
|
fabricatio/capabilities/task.py,sha256=_BAQonNy5JH3JxhLmPGfn0nDvn_ENKXyOdql8EVXRLE,4362
|
63
63
|
fabricatio/capabilities/extract.py,sha256=b4_Tuc9O6Pe71y4Tj-JHMb4simdhduVR-rcfD9yW8RA,2425
|
64
|
-
fabricatio/rust.cpython-312-x86_64-linux-gnu.so,sha256=
|
65
|
-
fabricatio-0.2.
|
66
|
-
fabricatio-0.2.
|
64
|
+
fabricatio/rust.cpython-312-x86_64-linux-gnu.so,sha256=TgEpq7LO6uoApCF8YVb74HiDGMSIsdpCfxEkMgOpgG0,4734664
|
65
|
+
fabricatio-0.2.13.dev0.data/scripts/tdown,sha256=f-_G7qusdwSJDsD1OaUT321lmJeZxRKnNOT19mnrVy4,4583280
|
66
|
+
fabricatio-0.2.13.dev0.data/scripts/ttm,sha256=bO9U2GB_zBq4YFZmFiD7TZ2ld8Nnq3EPD7n3RCcEl2s,3926464
|
67
|
+
fabricatio-0.2.13.dev0.dist-info/RECORD,,
|
Binary file
|
File without changes
|
File without changes
|