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