anyformat 2.5.0__tar.gz → 2.7.0__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.
- {anyformat-2.5.0 → anyformat-2.7.0}/PKG-INFO +1 -1
- {anyformat-2.5.0 → anyformat-2.7.0}/pyproject.toml +1 -1
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/sdk/_http.py +8 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/workflow/__init__.py +2 -3
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/workflow/nodes.py +20 -7
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/workflow/topology.py +3 -1
- anyformat-2.7.0/src/anyformat/workflow/upstream.py +58 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/README.md +0 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/sdk/__init__.py +0 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/sdk/_banner.py +0 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/sdk/_source.py +0 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/sdk/_viz.py +0 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/sdk/builder.py +0 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/sdk/cli.py +0 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/sdk/client.py +0 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/sdk/errors.py +0 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/sdk/handles.py +0 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/sdk/result.py +0 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/sdk/views.py +0 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/workflow/builder.py +0 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/workflow/checks.py +0 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/workflow/definition.py +0 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/workflow/fields.py +0 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/workflow/results.py +0 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/workflow/schema.py +0 -0
- {anyformat-2.5.0 → anyformat-2.7.0}/src/anyformat/workflow/template_tokens.py +0 -0
|
@@ -64,6 +64,11 @@ class PacketFile:
|
|
|
64
64
|
# otherwise. Only the upload/create response carries it — the pre-rename name
|
|
65
65
|
# isn't persisted, so later reads expose ``name`` alone.
|
|
66
66
|
original_name: str | None = None
|
|
67
|
+
# Set only on a packet read, which signs ``download_url`` to the file's original bytes until
|
|
68
|
+
# ``download_url_expires_at``; all three are ``None`` when the bytes cannot be linked.
|
|
69
|
+
content_type: str | None = None
|
|
70
|
+
download_url: str | None = None
|
|
71
|
+
download_url_expires_at: str | None = None
|
|
67
72
|
|
|
68
73
|
|
|
69
74
|
@dataclass(frozen=True)
|
|
@@ -1080,6 +1085,9 @@ def parse_packet_file(data: dict) -> PacketFile:
|
|
|
1080
1085
|
id=data["id"],
|
|
1081
1086
|
name=data.get("name", ""),
|
|
1082
1087
|
original_name=data.get("original_name"),
|
|
1088
|
+
content_type=data.get("content_type"),
|
|
1089
|
+
download_url=data.get("download_url"),
|
|
1090
|
+
download_url_expires_at=data.get("download_url_expires_at"),
|
|
1083
1091
|
)
|
|
1084
1092
|
|
|
1085
1093
|
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
# storage-format methods (no to_config / from_config / @model_serializer
|
|
3
3
|
# beyond what pydantic ships): storage shape == wire shape ==
|
|
4
4
|
# ``node.model_dump(exclude_none=True)``. Runtime Node->Task construction
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
# only emits typed nodes and never imports a Task class.
|
|
5
|
+
# is ``anyformat.domain.node_plan.plan_node``, which the core compiler calls
|
|
6
|
+
# per node, so the backend only emits typed nodes and never imports a Task class.
|
|
8
7
|
from anyformat.workflow.builder import WorkflowBuilder, WorkflowBuilderError
|
|
9
8
|
from anyformat.workflow.checks import (
|
|
10
9
|
AllOfCheck,
|
|
@@ -300,7 +300,7 @@ class ExtractionSchema(BaseModel):
|
|
|
300
300
|
|
|
301
301
|
class ExtractNode(BaseNode):
|
|
302
302
|
type: Literal["extract"]
|
|
303
|
-
# `mode="agentic"`
|
|
303
|
+
# `mode="agentic"` plans the agentic extract (`plan_node`). Legacy data
|
|
304
304
|
# may carry it; the typed builder does not yet expose it as a kwarg.
|
|
305
305
|
# `mode="lite"` is a standard extract on a cheaper model (gpt-5.6-luna).
|
|
306
306
|
mode: Literal["standard", "agentic", "max", "lite"] = Field(
|
|
@@ -392,7 +392,7 @@ class ExtractNode(BaseNode):
|
|
|
392
392
|
@property
|
|
393
393
|
def no_confidence_reason(self) -> str | None:
|
|
394
394
|
"""Why this extract scores no confidence, or None when it does. An agentic extract
|
|
395
|
-
|
|
395
|
+
wins over the row extractor in `plan_node`, so it scores either way."""
|
|
396
396
|
if not self.confidence:
|
|
397
397
|
return "confidence is off"
|
|
398
398
|
if self.mode == "agentic":
|
|
@@ -607,10 +607,15 @@ EmailAddress = Annotated[
|
|
|
607
607
|
]
|
|
608
608
|
|
|
609
609
|
|
|
610
|
-
#
|
|
610
|
+
# SES refuses a send naming more addresses than this across to, cc and bcc together.
|
|
611
611
|
MAX_EMAIL_RECIPIENTS = 50
|
|
612
612
|
|
|
613
613
|
|
|
614
|
+
def require_within_recipient_cap(to: list[str], cc: list[str]) -> None:
|
|
615
|
+
if len(to) + len(cc) > MAX_EMAIL_RECIPIENTS:
|
|
616
|
+
raise ValueError(f"to and cc together name more than {MAX_EMAIL_RECIPIENTS} addresses")
|
|
617
|
+
|
|
618
|
+
|
|
614
619
|
class EmailBody(BaseModel):
|
|
615
620
|
"""Where an Email node's body comes from: its own template, or an upstream report."""
|
|
616
621
|
|
|
@@ -651,16 +656,18 @@ class EmailAlertNode(BaseNode):
|
|
|
651
656
|
"""
|
|
652
657
|
|
|
653
658
|
type: Literal["email_alert"]
|
|
654
|
-
to: list[EmailAddress] = Field(
|
|
659
|
+
to: list[EmailAddress] = Field(
|
|
660
|
+
min_length=1,
|
|
661
|
+
max_length=MAX_EMAIL_RECIPIENTS,
|
|
662
|
+
description=f"Recipients; to and cc together name at most {MAX_EMAIL_RECIPIENTS} addresses.",
|
|
663
|
+
)
|
|
655
664
|
cc: list[EmailAddress] = Field(
|
|
656
665
|
default_factory=list, max_length=MAX_EMAIL_RECIPIENTS, description="Copied recipients."
|
|
657
666
|
)
|
|
658
667
|
reply_to: Annotated[EmailAddress | None, BeforeValidator(_empty_str_to_none)] = Field(
|
|
659
668
|
default=None, description="Where replies go."
|
|
660
669
|
)
|
|
661
|
-
subject_template: str = Field(
|
|
662
|
-
min_length=1, description="Subject with ``${field.*}`` tokens, on one line."
|
|
663
|
-
)
|
|
670
|
+
subject_template: str = Field(min_length=1, description="Subject with ``${field.*}`` tokens, on one line.")
|
|
664
671
|
body: EmailBody
|
|
665
672
|
on_missing: Literal["hold", "send"] = Field(
|
|
666
673
|
default="hold",
|
|
@@ -685,6 +692,11 @@ class EmailAlertNode(BaseNode):
|
|
|
685
692
|
raise ValueError("an address appears more than once across to and cc")
|
|
686
693
|
return self
|
|
687
694
|
|
|
695
|
+
@model_validator(mode="after")
|
|
696
|
+
def _within_the_recipient_cap(self) -> "EmailAlertNode":
|
|
697
|
+
require_within_recipient_cap(self.to, self.cc)
|
|
698
|
+
return self
|
|
699
|
+
|
|
688
700
|
@classmethod
|
|
689
701
|
def accepts(cls, predecessor: type["BaseNode"]) -> bool:
|
|
690
702
|
return predecessor in (ExtractNode, ValidateNode, IfElseNode)
|
|
@@ -958,6 +970,7 @@ __all__ = [
|
|
|
958
970
|
"ExtractNode",
|
|
959
971
|
"MAX_CODE_BYTES",
|
|
960
972
|
"MAX_EMAIL_RECIPIENTS",
|
|
973
|
+
"require_within_recipient_cap",
|
|
961
974
|
"MAX_EXAMPLE_REPORT_BYTES",
|
|
962
975
|
"PUBLIC_HIDDEN_NODE_KEYS",
|
|
963
976
|
"strip_public_hidden_keys",
|
|
@@ -564,7 +564,9 @@ class EveryNonParseNodeHasInboundEdge:
|
|
|
564
564
|
targets = {e.target for e in graph.edges}
|
|
565
565
|
violations: list[Violation] = []
|
|
566
566
|
for node in graph.nodes:
|
|
567
|
-
|
|
567
|
+
# A knowledge node opts in by presence and has no handles, so it is
|
|
568
|
+
# saved unwired; it is still no entry, which ``needs_inbound_edge`` reports.
|
|
569
|
+
if not self.needs_inbound_edge(type(node)) or isinstance(node, KnowledgeNode):
|
|
568
570
|
continue
|
|
569
571
|
if node.id not in targets:
|
|
570
572
|
violations.append(
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""Which upstream node a sink reads: the run compiler (anyformat-core) and the Email preview (backend) share it."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
# Node types that write no extraction of their own: smart_lookup enriches it in place, validate reads it,
|
|
8
|
+
# and if_else routes on it, so a consumer below them reads the extract above.
|
|
9
|
+
# Frontend mirror: ``services/frontend/src/features/studio/nodes/_shared/hooks/useUpstreamExtractFields.ts``.
|
|
10
|
+
EXTRACTION_TRANSPARENT_TYPES = frozenset({"smart_lookup", "validate", "if_else"})
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass(frozen=True)
|
|
14
|
+
class UpstreamGraph:
|
|
15
|
+
"""A graph as each node's type by id and its ``(source, target)`` edges."""
|
|
16
|
+
|
|
17
|
+
types: dict[str, str]
|
|
18
|
+
edges: tuple[tuple[str, str], ...]
|
|
19
|
+
|
|
20
|
+
def single_upstream(self, node_id: str) -> str:
|
|
21
|
+
"""``ValueError`` unless exactly one edge enters the node."""
|
|
22
|
+
sources = [source for source, target in self.edges if target == node_id]
|
|
23
|
+
if not sources:
|
|
24
|
+
raise ValueError(f"Node '{node_id}' has no predecessors in the graph")
|
|
25
|
+
if len(sources) > 1:
|
|
26
|
+
raise ValueError(f"Node '{node_id}' has multiple predecessors: {sources}")
|
|
27
|
+
return sources[0]
|
|
28
|
+
|
|
29
|
+
def extraction_source(self, node_id: str) -> str:
|
|
30
|
+
"""The node whose extraction ``node_id`` reads, past every extraction-transparent node; ``ValueError``
|
|
31
|
+
when a node on the way has no single predecessor."""
|
|
32
|
+
current = self.single_upstream(node_id)
|
|
33
|
+
seen: set[str] = set()
|
|
34
|
+
while self.types.get(current) in EXTRACTION_TRANSPARENT_TYPES:
|
|
35
|
+
if current in seen:
|
|
36
|
+
raise ValueError(
|
|
37
|
+
f"Cycle through extraction-transparent nodes while resolving extraction source for '{node_id}'"
|
|
38
|
+
)
|
|
39
|
+
seen.add(current)
|
|
40
|
+
current = self.single_upstream(current)
|
|
41
|
+
return current
|
|
42
|
+
|
|
43
|
+
def classification_source(self, node_id: str) -> str | None:
|
|
44
|
+
"""The classify node closest above ``node_id``; ``None`` when there is none or the path forks.
|
|
45
|
+
|
|
46
|
+
A nested arm sees every classifier on its path; only the nearest names its document.
|
|
47
|
+
"""
|
|
48
|
+
current = node_id
|
|
49
|
+
seen: set[str] = set()
|
|
50
|
+
while current not in seen:
|
|
51
|
+
seen.add(current)
|
|
52
|
+
sources = {source for source, target in self.edges if target == current}
|
|
53
|
+
if len(sources) != 1:
|
|
54
|
+
return None
|
|
55
|
+
current = sources.pop()
|
|
56
|
+
if self.types.get(current) == "classify":
|
|
57
|
+
return current
|
|
58
|
+
return None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|