fabricatio 0.2.13.dev3__cp312-cp312-win_amd64.whl → 0.3.13__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.
Files changed (41) hide show
  1. fabricatio/__init__.py +3 -3
  2. fabricatio/actions/article.py +32 -34
  3. fabricatio/actions/article_rag.py +58 -58
  4. fabricatio/actions/output.py +22 -21
  5. fabricatio/actions/rag.py +4 -3
  6. fabricatio/capabilities/check.py +29 -30
  7. fabricatio/capabilities/correct.py +23 -23
  8. fabricatio/capabilities/extract.py +36 -32
  9. fabricatio/capabilities/rag.py +34 -35
  10. fabricatio/capabilities/rating.py +77 -72
  11. fabricatio/capabilities/review.py +12 -11
  12. fabricatio/capabilities/task.py +4 -5
  13. fabricatio/core.py +22 -24
  14. fabricatio/decorators.py +10 -10
  15. fabricatio/fs/__init__.py +1 -2
  16. fabricatio/journal.py +2 -9
  17. fabricatio/models/action.py +2 -1
  18. fabricatio/models/extra/aricle_rag.py +10 -9
  19. fabricatio/models/extra/article_base.py +5 -6
  20. fabricatio/models/extra/article_main.py +11 -10
  21. fabricatio/models/generic.py +31 -59
  22. fabricatio/models/role.py +5 -3
  23. fabricatio/models/task.py +9 -9
  24. fabricatio/models/tool.py +5 -4
  25. fabricatio/models/usages.py +170 -161
  26. fabricatio/parser.py +2 -2
  27. fabricatio/rust.cp312-win_amd64.pyd +0 -0
  28. fabricatio/rust.pyi +435 -17
  29. fabricatio-0.3.13.data/scripts/tdown.exe +0 -0
  30. fabricatio-0.3.13.data/scripts/ttm.exe +0 -0
  31. {fabricatio-0.2.13.dev3.dist-info → fabricatio-0.3.13.dist-info}/METADATA +1 -3
  32. fabricatio-0.3.13.dist-info/RECORD +63 -0
  33. fabricatio/config.py +0 -430
  34. fabricatio/constants.py +0 -20
  35. fabricatio/models/events.py +0 -120
  36. fabricatio/rust_instances.py +0 -10
  37. fabricatio-0.2.13.dev3.data/scripts/tdown.exe +0 -0
  38. fabricatio-0.2.13.dev3.data/scripts/ttm.exe +0 -0
  39. fabricatio-0.2.13.dev3.dist-info/RECORD +0 -67
  40. {fabricatio-0.2.13.dev3.dist-info → fabricatio-0.3.13.dist-info}/WHEEL +0 -0
  41. {fabricatio-0.2.13.dev3.dist-info → fabricatio-0.3.13.dist-info}/licenses/LICENSE +0 -0
fabricatio/__init__.py CHANGED
@@ -1,19 +1,19 @@
1
1
  """Fabricatio is a Python library for building llm app using event-based agent structure."""
2
2
 
3
+ from fabricatio.rust import CONFIG, TEMPLATE_MANAGER, BibManager, Event
4
+
3
5
  from fabricatio import actions, capabilities, toolboxes, workflows
4
6
  from fabricatio.core import env
5
7
  from fabricatio.journal import logger
6
8
  from fabricatio.models import extra
7
9
  from fabricatio.models.action import Action, WorkFlow
8
- from fabricatio.models.events import Event
9
10
  from fabricatio.models.role import Role
10
11
  from fabricatio.models.task import Task
11
12
  from fabricatio.models.tool import ToolBox
12
13
  from fabricatio.parser import Capture, GenericCapture, JsonCapture, PythonCapture
13
- from fabricatio.rust import BibManager
14
- from fabricatio.rust_instances import TEMPLATE_MANAGER
15
14
 
