fabricatio 0.2.13.dev3__cp312-cp312-win_amd64.whl → 0.3.14__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.
- fabricatio/__init__.py +7 -14
- fabricatio/actions/article.py +58 -23
- fabricatio/actions/article_rag.py +6 -15
- fabricatio/actions/output.py +38 -3
- fabricatio/actions/rag.py +4 -4
- fabricatio/capabilities/advanced_judge.py +4 -7
- fabricatio/capabilities/advanced_rag.py +2 -1
- fabricatio/capabilities/censor.py +5 -4
- fabricatio/capabilities/check.py +6 -7
- fabricatio/capabilities/correct.py +5 -5
- fabricatio/capabilities/extract.py +7 -3
- fabricatio/capabilities/persist.py +103 -0
- fabricatio/capabilities/propose.py +2 -2
- fabricatio/capabilities/rag.py +43 -43
- fabricatio/capabilities/rating.py +11 -10
- fabricatio/capabilities/review.py +8 -6
- fabricatio/capabilities/task.py +22 -22
- fabricatio/decorators.py +4 -2
- fabricatio/{core.py → emitter.py} +35 -39
- fabricatio/fs/__init__.py +1 -2
- fabricatio/journal.py +2 -11
- fabricatio/models/action.py +14 -30
- fabricatio/models/extra/aricle_rag.py +14 -8
- fabricatio/models/extra/article_base.py +56 -25
- fabricatio/models/extra/article_essence.py +2 -1
- fabricatio/models/extra/article_main.py +16 -13
- fabricatio/models/extra/article_outline.py +2 -1
- fabricatio/models/extra/article_proposal.py +1 -1
- fabricatio/models/extra/rag.py +2 -2
- fabricatio/models/extra/rule.py +2 -1
- fabricatio/models/generic.py +56 -166
- fabricatio/models/kwargs_types.py +1 -54
- fabricatio/models/role.py +49 -26
- fabricatio/models/task.py +8 -9
- fabricatio/models/tool.py +7 -7
- fabricatio/models/usages.py +67 -61
- fabricatio/parser.py +60 -100
- fabricatio/rust.cp312-win_amd64.pyd +0 -0
- fabricatio/rust.pyi +469 -74
- fabricatio/utils.py +63 -162
- fabricatio-0.3.14.data/scripts/tdown.exe +0 -0
- fabricatio-0.3.14.data/scripts/ttm.exe +0 -0
- {fabricatio-0.2.13.dev3.dist-info → fabricatio-0.3.14.dist-info}/METADATA +10 -15
- fabricatio-0.3.14.dist-info/RECORD +64 -0
- {fabricatio-0.2.13.dev3.dist-info → fabricatio-0.3.14.dist-info}/WHEEL +1 -1
- fabricatio/config.py +0 -430
- fabricatio/constants.py +0 -20
- fabricatio/models/events.py +0 -120
- fabricatio/rust_instances.py +0 -10
- fabricatio-0.2.13.dev3.data/scripts/tdown.exe +0 -0
- fabricatio-0.2.13.dev3.data/scripts/ttm.exe +0 -0
- fabricatio-0.2.13.dev3.dist-info/RECORD +0 -67
- {fabricatio-0.2.13.dev3.dist-info → fabricatio-0.3.14.dist-info}/licenses/LICENSE +0 -0
fabricatio/rust.pyi
CHANGED
@@ -11,12 +11,12 @@ Key Features:
|
|
11
11
|
- Text utilities: Word boundary splitting and word counting.
|
12
12
|
"""
|
13
13
|
|
14
|
+
from enum import StrEnum
|
14
15
|
from pathlib import Path
|
15
|
-
from typing import Any, Dict, List, Optional, Tuple, overload
|
16
|
+
from typing import Any, Dict, List, Literal, Optional, Self, Tuple, Union, overload
|
16
17
|
|
17
18
|
from pydantic import JsonValue
|
18
19
|
|
19
|
-
|
20
20
|
class TemplateManager:
|
21
21
|
"""Template rendering engine using Handlebars templates.
|
22
22
|
|
@@ -26,17 +26,6 @@ class TemplateManager:
|
|
26
26
|
See: https://crates.io/crates/handlebars
|
27
27
|
"""
|
28
28
|
|
29
|
-
def __init__(
|
30
|
-
self, template_dirs: List[Path], suffix: Optional[str] = None, active_loading: Optional[bool] = None
|
31
|
-
) -> None:
|
32
|
-
"""Initialize the template manager.
|
33
|
-
|
34
|
-
Args:
|
35
|
-
template_dirs: List of directories containing template files
|
36
|
-
suffix: File extension for templates (defaults to 'hbs')
|
37
|
-
active_loading: Whether to enable dev mode for reloading templates on change
|
38
|
-
"""
|
39
|
-
|
40
29
|
@property
|
41
30
|
def template_count(self) -> int:
|
42
31
|
"""Returns the number of currently loaded templates."""
|
@@ -59,10 +48,8 @@ class TemplateManager:
|
|
59
48
|
|
60
49
|
@overload
|
61
50
|
def render_template(self, name: str, data: Dict[str, Any]) -> str: ...
|
62
|
-
|
63
51
|
@overload
|
64
52
|
def render_template(self, name: str, data: List[Dict[str, Any]]) -> List[str]: ...
|
65
|
-
|
66
53
|
def render_template(self, name: str, data: Dict[str, Any] | List[Dict[str, Any]]) -> str | List[str]:
|
67
54
|
"""Render a template with context data.
|
68
55
|
|
@@ -79,10 +66,8 @@ class TemplateManager:
|
|
79
66
|
|
80
67
|
@overload
|
81
68
|
def render_template_raw(self, template: str, data: Dict[str, Any]) -> str: ...
|
82
|
-
|
83
69
|
@overload
|
84
70
|
def render_template_raw(self, template: str, data: List[Dict[str, Any]]) -> List[str]: ...
|
85
|
-
|
86
71
|
def render_template_raw(self, template: str, data: Dict[str, Any] | List[Dict[str, Any]]) -> str | List[str]:
|
87
72
|
"""Render a template with context data.
|
88
73
|
|
@@ -94,7 +79,6 @@ class TemplateManager:
|
|
94
79
|
Rendered template content as string or list of strings
|
95
80
|
"""
|
96
81
|
|
97
|
-
|
98
82
|
class BibManager:
|
99
83
|
"""BibTeX bibliography manager for parsing and querying citation data."""
|
100
84
|
|
@@ -203,7 +187,6 @@ class BibManager:
|
|
203
187
|
Field value if found, None otherwise
|
204
188
|
"""
|
205
189
|
|
206
|
-
|
207
190
|
def blake3_hash(content: bytes) -> str:
|
208
191
|
"""Calculate the BLAKE3 cryptographic hash of data.
|
209
192
|
|
@@ -214,11 +197,9 @@ def blake3_hash(content: bytes) -> str:
|
|
214
197
|
Hex-encoded BLAKE3 hash string
|
215
198
|
"""
|
216
199
|
|
217
|
-
|
218
200
|
def detect_language(string: str) -> str:
|
219
201
|
"""Detect the language of a given string."""
|
220
202
|
|
221
|
-
|
222
203
|
def split_word_bounds(string: str) -> List[str]:
|
223
204
|
"""Split the string into words based on word boundaries.
|
224
205
|
|
@@ -229,7 +210,6 @@ def split_word_bounds(string: str) -> List[str]:
|
|
229
210
|
A list of words extracted from the string.
|
230
211
|
"""
|
231
212
|
|
232
|
-
|
233
213
|
def split_sentence_bounds(string: str) -> List[str]:
|
234
214
|
"""Split the string into sentences based on sentence boundaries.
|
235
215
|
|
@@ -240,7 +220,6 @@ def split_sentence_bounds(string: str) -> List[str]:
|
|
240
220
|
A list of sentences extracted from the string.
|
241
221
|
"""
|
242
222
|
|
243
|
-
|
244
223
|
def split_into_chunks(string: str, max_chunk_size: int, max_overlapping_rate: float = 0.3) -> List[str]:
|
245
224
|
"""Split the string into chunks of a specified size.
|
246
225
|
|
@@ -253,7 +232,6 @@ def split_into_chunks(string: str, max_chunk_size: int, max_overlapping_rate: fl
|
|
253
232
|
A list of chunks extracted from the string.
|
254
233
|
"""
|
255
234
|
|
256
|
-
|
257
235
|
def word_count(string: str) -> int:
|
258
236
|
"""Count the number of words in the string.
|
259
237
|
|
@@ -264,67 +242,51 @@ def word_count(string: str) -> int:
|
|
264
242
|
The number of words in the string.
|
265
243
|
"""
|
266
244
|
|
267
|
-
|
268
245
|
def is_chinese(string: str) -> bool:
|
269
246
|
"""Check if the given string is in Chinese."""
|
270
247
|
|
271
|
-
|
272
248
|
def is_english(string: str) -> bool:
|
273
249
|
"""Check if the given string is in English."""
|
274
250
|
|
275
|
-
|
276
251
|
def is_japanese(string: str) -> bool:
|
277
252
|
"""Check if the given string is in Japanese."""
|
278
253
|
|
279
|
-
|
280
254
|
def is_korean(string: str) -> bool:
|
281
255
|
"""Check if the given string is in Korean."""
|
282
256
|
|
283
|
-
|
284
257
|
def is_arabic(string: str) -> bool:
|
285
258
|
"""Check if the given string is in Arabic."""
|
286
259
|
|
287
|
-
|
288
260
|
def is_russian(string: str) -> bool:
|
289
261
|
"""Check if the given string is in Russian."""
|
290
262
|
|
291
|
-
|
292
263
|
def is_german(string: str) -> bool:
|
293
264
|
"""Check if the given string is in German."""
|
294
265
|
|
295
|
-
|
296
266
|
def is_french(string: str) -> bool:
|
297
267
|
"""Check if the given string is in French."""
|
298
268
|
|
299
|
-
|
300
269
|
def is_hindi(string: str) -> bool:
|
301
270
|
"""Check if the given string is in Hindi."""
|
302
271
|
|
303
|
-
|
304
272
|
def is_italian(string: str) -> bool:
|
305
273
|
"""Check if the given string is in Italian."""
|
306
274
|
|
307
|
-
|
308
275
|
def is_dutch(string: str) -> bool:
|
309
276
|
"""Check if the given string is in Dutch."""
|
310
277
|
|
311
|
-
|
312
278
|
def is_portuguese(string: str) -> bool:
|
313
279
|
"""Check if the given string is in Portuguese."""
|
314
280
|
|
315
|
-
|
316
281
|
def is_swedish(string: str) -> bool:
|
317
282
|
"""Check if the given string is in Swedish."""
|
318
283
|
|
319
|
-
|
320
284
|
def is_turkish(string: str) -> bool:
|
321
285
|
"""Check if the given string is in Turkish."""
|
322
286
|
|
323
|
-
|
324
287
|
def is_vietnamese(string: str) -> bool:
|
325
288
|
"""Check if the given string is in Vietnamese."""
|
326
289
|
|
327
|
-
|
328
290
|
def tex_to_typst(string: str) -> str:
|
329
291
|
"""Convert TeX to Typst.
|
330
292
|
|
@@ -335,29 +297,18 @@ def tex_to_typst(string: str) -> str:
|
|
335
297
|
The converted Typst string.
|
336
298
|
"""
|
337
299
|
|
300
|
+
def convert_all_tex_math(string: str) -> str:
|
301
|
+
r"""Unified function to convert all supported TeX math expressions in a string to Typst format.
|
338
302
|
|
339
|
-
|
340
|
-
"""Convert all inline TeX code in the string.
|
303
|
+
Handles $...$, $$...$$, \\(...\\), and \\[...\\]
|
341
304
|
|
342
305
|
Args:
|
343
|
-
string: The input string containing
|
306
|
+
string: The input string containing TeX math expressions.
|
344
307
|
|
345
308
|
Returns:
|
346
|
-
The
|
309
|
+
The string with TeX math expressions converted to Typst format.
|
347
310
|
"""
|
348
311
|
|
349
|
-
|
350
|
-
def convert_all_block_tex(string: str) -> str:
|
351
|
-
"""Convert all block TeX code in the string.
|
352
|
-
|
353
|
-
Args:
|
354
|
-
string: The input string containing block TeX code wrapped in $$code$$.
|
355
|
-
|
356
|
-
Returns:
|
357
|
-
The converted string with block TeX code replaced.
|
358
|
-
"""
|
359
|
-
|
360
|
-
|
361
312
|
def fix_misplaced_labels(string: str) -> str:
|
362
313
|
"""A func to fix labels in a string.
|
363
314
|
|
@@ -368,9 +319,8 @@ def fix_misplaced_labels(string: str) -> str:
|
|
368
319
|
The fixed string with labels properly placed.
|
369
320
|
"""
|
370
321
|
|
371
|
-
|
372
322
|
def comment(string: str) -> str:
|
373
|
-
"""Add comment to the string.
|
323
|
+
r"""Add comment to the string.
|
374
324
|
|
375
325
|
Args:
|
376
326
|
string: The input string to which comments will be added.
|
@@ -379,7 +329,6 @@ def comment(string: str) -> str:
|
|
379
329
|
The string with each line prefixed by '// '.
|
380
330
|
"""
|
381
331
|
|
382
|
-
|
383
332
|
def uncomment(string: str) -> str:
|
384
333
|
"""Remove comment from the string.
|
385
334
|
|
@@ -390,6 +339,15 @@ def uncomment(string: str) -> str:
|
|
390
339
|
The string with comments (lines starting with '// ' or '//') removed.
|
391
340
|
"""
|
392
341
|
|
342
|
+
def strip_comment(string: str) -> str:
|
343
|
+
"""Remove leading and trailing comment lines from a multi-line string.
|
344
|
+
|
345
|
+
Args:
|
346
|
+
string: Input string that may have comment lines at start and/or end
|
347
|
+
|
348
|
+
Returns:
|
349
|
+
str: A new string with leading and trailing comment lines removed
|
350
|
+
"""
|
393
351
|
|
394
352
|
def split_out_metadata(string: str) -> Tuple[Optional[JsonValue], str]:
|
395
353
|
"""Split out metadata from a string.
|
@@ -401,7 +359,6 @@ def split_out_metadata(string: str) -> Tuple[Optional[JsonValue], str]:
|
|
401
359
|
A tuple containing the metadata as a Python object (if parseable) and the remaining string.
|
402
360
|
"""
|
403
361
|
|
404
|
-
|
405
362
|
def to_metadata(data: JsonValue) -> str:
|
406
363
|
"""Convert a Python object to a YAML string.
|
407
364
|
|
@@ -412,16 +369,7 @@ def to_metadata(data: JsonValue) -> str:
|
|
412
369
|
The YAML string representation of the input data.
|
413
370
|
"""
|
414
371
|
|
415
|
-
|
416
|
-
def convert_to_inline_formula(string: str) -> str:
|
417
|
-
r"""Convert `$...$` to inline formula `\(...\)` and trim spaces."""
|
418
|
-
|
419
|
-
|
420
|
-
def convert_to_block_formula(string: str) -> str:
|
421
|
-
r"""Convert `$$...$$` to block formula `\[...\]` and trim spaces."""
|
422
|
-
|
423
|
-
|
424
|
-
def inplace_update(string: str, wrapper: str, new_body: str) -> Optional[str]:
|
372
|
+
def replace_thesis_body(string: str, wrapper: str, new_body: str) -> Optional[str]:
|
425
373
|
"""Replace content between wrapper strings.
|
426
374
|
|
427
375
|
Args:
|
@@ -431,13 +379,11 @@ def inplace_update(string: str, wrapper: str, new_body: str) -> Optional[str]:
|
|
431
379
|
|
432
380
|
Returns:
|
433
381
|
A new string with the content between wrappers replaced.
|
434
|
-
|
435
|
-
"""
|
436
382
|
|
383
|
+
"""
|
437
384
|
|
438
385
|
def extract_body(string: str, wrapper: str) -> Optional[str]:
|
439
|
-
"""
|
440
|
-
Extract the content between two occurrences of a wrapper string.
|
386
|
+
"""Extract the content between two occurrences of a wrapper string.
|
441
387
|
|
442
388
|
Args:
|
443
389
|
string: The input string containing content wrapped by delimiter strings.
|
@@ -446,3 +392,452 @@ def extract_body(string: str, wrapper: str) -> Optional[str]:
|
|
446
392
|
Returns:
|
447
393
|
The content between the first two occurrences of the wrapper string if found, otherwise None.
|
448
394
|
"""
|
395
|
+
|
396
|
+
class LLMConfig:
|
397
|
+
"""LLM configuration structure.
|
398
|
+
|
399
|
+
Contains parameters for configuring Language Learning Models.
|
400
|
+
"""
|
401
|
+
|
402
|
+
api_endpoint: Optional[str]
|
403
|
+
"""API endpoint URL for the LLM service."""
|
404
|
+
|
405
|
+
api_key: Optional[SecretStr]
|
406
|
+
"""Authentication key for the LLM service."""
|
407
|
+
|
408
|
+
timeout: Optional[int]
|
409
|
+
"""Maximum time in seconds to wait for a response."""
|
410
|
+
|
411
|
+
max_retries: Optional[int]
|
412
|
+
"""Number of retry attempts for failed requests."""
|
413
|
+
|
414
|
+
model: Optional[str]
|
415
|
+
"""Name of the LLM model to use."""
|
416
|
+
|
417
|
+
temperature: Optional[float]
|
418
|
+
"""Controls randomness in response generation (0.0-2.0)."""
|
419
|
+
|
420
|
+
stop_sign: Optional[List[str]]
|
421
|
+
"""Sequence(s) that signal the LLM to stop generating tokens."""
|
422
|
+
|
423
|
+
top_p: Optional[float]
|
424
|
+
"""Controls diversity via nucleus sampling (0.0-1.0)."""
|
425
|
+
|
426
|
+
generation_count: Optional[int]
|
427
|
+
"""Number of completions to generate for each prompt."""
|
428
|
+
|
429
|
+
stream: Optional[bool]
|
430
|
+
"""When true, responses are streamed as they're generated."""
|
431
|
+
|
432
|
+
max_tokens: Optional[int]
|
433
|
+
"""Maximum number of tokens to generate in the response."""
|
434
|
+
|
435
|
+
rpm: Optional[int]
|
436
|
+
"""Rate limit in requests per minute."""
|
437
|
+
|
438
|
+
tpm: Optional[int]
|
439
|
+
"""Rate limit in tokens per minute."""
|
440
|
+
|
441
|
+
presence_penalty: Optional[float]
|
442
|
+
"""Penalizes new tokens based on their presence in text so far (-2.0-2.0)."""
|
443
|
+
|
444
|
+
frequency_penalty: Optional[float]
|
445
|
+
"""Penalizes new tokens based on their frequency in text so far (-2.0-2.0)."""
|
446
|
+
|
447
|
+
class EmbeddingConfig:
|
448
|
+
"""Embedding configuration structure."""
|
449
|
+
|
450
|
+
model: Optional[str]
|
451
|
+
"""The embedding model name."""
|
452
|
+
|
453
|
+
dimensions: Optional[int]
|
454
|
+
"""The dimensions of the embedding."""
|
455
|
+
|
456
|
+
timeout: Optional[int]
|
457
|
+
"""The timeout of the embedding model in seconds."""
|
458
|
+
|
459
|
+
max_sequence_length: Optional[int]
|
460
|
+
"""The maximum sequence length of the embedding model."""
|
461
|
+
|
462
|
+
caching: Optional[bool]
|
463
|
+
"""Whether to cache the embedding."""
|
464
|
+
|
465
|
+
api_endpoint: Optional[str]
|
466
|
+
"""The API endpoint URL."""
|
467
|
+
|
468
|
+
api_key: Optional[SecretStr]
|
469
|
+
"""The API key."""
|
470
|
+
|
471
|
+
class RagConfig:
|
472
|
+
"""RAG (Retrieval Augmented Generation) configuration structure."""
|
473
|
+
|
474
|
+
milvus_uri: Optional[str]
|
475
|
+
"""The URI of the Milvus server."""
|
476
|
+
|
477
|
+
milvus_timeout: Optional[float]
|
478
|
+
"""The timeout of the Milvus server in seconds."""
|
479
|
+
|
480
|
+
milvus_token: Optional[SecretStr]
|
481
|
+
"""The token for Milvus authentication."""
|
482
|
+
|
483
|
+
milvus_dimensions: Optional[int]
|
484
|
+
"""The dimensions for Milvus vectors."""
|
485
|
+
|
486
|
+
class DebugConfig:
|
487
|
+
"""Debug configuration structure."""
|
488
|
+
|
489
|
+
log_level: Optional[str]
|
490
|
+
"""The logging level to use."""
|
491
|
+
|
492
|
+
class TemplateManagerConfig:
|
493
|
+
"""Template manager configuration structure."""
|
494
|
+
|
495
|
+
template_dir: List[Path]
|
496
|
+
"""The directories containing the templates."""
|
497
|
+
|
498
|
+
active_loading: Optional[bool]
|
499
|
+
"""Whether to enable active loading of templates."""
|
500
|
+
|
501
|
+
template_suffix: Optional[str]
|
502
|
+
"""The suffix of the templates."""
|
503
|
+
|
504
|
+
class TemplateConfig:
|
505
|
+
"""Template configuration structure."""
|
506
|
+
|
507
|
+
create_json_obj_template: str
|
508
|
+
"""The name of the create json object template which will be used to create a json object."""
|
509
|
+
|
510
|
+
draft_tool_usage_code_template: str
|
511
|
+
"""The name of the draft tool usage code template which will be used to draft tool usage code."""
|
512
|
+
|
513
|
+
make_choice_template: str
|
514
|
+
"""The name of the make choice template which will be used to make a choice."""
|
515
|
+
|
516
|
+
make_judgment_template: str
|
517
|
+
"""The name of the make judgment template which will be used to make a judgment."""
|
518
|
+
|
519
|
+
dependencies_template: str
|
520
|
+
"""The name of the dependencies template which will be used to manage dependencies."""
|
521
|
+
|
522
|
+
task_briefing_template: str
|
523
|
+
"""The name of the task briefing template which will be used to brief a task."""
|
524
|
+
|
525
|
+
rate_fine_grind_template: str
|
526
|
+
"""The name of the rate fine grind template which will be used to rate fine grind."""
|
527
|
+
|
528
|
+
draft_rating_manual_template: str
|
529
|
+
"""The name of the draft rating manual template which will be used to draft rating manual."""
|
530
|
+
|
531
|
+
draft_rating_criteria_template: str
|
532
|
+
"""The name of the draft rating criteria template which will be used to draft rating criteria."""
|
533
|
+
|
534
|
+
extract_reasons_from_examples_template: str
|
535
|
+
"""The name of the extract reasons from examples template which will be used to extract reasons from examples."""
|
536
|
+
|
537
|
+
extract_criteria_from_reasons_template: str
|
538
|
+
"""The name of the extract criteria from reasons template which will be used to extract criteria from reasons."""
|
539
|
+
|
540
|
+
draft_rating_weights_klee_template: str
|
541
|
+
"""The name of the draft rating weights klee template which will be used to draft rating weights with Klee method."""
|
542
|
+
|
543
|
+
retrieved_display_template: str
|
544
|
+
"""The name of the retrieved display template which will be used to display retrieved documents."""
|
545
|
+
|
546
|
+
liststr_template: str
|
547
|
+
"""The name of the liststr template which will be used to display a list of strings."""
|
548
|
+
|
549
|
+
refined_query_template: str
|
550
|
+
"""The name of the refined query template which will be used to refine a query."""
|
551
|
+
|
552
|
+
pathstr_template: str
|
553
|
+
"""The name of the pathstr template which will be used to acquire a path of strings."""
|
554
|
+
|
555
|
+
review_string_template: str
|
556
|
+
"""The name of the review string template which will be used to review a string."""
|
557
|
+
|
558
|
+
generic_string_template: str
|
559
|
+
"""The name of the generic string template which will be used to review a string."""
|
560
|
+
|
561
|
+
co_validation_template: str
|
562
|
+
"""The name of the co-validation template which will be used to co-validate a string."""
|
563
|
+
|
564
|
+
as_prompt_template: str
|
565
|
+
"""The name of the as prompt template which will be used to convert a string to a prompt."""
|
566
|
+
|
567
|
+
check_string_template: str
|
568
|
+
"""The name of the check string template which will be used to check a string."""
|
569
|
+
|
570
|
+
ruleset_requirement_breakdown_template: str
|
571
|
+
"""The name of the ruleset requirement breakdown template which will be used to breakdown a ruleset requirement."""
|
572
|
+
|
573
|
+
fix_troubled_obj_template: str
|
574
|
+
"""The name of the fix troubled object template which will be used to fix a troubled object."""
|
575
|
+
|
576
|
+
fix_troubled_string_template: str
|
577
|
+
"""The name of the fix troubled string template which will be used to fix a troubled string."""
|
578
|
+
|
579
|
+
rule_requirement_template: str
|
580
|
+
"""The name of the rule requirement template which will be used to generate a rule requirement."""
|
581
|
+
|
582
|
+
extract_template: str
|
583
|
+
"""The name of the extract template which will be used to extract model from string."""
|
584
|
+
|
585
|
+
chap_summary_template: str
|
586
|
+
"""The name of the chap summary template which will be used to generate a chapter summary."""
|
587
|
+
|
588
|
+
class RoutingConfig:
|
589
|
+
"""Routing configuration structure for controlling request dispatching behavior."""
|
590
|
+
|
591
|
+
max_parallel_requests: Optional[int]
|
592
|
+
"""The maximum number of parallel requests. None means not checked."""
|
593
|
+
|
594
|
+
allowed_fails: Optional[int]
|
595
|
+
"""The number of allowed fails before the routing is considered failed."""
|
596
|
+
|
597
|
+
retry_after: int
|
598
|
+
"""Minimum time to wait before retrying a failed request."""
|
599
|
+
|
600
|
+
cooldown_time: Optional[int]
|
601
|
+
"""Time to cooldown a deployment after failure in seconds."""
|
602
|
+
|
603
|
+
class GeneralConfig:
|
604
|
+
"""General configuration structure for application-wide settings."""
|
605
|
+
|
606
|
+
confirm_on_ops: bool
|
607
|
+
"""Whether to confirm operations before executing them."""
|
608
|
+
|
609
|
+
use_json_repair: bool
|
610
|
+
"""Whether to automatically repair malformed JSON."""
|
611
|
+
|
612
|
+
class ToolBoxConfig:
|
613
|
+
"""Configuration for toolbox functionality."""
|
614
|
+
|
615
|
+
tool_module_name: str
|
616
|
+
"""The name of the module containing the toolbox."""
|
617
|
+
|
618
|
+
data_module_name: str
|
619
|
+
"""The name of the module containing the data."""
|
620
|
+
|
621
|
+
class PymitterConfig:
|
622
|
+
"""Pymitter configuration structure for controlling event emission and listener behavior."""
|
623
|
+
|
624
|
+
delimiter: str
|
625
|
+
"""The delimiter used to separate the event name into segments."""
|
626
|
+
|
627
|
+
new_listener_event: bool
|
628
|
+
"""If set, a newListener event is emitted when a new listener is added."""
|
629
|
+
|
630
|
+
max_listeners: int
|
631
|
+
"""The maximum number of listeners per event. -1 means unlimited."""
|
632
|
+
|
633
|
+
class Config:
|
634
|
+
"""Configuration structure containing all system components."""
|
635
|
+
|
636
|
+
embedding: EmbeddingConfig
|
637
|
+
"""Embedding configuration."""
|
638
|
+
|
639
|
+
llm: LLMConfig
|
640
|
+
"""LLM configuration."""
|
641
|
+
|
642
|
+
debug: DebugConfig
|
643
|
+
"""Debug configuration."""
|
644
|
+
|
645
|
+
rag: RagConfig
|
646
|
+
"""RAG configuration."""
|
647
|
+
|
648
|
+
templates: TemplateConfig
|
649
|
+
"""Template configuration."""
|
650
|
+
|
651
|
+
template_manager: TemplateManagerConfig
|
652
|
+
"""Template manager configuration."""
|
653
|
+
|
654
|
+
routing: RoutingConfig
|
655
|
+
"""Routing configuration."""
|
656
|
+
|
657
|
+
general: GeneralConfig
|
658
|
+
"""General configuration."""
|
659
|
+
|
660
|
+
toolbox: ToolBoxConfig
|
661
|
+
"""Toolbox configuration."""
|
662
|
+
|
663
|
+
pymitter: PymitterConfig
|
664
|
+
"""Pymitter configuration."""
|
665
|
+
|
666
|
+
CONFIG: Config
|
667
|
+
|
668
|
+
class SecretStr:
|
669
|
+
"""A string that should not be exposed."""
|
670
|
+
|
671
|
+
def __init__(self, source: str) -> None: ...
|
672
|
+
def get_secret_value(self) -> str:
|
673
|
+
"""Expose the secret string."""
|
674
|
+
|
675
|
+
TEMPLATE_MANAGER: TemplateManager
|
676
|
+
|
677
|
+
class Event:
|
678
|
+
"""Event class that represents a hierarchical event with segments.
|
679
|
+
|
680
|
+
Events can be constructed from strings, lists of strings, or other Events.
|
681
|
+
"""
|
682
|
+
|
683
|
+
segments: List[str]
|
684
|
+
|
685
|
+
def __init__(self, segments: Optional[List[str]] = None) -> None:
|
686
|
+
"""Initialize a new Event with optional segments.
|
687
|
+
|
688
|
+
Args:
|
689
|
+
segments: Optional list of string segments
|
690
|
+
"""
|
691
|
+
|
692
|
+
@staticmethod
|
693
|
+
def instantiate_from(event: Union[str, Event, List[str]]) -> Event:
|
694
|
+
"""Create an Event from a string, list of strings, or another Event.
|
695
|
+
|
696
|
+
Args:
|
697
|
+
event: The source to create the Event from
|
698
|
+
|
699
|
+
Returns:
|
700
|
+
A new Event instance
|
701
|
+
|
702
|
+
Raises:
|
703
|
+
ValueError: If list elements are not strings
|
704
|
+
TypeError: If event is an invalid type
|
705
|
+
"""
|
706
|
+
|
707
|
+
@staticmethod
|
708
|
+
def quick_instantiate(event: Union[str, Event, List[str]]) -> Event:
|
709
|
+
"""Create an Event and append wildcard and pending status.
|
710
|
+
|
711
|
+
Args:
|
712
|
+
event: The source to create the Event from
|
713
|
+
|
714
|
+
Returns:
|
715
|
+
A new Event instance with wildcard and pending status appended
|
716
|
+
"""
|
717
|
+
|
718
|
+
def derive(self, event: Union[str, Event, List[str]]) -> Event:
|
719
|
+
"""Create a new Event by extending this one with another.
|
720
|
+
|
721
|
+
Args:
|
722
|
+
event: The Event to append
|
723
|
+
|
724
|
+
Returns:
|
725
|
+
A new Event that combines this Event with the provided one
|
726
|
+
"""
|
727
|
+
|
728
|
+
def collapse(self) -> str:
|
729
|
+
"""Convert the Event to a delimited string.
|
730
|
+
|
731
|
+
Returns:
|
732
|
+
String representation with segments joined by delimiter
|
733
|
+
"""
|
734
|
+
|
735
|
+
def fork(self) -> Event:
|
736
|
+
"""Create a copy of this Event.
|
737
|
+
|
738
|
+
Returns:
|
739
|
+
A new Event with the same segments
|
740
|
+
"""
|
741
|
+
|
742
|
+
def push(self, segment: str) -> Self:
|
743
|
+
"""Add a segment to the Event.
|
744
|
+
|
745
|
+
Args:
|
746
|
+
segment: String segment to add
|
747
|
+
|
748
|
+
Raises:
|
749
|
+
ValueError: If segment is empty or contains the delimiter
|
750
|
+
"""
|
751
|
+
|
752
|
+
def push_wildcard(self) -> Self:
|
753
|
+
"""Add a wildcard segment (*) to the Event."""
|
754
|
+
|
755
|
+
def push_pending(self) -> Self:
|
756
|
+
"""Add a pending status segment to the Event."""
|
757
|
+
|
758
|
+
def push_running(self) -> Self:
|
759
|
+
"""Add a running status segment to the Event."""
|
760
|
+
|
761
|
+
def push_finished(self) -> Self:
|
762
|
+
"""Add a finished status segment to the Event."""
|
763
|
+
|
764
|
+
def push_failed(self) -> Self:
|
765
|
+
"""Add a failed status segment to the Event."""
|
766
|
+
|
767
|
+
def push_cancelled(self) -> Self:
|
768
|
+
"""Add a cancelled status segment to the Event."""
|
769
|
+
|
770
|
+
def pop(self) -> Optional[str]:
|
771
|
+
"""Remove and return the last segment.
|
772
|
+
|
773
|
+
Returns:
|
774
|
+
The removed segment or None if the Event is empty
|
775
|
+
"""
|
776
|
+
|
777
|
+
def clear(self) -> Self:
|
778
|
+
"""Remove all segments from the Event."""
|
779
|
+
|
780
|
+
def concat(self, event: Union[str, Event, List[str]]) -> Self:
|
781
|
+
"""Append segments from another Event to this one.
|
782
|
+
|
783
|
+
Args:
|
784
|
+
event: The Event to append segments from
|
785
|
+
"""
|
786
|
+
|
787
|
+
def __hash__(self) -> int: ...
|
788
|
+
def __eq__(self, other: object) -> bool: ...
|
789
|
+
def __ne__(self, other: object) -> bool: ...
|
790
|
+
|
791
|
+
class TaskStatus(StrEnum, str):
|
792
|
+
"""Enumeration of possible task statuses."""
|
793
|
+
|
794
|
+
Pending: TaskStatus
|
795
|
+
"""Task is pending execution."""
|
796
|
+
|
797
|
+
Running: TaskStatus
|
798
|
+
"""Task is currently running."""
|
799
|
+
|
800
|
+
Finished: TaskStatus
|
801
|
+
"""Task has finished successfully."""
|
802
|
+
|
803
|
+
Failed: TaskStatus
|
804
|
+
"""Task has failed."""
|
805
|
+
|
806
|
+
Cancelled: TaskStatus
|
807
|
+
"""Task has been cancelled."""
|
808
|
+
|
809
|
+
class TEIClient:
|
810
|
+
"""Client for TEI reranking service.
|
811
|
+
|
812
|
+
Handles communication with a TEI reranking service to reorder text snippets
|
813
|
+
based on their relevance to a query.
|
814
|
+
"""
|
815
|
+
|
816
|
+
def __init__(self, base_url: str) -> None:
|
817
|
+
"""Initialize the TEI client.
|
818
|
+
|
819
|
+
Args:
|
820
|
+
base_url: URL to the TEI reranking service
|
821
|
+
"""
|
822
|
+
|
823
|
+
async def arerank(
|
824
|
+
self,
|
825
|
+
query: str,
|
826
|
+
texts: List[str],
|
827
|
+
truncate: bool = False,
|
828
|
+
truncation_direction: Literal["Left", "Right"] = "Left",
|
829
|
+
) -> List[Tuple[int, float]]:
|
830
|
+
"""Rerank texts based on relevance to query.
|
831
|
+
|
832
|
+
Args:
|
833
|
+
query: The query to match texts against
|
834
|
+
texts: List of text snippets to rerank
|
835
|
+
truncate: Whether to truncate texts to fit model context
|
836
|
+
truncation_direction: Direction to truncate from ("Left" or "Right")
|
837
|
+
|
838
|
+
Returns:
|
839
|
+
List of tuples containing (original_index, relevance_score)
|
840
|
+
|
841
|
+
Raises:
|
842
|
+
RuntimeError: If reranking fails or truncation_direction is invalid
|
843
|
+
"""
|