fabricatio 0.2.6.dev2__cp312-cp312-manylinux_2_34_x86_64.whl → 0.2.6.dev4__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/__init__.py CHANGED
@@ -2,59 +2,42 @@
2
2
 
3
3
  from importlib.util import find_spec
4
4
 
5
+ from fabricatio import actions, toolboxes, workflows
5
6
  from fabricatio._rust import BibManager
6
7
  from fabricatio._rust_instances import TEMPLATE_MANAGER
7
- from fabricatio.actions.article import ExtractArticleEssence, GenerateArticleProposal, GenerateOutline
8
- from fabricatio.actions.output import DumpFinalizedOutput
9
8
  from fabricatio.core import env
10
- from fabricatio.fs import MAGIKA, safe_json_read, safe_text_read
11
9
  from fabricatio.journal import logger
10
+ from fabricatio.models import extra
12
11
  from fabricatio.models.action import Action, WorkFlow
13
12
  from fabricatio.models.events import Event
14
- from fabricatio.models.extra import ArticleEssence
15
13
  from fabricatio.models.role import Role
16
14
  from fabricatio.models.task import Task
17
15
  from fabricatio.models.tool import ToolBox
18
- from fabricatio.models.utils import Message, Messages
19
16
  from fabricatio.parser import Capture, GenericCapture, JsonCapture, PythonCapture
20
- from fabricatio.toolboxes import arithmetic_toolbox, basic_toolboxes, fs_toolbox
21
- from fabricatio.workflows.articles import WriteOutlineWorkFlow
22
17
 
23
18
  __all__ = [
24
- "MAGIKA",
25
19
  "TEMPLATE_MANAGER",
26
20
  "Action",
27
- "ArticleEssence",
28
21
  "BibManager",
29
22
  "Capture",
30
- "DumpFinalizedOutput",
31
23
  "Event",
32
- "ExtractArticleEssence",
33
- "GenerateArticleProposal",
34
- "GenerateOutline",
35
24
  "GenericCapture",
36
25
  "JsonCapture",
37
- "Message",
38
- "Messages",
39
26
  "PythonCapture",
40
27
  "Role",
41
28
  "Task",
42
29
  "ToolBox",
43
30
  "WorkFlow",
44
- "WriteOutlineWorkFlow",
45
- "arithmetic_toolbox",
46
- "basic_toolboxes",
31
+ "actions",
47
32
  "env",
48
- "fs_toolbox",
33
+ "extra",
49
34
  "logger",
50
- "safe_json_read",
51
- "safe_text_read",
35
+ "toolboxes",
36
+ "workflows",
52
37
  ]
53
38
 
54
39
 
55
40
  if find_spec("pymilvus"):
56
- from fabricatio.actions.rag import InjectToDB
57
41
  from fabricatio.capabilities.rag import RAG
58
- from fabricatio.workflows.rag import StoreArticle
59
42
 
60
- __all__ += ["RAG", "InjectToDB", "StoreArticle"]
43
+ __all__ += ["RAG"]
fabricatio/_rust.pyi CHANGED
@@ -9,8 +9,9 @@ class TemplateManager:
9
9
 
10
10
  See: https://crates.io/crates/handlebars
11
11
  """
12
+
12
13
  def __init__(
13
- self, template_dirs: List[Path], suffix: Optional[str] = None, active_loading: Optional[bool] = None
14
+ self, template_dirs: List[Path], suffix: Optional[str] = None, active_loading: Optional[bool] = None
14
15
  ) -> None:
15
16
  """Initialize the template manager.
16
17
 
@@ -54,6 +55,7 @@ class TemplateManager:
54
55
  RuntimeError: If template rendering fails
55
56
  """
56
57
 
58
+
57
59
  def blake3_hash(content: bytes) -> str:
58
60
  """Calculate the BLAKE3 cryptographic hash of data.
59
61
 
@@ -64,6 +66,7 @@ def blake3_hash(content: bytes) -> str:
64
66
  Hex-encoded BLAKE3 hash string
65
67
  """
66
68
 
69
+
67
70
  class BibManager:
68
71
  """BibTeX bibliography manager for parsing and querying citation data."""
69
72
 
@@ -100,3 +103,13 @@ class BibManager:
100
103
  Uses nucleo_matcher for high-quality fuzzy text searching
101
104
  See: https://crates.io/crates/nucleo-matcher
102
105
  """
106
+
107
+ def list_titles(self, is_verbatim: Optional[bool] = False) -> List[str]:
108
+ """List all titles in the bibliography.
109
+
110
+ Args:
111
+ is_verbatim: Whether to return verbatim titles (without formatting)
112
+
113
+ Returns:
114
+ List of all titles in the bibliography
115
+ """
@@ -2,13 +2,15 @@
2
2
 
3
3
  from os import PathLike
4
4
  from pathlib import Path
