Documentation
¶
Overview ¶
Package artifact provides a service for managing artifacts.
An artifact is a file identified by an application name, a user ID, a session ID, and a filename. The service provides basic storage operations for artifacts, such as Save, Load, Delete, and List. It also supports versioning of artifacts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArtifactVersion ¶
type ArtifactVersion struct {
Version int64
// CanonicalURI is a stable identity for the stored payload. Implementations
// with a native scheme should use it, such as gs:// for Google Cloud Storage;
// other implementations should define a stable service-specific scheme. It
// is not necessarily a download endpoint or an authenticated HTTP URL.
CanonicalURI string
// Implementations must return a non-nil map containing only string values.
// It is empty when no custom metadata was saved.
CustomMetadata map[string]any
// CreateTime is when this artifact version was created.
CreateTime time.Time
// MimeType is the media type associated with the stored part. It may be empty
// when the part was saved without a media type.
MimeType string
}
ArtifactVersion contains metadata describing a specific version of an artifact. Service implementations must populate its fields as documented below.
type DeleteRequest ¶
type DeleteRequest struct {
AppName, UserID, SessionID, FileName string
// Below are optional fields.
Version int64
}
DeleteRequest is the parameter for [ArtifactService.Delete].
func (*DeleteRequest) Validate ¶
func (req *DeleteRequest) Validate() error
Validate checks if the struct is valid or if it is missing fields.
type GetArtifactVersionRequest ¶
type GetArtifactVersionRequest struct {
AppName, UserID, SessionID, FileName string
// Below are optional fields.
Version int64
}
GetArtifactVersionRequest is the parameter for [ArtifactService.GetArtifactVersion].
func (*GetArtifactVersionRequest) Validate ¶
func (req *GetArtifactVersionRequest) Validate() error
Validate checks if the struct is valid or if it is missing a field.
type GetArtifactVersionResponse ¶
type GetArtifactVersionResponse struct {
ArtifactVersion *ArtifactVersion
}
GetArtifactVersionResponse is the return type of [ArtifactService.GetArtifactVersion].
type ListRequest ¶
type ListRequest struct {
AppName, UserID, SessionID string
}
ListRequest is the parameter for [ArtifactService.List].
func (*ListRequest) Validate ¶
func (req *ListRequest) Validate() error
Validate checks if the struct is valid or if it is missing a field.
type ListResponse ¶
type ListResponse struct {
FileNames []string
}
ListResponse is the return type of [ArtifactService.List].
type LoadRequest ¶
type LoadRequest struct {
AppName, UserID, SessionID, FileName string
// Below are optional fields.
Version int64
}
LoadRequest is the parameter for [ArtifactService.Load].
func (*LoadRequest) Validate ¶
func (req *LoadRequest) Validate() error
Validate checks if the struct is valid or if it is missing fields.
type LoadResponse ¶
LoadResponse is the return type of [ArtifactService.Load].
type SaveRequest ¶
type SaveRequest struct {
AppName, UserID, SessionID, FileName string
// Part is the artifact to store.
Part *genai.Part
// CustomMetadata contains caller-defined metadata persisted with the artifact.
// Service implementations must convert each value to its string representation
// when saving it and return the value as a string.
CustomMetadata map[string]any
// If set, the artifact will be saved with this version.
// If unset, a new version will be created.
Version int64
}
SaveRequest is the parameter for [ArtifactService.Save].
func (*SaveRequest) Validate ¶
func (req *SaveRequest) Validate() error
Validate checks if the struct is valid or if it is missing fields.
type SaveResponse ¶
type SaveResponse struct {
Version int64
}
SaveResponse is the return type of [ArtifactService.Save].
type Service ¶
type Service interface {
// Save saves an artifact to the artifact service storage.
// The artifact is a file identified by the app name, user ID, session ID, and fileName.
// After saving the artifact, a revision ID is returned to identify the artifact version.
// Implementations that assign versions optimistically may fail to claim one
// while other writers save the same artifact; that failure is transient and
// the call can be retried.
Save(ctx context.Context, req *SaveRequest) (*SaveResponse, error)
// Load loads an artifact from the storage.
// The artifact is a file identified by the appName, userID, sessionID and fileName.
Load(ctx context.Context, req *LoadRequest) (*LoadResponse, error)
// Delete deletes an artifact. Deleting a non-existing entry is not an error.
Delete(ctx context.Context, req *DeleteRequest) error
// List lists all the artifact filenames within a session.
List(ctx context.Context, req *ListRequest) (*ListResponse, error)
// Versions lists all versions of an artifact.
Versions(ctx context.Context, req *VersionsRequest) (*VersionsResponse, error)
// GetArtifactVersion gets the metadata for a specific version of an artifact.
GetArtifactVersion(ctx context.Context, req *GetArtifactVersionRequest) (*GetArtifactVersionResponse, error)
}
Service is the artifact storage service.
func InMemoryService ¶
func InMemoryService() Service
InMemoryService returns a new in-memory artifact service.
type VersionsRequest ¶
type VersionsRequest struct {
AppName, UserID, SessionID, FileName string
}
VersionsRequest is the parameter for [ArtifactService.Versions].
func (*VersionsRequest) Validate ¶
func (req *VersionsRequest) Validate() error
Validate checks if the struct is valid or if its missing field
type VersionsResponse ¶
type VersionsResponse struct {
Versions []int64
}
VersionsResponse is the parameter for [ArtifactService.Versions].
Directories
¶
| Path | Synopsis |
|---|---|
|
Package gcsartifact provides a Google Cloud Storage (GCS) artifact.Service.
|
Package gcsartifact provides a Google Cloud Storage (GCS) artifact.Service. |