ai-pipeline-core 0.1.7__tar.gz → 0.1.8__tar.gz
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-0.1.7 → ai_pipeline_core-0.1.8}/PKG-INFO +51 -34
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/README.md +50 -33
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/__init__.py +5 -5
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/documents/document.py +16 -1
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/flow/config.py +21 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/llm/model_options.py +4 -0
- ai_pipeline_core-0.1.8/ai_pipeline_core/pipeline.py +414 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/simple_runner/cli.py +43 -11
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/pyproject.toml +8 -4
- ai_pipeline_core-0.1.7/ai_pipeline_core/pipeline.py +0 -418
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/.gitignore +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/LICENSE +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/documents/__init__.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/documents/document_list.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/documents/flow_document.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/documents/mime_type.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/documents/task_document.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/documents/utils.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/exceptions.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/flow/__init__.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/flow/options.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/llm/__init__.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/llm/ai_messages.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/llm/client.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/llm/model_response.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/llm/model_types.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/logging/__init__.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/logging/logging.yml +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/logging/logging_config.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/logging/logging_mixin.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/prefect.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/prompt_manager.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/py.typed +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/settings.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/simple_runner/__init__.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/simple_runner/simple_runner.py +0 -0
- {ai_pipeline_core-0.1.7 → ai_pipeline_core-0.1.8}/ai_pipeline_core/tracing.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ai-pipeline-core
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.8
|
|
4
4
|
Summary: Core utilities for AI-powered processing pipelines using prefect
|
|
5
5
|
Project-URL: Homepage, https://github.com/bbarwik/ai-pipeline-core
|
|
6
6
|
Project-URL: Repository, https://github.com/bbarwik/ai-pipeline-core
|
|
@@ -151,7 +151,7 @@ async def process_document(doc: Document):
|
|
|
151
151
|
return response.parsed
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
-
### Enhanced Pipeline Decorators
|
|
154
|
+
### Enhanced Pipeline Decorators
|
|
155
155
|
```python
|
|
156
156
|
from ai_pipeline_core import pipeline_flow, pipeline_task
|
|
157
157
|
from ai_pipeline_core.flow import FlowOptions
|
|
@@ -182,7 +182,7 @@ async def my_pipeline(
|
|
|
182
182
|
return DocumentList(results)
|
|
183
183
|
```
|
|
184
184
|
|
|
185
|
-
### Simple Runner Utility
|
|
185
|
+
### Simple Runner Utility
|
|
186
186
|
```python
|
|
187
187
|
from ai_pipeline_core.simple_runner import run_cli, run_pipeline
|
|
188
188
|
from ai_pipeline_core.flow import FlowOptions
|
|
@@ -206,7 +206,7 @@ async def main():
|
|
|
206
206
|
)
|
|
207
207
|
```
|
|
208
208
|
|
|
209
|
-
### Clean Prefect Decorators
|
|
209
|
+
### Clean Prefect Decorators
|
|
210
210
|
```python
|
|
211
211
|
# Import clean Prefect decorators without tracing
|
|
212
212
|
from ai_pipeline_core.prefect import flow, task
|
|
@@ -214,12 +214,12 @@ from ai_pipeline_core.prefect import flow, task
|
|
|
214
214
|
# Or use pipeline decorators with tracing
|
|
215
215
|
from ai_pipeline_core import pipeline_flow, pipeline_task
|
|
216
216
|
|
|
217
|
-
@task # Clean Prefect task
|
|
217
|
+
@task # Clean Prefect task (supports both sync and async)
|
|
218
218
|
def compute(x: int) -> int:
|
|
219
219
|
return x * 2
|
|
220
220
|
|
|
221
|
-
@pipeline_task(trace_level="always") # With tracing
|
|
222
|
-
def compute_traced(x: int) -> int:
|
|
221
|
+
@pipeline_task(trace_level="always") # With tracing (async only)
|
|
222
|
+
async def compute_traced(x: int) -> int:
|
|
223
223
|
return x * 2
|
|
224
224
|
```
|
|
225
225
|
|
|
@@ -246,12 +246,12 @@ docs = DocumentList([doc1, doc2])
|
|
|
246
246
|
Managed AI interactions with built-in retry logic, cost tracking, and structured outputs.
|
|
247
247
|
|
|
248
248
|
**Supported Models** (via LiteLLM proxy):
|
|
249
|
-
- OpenAI:
|
|
250
|
-
- Anthropic:
|
|
251
|
-
- Google:
|
|
252
|
-
- xAI:
|
|
253
|
-
- Perplexity:
|
|
254
|
-
- And many more through LiteLLM compatibility
|
|
249
|
+
- OpenAI: gpt-5
|
|
250
|
+
- Anthropic: claude-4
|
|
251
|
+
- Google: gemini-2.5
|
|
252
|
+
- xAI: grok-3, grok-4
|
|
253
|
+
- Perplexity: sonar-pro-search
|
|
254
|
+
- And many more through LiteLLM compatibility. Every model from openrouter should work.
|
|
255
255
|
|
|
256
256
|
```python
|
|
257
257
|
from ai_pipeline_core.llm import generate_structured, AIMessages, ModelOptions
|
|
@@ -328,13 +328,13 @@ ai_pipeline_core/
|
|
|
328
328
|
│ └── model_options.py # Configuration models
|
|
329
329
|
├── flow/ # Prefect flow utilities
|
|
330
330
|
│ ├── config.py # Type-safe flow configuration
|
|
331
|
-
│ └── options.py # FlowOptions base class
|
|
332
|
-
├── simple_runner/ # Pipeline execution utilities
|
|
331
|
+
│ └── options.py # FlowOptions base class
|
|
332
|
+
├── simple_runner/ # Pipeline execution utilities
|
|
333
333
|
│ ├── cli.py # CLI interface
|
|
334
334
|
│ └── simple_runner.py # Core runner logic
|
|
335
335
|
├── logging/ # Structured logging
|
|
336
|
-
├── pipeline.py # Enhanced decorators
|
|
337
|
-
├── prefect.py # Clean Prefect exports
|
|
336
|
+
├── pipeline.py # Enhanced decorators
|
|
337
|
+
├── prefect.py # Clean Prefect exports
|
|
338
338
|
├── tracing.py # Observability decorators
|
|
339
339
|
└── settings.py # Centralized configuration
|
|
340
340
|
```
|
|
@@ -345,6 +345,7 @@ ai_pipeline_core/
|
|
|
345
345
|
```bash
|
|
346
346
|
make test # Run all tests
|
|
347
347
|
make test-cov # Run with coverage report
|
|
348
|
+
make test-showcase # Test the showcase.py CLI example
|
|
348
349
|
pytest tests/test_documents.py::TestDocument::test_creation # Single test
|
|
349
350
|
```
|
|
350
351
|
|
|
@@ -481,6 +482,22 @@ For learning purposes, see [CLAUDE.md](CLAUDE.md) for our comprehensive coding s
|
|
|
481
482
|
|
|
482
483
|
- [CLAUDE.md](CLAUDE.md) - Detailed coding standards and architecture guide
|
|
483
484
|
|
|
485
|
+
## Examples
|
|
486
|
+
|
|
487
|
+
### In This Repository
|
|
488
|
+
- [showcase.py](examples/showcase.py) - Complete example demonstrating all core features including the CLI runner
|
|
489
|
+
```bash
|
|
490
|
+
# Run the showcase example with CLI
|
|
491
|
+
python examples/showcase.py ./output --temperature 0.7 --batch-size 5
|
|
492
|
+
|
|
493
|
+
# Show help
|
|
494
|
+
python examples/showcase.py --help
|
|
495
|
+
```
|
|
496
|
+
- [showcase.jinja2](examples/showcase.jinja2) - Example Jinja2 prompt template
|
|
497
|
+
|
|
498
|
+
### Real-World Application
|
|
499
|
+
- [AI Documentation Writer](https://github.com/bbarwik/ai-documentation-writer) - Production-ready example showing how to build sophisticated AI pipelines for automated documentation generation. See [examples/ai-documentation-writer.md](examples/ai-documentation-writer.md) for a detailed overview.
|
|
500
|
+
|
|
484
501
|
### dependencies_docs/ Directory
|
|
485
502
|
> [!NOTE]
|
|
486
503
|
> The `dependencies_docs/` directory contains guides for AI assistants (like Claude Code) on how to interact with the project's external dependencies and tooling, NOT user documentation for ai-pipeline-core itself. These files are excluded from repository listings to avoid confusion.
|
|
@@ -511,29 +528,29 @@ Built with:
|
|
|
511
528
|
- [LiteLLM](https://litellm.ai/) - LLM proxy
|
|
512
529
|
- [Pydantic](https://pydantic-docs.helpmanual.io/) - Data validation
|
|
513
530
|
|
|
514
|
-
## What's New in v0.1.
|
|
531
|
+
## What's New in v0.1.8
|
|
515
532
|
|
|
516
|
-
###
|
|
517
|
-
- **
|
|
518
|
-
- **
|
|
519
|
-
- **
|
|
520
|
-
- **
|
|
521
|
-
- **Expanded Exports**: All major components now accessible from top-level package import
|
|
533
|
+
### Breaking Changes
|
|
534
|
+
- **Async-Only Pipeline Decorators**: `@pipeline_flow` and `@pipeline_task` now require `async def` functions (raises TypeError for sync)
|
|
535
|
+
- **Document Class Name Validation**: Document subclasses cannot start with "Test" prefix (pytest conflict prevention)
|
|
536
|
+
- **FlowConfig Validation**: OUTPUT_DOCUMENT_TYPE cannot be in INPUT_DOCUMENT_TYPES (prevents circular dependencies)
|
|
537
|
+
- **Temperature Field**: Added optional `temperature` field to `ModelOptions` for explicit control
|
|
522
538
|
|
|
523
|
-
###
|
|
524
|
-
-
|
|
525
|
-
-
|
|
526
|
-
-
|
|
527
|
-
-
|
|
539
|
+
### Major Improvements
|
|
540
|
+
- **Pipeline Module Refactoring**: Reduced from ~400 to ~150 lines with cleaner Protocol-based typing
|
|
541
|
+
- **Enhanced Validation**: FlowConfig and Document classes now validate at definition time
|
|
542
|
+
- **Better CLI Support**: Auto-displays help when no arguments provided, improved context management
|
|
543
|
+
- **Test Suite Updates**: All tests updated to use async/await consistently
|
|
528
544
|
|
|
529
|
-
###
|
|
530
|
-
-
|
|
531
|
-
-
|
|
532
|
-
-
|
|
545
|
+
### Documentation Updates
|
|
546
|
+
- Added Document naming rules to CLAUDE.md
|
|
547
|
+
- Added FlowConfig validation rules
|
|
548
|
+
- Added code elegance principles section
|
|
549
|
+
- Updated guide_for_ai.md to API reference format
|
|
533
550
|
|
|
534
551
|
## Stability Notice
|
|
535
552
|
|
|
536
|
-
**Current Version**: 0.1.
|
|
553
|
+
**Current Version**: 0.1.8
|
|
537
554
|
**Status**: Internal Preview
|
|
538
555
|
**API Stability**: Unstable - Breaking changes expected
|
|
539
556
|
**Recommended Use**: Learning and reference only
|
|
@@ -109,7 +109,7 @@ async def process_document(doc: Document):
|
|
|
109
109
|
return response.parsed
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
-
### Enhanced Pipeline Decorators
|
|
112
|
+
### Enhanced Pipeline Decorators
|
|
113
113
|
```python
|
|
114
114
|
from ai_pipeline_core import pipeline_flow, pipeline_task
|
|
115
115
|
from ai_pipeline_core.flow import FlowOptions
|
|
@@ -140,7 +140,7 @@ async def my_pipeline(
|
|
|
140
140
|
return DocumentList(results)
|
|
141
141
|
```
|
|
142
142
|
|
|
143
|
-
### Simple Runner Utility
|
|
143
|
+
### Simple Runner Utility
|
|
144
144
|
```python
|
|
145
145
|
from ai_pipeline_core.simple_runner import run_cli, run_pipeline
|
|
146
146
|
from ai_pipeline_core.flow import FlowOptions
|
|
@@ -164,7 +164,7 @@ async def main():
|
|
|
164
164
|
)
|
|
165
165
|
```
|
|
166
166
|
|
|
167
|
-
### Clean Prefect Decorators
|
|
167
|
+
### Clean Prefect Decorators
|
|
168
168
|
```python
|
|
169
169
|
# Import clean Prefect decorators without tracing
|
|
170
170
|
from ai_pipeline_core.prefect import flow, task
|
|
@@ -172,12 +172,12 @@ from ai_pipeline_core.prefect import flow, task
|
|
|
172
172
|
# Or use pipeline decorators with tracing
|
|
173
173
|
from ai_pipeline_core import pipeline_flow, pipeline_task
|
|
174
174
|
|
|
175
|
-
@task # Clean Prefect task
|
|
175
|
+
@task # Clean Prefect task (supports both sync and async)
|
|
176
176
|
def compute(x: int) -> int:
|
|
177
177
|
return x * 2
|
|
178
178
|
|
|
179
|
-
@pipeline_task(trace_level="always") # With tracing
|
|
180
|
-
def compute_traced(x: int) -> int:
|
|
179
|
+
@pipeline_task(trace_level="always") # With tracing (async only)
|
|
180
|
+
async def compute_traced(x: int) -> int:
|
|
181
181
|
return x * 2
|
|
182
182
|
```
|
|
183
183
|
|
|
@@ -204,12 +204,12 @@ docs = DocumentList([doc1, doc2])
|
|
|
204
204
|
Managed AI interactions with built-in retry logic, cost tracking, and structured outputs.
|
|
205
205
|
|
|
206
206
|
**Supported Models** (via LiteLLM proxy):
|
|
207
|
-
- OpenAI:
|
|
208
|
-
- Anthropic:
|
|
209
|
-
- Google:
|
|
210
|
-
- xAI:
|
|
211
|
-
- Perplexity:
|
|
212
|
-
- And many more through LiteLLM compatibility
|
|
207
|
+
- OpenAI: gpt-5
|
|
208
|
+
- Anthropic: claude-4
|
|
209
|
+
- Google: gemini-2.5
|
|
210
|
+
- xAI: grok-3, grok-4
|
|
211
|
+
- Perplexity: sonar-pro-search
|
|
212
|
+
- And many more through LiteLLM compatibility. Every model from openrouter should work.
|
|
213
213
|
|
|
214
214
|
```python
|
|
215
215
|
from ai_pipeline_core.llm import generate_structured, AIMessages, ModelOptions
|
|
@@ -286,13 +286,13 @@ ai_pipeline_core/
|
|
|
286
286
|
│ └── model_options.py # Configuration models
|
|
287
287
|
├── flow/ # Prefect flow utilities
|
|
288
288
|
│ ├── config.py # Type-safe flow configuration
|
|
289
|
-
│ └── options.py # FlowOptions base class
|
|
290
|
-
├── simple_runner/ # Pipeline execution utilities
|
|
289
|
+
│ └── options.py # FlowOptions base class
|
|
290
|
+
├── simple_runner/ # Pipeline execution utilities
|
|
291
291
|
│ ├── cli.py # CLI interface
|
|
292
292
|
│ └── simple_runner.py # Core runner logic
|
|
293
293
|
├── logging/ # Structured logging
|
|
294
|
-
├── pipeline.py # Enhanced decorators
|
|
295
|
-
├── prefect.py # Clean Prefect exports
|
|
294
|
+
├── pipeline.py # Enhanced decorators
|
|
295
|
+
├── prefect.py # Clean Prefect exports
|
|
296
296
|
├── tracing.py # Observability decorators
|
|
297
297
|
└── settings.py # Centralized configuration
|
|
298
298
|
```
|
|
@@ -303,6 +303,7 @@ ai_pipeline_core/
|
|
|
303
303
|
```bash
|
|
304
304
|
make test # Run all tests
|
|
305
305
|
make test-cov # Run with coverage report
|
|
306
|
+
make test-showcase # Test the showcase.py CLI example
|
|
306
307
|
pytest tests/test_documents.py::TestDocument::test_creation # Single test
|
|
307
308
|
```
|
|
308
309
|
|
|
@@ -439,6 +440,22 @@ For learning purposes, see [CLAUDE.md](CLAUDE.md) for our comprehensive coding s
|
|
|
439
440
|
|
|
440
441
|
- [CLAUDE.md](CLAUDE.md) - Detailed coding standards and architecture guide
|
|
441
442
|
|
|
443
|
+
## Examples
|
|
444
|
+
|
|
445
|
+
### In This Repository
|
|
446
|
+
- [showcase.py](examples/showcase.py) - Complete example demonstrating all core features including the CLI runner
|
|
447
|
+
```bash
|
|
448
|
+
# Run the showcase example with CLI
|
|
449
|
+
python examples/showcase.py ./output --temperature 0.7 --batch-size 5
|
|
450
|
+
|
|
451
|
+
# Show help
|
|
452
|
+
python examples/showcase.py --help
|
|
453
|
+
```
|
|
454
|
+
- [showcase.jinja2](examples/showcase.jinja2) - Example Jinja2 prompt template
|
|
455
|
+
|
|
456
|
+
### Real-World Application
|
|
457
|
+
- [AI Documentation Writer](https://github.com/bbarwik/ai-documentation-writer) - Production-ready example showing how to build sophisticated AI pipelines for automated documentation generation. See [examples/ai-documentation-writer.md](examples/ai-documentation-writer.md) for a detailed overview.
|
|
458
|
+
|
|
442
459
|
### dependencies_docs/ Directory
|
|
443
460
|
> [!NOTE]
|
|
444
461
|
> The `dependencies_docs/` directory contains guides for AI assistants (like Claude Code) on how to interact with the project's external dependencies and tooling, NOT user documentation for ai-pipeline-core itself. These files are excluded from repository listings to avoid confusion.
|
|
@@ -469,29 +486,29 @@ Built with:
|
|
|
469
486
|
- [LiteLLM](https://litellm.ai/) - LLM proxy
|
|
470
487
|
- [Pydantic](https://pydantic-docs.helpmanual.io/) - Data validation
|
|
471
488
|
|
|
472
|
-
## What's New in v0.1.
|
|
489
|
+
## What's New in v0.1.8
|
|
473
490
|
|
|
474
|
-
###
|
|
475
|
-
- **
|
|
476
|
-
- **
|
|
477
|
-
- **
|
|
478
|
-
- **
|
|
479
|
-
- **Expanded Exports**: All major components now accessible from top-level package import
|
|
491
|
+
### Breaking Changes
|
|
492
|
+
- **Async-Only Pipeline Decorators**: `@pipeline_flow` and `@pipeline_task` now require `async def` functions (raises TypeError for sync)
|
|
493
|
+
- **Document Class Name Validation**: Document subclasses cannot start with "Test" prefix (pytest conflict prevention)
|
|
494
|
+
- **FlowConfig Validation**: OUTPUT_DOCUMENT_TYPE cannot be in INPUT_DOCUMENT_TYPES (prevents circular dependencies)
|
|
495
|
+
- **Temperature Field**: Added optional `temperature` field to `ModelOptions` for explicit control
|
|
480
496
|
|
|
481
|
-
###
|
|
482
|
-
-
|
|
483
|
-
-
|
|
484
|
-
-
|
|
485
|
-
-
|
|
497
|
+
### Major Improvements
|
|
498
|
+
- **Pipeline Module Refactoring**: Reduced from ~400 to ~150 lines with cleaner Protocol-based typing
|
|
499
|
+
- **Enhanced Validation**: FlowConfig and Document classes now validate at definition time
|
|
500
|
+
- **Better CLI Support**: Auto-displays help when no arguments provided, improved context management
|
|
501
|
+
- **Test Suite Updates**: All tests updated to use async/await consistently
|
|
486
502
|
|
|
487
|
-
###
|
|
488
|
-
-
|
|
489
|
-
-
|
|
490
|
-
-
|
|
503
|
+
### Documentation Updates
|
|
504
|
+
- Added Document naming rules to CLAUDE.md
|
|
505
|
+
- Added FlowConfig validation rules
|
|
506
|
+
- Added code elegance principles section
|
|
507
|
+
- Updated guide_for_ai.md to API reference format
|
|
491
508
|
|
|
492
509
|
## Stability Notice
|
|
493
510
|
|
|
494
|
-
**Current Version**: 0.1.
|
|
511
|
+
**Current Version**: 0.1.8
|
|
495
512
|
**Status**: Internal Preview
|
|
496
513
|
**API Stability**: Unstable - Breaking changes expected
|
|
497
514
|
**Recommended Use**: Learning and reference only
|
|
@@ -27,12 +27,12 @@ from .logging import (
|
|
|
27
27
|
)
|
|
28
28
|
from .logging import get_pipeline_logger as get_logger
|
|
29
29
|
from .pipeline import pipeline_flow, pipeline_task
|
|
30
|
-
from .prefect import
|
|
30
|
+
from .prefect import disable_run_logger, prefect_test_harness
|
|
31
31
|
from .prompt_manager import PromptManager
|
|
32
32
|
from .settings import settings
|
|
33
33
|
from .tracing import TraceInfo, TraceLevel, trace
|
|
34
34
|
|
|
35
|
-
__version__ = "0.1.
|
|
35
|
+
__version__ = "0.1.8"
|
|
36
36
|
|
|
37
37
|
__all__ = [
|
|
38
38
|
# Config/Settings
|
|
@@ -54,12 +54,12 @@ __all__ = [
|
|
|
54
54
|
# Flow/Task
|
|
55
55
|
"FlowConfig",
|
|
56
56
|
"FlowOptions",
|
|
57
|
-
# Prefect decorators (clean, no tracing)
|
|
58
|
-
"task",
|
|
59
|
-
"flow",
|
|
60
57
|
# Pipeline decorators (with tracing)
|
|
61
58
|
"pipeline_task",
|
|
62
59
|
"pipeline_flow",
|
|
60
|
+
# Prefect decorators (clean, no tracing)
|
|
61
|
+
"prefect_test_harness",
|
|
62
|
+
"disable_run_logger",
|
|
63
63
|
# LLM
|
|
64
64
|
"llm",
|
|
65
65
|
"ModelName",
|
|
@@ -26,12 +26,27 @@ TModel = TypeVar("TModel", bound=BaseModel)
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
class Document(BaseModel, ABC):
|
|
29
|
-
"""Abstract base class for all documents
|
|
29
|
+
"""Abstract base class for all documents.
|
|
30
|
+
|
|
31
|
+
Warning: Document subclasses should NOT start with 'Test' prefix as this
|
|
32
|
+
causes conflicts with pytest test discovery. Classes with 'Test' prefix
|
|
33
|
+
will be rejected at definition time.
|
|
34
|
+
"""
|
|
30
35
|
|
|
31
36
|
MAX_CONTENT_SIZE: ClassVar[int] = 25 * 1024 * 1024 # 25MB default
|
|
32
37
|
DESCRIPTION_EXTENSION: ClassVar[str] = ".description.md"
|
|
33
38
|
MARKDOWN_LIST_SEPARATOR: ClassVar[str] = "\n\n---\n\n"
|
|
34
39
|
|
|
40
|
+
def __init_subclass__(cls, **kwargs: Any) -> None:
|
|
41
|
+
"""Validate subclass names to prevent pytest conflicts."""
|
|
42
|
+
super().__init_subclass__(**kwargs)
|
|
43
|
+
if cls.__name__.startswith("Test"):
|
|
44
|
+
raise TypeError(
|
|
45
|
+
f"Document subclass '{cls.__name__}' cannot start with 'Test' prefix. "
|
|
46
|
+
"This causes conflicts with pytest test discovery. "
|
|
47
|
+
"Please use a different name (e.g., 'SampleDocument', 'ExampleDocument')."
|
|
48
|
+
)
|
|
49
|
+
|
|
35
50
|
def __init__(self, **data: Any) -> None:
|
|
36
51
|
"""Prevent direct instantiation of abstract Document class."""
|
|
37
52
|
if type(self) is Document:
|
|
@@ -14,6 +14,27 @@ class FlowConfig(ABC):
|
|
|
14
14
|
INPUT_DOCUMENT_TYPES: ClassVar[list[type[FlowDocument]]]
|
|
15
15
|
OUTPUT_DOCUMENT_TYPE: ClassVar[type[FlowDocument]]
|
|
16
16
|
|
|
17
|
+
def __init_subclass__(cls, **kwargs):
|
|
18
|
+
"""Validate that OUTPUT_DOCUMENT_TYPE is not in INPUT_DOCUMENT_TYPES."""
|
|
19
|
+
super().__init_subclass__(**kwargs)
|
|
20
|
+
|
|
21
|
+
# Skip validation for the abstract base class itself
|
|
22
|
+
if cls.__name__ == "FlowConfig":
|
|
23
|
+
return
|
|
24
|
+
|
|
25
|
+
# Ensure required attributes are defined
|
|
26
|
+
if not hasattr(cls, "INPUT_DOCUMENT_TYPES"):
|
|
27
|
+
raise TypeError(f"FlowConfig {cls.__name__} must define INPUT_DOCUMENT_TYPES")
|
|
28
|
+
if not hasattr(cls, "OUTPUT_DOCUMENT_TYPE"):
|
|
29
|
+
raise TypeError(f"FlowConfig {cls.__name__} must define OUTPUT_DOCUMENT_TYPE")
|
|
30
|
+
|
|
31
|
+
# Validate that output type is not in input types
|
|
32
|
+
if cls.OUTPUT_DOCUMENT_TYPE in cls.INPUT_DOCUMENT_TYPES:
|
|
33
|
+
raise TypeError(
|
|
34
|
+
f"FlowConfig {cls.__name__}: OUTPUT_DOCUMENT_TYPE "
|
|
35
|
+
f"({cls.OUTPUT_DOCUMENT_TYPE.__name__}) cannot be in INPUT_DOCUMENT_TYPES"
|
|
36
|
+
)
|
|
37
|
+
|
|
17
38
|
@classmethod
|
|
18
39
|
def get_input_document_types(cls) -> list[type[FlowDocument]]:
|
|
19
40
|
"""
|
|
@@ -4,6 +4,7 @@ from pydantic import BaseModel
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class ModelOptions(BaseModel):
|
|
7
|
+
temperature: float | None = None
|
|
7
8
|
system_prompt: str | None = None
|
|
8
9
|
search_context_size: Literal["low", "medium", "high"] | None = None
|
|
9
10
|
reasoning_effort: Literal["low", "medium", "high"] | None = None
|
|
@@ -21,6 +22,9 @@ class ModelOptions(BaseModel):
|
|
|
21
22
|
"extra_body": {},
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
if self.temperature:
|
|
26
|
+
kwargs["temperature"] = self.temperature
|
|
27
|
+
|
|
24
28
|
if self.max_completion_tokens:
|
|
25
29
|
kwargs["max_completion_tokens"] = self.max_completion_tokens
|
|
26
30
|
|