5
- from typing import Callable, List, Optional
5
+ from typing import Any, Callable, List, Optional
6
6
 
7
7
  from fabricatio.fs import safe_text_read
8
8
  from fabricatio.journal import logger
9
9
  from fabricatio.models.action import Action
10
10
  from fabricatio.models.extra import ArticleEssence, ArticleOutline, ArticleProposal
11
11
  from fabricatio.models.task import Task
12
+ from questionary import confirm, text
13
+ from rich import print as rprint
12
14
 
13
15
 
14
16
  class ExtractArticleEssence(Action):
@@ -66,7 +68,7 @@ class GenerateArticleProposal(Action):
66
68
  class GenerateOutline(Action):
67
69
  """Generate the article based on the outline."""
68
70
 
69
- output_key: str = "article"
71
+ output_key: str = "article_outline"
70
72
  """The key of the output data."""
71
73
 
72
74
  async def _execute(
@@ -79,3 +81,45 @@ class GenerateOutline(Action):
79
81
  article_proposal.display(),
80
82
  system_message=f"# your personal briefing: \n{self.briefing}",
81
83
  )
84
+
85
+
86
+ class CorrectProposal(Action):
87
+ """Correct the proposal of the article."""
88
+
89
+ output_key: str = "corrected_proposal"
90
+
91
+ async def _execute(self, task_input: Task, article_proposal: ArticleProposal, **_) -> Any:
92
+ input_path = await self.awhich_pathstr(
93
+ f"{task_input.briefing}\nExtract the path of file, which contains the article briefing that I need to read."
94
+ )
95
+
96
+ rprint(article_proposal.display())
97
+ ret = None
98
+ while await confirm("Do you want to correct the Proposal?").ask_async():
99
+ topic = await text("What is the topic of the proposal?").ask_async()
100
+ ret = await self.correct_obj(
101
+ article_proposal,
102
+ safe_text_read(input_path),
103
+ topic=topic,
104
+ )
105
+ return ret or article_proposal
106
+
107
+
108
+ class CorrectOutline(Action):
109
+ """Correct the outline of the article."""
110
+
111
+ output_key: str = "corrected_outline"
112
+ """The key of the output data."""
113
+
114
+ async def _execute(
115
+ self,
116
+ article_outline: ArticleOutline,
117
+ article_proposal: ArticleProposal,
118
+ **_,
119
+ ) -> Optional[str]:
120
+ rprint(article_outline.finalized_dump())
121
+ ret = None
122
+ while await confirm("Do you want to correct the outline?").ask_async():
123
+ topic = await text("What is the topic of the outline?").ask_async()
124
+ ret = await self.correct_obj(article_outline, article_proposal.display(), topic=topic)
125
+ return ret or article_outline
@@ -126,7 +126,7 @@ class ArticleSectionOutline(Base):
126
126
  """The title of the section."""
127
127
  description: str = Field(...)
128
128
  """A brief description of the section's content should be, how it fits into the overall structure of the paper, and its significance in the context of the research."""
129
- subsections: List[ArticleSubsectionOutline] = Field(default_factory=list)
129
+ subsections: List[ArticleSubsectionOutline]
130
130
  """The subsections of the section, outlining their content and significance."""
131
131
 
132
132
 
@@ -137,7 +137,7 @@ class ArticleChapterOutline(Base):
137
137
  """The title of the chapter."""
138
138
  description: str = Field(...)
139
139
  """A brief description of the chapter's content should be, how it fits into the overall structure of the paper, and its significance in the context of the research."""
140
- sections: List[ArticleSectionOutline] = Field(default_factory=list)
140
+ sections: List[ArticleSectionOutline]
141
141
  """The sections of the chapter, outlining their content and significance."""
142
142
 
143
143
 
@@ -150,7 +150,7 @@ class ArticleOutline(ProposedAble, Display, FinalizedDumpAble):
150
150
  prospect: str = Field(...)
151
151
  """A brief description of the research problem or question that the paper aims to address manipulating methods or techniques"""
152
152
 
153
- chapters: List[ArticleChapterOutline] = Field(default_factory=list)
153
+ chapters: List[ArticleChapterOutline]
154
154
  """The chapters of the paper, outlining their content and significance."""
155
155
 
156
156
  def finalized_dump(self) -> str:
@@ -1,6 +1,6 @@
1
1
  """This module contains the types for the keyword arguments of the methods in the models module."""
2
2
 
3
- from typing import Any, TypedDict
3
+ from typing import Any, Required, TypedDict
4
4
 
5
5
  from litellm.caching.caching import CacheMode
6
6
  from litellm.types.caching import CachingSupportedCallTypes
@@ -91,7 +91,7 @@ class ReviewKwargs[T](ValidateKwargs[T], total=False):
91
91
  specific topics and review criteria.
92
92
  """
93
93
 
94
- topic: str
94
+ topic: Required[str]
95
95
  criteria: set[str]
96
96
 
97
97
 
fabricatio/parser.py CHANGED
@@ -64,6 +64,7 @@ class Capture(BaseModel):
64
64
  """
65
65
  match = self._compiled.search(text)
66
66
  if match is None:
67
+ logger.debug(f"Capture Failed: \n{text}")
67
68
  return None
68
69
  groups = self.fix(match.groups()) if configs.general.use_json_repair else match.groups()
69
70
  if self.target_groups:
@@ -1,6 +1,6 @@
1
1
  """Store article essence in the database."""
2
2
 
3
- from fabricatio.actions.article import GenerateArticleProposal, GenerateOutline
3
+ from fabricatio.actions.article import CorrectOutline, CorrectProposal, GenerateArticleProposal, GenerateOutline
4
4
  from fabricatio.actions.output import DumpFinalizedOutput
5
5
  from fabricatio.models.action import WorkFlow
6
6
 
@@ -13,3 +13,14 @@ WriteOutlineWorkFlow = WorkFlow(
13
13
  DumpFinalizedOutput(output_key="task_output"),
14
14
  ),
15
15
  )
16
+ WriteOutlineCorrectedWorkFlow = WorkFlow(
17
+ name="Generate Article Outline",
18
+ description="Generate an outline for an article. dump the outline to the given path. in typst format.",
19
+ steps=(
20
+ GenerateArticleProposal,
21
+ CorrectProposal(output_key="article_proposal"),
22
+ GenerateOutline,
23
+ CorrectOutline(output_key="to_dump"),
24
+ DumpFinalizedOutput(output_key="task_output"),
25
+ ),
26
+ )
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fabricatio
3
- Version: 0.2.6.dev2
3
+ Version: 0.2.6.dev4
4
4
  Classifier: License :: OSI Approved :: MIT License
5
5
  Classifier: Programming Language :: Rust
6
6
  Classifier: Programming Language :: Python :: 3.12
@@ -1,13 +1,13 @@
1
- fabricatio-0.2.6.dev2.dist-info/METADATA,sha256=Y6L-yF34GPs0csU6zdhZxzJ8OOsNxa26hT3iBaD7Jn8,13693
2
- fabricatio-0.2.6.dev2.dist-info/WHEEL,sha256=RIvmwLDYujv60MYBx2jxyP4vdn1DD7X0kBgz1TQvZuc,108
3
- fabricatio-0.2.6.dev2.dist-info/licenses/LICENSE,sha256=yDZaTLnOi03bi3Dk6f5IjhLUc5old2yOsihHWU0z-i0,1067
1
+ fabricatio-0.2.6.dev4.dist-info/METADATA,sha256=x15F4qzX0H3HfdNwW2hgbB5SVkkKWumhDAgpM1evTzE,13693
2
+ fabricatio-0.2.6.dev4.dist-info/WHEEL,sha256=RIvmwLDYujv60MYBx2jxyP4vdn1DD7X0kBgz1TQvZuc,108
3
+ fabricatio-0.2.6.dev4.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
7
  fabricatio/models/tool.py,sha256=ATwbOyvOTzrfAKcbOmCqdG3je4-T5jrM6FIw4cDPRDY,6863
8
8
  fabricatio/models/role.py,sha256=pQUHj5jx5OqbbDufhvoqqF72R0dJ6aIrREieASe96Ls,1794
9
- fabricatio/models/extra.py,sha256=ndK8EKzANT7sz_1f00PtJgs8922M9V3_G4JlORXySKk,7241
10
- fabricatio/models/kwargs_types.py,sha256=30hREqUXw4_0fVl6-NPdnTN07hSBiCWcdVr5z6RH6jE,4415
9
+ fabricatio/models/extra.py,sha256=wOEJueEwSCfcnCvgITnl0lM8IrWwmtxmksjtBcYueKk,7151
10
+ fabricatio/models/kwargs_types.py,sha256=7MjoTtGfSUx4jws_DlvK2ud7au6Y2z50Umr3PFtmSTc,4435
11
11
  fabricatio/models/utils.py,sha256=KmsTQcBCTYgnsZz7U1ECSfLRdswWPkKtGg8mBMaXrwA,4850
12
12
  fabricatio/models/usages.py,sha256=DiCiS1_YsHyB1-cQJdevyVxAn5_B9x0717mis8DNG9s,27952
13
13
  fabricatio/models/events.py,sha256=UvOc6V3vfjKuvh7irDezJ8EGpsNo5yzLdq4xQexVonw,4063
@@ -22,21 +22,21 @@ fabricatio/fs/curd.py,sha256=FuG75qco4dX8vhIK27gKz9rKUXbWHOFg5yK3nGLB25s,4469
22
22
  fabricatio/fs/__init__.py,sha256=hTuYtzmvIGtbg7PTdoqLEQJ0E63hOzZltCIrLlDKaSE,559
