-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsummarizer_settings.py
More file actions
86 lines (79 loc) · 2.83 KB
/
summarizer_settings.py
File metadata and controls
86 lines (79 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""Contains settings for summarizer."""
from typing import Optional
from pydantic import Field, PositiveInt, model_validator
from pydantic_settings import BaseSettings, SettingsConfigDict
class SummarizerSettings(BaseSettings):
"""
Contains settings regarding the summarizer.
Attributes
----------
maximum_input_size : int
The maximum size of the input that the summarizer can handle. Default is 8000.
maximum_concurrency : int
The maximum number of concurrent summarization processes. Default is 10.
max_retries: Optional[PositiveInt]
Total retries, not counting the initial attempt.
retry_base_delay: Optional[float]
Base delay in seconds for the first retry.
retry_max_delay: Optional[float]
Maximum delay cap in seconds for any single wait.
backoff_factor: Optional[float]
Exponential backoff factor (>= 1).
attempt_cap: Optional[int]
Cap for exponent growth (backoff_factor ** attempt_cap).
jitter_min: Optional[float]
Minimum jitter in seconds.
jitter_max: Optional[float]
Maximum jitter in seconds.
"""
model_config = SettingsConfigDict(env_prefix="SUMMARIZER_", case_sensitive=False)
maximum_input_size: int = Field(default=8000)
maximum_concurrency: int = Field(default=10)
max_retries: Optional[PositiveInt] = Field(
default=None,
title="Max Retries",
description="Total retries, not counting the initial attempt.",
)
retry_base_delay: Optional[float] = Field(
default=None,
ge=0,
title="Retry Base Delay",
description="Base delay in seconds for the first retry.",
)
retry_max_delay: Optional[float] = Field(
default=None,
gt=0,
title="Retry Max Delay",
description="Maximum delay cap in seconds for any single wait.",
)
backoff_factor: Optional[float] = Field(
default=None,
ge=1.0,
title="Backoff Factor",
description="Exponential backoff factor (>= 1).",
)
attempt_cap: Optional[int] = Field(
default=None,
ge=0,
title="Attempt Cap",
description="Cap for exponent growth (backoff_factor ** attempt_cap).",
)
jitter_min: Optional[float] = Field(
default=None,
ge=0.0,
title="Jitter Min (s)",
description="Minimum jitter in seconds.",
)
jitter_max: Optional[float] = Field(
default=None,
ge=0.0,
title="Jitter Max (s)",
description="Maximum jitter in seconds.",
)
@model_validator(mode="after")
def _check_relations(self) -> "SummarizerSettings":
if not self.jitter_min or not self.jitter_max:
return self
if self.jitter_max < self.jitter_min:
raise ValueError("jitter_max must be >= jitter_min")
return self