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