ai-pipeline-core 0.1.2__tar.gz → 0.1.3__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.
Files changed (30) hide show
  1. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/PKG-INFO +1 -1
  2. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/documents/document.py +27 -6
  3. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/llm/client.py +1 -1
  4. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/pyproject.toml +2 -2
  5. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/.gitignore +0 -0
  6. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/LICENSE +0 -0
  7. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/README.md +0 -0
  8. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/__init__.py +0 -0
  9. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/documents/__init__.py +0 -0
  10. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/documents/document_list.py +0 -0
  11. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/documents/flow_document.py +0 -0
  12. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/documents/mime_type.py +0 -0
  13. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/documents/task_document.py +0 -0
  14. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/documents/utils.py +0 -0
  15. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/exceptions.py +0 -0
  16. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/flow/__init__.py +0 -0
  17. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/flow/config.py +0 -0
  18. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/llm/__init__.py +0 -0
  19. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/llm/ai_messages.py +0 -0
  20. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/llm/model_options.py +0 -0
  21. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/llm/model_response.py +0 -0
  22. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/llm/model_types.py +0 -0
  23. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/logging/__init__.py +0 -0
  24. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/logging/logging.yml +0 -0
  25. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/logging/logging_config.py +0 -0
  26. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/logging/logging_mixin.py +0 -0
  27. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/prompt_manager.py +0 -0
  28. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/py.typed +0 -0
  29. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/ai_pipeline_core/settings.py +0 -0
  30. {ai_pipeline_core-0.1.2 → ai_pipeline_core-0.1.3}/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.2
3
+ Version: 0.1.3
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
@@ -1,6 +1,7 @@
1
1
  import base64
2
2
  import hashlib
3
3
  import json
4
+ import re
4
5
  from abc import ABC, abstractmethod
5
6
  from base64 import b32encode
6
7
  from enum import StrEnum
@@ -26,6 +27,7 @@ class Document(BaseModel, ABC):
26
27
 
27
28
  MAX_CONTENT_SIZE: ClassVar[int] = 10 * 1024 * 1024 # 10MB default
28
29
  DESCRIPTION_EXTENSION: ClassVar[str] = ".description.md"
30
+ MARKDOWN_LIST_SEPARATOR: ClassVar[str] = "\n\n---\n\n"
29
31
 
30
32
  def __init__(self, **data: Any) -> None:
31
33
  """Prevent direct instantiation of abstract Document class."""
@@ -199,15 +201,34 @@ class Document(BaseModel, ABC):
199
201
 
200
202
  def as_yaml(self) -> Any:
201
203
  """Parse document as YAML"""
202
- if not self.is_text:
203
- raise ValueError(f"Document is not text: {self.name}")
204
- return YAML().load(self.content.decode("utf-8")) # type: ignore
204
+ return YAML().load(self.as_text())
205
205
 
206
206
  def as_json(self) -> Any:
207
207
  """Parse document as JSON"""
208
- if not self.is_text:
209
- raise ValueError(f"Document is not text: {self.name}")
210
- return json.loads(self.content.decode("utf-8"))
208
+ return json.loads(self.as_text())
209
+
210
+ def as_markdown_list(self) -> list[str]:
211
+ """Parse document as a markdown list"""
212
+ return self.as_text().split(self.MARKDOWN_LIST_SEPARATOR)
213
+
214
+ @classmethod
215
+ def create(cls, name: str, description: str | None, content: bytes | str) -> Self:
216
+ """Create a document from a name, description, and content"""
217
+ if isinstance(content, str):
218
+ content = content.encode("utf-8")
219
+ return cls(name=name, description=description, content=content)
220
+
221
+ @classmethod
222
+ def create_as_markdown_list(cls, name: str, description: str | None, items: list[str]) -> Self:
223
+ """Create a document from a name, description, and list of strings"""
224
+ # remove other list separators (lines that are only the separator + whitespace)
225
+ separator = Document.MARKDOWN_LIST_SEPARATOR.strip()
226
+ pattern = re.compile(rf"^[ \t]*{re.escape(separator)}[ \t]*(?:\r?\n|$)", flags=re.MULTILINE)
227
+ # Normalize CRLF/CR to LF before cleaning to ensure consistent behavior
228
+ normalized_items = [re.sub(r"\r\n?", "\n", item) for item in items]
229
+ cleaned_items = [pattern.sub("", item) for item in normalized_items]
230
+ content = Document.MARKDOWN_LIST_SEPARATOR.join(cleaned_items)
231
+ return cls.create(name, description, content)
211
232
 
212
233
  def serialize_model(self) -> dict[str, Any]:
213
234
  """Serialize document to a dictionary with proper encoding."""
@@ -162,7 +162,7 @@ async def generate(
162
162
  T = TypeVar("T", bound=BaseModel)
163
163
 
164
164
 
165
- @trace
165
+ @trace(ignore_inputs=["context"])
166
166
  async def generate_structured(
167
167
  model: ModelName,
168
168
  response_format: type[T],
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ai-pipeline-core"
3
- version = "0.1.2"
3
+ version = "0.1.3"
4
4
  description = "Core utilities for AI-powered processing pipelines using prefect"
5
5
  readme = "README.md"
6
6
  license = {text = "MIT"}
@@ -140,7 +140,7 @@ reportIncompatibleVariableOverride = "error"
140
140
  reportMissingParameterType = "warning"
141
141
 
142
142
  [tool.bumpversion]
143
- current_version = "0.1.2"
143
+ current_version = "0.1.3"
144
144
  commit = true
145
145
  tag = true
146
146
  tag_name = "v{new_version}"