ai-pipeline-core 0.3.0__py3-none-any.whl → 0.3.4__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.
@@ -59,7 +59,7 @@ Quick Start:
59
59
  ... ) -> DocumentList:
60
60
  ... # Messages accept AIMessages or str. Wrap documents: AIMessages([doc])
61
61
  ... response = await llm.generate(
62
- ... "gpt-5",
62
+ ... "gpt-5.1",
63
63
  ... messages=AIMessages([documents[0]])
64
64
  ... )
65
65
  ... result = OutputDoc.create(
@@ -82,6 +82,26 @@ Optional Environment Variables:
82
82
  - LMNR_DEBUG: Set to "true" to enable debug-level traces
83
83
  """
84
84
 
85
+ import os
86
+ import sys
87
+
88
+ # Disable Prefect's built-in OpenTelemetry spans to prevent duplicates.
89
+ # All tracing is handled by our @trace decorator and Laminar SDK.
90
+ # Must be set before Prefect is imported by submodules below.
91
+ os.environ.setdefault("PREFECT_CLOUD_ENABLE_ORCHESTRATION_TELEMETRY", "false")
92
+
93
+ # If Prefect was already imported (user imported it before us), refresh its cached settings.
94
+ if "prefect" in sys.modules:
95
+ try:
96
+ from prefect.settings import get_current_settings # noqa: PLC0415
97
+
98
+ if get_current_settings().cloud.enable_orchestration_telemetry:
99
+ from prefect.context import refresh_global_settings_context # noqa: PLC0415
100
+
101
+ refresh_global_settings_context()
102
+ except (ImportError, AttributeError):
103
+ pass
104
+
85
105
  from . import llm, progress
86
106
  from .deployment import DeploymentContext, DeploymentResult, PipelineDeployment
87
107
  from .documents import (
@@ -95,6 +115,15 @@ from .documents import (
95
115
  sanitize_url,
96
116
  )
97
117
  from .flow import FlowConfig, FlowOptions
118
+ from .images import (
119
+ ImagePart,
120
+ ImagePreset,
121
+ ImageProcessingConfig,
122
+ ImageProcessingError,
123
+ ProcessedImage,
124
+ process_image,
125
+ process_image_to_documents,
126
+ )
98
127
  from .llm import (
99
128
  AIMessages,
100
129
  AIMessageType,
@@ -121,7 +150,7 @@ from .settings import Settings
121
150
  from .tracing import TraceInfo, TraceLevel, set_trace_cost, trace
122
151
  from .utils.remote_deployment import remote_deployment
123
152
 
124
- __version__ = "0.3.0"
153
+ __version__ = "0.3.4"
125
154
 
126
155
  __all__ = [
127
156
  # Config/Settings
@@ -175,6 +204,14 @@ __all__ = [
175
204
  # Prompt Builder
176
205
  "PromptBuilder",
177
206
  "EnvironmentVariable",
207
+ # Images
208
+ "process_image",
209
+ "process_image_to_documents",
210
+ "ImagePreset",
211
+ "ImageProcessingConfig",
212
+ "ProcessedImage",
213
+ "ImagePart",
214
+ "ImageProcessingError",
178
215
  # Utils
179
216
  "PromptManager",
180
217
  ]
@@ -0,0 +1,26 @@
1
+ """Local trace debugging system for AI pipelines.
2
+
3
+ This module provides filesystem-based trace debugging that saves all spans
4
+ with their inputs/outputs for LLM-assisted debugging.
5
+
6
+ Enable by setting TRACE_DEBUG_PATH environment variable.
7
+ """
8
+
9
+ from .config import TraceDebugConfig
10
+ from .content import ArtifactStore, ContentRef, ContentWriter, reconstruct_span_content
11
+ from .processor import LocalDebugSpanProcessor
12
+ from .summary import generate_summary
13
+ from .writer import LocalTraceWriter, TraceState, WriteJob
14
+
15
+ __all__ = [
16
+ "TraceDebugConfig",
17
+ "ContentRef",
18
+ "ContentWriter",
19
+ "ArtifactStore",
20
+ "reconstruct_span_content",
21
+ "LocalDebugSpanProcessor",
22
+ "LocalTraceWriter",
23
+ "TraceState",
24
+ "WriteJob",
25
+ "generate_summary",
26
+ ]
@@ -0,0 +1,91 @@
1
+ """Configuration for local trace debugging."""
2
+
3
+ from pathlib import Path
4
+
5
+ from pydantic import BaseModel, ConfigDict, Field
6
+
7
+
8
+ class TraceDebugConfig(BaseModel):
9
+ """Configuration for local trace debugging.
10
+
11
+ Controls how traces are written to the local filesystem for debugging.
12
+ Enable by setting TRACE_DEBUG_PATH environment variable.
13
+ """
14
+
15
+ model_config = ConfigDict(frozen=True)
16
+
17
+ path: Path = Field(description="Directory for debug traces")
18
+ enabled: bool = Field(default=True, description="Whether debug tracing is enabled")
19
+
20
+ # Content size limits (Issue #2)
21
+ max_file_bytes: int = Field(
22
+ default=50_000,
23
+ description="Max bytes for input.yaml or output.yaml. Elements externalized to stay under.",
24
+ )
25
+ max_element_bytes: int = Field(
26
+ default=10_000,
27
+ description="Max bytes for single element. Above this, partial + artifact ref.",
28
+ )
29
+ element_excerpt_bytes: int = Field(
30
+ default=2_000,
31
+ description="Bytes of content to keep inline when element exceeds max_element_bytes.",
32
+ )
33
+ max_content_bytes: int = Field(
34
+ default=10_000_000,
35
+ description="Max bytes for any single artifact. Above this, truncate.",
36
+ )
37
+
38
+ # Image handling (Issue #7 - no changes per user)
39
+ extract_base64_images: bool = Field(
40
+ default=True,
41
+ description="Extract base64 images to artifact files",
42
+ )
43
+
44
+ # Span optimization (Issue #4)
45
+ merge_wrapper_spans: bool = Field(
46
+ default=True,
47
+ description="Merge Prefect wrapper spans with inner traced function spans",
48
+ )
49
+
50
+ # Events (Issue #12)
51
+ events_file_mode: str = Field(
52
+ default="errors_only",
53
+ description="When to write events.yaml: 'all', 'errors_only', 'none'",
54
+ )
55
+
56
+ # Indexes (Issue #1)
57
+ include_llm_index: bool = Field(
58
+ default=True,
59
+ description="Generate _llm_calls.yaml with LLM-specific details",
60
+ )
61
+ include_error_index: bool = Field(
62
+ default=True,
63
+ description="Generate _errors.yaml with failed span details",
64
+ )
65
+
66
+ # Cleanup
67
+ max_traces: int | None = Field(
68
+ default=None,
69
+ description="Max number of traces to keep. None for unlimited.",
70
+ )
71
+
72
+ # Security - default redaction patterns for common secrets
73
+ redact_patterns: tuple[str, ...] = Field(
74
+ default=(
75
+ r"sk-[a-zA-Z0-9]{20,}", # OpenAI API keys
76
+ r"sk-proj-[a-zA-Z0-9\-_]{20,}", # OpenAI project keys
77
+ r"AKIA[0-9A-Z]{16}", # AWS access keys
78
+ r"ghp_[a-zA-Z0-9]{36}", # GitHub personal tokens
79
+ r"gho_[a-zA-Z0-9]{36}", # GitHub OAuth tokens
80
+ r"xoxb-[a-zA-Z0-9\-]+", # Slack bot tokens
81
+ r"xoxp-[a-zA-Z0-9\-]+", # Slack user tokens
82
+ r"(?i)password\s*[:=]\s*['\"]?[^\s'\"]+", # Passwords
83
+ r"(?i)secret\s*[:=]\s*['\"]?[^\s'\"]+", # Secrets
84
+ r"(?i)api[_\-]?key\s*[:=]\s*['\"]?[^\s'\"]+", # API keys
85
+ r"(?i)bearer\s+[a-zA-Z0-9\-_\.]+", # Bearer tokens
86
+ ),
87
+ description="Regex patterns for secrets to redact",
88
+ )
89
+
90
+ # Summary
91
+ generate_summary: bool = Field(default=True, description="Generate _summary.md")