Skip to content

Commit 99ca6aa

Browse files
GWealecopybara-github
authored andcommitted
feat: add file-backed artifact service
- add FileArtifactService that persists artifacts to the local filesystem - adjust BaseArtifactService and exports so callers can wire in the filebacked implementation Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 828629298
1 parent d9ec07d commit 99ca6aa

File tree

4 files changed

+1041
-42
lines changed

4 files changed

+1041
-42
lines changed

src/google/adk/artifacts/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
# limitations under the License.
1414

1515
from .base_artifact_service import BaseArtifactService
16+
from .file_artifact_service import FileArtifactService
1617
from .gcs_artifact_service import GcsArtifactService
1718
from .in_memory_artifact_service import InMemoryArtifactService
1819

1920
__all__ = [
2021
'BaseArtifactService',
22+
'FileArtifactService',
2123
'GcsArtifactService',
2224
'InMemoryArtifactService',
2325
]

src/google/adk/artifacts/base_artifact_service.py

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,44 @@
2020
from typing import Optional
2121

2222
from google.genai import types
23+
from pydantic import alias_generators
2324
from pydantic import BaseModel
25+
from pydantic import ConfigDict
2426
from pydantic import Field
2527

2628

2729
class ArtifactVersion(BaseModel):
28-
"""Represents the metadata of a specific version of an artifact."""
29-
30-
version: int
31-
"""The version number of the artifact."""
32-
canonical_uri: str
33-
"""The canonical URI of the artifact version."""
34-
custom_metadata: dict[str, Any] = Field(default_factory=dict)
35-
"""A dictionary of custom metadata associated with the artifact version."""
36-
create_time: float = Field(default_factory=lambda: datetime.now().timestamp())
37-
"""The creation time of the artifact version."""
38-
mime_type: Optional[str] = None
39-
"""The MIME type of the artifact version."""
30+
"""Metadata describing a specific version of an artifact."""
31+
32+
model_config = ConfigDict(
33+
alias_generator=alias_generators.to_camel,
34+
populate_by_name=True,
35+
)
36+
37+
version: int = Field(
38+
description=(
39+
"Monotonically increasing identifier for the artifact version."
40+
)
41+
)
42+
canonical_uri: str = Field(
43+
description="Canonical URI referencing the persisted artifact payload."
44+
)
45+
custom_metadata: dict[str, Any] = Field(
46+
default_factory=dict,
47+
description="Optional user-supplied metadata stored with the artifact.",
48+
)
49+
create_time: float = Field(
50+
default_factory=lambda: datetime.now().timestamp(),
51+
description=(
52+
"Unix timestamp (seconds) when the version record was created."
53+
),
54+
)
55+
mime_type: Optional[str] = Field(
56+
default=None,
57+
description=(
58+
"MIME type when the artifact payload is stored as binary data."
59+
),
60+
)
4061

4162

4263
class BaseArtifactService(ABC):

0 commit comments

Comments
 (0)