23
23
  fabricatio/config.py,sha256=qoPSAlXfaKk3nGP3lQa6wy1YvnRSnNrmdJz6iOdFMCY,15902
24
24
  fabricatio/journal.py,sha256=Op0wC-JlZumnAc_aDmYM4ljnSNLoKEEMfcIRbCF69ow,455
25
- fabricatio/__init__.py,sha256=_CXelMxaKds7whHnELRVakOL0Lnp0OZPIORy5phapYA,1866
25
+ fabricatio/__init__.py,sha256=6EjK4SxbnvFxdO9ftkXD9rxSuoPEIITNzUkuMO9s3yU,1092
26
26
  fabricatio/actions/output.py,sha256=wNyLNxjqBlms0hyxap8XUPgN53izipJrCOtpX6aluFQ,626
27
27
  fabricatio/actions/rag.py,sha256=xCCNPM4pgjGlKaIl1J4SpWoNx3oWlSMxq6pQRSquXmc,788
28
- fabricatio/actions/article.py,sha256=sZktrKHwKnVQ7VFxMUCucik5mVfrK_ArlgzAi8QAEp4,2744
28
+ fabricatio/actions/article.py,sha256=dQ0Ca83v8yhO2n-IGtm4gIojXfsYD8s-HWRpPO5a7a4,4338
29
29
  fabricatio/_rust_instances.py,sha256=bQmlhUCcxTmRgvw1SfzYzNNpgW_UCjmkYw5f-VPAyg8,304
30
- fabricatio/workflows/articles.py,sha256=utvKDBFEJbcM76729-H2AvgMCNcsX1NquqMpHqGZq8E,565
30
+ fabricatio/workflows/articles.py,sha256=oHNV5kNKEcOKP55FA7I1SlxQRlk6N26cpem_QYu05g0,1021
31
31
  fabricatio/workflows/rag.py,sha256=uOZXprD479fUhLA6sYvEM8RWcVcUZXXtP0xRbTMPdHE,509
32
- fabricatio/parser.py,sha256=uewTtO5N_5FAX_4rVzysGJsVs75J0vR-Iz7_dvWfGQk,6045
32
+ fabricatio/parser.py,sha256=Jr2ELtcmiRNAyz76TCWoJuUpG7zrJoRn3GfaX9vZSJM,6099
33
33
  fabricatio/capabilities/correct.py,sha256=BiLEAk6e1KbwUMhTexmDfgtlPUct_bG0igDK7CwHqao,5107
34
34
  fabricatio/capabilities/rag.py,sha256=ghctqjIf6KDe6PP8-SDzKN1zxh94rXk5Y5hHFtG_46Y,15404
35
35
  fabricatio/capabilities/rating.py,sha256=ZQrKKmmIgnN4zgNnG_GmWa5Nyxpk03JYW32RJ4R5vvQ,14067
36
36
  fabricatio/capabilities/review.py,sha256=TX7av4b2N7MRDHMowsIZfiujXRRNxjUMNHtCFVA1UTM,10824
37
37
  fabricatio/capabilities/propose.py,sha256=4QvONVVUp1rs34Te2Rjams6NioEt6FhEAxDWiveQnSg,1544
38
38
  fabricatio/capabilities/task.py,sha256=uAp4tC9cbq3Ux-VQHjYdEzKLE3Jr8vhB6HKLPbhozIo,4494
39
- fabricatio/_rust.pyi,sha256=xXSaL7llihyFIyr9_k6e5RRJVNYk2jM-jrrheNvvaIA,3067
40
- fabricatio/_rust.cpython-312-x86_64-linux-gnu.so,sha256=74s_TC4HghV27dU5SlwPhHVbGQXAjB_tRTopjpIWjBI,1899904
41
- fabricatio-0.2.6.dev2.data/scripts/tdown,sha256=_ZohEMMAnhhlAKfxVua2YoN3LSsaWp1RVXCA6y1EBTg,4573488
42
- fabricatio-0.2.6.dev2.dist-info/RECORD,,
39
+ fabricatio/_rust.pyi,sha256=1TvnaXK_QKM8Et05LkZ_vOGR4WISVd9X8lU6OTwFFaU,3376
40
+ fabricatio/_rust.cpython-312-x86_64-linux-gnu.so,sha256=3fbtHUY9vCdKAyhn-ZoTII7ddg-G33HXGTCD5BvrfF0,1910296
41
+ fabricatio-0.2.6.dev4.data/scripts/tdown,sha256=xtxnxCR31GJEl1qF0Z1UDI43FK7kzGxzpRkMnVaZSP0,4575216
42
+ fabricatio-0.2.6.dev4.dist-info/RECORD,,
Binary file