fabricatio 0.2.6.dev3__cp39-cp39-win_amd64.whl → 0.2.6.dev4__cp39-cp39-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.
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"]
Binary file
fabricatio/_rust.pyi CHANGED
@@ -1,7 +1,6 @@
1
1
  from pathlib import Path
2
2
  from typing import Any, Dict, List, Optional
3
3
 
4
-
5
4
  class TemplateManager:
6
5
  """Template rendering engine using Handlebars templates.
7
6
 
@@ -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
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fabricatio
3
- Version: 0.2.6.dev3
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,7 +1,7 @@
1
- fabricatio-0.2.6.dev3.dist-info/METADATA,sha256=KJbkh6wKtq_I4DU82JI7ZNWDKL6lCV3bz1yFcEr1gX4,14085
2
- fabricatio-0.2.6.dev3.dist-info/WHEEL,sha256=SmPT9fUKPAPiE6hwAZ9_NHUVRjWSQ_RENTrzrvPx4p0,94
3
- fabricatio-0.2.6.dev3.dist-info/licenses/LICENSE,sha256=do7J7EiCGbq0QPbMAL_FqLYufXpHnCnXBOuqVPwSV8Y,1088
4
- fabricatio/actions/article.py,sha256=yzRwgc203vI3MW_oWyFybDxTz6kaBBvUgN2zOJJ9Amc,2825
1
+ fabricatio-0.2.6.dev4.dist-info/METADATA,sha256=ubAfxfpUafH4ygWS6xMDBD80OX7Cull2_D0W8D30NAI,14085
2
+ fabricatio-0.2.6.dev4.dist-info/WHEEL,sha256=SmPT9fUKPAPiE6hwAZ9_NHUVRjWSQ_RENTrzrvPx4p0,94
3
+ fabricatio-0.2.6.dev4.dist-info/licenses/LICENSE,sha256=do7J7EiCGbq0QPbMAL_FqLYufXpHnCnXBOuqVPwSV8Y,1088
4
+ fabricatio/actions/article.py,sha256=d3i4i7h88yG8gvEW2SLDKM-FSsUv7qqiLgWpe6AJfSk,4463
5
5
  fabricatio/actions/output.py,sha256=KSSLvEvXsA10ACN2mbqGo98QwKLVUAoMUJNKYk6HhGc,645
6
6
  fabricatio/actions/rag.py,sha256=GpT7YlqOYznZyaT-6Y84_33HtZGT-5s71ZK8iroQA9g,813
7
7
  fabricatio/capabilities/correct.py,sha256=0BYhjo9WrLwKsXQR8bTPvdQITbrMs7RX1xpzhuQt_yY,5222
@@ -19,24 +19,24 @@ fabricatio/fs/__init__.py,sha256=PCf0s_9KDjVfNw7AfPoJzGt3jMq4gJOfbcT4pb0D0ZY,588
19
19
  fabricatio/journal.py,sha256=stnEP88aUBA_GmU9gfTF2EZI8FS2OyMLGaMSTgK4QgA,476
20
20
  fabricatio/models/action.py,sha256=25kaph3csV0VQtxVPQCyRAusgwp6E1R1g4KBs7H9T2c,6448
21
21
  fabricatio/models/events.py,sha256=QvlnS8FEELg6KNabcJMeh2GV_y0ZBzKOPphcteKYWYU,4183
22
- fabricatio/models/extra.py,sha256=O8ncZVsaNmlR5f8c_b2HJc-yVZQ2YhB6ddDbfT0Ysh4,7412
22
+ fabricatio/models/extra.py,sha256=FkNpctRWFE_BTfOmByWeOAXn8pbCauB7d68Ow_qUkqI,7322
23
23
  fabricatio/models/generic.py,sha256=IdPJMf3qxZFq8yqd6OuAYKfCM0wBlJkozgxvxQZVEEc,14025
24
- fabricatio/models/kwargs_types.py,sha256=Q-dTKfh-_FddyVCI13FzLBlgVjYrRtzXpZoQdy-G9I4,4573
24
+ fabricatio/models/kwargs_types.py,sha256=Dfmd18SABDeV9JsI1JfPNpoB8FtB6qVYgJshZBsN1P0,4593
25
25
  fabricatio/models/role.py,sha256=7S3HSjFLaSTZ5bzgTJLeZ3PpAQDEGBxPhou5Mp8ONpQ,1842
26
26
  fabricatio/models/task.py,sha256=8NaR7ojQWyM740EDTqt9stwHKdrD6axCRpLKo0QzS-I,10492
27
27
  fabricatio/models/tool.py,sha256=4b-v4WIC_LuLOKzzXL9bvKXr8vmGZ8O2uAFv5-1KRA0,7052
28
28
  fabricatio/models/usages.py,sha256=hR4OU4sjQ2jKaH5_kkN83vG58n3kcKnt9osND0BYi0Q,28634
29
29
  fabricatio/models/utils.py,sha256=1bCqeB6za7ecCAM3cU1raNWuN56732m45rXtlIlc3I4,5017
30
- fabricatio/parser.py,sha256=SzyVzbKj5L_0IcI5Z5ILpopJxE-1hGhmomskTWdcc68,6194
30
+ fabricatio/parser.py,sha256=b1Em7zoEepQIrxgM51Damnbsx_AhPab-BefIWHGo1Ss,6249
31
31
  fabricatio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
32
  fabricatio/toolboxes/arithmetic.py,sha256=WLqhY-Pikv11Y_0SGajwZx3WhsLNpHKf9drzAqOf_nY,1369
33
33
  fabricatio/toolboxes/fs.py,sha256=l4L1CVxJmjw9Ld2XUpIlWfV0_Fu_2Og6d3E13I-S4aE,736
34
34
  fabricatio/toolboxes/__init__.py,sha256=KBJi5OG_pExscdlM7Bnt_UF43j4I3Lv6G71kPVu4KQU,395
35
- fabricatio/workflows/articles.py,sha256=RebdC_BzSXC-xsck5I9ccC_XIgfhtoeM8FZuhtVDn3U,580
35
+ fabricatio/workflows/articles.py,sha256=G5HGRr-DHuYuEcfhFdFAuDvTTJ9aSU_UQ2yYXEjTMtM,1047
36
36
  fabricatio/workflows/rag.py,sha256=-YYp2tlE9Vtfgpg6ROpu6QVO8j8yVSPa6yDzlN3qVxs,520
37
- fabricatio/_rust.pyi,sha256=xWLrjRw4mOxehy61IkaSXCAPoAT6XSZPg99RgRk12vw,3493
37
+ fabricatio/_rust.pyi,sha256=eawBfpyGrB-JtOh4I6RSbjFSq83SSl-0syBeZ-g8270,3491
38
38
  fabricatio/_rust_instances.py,sha256=2GwF8aVfYNemRI2feBzH1CZfBGno-XJJE5imJokGEYw,314
39
- fabricatio/__init__.py,sha256=wTPzKLGztMr7orV-KizHRXJFhPGncvAHE7BPeSmBVDU,1926
40
- fabricatio/_rust.cp39-win_amd64.pyd,sha256=i5KBa8RtgD5i6c2eHDoevqClBvzDbYmg22FFSJ2w4UA,1824768
41
- fabricatio-0.2.6.dev3.data/scripts/tdown.exe,sha256=gEr6Y6FaEEAjGcO1mehImF99ygg07XumvGFOqa52Cvs,3398144
42
- fabricatio-0.2.6.dev3.dist-info/RECORD,,
39
+ fabricatio/__init__.py,sha256=SzBYsRhZeL77jLtfJEjmoHOSwHwUGyvMATX6xfndLDM,1135
40
+ fabricatio/_rust.cp39-win_amd64.pyd,sha256=bkzJH6SS5nSFzAOx95RP-flNoBUsau_bk8S_AsKYZuU,1824768
41
+ fabricatio-0.2.6.dev4.data/scripts/tdown.exe,sha256=pXfruD6ZBL0_05mWalUoeyLLqzpHRSiHKYcp6WwwDgU,3398144
42
+ fabricatio-0.2.6.dev4.dist-info/RECORD,,