artifacts

package
v0.0.0-...-28e2b1b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package artifacts provides functionality for storing and retrieving artifacts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArtifactService

type ArtifactService interface {
	// SaveArtifact saves an artifact to the artifact service storage.
	// The artifact is identified by app name, user ID, session ID, and filename.
	// After saving, it returns a revision ID to identify the artifact version.
	SaveArtifact(ctx context.Context, appName, userID, sessionID, filename string, artifact Part) (int, error)

	// LoadArtifact gets an artifact from the artifact service storage.
	// If version is nil, the latest version will be returned.
	LoadArtifact(ctx context.Context, appName, userID, sessionID, filename string, version *int) (*Part, error)

	// ListArtifactKeys lists all the artifact filenames within a session.
	ListArtifactKeys(ctx context.Context, appName, userID, sessionID string) ([]string, error)

	// DeleteArtifact deletes an artifact.
	DeleteArtifact(ctx context.Context, appName, userID, sessionID, filename string) error

	// ListVersions lists all versions of an artifact.
	ListVersions(ctx context.Context, appName, userID, sessionID, filename string) ([]int, error)
}

ArtifactService defines the interface for artifact services.

type GcsArtifactService

type GcsArtifactService struct {
	// contains filtered or unexported fields
}

GcsArtifactService provides a Google Cloud Storage implementation of the ArtifactService.

func NewGcsArtifactService

func NewGcsArtifactService(ctx context.Context, bucketName string, opts ...option.ClientOption) (*GcsArtifactService, error)

NewGcsArtifactService creates a new instance of GcsArtifactService.

func (*GcsArtifactService) Close

func (s *GcsArtifactService) Close() error

Close closes the GCS client.

func (*GcsArtifactService) DeleteArtifact

func (s *GcsArtifactService) DeleteArtifact(ctx context.Context, appName, userID, sessionID, filename string) error

DeleteArtifact removes an artifact from Google Cloud Storage.

func (*GcsArtifactService) ListArtifactKeys

func (s *GcsArtifactService) ListArtifactKeys(ctx context.Context, appName, userID, sessionID string) ([]string, error)

ListArtifactKeys lists all artifact filenames within a session.

func (*GcsArtifactService) ListVersions

func (s *GcsArtifactService) ListVersions(ctx context.Context, appName, userID, sessionID, filename string) ([]int, error)

ListVersions lists all versions of an artifact.

func (*GcsArtifactService) LoadArtifact

func (s *GcsArtifactService) LoadArtifact(ctx context.Context, appName, userID, sessionID, filename string, version *int) (*Part, error)

LoadArtifact retrieves an artifact from Google Cloud Storage.

func (*GcsArtifactService) SaveArtifact

func (s *GcsArtifactService) SaveArtifact(ctx context.Context, appName, userID, sessionID, filename string, artifact Part) (int, error)

SaveArtifact saves an artifact to Google Cloud Storage.

type InMemoryArtifactService

type InMemoryArtifactService struct {
	// contains filtered or unexported fields
}

InMemoryArtifactService provides an in-memory implementation of the ArtifactService.

func NewInMemoryArtifactService

func NewInMemoryArtifactService() *InMemoryArtifactService

NewInMemoryArtifactService creates a new instance of InMemoryArtifactService.

func (*InMemoryArtifactService) DeleteArtifact

func (s *InMemoryArtifactService) DeleteArtifact(ctx context.Context, appName, userID, sessionID, filename string) error

DeleteArtifact removes an artifact from the in-memory storage.

func (*InMemoryArtifactService) ListArtifactKeys

func (s *InMemoryArtifactService) ListArtifactKeys(ctx context.Context, appName, userID, sessionID string) ([]string, error)

ListArtifactKeys lists all artifact filenames within a session.

func (*InMemoryArtifactService) ListVersions

func (s *InMemoryArtifactService) ListVersions(ctx context.Context, appName, userID, sessionID, filename string) ([]int, error)

ListVersions lists all versions of an artifact.

func (*InMemoryArtifactService) LoadArtifact

func (s *InMemoryArtifactService) LoadArtifact(ctx context.Context, appName, userID, sessionID, filename string, version *int) (*Part, error)

LoadArtifact retrieves an artifact from the in-memory storage.

func (*InMemoryArtifactService) SaveArtifact

func (s *InMemoryArtifactService) SaveArtifact(ctx context.Context, appName, userID, sessionID, filename string, artifact Part) (int, error)

SaveArtifact saves an artifact to the in-memory storage.

type Part

type Part struct {
	// Text contains the textual content of the artifact.
	// Either Text or Data should be populated, but not both.
	Text string

	// Data contains the binary content of the artifact.
	// Either Text or Data should be populated, but not both.
	Data []byte

	// MimeType represents the MIME type of the content.
	MimeType string
}

Part represents an artifact part, similar to google.genai.types.Part in Python.

func FromBytes

func FromBytes(data []byte, mimeType string) Part

FromBytes creates a Part instance from binary data.

func FromText

func FromText(text string, mimeType string) Part

FromText creates a Part instance from text content.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL