fabricatio 0.2.12.dev3__cp312-cp312-win_amd64.whl → 0.2.13.dev0__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.
@@ -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
Binary file
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."""
@@ -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,15 +1,15 @@
1
- fabricatio-0.2.12.dev3.dist-info/METADATA,sha256=iMt48rBNujWl2lSSwiAHtT22G-K7zpXLPwnV8K_32mw,5263
2
- fabricatio-0.2.12.dev3.dist-info/WHEEL,sha256=jABKVkLC9kJr8mi_er5jOqpiQUjARSLXDUIIxDqsS50,96
3
- fabricatio-0.2.12.dev3.dist-info/licenses/LICENSE,sha256=do7J7EiCGbq0QPbMAL_FqLYufXpHnCnXBOuqVPwSV8Y,1088
1
+ fabricatio-0.2.13.dev0.dist-info/METADATA,sha256=VF_2f3NYiTYQ_AT0DvnBy42fBBaDCjV-t1XzZn5ts2E,5263
2
+ fabricatio-0.2.13.dev0.dist-info/WHEEL,sha256=jABKVkLC9kJr8mi_er5jOqpiQUjARSLXDUIIxDqsS50,96
3
+ fabricatio-0.2.13.dev0.dist-info/licenses/LICENSE,sha256=do7J7EiCGbq0QPbMAL_FqLYufXpHnCnXBOuqVPwSV8Y,1088
4
4
  fabricatio/actions/article.py,sha256=SFl1zc0hz9vW2sW4VJm9-w8E7kLEty-2LzXi9wgWMmE,10905
5
- fabricatio/actions/article_rag.py,sha256=dJJfPkfwnx8P4BebESOpPaeTfvER-1U68aPXpwMdDCQ,18723
5
+ fabricatio/actions/article_rag.py,sha256=1VlTFLrtsNfIrfHLEiR0u7eAuZjnIMNtdcj4HbTYMy0,18960
6
6
  fabricatio/actions/fs.py,sha256=gJR14U4ln35nt8Z7OWLVAZpqGaLnED-r1Yi-lX22tkI,959
7
7
  fabricatio/actions/output.py,sha256=lX0HkDse3ypCzZgeF-8Dr-EnNFdBiE-WQ1iLPFlGM1g,8302
8
8
  fabricatio/actions/rag.py,sha256=KN-OWgcQjGmNgSZ-s5B8m4LpYKSGFJR8eq72mo2CP9k,3592
9
9
  fabricatio/actions/rules.py,sha256=dkvCgNDjt2KSO1VgPRsxT4YBmIIMeetZb5tiz-slYkU,3640
10
10
  fabricatio/actions/__init__.py,sha256=wVENCFtpVb1rLFxoOFJt9-8smLWXuJV7IwA8P3EfFz4,48
11
11
  fabricatio/capabilities/advanced_judge.py,sha256=selB0Gwf1F4gGJlwBiRo6gI4KOUROgh3WnzO3mZFEls,706
12
- fabricatio/capabilities/advanced_rag.py,sha256=gt4ccqyMSVwQLwsEyJrjPc-RXMZZBwObIjsh8A8ILbM,2386
12
+ fabricatio/capabilities/advanced_rag.py,sha256=1LAAaCgVnZllNzLH3yW9MNwguUNPB7NMOJbD83VLdAo,2376
13
13
  fabricatio/capabilities/censor.py,sha256=bBT5qy-kp7fh8g4Lz3labSwxwJ60gGd_vrkc6k1cZ1U,4719
14
14
  fabricatio/capabilities/check.py,sha256=kYqzohhv2bZfl1aKSUt7a8snT8YEl2zgha_ZdAdMMfQ,8622
15
15
  fabricatio/capabilities/correct.py,sha256=W_cInqlciNEhyMK0YI53jk4EvW9uAdge90IO9OElUmA,10420
@@ -35,7 +35,7 @@ fabricatio/models/extra/advanced_judge.py,sha256=INUl_41C8jkausDekkjnEmTwNfLCJ23
35
35
  fabricatio/models/extra/aricle_rag.py,sha256=p91JI8FmFSrHVg5KbhJq4w8vQdx4VUW75SrtQUi9ju4,10987
36
36
  fabricatio/models/extra/article_base.py,sha256=R8EOlQBs7hadjP9cxG_uc24DJDpiVpJW9Wb9DA6XmXE,14516
37
37
  fabricatio/models/extra/article_essence.py,sha256=mlIkkRMR3I1RtqiiOnmIE3Vy623L4eECumkRzryE1pw,2749
38
- fabricatio/models/extra/article_main.py,sha256=zbWhXAvDPBfg3EHZRf7kVEChPZagqWbzeYFJdJtaDOY,11211
38
+ fabricatio/models/extra/article_main.py,sha256=pwY2bTYlnz8nh8y3nb_8nnYcYCmoed7ejK-ZSD8ocYc,11584
39
39
  fabricatio/models/extra/article_outline.py,sha256=C9WNZNSz6gyuw9lDp29qidPvHBTENaeqcHfCoE_Y7F4,2793
40
40
  fabricatio/models/extra/article_proposal.py,sha256=NbyjW-7UiFPtnVD9nte75re4xL2pD4qL29PpNV4Cg_M,1870
41
41
  fabricatio/models/extra/patches.py,sha256=_WNCxtYzzsVfUxI16vu4IqsLahLYRHdbQN9er9tqhC0,997
@@ -51,7 +51,7 @@ fabricatio/models/tool.py,sha256=jQ51g4lwTPfsMF1nbreDJtBczbxIHoXcPuLSOqHliq8,125
51
51
  fabricatio/models/usages.py,sha256=0bzITf0vug9ZaN6qnjNfFB7T8BAvpXE0bvx0otFYLLA,33356
52
52
  fabricatio/parser.py,sha256=-RbW2yzfJiu2ARq-lZw4tfgsjY2rIZWtJpoUmaE6gJQ,6637
53
53
  fabricatio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
- fabricatio/rust.pyi,sha256=kU-I0PD-tG0RGTy5xUobneXY-E06Qopjp4v1awpYmGw,11339
54
+ fabricatio/rust.pyi,sha256=HbdeWbVK7QL2Z3VHh2aMJ1sGUGZyYoOLzDtn5nQIv18,11591
55
55
  fabricatio/rust_instances.py,sha256=Byeo8KHW_dJiXujJq7YPGDLBX5bHNDYbBc4sY3uubVY,313
56
56
  fabricatio/toolboxes/arithmetic.py,sha256=WLqhY-Pikv11Y_0SGajwZx3WhsLNpHKf9drzAqOf_nY,1369
57
57
  fabricatio/toolboxes/fs.py,sha256=l4L1CVxJmjw9Ld2XUpIlWfV0_Fu_2Og6d3E13I-S4aE,736
@@ -61,6 +61,7 @@ fabricatio/workflows/articles.py,sha256=ObYTFUqLUk_CzdmmnX6S7APfxcGmPFqnFr9pdjU7
61
61
  fabricatio/workflows/rag.py,sha256=-YYp2tlE9Vtfgpg6ROpu6QVO8j8yVSPa6yDzlN3qVxs,520
62
62
  fabricatio/workflows/__init__.py,sha256=5ScFSTA-bvhCesj3U9Mnmi6Law6N1fmh5UKyh58L3u8,51
63
63
  fabricatio/__init__.py,sha256=Rmvq2VgdS2u68vnOi2i5RbeWbAwrJDbk8D8D883PJWE,1022
64
- fabricatio/rust.cp312-win_amd64.pyd,sha256=YARjZHId5jH51qUqMMIKn7RotIiwm8oT6UqBv8PotKI,4435456
65
- fabricatio-0.2.12.dev3.data/scripts/tdown.exe,sha256=rpmuLrxy-ZZiqVzrMYH_oFpanqkpE6dlI1aY9rCxCiA,3350016
66
- fabricatio-0.2.12.dev3.dist-info/RECORD,,
64
+ fabricatio/rust.cp312-win_amd64.pyd,sha256=DiAJU6I8WeitBZaYiA5q_YL7VlxDGuQ4LcUgyGMuZ9s,4455936
65
+ fabricatio-0.2.13.dev0.data/scripts/tdown.exe,sha256=8UDdHeKT5n45yYe5UsDmBVm-aPveFi-LNUjpx97DNGs,3350528
66
+ fabricatio-0.2.13.dev0.data/scripts/ttm.exe,sha256=epNQ6JY5Rg2M1sR-Vei7OMthswpV1l2oyWr5TyY2aFw,2555392
67
+ fabricatio-0.2.13.dev0.dist-info/RECORD,,