16
15
  __all__ = [
16
+ "CONFIG",
17
17
  "TEMPLATE_MANAGER",
18
18
  "Action",
19
19
  "BibManager",
@@ -4,15 +4,14 @@ from asyncio import gather
4
4
  from pathlib import Path
5
5
  from typing import Callable, List, Optional
6
6
 
7
+ from fabricatio.rust import CONFIG, TEMPLATE_MANAGER, BibManager, detect_language
7
8
  from more_itertools import filter_map
8
9
  from pydantic import Field
9
10
  from rich import print as r_print
10
11
 
11
- from fabricatio import TEMPLATE_MANAGER
12
12
  from fabricatio.capabilities.censor import Censor
13
13
  from fabricatio.capabilities.extract import Extract
14
14
  from fabricatio.capabilities.propose import Propose
15
- from fabricatio.config import configs
16
15
  from fabricatio.fs import dump_text, safe_text_read
17
16
  from fabricatio.journal import logger
18
17
  from fabricatio.models.action import Action
@@ -24,7 +23,6 @@ from fabricatio.models.extra.rule import RuleSet
24
23
  from fabricatio.models.kwargs_types import ValidateKwargs
25
24
  from fabricatio.models.task import Task
26
25
  from fabricatio.models.usages import LLMUsage
27
- from fabricatio.rust import BibManager, detect_language
28
26
  from fabricatio.utils import ok, wrapp_in_block
29
27
 
30
28
 
@@ -40,10 +38,10 @@ class ExtractArticleEssence(Action, Propose):
40
38
  """The key of the output data."""
41
39
 
42
40
  async def _execute(
43
- self,
44
- task_input: Task,
45
- reader: Callable[[str], Optional[str]] = lambda p: Path(p).read_text(encoding="utf-8"),
46
- **_,
41
+ self,
42
+ task_input: Task,
43
+ reader: Callable[[str], Optional[str]] = lambda p: Path(p).read_text(encoding="utf-8"),
44
+ **_,
47
45
  ) -> List[ArticleEssence]:
48
46
  if not task_input.dependencies:
49
47
  logger.info(err := "Task not approved, since no dependencies are provided.")
@@ -56,11 +54,11 @@ class ExtractArticleEssence(Action, Propose):
56
54
  out = []
57
55
 
58
56
  for ess in await self.propose(
59
- ArticleEssence,
60
- [
61
- f"{c}\n\n\nBased the provided academic article above, you need to extract the essence from it.\n\nWrite the value string using `{detect_language(c)}`"
62
- for c in contents
63
- ],
57
+ ArticleEssence,
58
+ [
59
+ f"{c}\n\n\nBased the provided academic article above, you need to extract the essence from it.\n\nWrite the value string using `{detect_language(c)}`"
60
+ for c in contents
61
+ ],
64
62
  ):
65
63
  if ess is None:
66
64
  logger.warning("Could not extract article essence")
@@ -77,10 +75,10 @@ class FixArticleEssence(Action):
77
75
  """The key of the output data."""
78
76
 
79
77
  async def _execute(
80
- self,
81
- bib_mgr: BibManager,
82
- article_essence: List[ArticleEssence],
83
- **_,
78
+ self,
79
+ bib_mgr: BibManager,
80
+ article_essence: List[ArticleEssence],
81
+ **_,
84
82
  ) -> List[ArticleEssence]:
85
83
  out = []
86
84
  count = 0
@@ -107,11 +105,11 @@ class GenerateArticleProposal(Action, Propose):
107
105
  """The key of the output data."""
108
106
 
109
107
  async def _execute(
110
- self,
111
- task_input: Optional[Task] = None,
112
- article_briefing: Optional[str] = None,
113
- article_briefing_path: Optional[str] = None,
114
- **_,
108
+ self,
109
+ task_input: Optional[Task] = None,
110
+ article_briefing: Optional[str] = None,
111
+ article_briefing_path: Optional[str] = None,
112
+ **_,
115
113
  ) -> Optional[ArticleProposal]:
116
114
  if article_briefing is None and article_briefing_path is None and task_input is None:
117
115
  logger.error("Task not approved, since all inputs are None.")
@@ -150,10 +148,10 @@ class GenerateInitialOutline(Action, Extract):
150
148
  """The kwargs to extract the outline."""
151
149
 
152
150
  async def _execute(
153
- self,
154
- article_proposal: ArticleProposal,
155
- supervisor: Optional[bool] = None,
156
- **_,
151
+ self,
152
+ article_proposal: ArticleProposal,
153
+ supervisor: Optional[bool] = None,
154
+ **_,
157
155
  ) -> Optional[ArticleOutline]:
158
156
  req = (
159
157
  f"Design each chapter of a proper and academic and ready for release manner.\n"
@@ -208,10 +206,10 @@ class FixIntrospectedErrors(Action, Censor):
208
206
  """The maximum number of errors to fix."""
209
207
 
210
208
  async def _execute(
211
- self,
212
- article_outline: ArticleOutline,
213
- intro_fix_ruleset: Optional[RuleSet] = None,
214
- **_,
209
+ self,
210
+ article_outline: ArticleOutline,
211
+ intro_fix_ruleset: Optional[RuleSet] = None,
212
+ **_,
215
213
  ) -> Optional[ArticleOutline]:
216
214
  counter = 0
217
215
  origin = article_outline
@@ -243,10 +241,10 @@ class GenerateArticle(Action, Censor):
243
241
  ruleset: Optional[RuleSet] = None
244
242
 
245
243
  async def _execute(
246
- self,
247
- article_outline: ArticleOutline,
248
- article_gen_ruleset: Optional[RuleSet] = None,
249
- **_,
244
+ self,
245
+ article_outline: ArticleOutline,
246
+ article_gen_ruleset: Optional[RuleSet] = None,
247
+ **_,
250
248
  ) -> Optional[Article]:
251
249
  article: Article = Article.from_outline(ok(article_outline, "Article outline not specified.")).update_ref(
252
250
  article_outline
@@ -296,7 +294,7 @@ class WriteChapterSummary(Action, LLMUsage):
296
294
  for raw in (
297
295
  await self.aask(
298
296
  TEMPLATE_MANAGER.render_template(
299
- configs.templates.chap_summary_template,
297
+ CONFIG.templates.chap_summary_template,
300
298
  [
301
299
  {
302
300
  "chapter": a.to_typst_code(),
@@ -4,9 +4,16 @@ from asyncio import gather
4
4
  from pathlib import Path
5
5
  from typing import ClassVar, List, Optional
6
6
 
7
+ from fabricatio.rust import (
8
+ BibManager,
9
+ convert_all_block_tex,
10
+ convert_all_inline_tex,
11
+ convert_to_block_formula,
12
+ convert_to_inline_formula,
13
+ fix_misplaced_labels,
14
+ )
7
15
  from pydantic import Field, PositiveInt
8
16
 
9
- from fabricatio import BibManager
10
17
  from fabricatio.capabilities.advanced_rag import AdvancedRAG
11
18
  from fabricatio.capabilities.censor import Censor
12
19
  from fabricatio.capabilities.extract import Extract
@@ -20,13 +27,6 @@ from fabricatio.models.extra.article_main import Article, ArticleChapter, Articl
20
27
  from fabricatio.models.extra.article_outline import ArticleOutline
21
28
  from fabricatio.models.extra.rule import RuleSet
22
29
  from fabricatio.models.kwargs_types import ChooseKwargs, LLMKwargs
23
- from fabricatio.rust import (
24
- convert_all_block_tex,
25
- convert_all_inline_tex,
26
- convert_to_block_formula,
27
- convert_to_inline_formula,
28
- fix_misplaced_labels,
29
- )
30
30
  from fabricatio.utils import ok
31
31
 
32
32
  TYPST_CITE_USAGE = (
@@ -78,11 +78,11 @@ class WriteArticleContentRAG(Action, Extract, AdvancedRAG):
78
78
  tei_endpoint: Optional[str] = None
79
79
 
80
80
  async def _execute(
81
- self,
82
- article_outline: ArticleOutline,
83
- collection_name: Optional[str] = None,
84
- supervisor: Optional[bool] = None,
85
- **cxt,
81
+ self,
82
+ article_outline: ArticleOutline,
83
+ collection_name: Optional[str] = None,
84
+ supervisor: Optional[bool] = None,
85
+ **cxt,
86
86
  ) -> Article:
87
87
  article = Article.from_outline(article_outline).update_ref(article_outline)
88
88
  self.target_collection = collection_name or self.safe_target_collection
@@ -103,12 +103,12 @@ class WriteArticleContentRAG(Action, Extract, AdvancedRAG):
103
103
  "questionary", "`questionary` is required for supervisor mode, please install it by `fabricatio[qa]`"
104
104
  )
105
105
  async def _supervisor_inner(
106
- self,
107
- article: Article,
108
- article_outline: ArticleOutline,
109
- chap: ArticleChapter,
110
- sec: ArticleSection,
111
- subsec: ArticleSubsection,
106
+ self,
107
+ article: Article,
108
+ article_outline: ArticleOutline,
109
+ chap: ArticleChapter,
110
+ sec: ArticleSection,
111
+ subsec: ArticleSubsection,
112
112
  ) -> ArticleSubsection:
113
113
  from questionary import confirm, text
114
114
  from rich import print as r_print
@@ -137,12 +137,12 @@ class WriteArticleContentRAG(Action, Extract, AdvancedRAG):
137
137
  return await self.extract_new_subsec(subsec, raw_paras, cm)
138
138
 
139
139
  async def _inner(
140
- self,
141
- article: Article,
142
- article_outline: ArticleOutline,
143
- chap: ArticleChapter,
144
- sec: ArticleSection,
145
- subsec: ArticleSubsection,
140
+ self,
141
+ article: Article,
142
+ article_outline: ArticleOutline,
143
+ chap: ArticleChapter,
144
+ sec: ArticleSection,
145
+ subsec: ArticleSubsection,
146
146
  ) -> ArticleSubsection:
147
147
  cm = CitationManager()
148
148
 
@@ -159,7 +159,7 @@ class WriteArticleContentRAG(Action, Extract, AdvancedRAG):
159
159
  return await self.extract_new_subsec(subsec, raw_paras, cm)
160
160
 
161
161
  async def extract_new_subsec(
162
- self, subsec: ArticleSubsection, raw_paras: str, cm: CitationManager
162
+ self, subsec: ArticleSubsection, raw_paras: str, cm: CitationManager
163
163
  ) -> ArticleSubsection:
164
164
  """Extract the new subsec."""
165
165
  new_subsec = ok(
@@ -182,14 +182,14 @@ class WriteArticleContentRAG(Action, Extract, AdvancedRAG):
182
182
  return subsec
183
183
 
184
184
  async def write_raw(
185
- self,
186
- article: Article,
187
- article_outline: ArticleOutline,
188
- chap: ArticleChapter,
189
- sec: ArticleSection,
190
- subsec: ArticleSubsection,
191
- cm: CitationManager,
192
- extra_instruction: str = "",
185
+ self,
186
+ article: Article,
187
+ article_outline: ArticleOutline,
188
+ chap: ArticleChapter,
189
+ sec: ArticleSection,
190
+ subsec: ArticleSubsection,
191
+ cm: CitationManager,
192
+ extra_instruction: str = "",
193
193
  ) -> str:
194
194
  """Write the raw paragraphs of the subsec."""
195
195
  return await self.aask(
@@ -205,14 +205,14 @@ class WriteArticleContentRAG(Action, Extract, AdvancedRAG):
205
205
  )
206
206
 
207
207
  async def search_database(
208
- self,
209
- article: Article,
210
- article_outline: ArticleOutline,
211
- chap: ArticleChapter,
212
- sec: ArticleSection,
213
- subsec: ArticleSubsection,
214
- cm: CitationManager,
215
- extra_instruction: str = "",
208
+ self,
209
+ article: Article,
210
+ article_outline: ArticleOutline,
211
+ chap: ArticleChapter,
212
+ sec: ArticleSection,
213
+ subsec: ArticleSubsection,
214
+ cm: CitationManager,
215
+ extra_instruction: str = "",
216
216
  ) -> None:
217
217
  """Search database for related references."""
218
218
  search_req = (
@@ -321,12 +321,12 @@ class TweakArticleRAG(Action, RAG, Censor):
321
321
  """The limit of references to be retrieved"""
322
322
 
323
323
  async def _execute(
324
- self,
325
- article: Article,
326
- collection_name: str = "article_essence",
327
- twk_rag_ruleset: Optional[RuleSet] = None,
328
- parallel: bool = False,
329
- **cxt,
324
+ self,
325
+ article: Article,
326
+ collection_name: str = "article_essence",
327
+ twk_rag_ruleset: Optional[RuleSet] = None,
328
+ parallel: bool = False,
329
+ **cxt,
330
330
  ) -> Article:
331
331
  """Write an article based on the provided outline.
332
332
 
@@ -381,10 +381,10 @@ class TweakArticleRAG(Action, RAG, Censor):
381
381
  subsec,
382
382
  ruleset=ruleset,
383
383
  reference=f"{'\n\n'.join(d.display() for d in await self.aretrieve(refind_q, document_model=ArticleEssence, max_accepted=self.ref_limit))}\n\n"
384
- f"You can use Reference above to rewrite the `{subsec.__class__.__name__}`.\n"
385
- f"You should Always use `{subsec.language}` as written language, "
386
- f"which is the original language of the `{subsec.title}`. "
387
- f"since rewrite a `{subsec.__class__.__name__}` in a different language is usually a bad choice",
384
+ f"You can use Reference above to rewrite the `{subsec.__class__.__name__}`.\n"
385
+ f"You should Always use `{subsec.language}` as written language, "
386
+ f"which is the original language of the `{subsec.title}`. "
387
+ f"since rewrite a `{subsec.__class__.__name__}` in a different language is usually a bad choice",
388
388
  )
389
389
 
390
390
 
@@ -399,12 +399,12 @@ class ChunkArticle(Action):
399
399
  """The maximum overlapping rate between chunks."""
400
400
 
401
401
  async def _execute(
402
- self,
403
- article_path: str | Path,
404
- bib_manager: BibManager,
405
- max_chunk_size: Optional[int] = None,
406
- max_overlapping_rate: Optional[float] = None,
407
- **_,
402
+ self,
403
+ article_path: str | Path,
404
+ bib_manager: BibManager,
405
+ max_chunk_size: Optional[int] = None,
406
+ max_overlapping_rate: Optional[float] = None,
407
+ **_,
408
408
  ) -> List[ArticleChunk]:
409
409
  return ArticleChunk.from_file(
410
410
  article_path,
@@ -3,7 +3,8 @@
3
3
  from pathlib import Path
4
4
  from typing import Any, Iterable, List, Mapping, Optional, Type
5
5
 
6
- from fabricatio import TEMPLATE_MANAGER
6
+ from fabricatio.rust import TEMPLATE_MANAGER
7
+
7
8
  from fabricatio.fs import dump_text
8
9
  from fabricatio.journal import logger
9
10
  from fabricatio.models.action import Action
@@ -20,11 +21,11 @@ class DumpFinalizedOutput(Action, LLMUsage):
20
21
  dump_path: Optional[str] = None
21
22
 
22
23
  async def _execute(
23
- self,
24
- to_dump: FinalizedDumpAble,
25
- task_input: Optional[Task] = None,
26
- dump_path: Optional[str | Path] = None,
27
- **_,
24
+ self,
25
+ to_dump: FinalizedDumpAble,
26
+ task_input: Optional[Task] = None,
27
+ dump_path: Optional[str | Path] = None,
28
+ **_,
28
29
  ) -> str:
29
30
  dump_path = Path(
30
31
  dump_path
@@ -51,11 +52,11 @@ class RenderedDump(Action, LLMUsage):
51
52
  """The template name to render the data."""
52
53
 
53
54
  async def _execute(
54
- self,
55
- to_dump: FinalizedDumpAble,
56
- task_input: Optional[Task] = None,
57
- dump_path: Optional[str | Path] = None,
58
- **_,
55
+ self,
56
+ to_dump: FinalizedDumpAble,
57
+ task_input: Optional[Task] = None,
58
+ dump_path: Optional[str | Path] = None,
59
+ **_,
59
60
  ) -> str:
60
61
  dump_path = Path(
61
62
  dump_path
@@ -90,10 +91,10 @@ class PersistentAll(Action, LLMUsage):
90
91
  """Whether to remove the existing dir before dumping."""
91
92
 
92
93
  async def _execute(
93
- self,
94
- task_input: Optional[Task] = None,
95
- persist_dir: Optional[str | Path] = None,
96
- **cxt,
94
+ self,
95
+ task_input: Optional[Task] = None,
96
+ persist_dir: Optional[str | Path] = None,
97
+ **cxt,
97
98
  ) -> int:
98
99
  persist_dir = Path(
99
100
  persist_dir
@@ -123,7 +124,7 @@ class PersistentAll(Action, LLMUsage):
123
124
  v.persist(final_dir)
124
125
  count += 1
125
126
  if isinstance(v, Iterable) and any(
126
- persistent_ables := (pers for pers in v if isinstance(pers, PersistentAble))
127
+ persistent_ables := (pers for pers in v if isinstance(pers, PersistentAble))
127
128
  ):
128
129
  logger.info(f"Persisting collection {k} to {final_dir}")
129
130
  final_dir.mkdir(parents=True, exist_ok=True)
@@ -173,11 +174,11 @@ class RetrieveFromLatest[T: PersistentAble](RetrieveFromPersistent[T], FromMappi
173
174
 
174
175
  @classmethod
175
176
  def from_mapping(
176
- cls,
177
- mapping: Mapping[str, str | Path],
178
- *,
179
- retrieve_cls: Type[T],
180
- **kwargs,
177
+ cls,
178
+ mapping: Mapping[str, str | Path],
179
+ *,
180
+ retrieve_cls: Type[T],
181
+ **kwargs,
181
182
  ) -> List["RetrieveFromLatest[T]"]:
182
183
  """Create a list of `RetrieveFromLatest` from the mapping."""
183
184
  return [
fabricatio/actions/rag.py CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  from typing import List, Optional
4
4
 
5
+ from fabricatio.rust import CONFIG
6
+
5
7
  from fabricatio.capabilities.rag import RAG
6
- from fabricatio.config import configs
7
8
  from fabricatio.journal import logger
8
9
  from fabricatio.models.action import Action
9
10
  from fabricatio.models.extra.rag import MilvusClassicModel, MilvusDataBase
@@ -39,9 +40,9 @@ class InjectToDB(Action, RAG):
39
40
  schema=seq[0].as_milvus_schema(
40
41
  ok(
41
42
  self.milvus_dimensions
42
- or configs.rag.milvus_dimensions
43
+ or CONFIG.rag.milvus_dimensions
43
44
  or self.embedding_dimensions
44
- or configs.embedding.dimensions
45
+ or CONFIG.embedding.dimensions
45
46
  ),
46
47
  ),
47
48
  index_params=IndexParams(
@@ -3,17 +3,16 @@
3
3
  from asyncio import gather
4
4
  from typing import List, Optional, Unpack
5
5
 
6
- from fabricatio import TEMPLATE_MANAGER
6
+ from fabricatio.rust import CONFIG, TEMPLATE_MANAGER, detect_language
7
+
7
8
  from fabricatio.capabilities.advanced_judge import AdvancedJudge
8
9
  from fabricatio.capabilities.propose import Propose
9
- from fabricatio.config import configs
10
10
  from fabricatio.journal import logger
11
11
  from fabricatio.models.extra.patches import RuleSetMetadata
12
12
  from fabricatio.models.extra.problem import Improvement
13
13
  from fabricatio.models.extra.rule import Rule, RuleSet
14
14
  from fabricatio.models.generic import Display, WithBriefing
15
15
  from fabricatio.models.kwargs_types import ValidateKwargs
16
- from fabricatio.rust import detect_language
17
16
  from fabricatio.utils import override_kwargs
18
17
 
19
18
 
@@ -25,7 +24,7 @@ class Check(AdvancedJudge, Propose):
25
24
  """
26
25
 
27
26
  async def draft_ruleset(
28
- self, ruleset_requirement: str, rule_count: int = 0, **kwargs: Unpack[ValidateKwargs[Rule]]
27
+ self, ruleset_requirement: str, rule_count: int = 0, **kwargs: Unpack[ValidateKwargs[Rule]]
29
28
  ) -> Optional[RuleSet]:
30
29
  """Generate rule set based on requirement description.
31
30
 
@@ -45,7 +44,7 @@ class Check(AdvancedJudge, Propose):
45
44
  rule_reqs = (
46
45
  await self.alist_str(
47
46
  TEMPLATE_MANAGER.render_template(
48
- configs.templates.ruleset_requirement_breakdown_template,
47
+ CONFIG.templates.ruleset_requirement_breakdown_template,
49
48
  {"ruleset_requirement": ruleset_requirement},
50
49
  ),
51
50
  rule_count,
@@ -61,7 +60,7 @@ class Check(AdvancedJudge, Propose):
61
60
  rules = await self.propose(
62
61
  Rule,
63
62
  [
64
- TEMPLATE_MANAGER.render_template(configs.templates.rule_requirement_template, {"rule_requirement": r})
63
+ TEMPLATE_MANAGER.render_template(CONFIG.templates.rule_requirement_template, {"rule_requirement": r})
65
64
  for r in rule_reqs
66
65
  ],
67
66
  **kwargs,
@@ -81,11 +80,11 @@ class Check(AdvancedJudge, Propose):
81
80
  return RuleSet(rules=rules, **ruleset_patch.as_kwargs())
82
81
 
83
82
  async def check_string_against_rule(
84
- self,
85
- input_text: str,
86
- rule: Rule,
87
- reference: str = "",
88
- **kwargs: Unpack[ValidateKwargs[Improvement]],
83
+ self,
84
+ input_text: str,
85
+ rule: Rule,
86
+ reference: str = "",
87
+ **kwargs: Unpack[ValidateKwargs[Improvement]],
89
88
  ) -> Optional[Improvement]:
90
89
  """Validate text against specific rule.
91
90
 
@@ -104,15 +103,15 @@ class Check(AdvancedJudge, Propose):
104
103
  - Proposes Improvement only when violation is confirmed
105
104
  """
106
105
  if judge := await self.evidently_judge(
107
- f"# Content to exam\n{input_text}\n\n# Rule Must to follow\n{rule.display()}\nDoes `Content to exam` provided above violate the `{rule.name}` provided above?"
108
- f"should I take some measure to fix that violation? true for I do need, false for I don't need.",
109
- **override_kwargs(kwargs, default=None),
106
+ f"# Content to exam\n{input_text}\n\n# Rule Must to follow\n{rule.display()}\nDoes `Content to exam` provided above violate the `{rule.name}` provided above?"
107
+ f"should I take some measure to fix that violation? true for I do need, false for I don't need.",
108
+ **override_kwargs(kwargs, default=None),
110
109
  ):
111
110
  logger.info(f"Rule `{rule.name}` violated: \n{judge.display()}")
112
111
  return await self.propose(
113
112
  Improvement,
114
113
  TEMPLATE_MANAGER.render_template(
115
- configs.templates.check_string_template,
114
+ CONFIG.templates.check_string_template,
116
115
  {"to_check": input_text, "rule": rule.display(), "judge": judge.display(), "reference": reference},
117
116
  ),
118
117
  **kwargs,
@@ -120,11 +119,11 @@ class Check(AdvancedJudge, Propose):
120
119
  return None
121
120
 
122
121
  async def check_obj_against_rule[M: (Display, WithBriefing)](
123
- self,
124
- obj: M,
125
- rule: Rule,
126
- reference: str = "",
127
- **kwargs: Unpack[ValidateKwargs[Improvement]],
122
+ self,
123
+ obj: M,
124
+ rule: Rule,
125
+ reference: str = "",
126
+ **kwargs: Unpack[ValidateKwargs[Improvement]],
128
127
  ) -> Optional[Improvement]:
129
128
  """Validate object against rule using text representation.
130
129
 
@@ -152,11 +151,11 @@ class Check(AdvancedJudge, Propose):
152
151
  return await self.check_string_against_rule(input_text, rule, reference, **kwargs)
153
152
 
154
153
  async def check_string(
155
- self,
156
- input_text: str,
157
- ruleset: RuleSet,
158
- reference: str = "",
159
- **kwargs: Unpack[ValidateKwargs[Improvement]],
154
+ self,
155
+ input_text: str,
156
+ ruleset: RuleSet,
157
+ reference: str = "",
158
+ **kwargs: Unpack[ValidateKwargs[Improvement]],
160
159
  ) -> Optional[List[Improvement]]:
161
160
  """Validate text against full ruleset.
162
161
 
@@ -183,11 +182,11 @@ class Check(AdvancedJudge, Propose):
183
182
  return [imp for imp in imp_seq if imp]
184
183
 
185
184
  async def check_obj[M: (Display, WithBriefing)](
186
- self,
187
- obj: M,
188
- ruleset: RuleSet,
189
- reference: str = "",
190
- **kwargs: Unpack[ValidateKwargs[Improvement]],
185
+ self,
186
+ obj: M,
187
+ ruleset: RuleSet,
188
+ reference: str = "",
189
+ **kwargs: Unpack[ValidateKwargs[Improvement]],
191
190
  ) -> Optional[List[Improvement]]:
192
191
  """Validate object against full ruleset.
193
192