fabricatio 0.2.12.dev3__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.
@@ -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,
@@ -24,7 +24,7 @@ class AdvancedRAG(RAG):
24
24
  **kwargs: Unpack[FetchKwargs],
25
25
  ) -> CitationManager:
26
26
  """Asynchronously performs a clued search based on a given requirement and citation manager."""
27
- if max_round<=0:
27
+ if max_round <= 0:
28
28
  raise ValueError("max_round should be greater than 0")
29
29
  if max_round == 1:
30
30
  logger.warning(
@@ -33,21 +33,21 @@ class AdvancedRAG(RAG):
33
33
 
34
34
  refinery_kwargs = refinery_kwargs or {}
35
35
 
36
- for i in range(max_round + 1, 1):
37
- logger.info(f"Round [{i + 1}/{max_round}] search started.")
36
+ for i in range(1, max_round + 1):
37
+ logger.info(f"Round [{i}/{max_round}] search started.")
38
38
  ref_q = await self.arefined_query(
39
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."
40
40
  f"\n\n{requirement}",
41
41
  **refinery_kwargs,
42
42
  )
43
43
  if ref_q is None:
44
- logger.error(f"At round [{i + 1}/{max_round}] search, failed to refine the query, exit.")
44
+ logger.error(f"At round [{i}/{max_round}] search, failed to refine the query, exit.")
45
45
  return cm
46
46
  refs = await self.aretrieve(ref_q, ArticleChunk, base_accepted, **kwargs)
47
47
 
48
48
  if (max_capacity := max_capacity - len(refs)) < 0:
49
49
  cm.add_chunks(refs[0:max_capacity])
50
- logger.debug(f"At round [{i + 1}/{max_round}] search, the capacity is not enough, exit.")
50
+ logger.debug(f"At round [{i}/{max_round}] search, the capacity is not enough, exit.")
51
51
  return cm
52
52
 
53
53
  cm.add_chunks(refs)
@@ -161,13 +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
- for _, _, subsec in self.iter_subsections():
167
- for p in subsec.paragraphs:
168
- p.content = fix_misplaced_labels(p.content)
169
- p.content = convert_all_inline_tex(p.content)
170
- p.content = convert_all_block_tex(p.content)
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)
171
178
  return self
172
179
 
173
180
  @override
fabricatio/rust.pyi CHANGED
@@ -377,3 +377,8 @@ def to_metadata(data: JsonValue) -> str:
377
377
  The YAML string representation of the input data.
378
378
  """
379
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fabricatio
3
- Version: 0.2.12.dev3
3
+ Version: 0.2.13.dev0
4
4
  Classifier: License :: OSI Approved :: MIT License
5
5
  Classifier: Programming Language :: Rust
6
6
  Classifier: Programming Language :: Python :: 3.12
@@ -1,6 +1,6 @@
1
- fabricatio-0.2.12.dev3.dist-info/METADATA,sha256=YCdvNpYywNbwF7ZX4_mBS-A5yhGbYTvoiOyihr24qzo,5120
2
- fabricatio-0.2.12.dev3.dist-info/WHEEL,sha256=7FgAcpQES0h1xhfN9Ugve9FTUilU6sRAr1WJ5ph2cuw,108
3
- fabricatio-0.2.12.dev3.dist-info/licenses/LICENSE,sha256=yDZaTLnOi03bi3Dk6f5IjhLUc5old2yOsihHWU0z-i0,1067
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,7 +10,7 @@ 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=PVFfTNDSWMGVSkrQqKXkZafHoKygD_3czeri-aCRM2M,10924
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
@@ -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=UhQY1bEB6RrCo8Yv3mq6NRtzEWOSsZzeeYtxSGagGWc,10960
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=XcPSHJzODKUGJHjY_3Mj6la7hwZmTeWLECeATq8iRfk,18297
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=gv2qHqPQpiCmIPHhbibdBeWVhrKB4Xm3kqERCg7HEAw,2330
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=k-zgqY_boW8AjnkndawuMWVuPt1QuWKufO2zzpdeG4U,4727424
65
- fabricatio-0.2.12.dev3.data/scripts/tdown,sha256=VYqmPnlR2_DvwJGkX9lP45fBgPl7MLVJGD2rVt73okg,4585400
66
- fabricatio-0.2.12.dev3.dist-info/RECORD,,
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