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 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 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
// 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.
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)
}
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 gcs provides a Google Cloud Storage (GCS) implementation of the artifact.Service interface.
|
Package gcs provides a Google Cloud Storage (GCS) implementation of the artifact.Service interface. |