ai-pipeline-core 0.1.12__py3-none-any.whl → 0.4.1__py3-none-any.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.
- ai_pipeline_core/__init__.py +83 -119
- ai_pipeline_core/deployment/__init__.py +34 -0
- ai_pipeline_core/deployment/base.py +861 -0
- ai_pipeline_core/deployment/contract.py +80 -0
- ai_pipeline_core/deployment/deploy.py +561 -0
- ai_pipeline_core/deployment/helpers.py +97 -0
- ai_pipeline_core/deployment/progress.py +126 -0
- ai_pipeline_core/deployment/remote.py +116 -0
- ai_pipeline_core/docs_generator/__init__.py +54 -0
- ai_pipeline_core/docs_generator/__main__.py +5 -0
- ai_pipeline_core/docs_generator/cli.py +196 -0
- ai_pipeline_core/docs_generator/extractor.py +324 -0
- ai_pipeline_core/docs_generator/guide_builder.py +644 -0
- ai_pipeline_core/docs_generator/trimmer.py +35 -0
- ai_pipeline_core/docs_generator/validator.py +114 -0
- ai_pipeline_core/document_store/__init__.py +13 -0
- ai_pipeline_core/document_store/_summary.py +9 -0
- ai_pipeline_core/document_store/_summary_worker.py +170 -0
- ai_pipeline_core/document_store/clickhouse.py +492 -0
- ai_pipeline_core/document_store/factory.py +38 -0
- ai_pipeline_core/document_store/local.py +312 -0
- ai_pipeline_core/document_store/memory.py +85 -0
- ai_pipeline_core/document_store/protocol.py +68 -0
- ai_pipeline_core/documents/__init__.py +14 -15
- ai_pipeline_core/documents/_context_vars.py +85 -0
- ai_pipeline_core/documents/_hashing.py +52 -0
- ai_pipeline_core/documents/attachment.py +85 -0
- ai_pipeline_core/documents/context.py +128 -0
- ai_pipeline_core/documents/document.py +349 -1062
- ai_pipeline_core/documents/mime_type.py +40 -85
- ai_pipeline_core/documents/utils.py +62 -7
- ai_pipeline_core/exceptions.py +10 -62
- ai_pipeline_core/images/__init__.py +309 -0
- ai_pipeline_core/images/_processing.py +151 -0
- ai_pipeline_core/llm/__init__.py +5 -3
- ai_pipeline_core/llm/ai_messages.py +284 -73
- ai_pipeline_core/llm/client.py +462 -209
- ai_pipeline_core/llm/model_options.py +86 -53
- ai_pipeline_core/llm/model_response.py +187 -241
- ai_pipeline_core/llm/model_types.py +34 -54
- ai_pipeline_core/logging/__init__.py +2 -9
- ai_pipeline_core/logging/logging.yml +1 -1
- ai_pipeline_core/logging/logging_config.py +27 -43
- ai_pipeline_core/logging/logging_mixin.py +17 -51
- ai_pipeline_core/observability/__init__.py +32 -0
- ai_pipeline_core/observability/_debug/__init__.py +30 -0
- ai_pipeline_core/observability/_debug/_auto_summary.py +94 -0
- ai_pipeline_core/observability/_debug/_config.py +95 -0
- ai_pipeline_core/observability/_debug/_content.py +764 -0
- ai_pipeline_core/observability/_debug/_processor.py +98 -0
- ai_pipeline_core/observability/_debug/_summary.py +312 -0
- ai_pipeline_core/observability/_debug/_types.py +75 -0
- ai_pipeline_core/observability/_debug/_writer.py +843 -0
- ai_pipeline_core/observability/_document_tracking.py +146 -0
- ai_pipeline_core/observability/_initialization.py +194 -0
- ai_pipeline_core/observability/_logging_bridge.py +57 -0
- ai_pipeline_core/observability/_summary.py +81 -0
- ai_pipeline_core/observability/_tracking/__init__.py +6 -0
- ai_pipeline_core/observability/_tracking/_client.py +178 -0
- ai_pipeline_core/observability/_tracking/_internal.py +28 -0
- ai_pipeline_core/observability/_tracking/_models.py +138 -0
- ai_pipeline_core/observability/_tracking/_processor.py +158 -0
- ai_pipeline_core/observability/_tracking/_service.py +311 -0
- ai_pipeline_core/observability/_tracking/_writer.py +229 -0
- ai_pipeline_core/observability/tracing.py +640 -0
- ai_pipeline_core/pipeline/__init__.py +10 -0
- ai_pipeline_core/pipeline/decorators.py +915 -0
- ai_pipeline_core/pipeline/options.py +16 -0
- ai_pipeline_core/prompt_manager.py +26 -105
- ai_pipeline_core/settings.py +41 -32
- ai_pipeline_core/testing.py +9 -0
- ai_pipeline_core-0.4.1.dist-info/METADATA +807 -0
- ai_pipeline_core-0.4.1.dist-info/RECORD +76 -0
- {ai_pipeline_core-0.1.12.dist-info → ai_pipeline_core-0.4.1.dist-info}/WHEEL +1 -1
- ai_pipeline_core/documents/document_list.py +0 -240
- ai_pipeline_core/documents/flow_document.py +0 -128
- ai_pipeline_core/documents/task_document.py +0 -133
- ai_pipeline_core/documents/temporary_document.py +0 -95
- ai_pipeline_core/flow/__init__.py +0 -9
- ai_pipeline_core/flow/config.py +0 -314
- ai_pipeline_core/flow/options.py +0 -75
- ai_pipeline_core/pipeline.py +0 -717
- ai_pipeline_core/prefect.py +0 -54
- ai_pipeline_core/simple_runner/__init__.py +0 -24
- ai_pipeline_core/simple_runner/cli.py +0 -255
- ai_pipeline_core/simple_runner/simple_runner.py +0 -385
- ai_pipeline_core/tracing.py +0 -475
- ai_pipeline_core-0.1.12.dist-info/METADATA +0 -450
- ai_pipeline_core-0.1.12.dist-info/RECORD +0 -36
- {ai_pipeline_core-0.1.12.dist-info → ai_pipeline_core-0.4.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"""Configuration options for LLM generation.
|
|
2
2
|
|
|
3
|
-
@public
|
|
4
|
-
|
|
5
3
|
Provides the ModelOptions class for configuring model behavior,
|
|
6
4
|
retry logic, and advanced features like web search and reasoning.
|
|
7
5
|
"""
|
|
@@ -12,9 +10,7 @@ from pydantic import BaseModel
|
|
|
12
10
|
|
|
13
11
|
|
|
14
12
|
class ModelOptions(BaseModel):
|
|
15
|
-
"""Configuration options for LLM generation requests.
|
|
16
|
-
|
|
17
|
-
@public
|
|
13
|
+
r"""Configuration options for LLM generation requests.
|
|
18
14
|
|
|
19
15
|
ModelOptions encapsulates all configuration parameters for model
|
|
20
16
|
generation, including model behavior settings, retry logic, and
|
|
@@ -45,9 +41,13 @@ class ModelOptions(BaseModel):
|
|
|
45
41
|
|
|
46
42
|
retries: Number of retry attempts on failure (default: 3).
|
|
47
43
|
|
|
48
|
-
retry_delay_seconds: Seconds to wait between retries (default:
|
|
44
|
+
retry_delay_seconds: Seconds to wait between retries (default: 20).
|
|
45
|
+
|
|
46
|
+
timeout: Maximum seconds to wait for response (default: 600).
|
|
49
47
|
|
|
50
|
-
|
|
48
|
+
cache_ttl: Cache TTL for context messages (default: "300s").
|
|
49
|
+
String format like "60s", "5m", or None to disable caching.
|
|
50
|
+
Applied to the last context message for efficient token reuse.
|
|
51
51
|
|
|
52
52
|
service_tier: API tier selection for performance/cost trade-offs.
|
|
53
53
|
"auto": Let API choose
|
|
@@ -62,40 +62,48 @@ class ModelOptions(BaseModel):
|
|
|
62
62
|
max_completion_tokens: Maximum tokens to generate.
|
|
63
63
|
None uses model default.
|
|
64
64
|
|
|
65
|
+
stop: Stop sequences that halt generation when encountered.
|
|
66
|
+
Can be a single string or list of strings.
|
|
67
|
+
When the model generates any of these sequences, it stops immediately.
|
|
68
|
+
Maximum of 4 stop sequences supported by most providers.
|
|
69
|
+
|
|
65
70
|
response_format: Pydantic model class for structured output.
|
|
66
71
|
Pass a Pydantic model; the client converts it to JSON Schema.
|
|
67
|
-
Set automatically by generate_structured().
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
72
|
+
Set automatically by generate_structured().
|
|
73
|
+
Structured output support varies by provider and model.
|
|
74
|
+
|
|
75
|
+
verbosity: Controls output verbosity for models that support it.
|
|
76
|
+
Literal["low", "medium", "high"] | None
|
|
77
|
+
"low": Minimal output
|
|
78
|
+
"medium": Standard output
|
|
79
|
+
"high": Detailed output
|
|
80
|
+
Note: Only some models support verbosity control.
|
|
81
|
+
|
|
82
|
+
usage_tracking: Enable token usage tracking in API responses (default: True).
|
|
83
|
+
When enabled, adds {"usage": {"include": True}} to extra_body.
|
|
84
|
+
Disable for providers that don't support usage tracking.
|
|
85
|
+
|
|
86
|
+
user: User identifier for cost tracking and monitoring.
|
|
87
|
+
A unique identifier representing the end-user, which can help track costs
|
|
88
|
+
and detect abuse. Maximum length is typically 256 characters.
|
|
89
|
+
Useful for multi-tenant applications or per-user billing.
|
|
90
|
+
|
|
91
|
+
metadata: Custom metadata tags for tracking and observability.
|
|
92
|
+
Dictionary of string key-value pairs for tagging requests.
|
|
93
|
+
Useful for tracking experiments, versions, or custom attributes.
|
|
94
|
+
Maximum of 16 key-value pairs, each key/value max 64 characters.
|
|
95
|
+
Passed through to LMNR tracing and API provider metadata.
|
|
96
|
+
|
|
97
|
+
extra_body: Additional provider-specific parameters to pass in request body.
|
|
98
|
+
Dictionary of custom parameters not covered by standard options.
|
|
99
|
+
Merged with usage_tracking if both are set.
|
|
100
|
+
Useful for beta features or provider-specific capabilities.
|
|
101
|
+
|
|
102
|
+
Not all options apply to all models. search_context_size only works with search models,
|
|
103
|
+
reasoning_effort only works with models that support explicit reasoning, and
|
|
104
|
+
response_format is set internally by generate_structured(). cache_ttl accepts formats
|
|
105
|
+
like "120s", "5m", "1h" or None (default: "300s"). Stop sequences are limited to 4 by
|
|
106
|
+
most providers.
|
|
99
107
|
"""
|
|
100
108
|
|
|
101
109
|
temperature: float | None = None
|
|
@@ -103,13 +111,21 @@ class ModelOptions(BaseModel):
|
|
|
103
111
|
search_context_size: Literal["low", "medium", "high"] | None = None
|
|
104
112
|
reasoning_effort: Literal["low", "medium", "high"] | None = None
|
|
105
113
|
retries: int = 3
|
|
106
|
-
retry_delay_seconds: int =
|
|
107
|
-
timeout: int =
|
|
114
|
+
retry_delay_seconds: int = 20
|
|
115
|
+
timeout: int = 600
|
|
116
|
+
cache_ttl: str | None = "300s"
|
|
108
117
|
service_tier: Literal["auto", "default", "flex", "scale", "priority"] | None = None
|
|
109
118
|
max_completion_tokens: int | None = None
|
|
119
|
+
stop: str | list[str] | None = None
|
|
110
120
|
response_format: type[BaseModel] | None = None
|
|
111
|
-
|
|
112
|
-
|
|
121
|
+
verbosity: Literal["low", "medium", "high"] | None = None
|
|
122
|
+
stream: bool = False
|
|
123
|
+
usage_tracking: bool = True
|
|
124
|
+
user: str | None = None
|
|
125
|
+
metadata: dict[str, str] | None = None
|
|
126
|
+
extra_body: dict[str, Any] | None = None
|
|
127
|
+
|
|
128
|
+
def to_openai_completion_kwargs(self) -> dict[str, Any]: # noqa: C901
|
|
113
129
|
"""Convert options to OpenAI API completion parameters.
|
|
114
130
|
|
|
115
131
|
Transforms ModelOptions fields into the format expected by
|
|
@@ -125,38 +141,42 @@ class ModelOptions(BaseModel):
|
|
|
125
141
|
API parameter mapping:
|
|
126
142
|
- temperature -> temperature
|
|
127
143
|
- max_completion_tokens -> max_completion_tokens
|
|
144
|
+
- stop -> stop (string or list of strings)
|
|
128
145
|
- reasoning_effort -> reasoning_effort
|
|
129
146
|
- search_context_size -> web_search_options.search_context_size
|
|
130
147
|
- response_format -> response_format
|
|
131
148
|
- service_tier -> service_tier
|
|
149
|
+
- verbosity -> verbosity
|
|
150
|
+
- user -> user (for cost tracking)
|
|
151
|
+
- metadata -> metadata (for tracking/observability)
|
|
152
|
+
- extra_body -> extra_body (merged with usage tracking)
|
|
132
153
|
|
|
133
154
|
Web Search Structure:
|
|
134
155
|
When search_context_size is set, creates:
|
|
135
156
|
{"web_search_options": {"search_context_size": "low|medium|high"}}
|
|
136
157
|
Non-search models silently ignore this parameter.
|
|
137
158
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
>>> kwargs
|
|
142
|
-
{'timeout': 60, 'extra_body': {}, 'temperature': 0.5}
|
|
143
|
-
|
|
144
|
-
Note:
|
|
145
|
-
- system_prompt is handled separately in _process_messages()
|
|
146
|
-
- retries and retry_delay_seconds are used by retry logic
|
|
147
|
-
- extra_body is always included for potential extensions
|
|
159
|
+
system_prompt is handled separately in _process_messages().
|
|
160
|
+
retries and retry_delay_seconds are used by retry logic.
|
|
161
|
+
extra_body always includes usage tracking for cost monitoring.
|
|
148
162
|
"""
|
|
149
163
|
kwargs: dict[str, Any] = {
|
|
150
164
|
"timeout": self.timeout,
|
|
151
165
|
"extra_body": {},
|
|
152
166
|
}
|
|
153
167
|
|
|
168
|
+
if self.extra_body:
|
|
169
|
+
kwargs["extra_body"] = self.extra_body
|
|
170
|
+
|
|
154
171
|
if self.temperature:
|
|
155
172
|
kwargs["temperature"] = self.temperature
|
|
156
173
|
|
|
157
174
|
if self.max_completion_tokens:
|
|
158
175
|
kwargs["max_completion_tokens"] = self.max_completion_tokens
|
|
159
176
|
|
|
177
|
+
if self.stop:
|
|
178
|
+
kwargs["stop"] = self.stop
|
|
179
|
+
|
|
160
180
|
if self.reasoning_effort:
|
|
161
181
|
kwargs["reasoning_effort"] = self.reasoning_effort
|
|
162
182
|
|
|
@@ -169,4 +189,17 @@ class ModelOptions(BaseModel):
|
|
|
169
189
|
if self.service_tier:
|
|
170
190
|
kwargs["service_tier"] = self.service_tier
|
|
171
191
|
|
|
192
|
+
if self.verbosity:
|
|
193
|
+
kwargs["verbosity"] = self.verbosity
|
|
194
|
+
|
|
195
|
+
if self.user:
|
|
196
|
+
kwargs["user"] = self.user
|
|
197
|
+
|
|
198
|
+
if self.metadata:
|
|
199
|
+
kwargs["metadata"] = self.metadata
|
|
200
|
+
|
|
201
|
+
if self.usage_tracking:
|
|
202
|
+
kwargs["extra_body"]["usage"] = {"include": True}
|
|
203
|
+
kwargs["stream_options"] = {"include_usage": True}
|
|
204
|
+
|
|
172
205
|
return kwargs
|