Skip to content

ArtifactService interface get_artifact_version function-2 #796 - 9#808

Closed
adk-bot wants to merge 1 commit into
mainfrom
agent-changes-20251022-210954
Closed

ArtifactService interface get_artifact_version function-2 #796 - 9#808
adk-bot wants to merge 1 commit into
mainfrom
agent-changes-20251022-210954

Conversation

@adk-bot

@adk-bot adk-bot commented Oct 22, 2025

Copy link
Copy Markdown
Collaborator

This pull request updates the documentation for the BaseArtifactService to include the new list_artifact_versions and get_artifact_version methods, as requested in issue #796.

@joefernandez joefernandez changed the title Update ADK doc according to issue #796 - 9 Update ADK doc according to issue #796 - 9 - ArtifactService interface get_artifact_version function Nov 4, 2025
@jcwriter74

Copy link
Copy Markdown
Collaborator

#20 BaseArtifactService to include the new list_artifact_versions and get_artifact_version methods

Example of Implementation

from abc import ABC, abstractmethod

class BaseArtifactService(ABC):
    @abstractmethod
    def list_artifact_versions(self, name: str): pass
    
    @abstractmethod
    def get_artifact_version(self, name: str, version: int): pass

class SimpleArtifactService(BaseArtifactService):
    def __init__(self):
        # Mock data: { artifact_name: [list of version dicts] }
        self.data = {
            "model": [{"v": 1, "uri": "gs://v1"}, {"v": 2, "uri": "gs://v2"}]
        }

    def list_artifact_versions(self, name: str):
        return self.data.get(name, [])

    def get_artifact_version(self, name: str, version: int):
        return next((x for x in self.data.get(name, []) if x["v"] == version), None)

# Usage
service = SimpleArtifactService()

print("Versions:", service.list_artifact_versions("model"))
print("Version 2:", service.get_artifact_version("model", 2))

Common Use Cases

Artifacts provide a flexible way to handle binary data within your ADK applications.

Here are some typical scenarios where they prove valuable:

Generated Reports/Files:

  • A tool or agent generates a report (e.g., a PDF analysis, a CSV data export, an image chart).
    Handling User Uploads:
  • A user uploads a file (e.g., an image for analysis, a document for summarization) through a front-end interface.
    Storing Intermediate Binary Results:
  • An agent performs a complex multi-step process where one step generates intermediate binary data (e.g., audio synthesis, simulation results).
    Persistent User Data:
  • Storing user-specific configuration or data that isn't a simple key-value state.
    Caching Generated Binary Content:
  • An agent frequently generates the same binary output based on certain inputs (e.g., a company logo image, a standard audio greeting)

Interface:

Defined by the abstract base class BaseArtifactService, any concrete implementation must provide methods, among which there are:

  • list_artifact_versions: Lists all versions and their metadata for a specific artifact.
  • get_artifact_version: Gets the metadata for a specific version of an artifact.

Docs already added:
Artifacts, Interface in PR

@jcwriter74

Copy link
Copy Markdown
Collaborator

Issue already closed, documentation added above

@jcwriter74 jcwriter74 closed this Jun 5, 2026
@jcwriter74 jcwriter74 changed the title Update ADK doc according to issue #796 - 9 - ArtifactService interface get_artifact_version function ArtifactService interface get_artifact_version function-1 #796 - 9 Jun 23, 2026
@jcwriter74 jcwriter74 changed the title ArtifactService interface get_artifact_version function-1 #796 - 9 ArtifactService interface get_artifact_version function-2 #796 - 9 Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants