prompt

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreatePromptRequest

type CreatePromptRequest struct {
	Name          string  `json:"name" validate:"required,min=1,max=255"`
	Template      string  `json:"template" validate:"required,min=1"`
	CommitMessage string  `json:"commit_message" validate:"required,min=1,max=500"`
	Label         *string `json:"label,omitempty" validate:"omitempty,oneof=production latest"`
}

CreatePromptRequest represents the request to create a new prompt

type CreatePromptVersionRequest

type CreatePromptVersionRequest struct {
	Template      string  `json:"template" validate:"required,min=1"`
	CommitMessage string  `json:"commit_message" validate:"required,min=1,max=500"`
	Label         *string `json:"label,omitempty" validate:"omitempty,oneof=production latest"`
}

CreatePromptVersionRequest represents the request to create a new prompt version

type Prompt

type Prompt struct {
	ID        uuid.UUID `json:"id" db:"id"`
	ProjectID uuid.UUID `json:"project_id" db:"project_id"`
	Name      string    `json:"name" db:"name"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}

Prompt represents a prompt template

type PromptRepo

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

PromptRepo handles database operations for prompts and prompt versions

func NewPromptRepo

func NewPromptRepo(db *sqlx.DB) *PromptRepo

NewPromptRepo creates a new prompt repository

func (*PromptRepo) CreatePrompt

func (r *PromptRepo) CreatePrompt(ctx context.Context, projectID uuid.UUID, name string) (*Prompt, error)

CreatePrompt creates a new prompt

func (*PromptRepo) CreatePromptVersion

func (r *PromptRepo) CreatePromptVersion(ctx context.Context, projectID uuid.UUID, promptID uuid.UUID, template, commitMessage string, label *string) (*PromptVersion, error)

CreatePromptVersion creates a new prompt version with auto-incremented version number

func (*PromptRepo) DeletePrompt

func (r *PromptRepo) DeletePrompt(ctx context.Context, projectID uuid.UUID, promptID uuid.UUID) error

DeletePrompt deletes a prompt and all its versions (cascade delete)

func (*PromptRepo) DeletePromptVersion

func (r *PromptRepo) DeletePromptVersion(ctx context.Context, versionID uuid.UUID) error

DeletePromptVersion deletes a specific prompt version

func (*PromptRepo) GetLatestPromptVersion

func (r *PromptRepo) GetLatestPromptVersion(ctx context.Context, projectID uuid.UUID, promptName string) (*PromptVersionWithPrompt, error)

GetLatestPromptVersion retrieves the latest version of a prompt by name

func (*PromptRepo) GetPromptByID

func (r *PromptRepo) GetPromptByID(ctx context.Context, projectID uuid.UUID, id uuid.UUID) (*Prompt, error)

GetPromptByID retrieves a prompt by ID

func (*PromptRepo) GetPromptByName

func (r *PromptRepo) GetPromptByName(ctx context.Context, projectID uuid.UUID, name string) (*Prompt, error)

GetPromptByName retrieves a prompt by name

func (*PromptRepo) GetPromptVersion

func (r *PromptRepo) GetPromptVersion(ctx context.Context, projectID uuid.UUID, promptName string, version int) (*PromptVersionWithPrompt, error)

GetPromptVersion retrieves a specific prompt version by prompt name and version number

func (*PromptRepo) GetPromptVersionByID added in v0.1.11

func (r *PromptRepo) GetPromptVersionByID(ctx context.Context, projectID uuid.UUID, promptVersionID uuid.UUID) (*PromptVersionWithPrompt, error)

GetPromptVersionByID retrives a prompt version by prompt version id

func (*PromptRepo) GetPromptVersionByLabel

func (r *PromptRepo) GetPromptVersionByLabel(ctx context.Context, projectID uuid.UUID, promptName, label string) (*PromptVersionWithPrompt, error)

GetPromptVersionByLabel retrieves a prompt version by prompt name and label

func (*PromptRepo) GetPromptVersionByVersion added in v0.1.11

func (r *PromptRepo) GetPromptVersionByVersion(ctx context.Context, projectID uuid.UUID, promptID uuid.UUID, version int) (*PromptVersionWithPrompt, error)

GetPromptVersionByVersion retrieves a prompt version by prompt id and version

func (*PromptRepo) ListPromptVersions

func (r *PromptRepo) ListPromptVersions(ctx context.Context, projectID uuid.UUID, promptID uuid.UUID) ([]*PromptVersion, error)

ListPromptVersions retrieves all versions for a specific prompt

func (*PromptRepo) ListPrompts

func (r *PromptRepo) ListPrompts(ctx context.Context, projectID uuid.UUID) ([]*PromptWithLatestVersion, error)

ListPrompts retrieves all prompts with their latest version information

func (*PromptRepo) UpdatePromptVersionLabel

func (r *PromptRepo) UpdatePromptVersionLabel(ctx context.Context, projectID uuid.UUID, versionID uuid.UUID, label *string) (*PromptVersion, error)

UpdatePromptVersionLabel updates the label of a prompt version

type PromptService

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

PromptService handles business logic for prompts and prompt versions

func NewPromptService

func NewPromptService(repo *PromptRepo) *PromptService

NewPromptService creates a new prompt service

func (*PromptService) CreatePrompt

func (s *PromptService) CreatePrompt(ctx context.Context, projectID uuid.UUID, req *CreatePromptRequest) (*PromptWithLatestVersion, error)

CreatePrompt creates a new prompt with its first version

func (*PromptService) CreatePromptVersion

func (s *PromptService) CreatePromptVersion(ctx context.Context, projectID uuid.UUID, promptName string, req *CreatePromptVersionRequest) (*PromptVersionWithPrompt, error)

CreatePromptVersion creates a new prompt version

func (*PromptService) DeletePrompt

func (s *PromptService) DeletePrompt(ctx context.Context, projectID uuid.UUID, promptName string) error

DeletePrompt deletes a prompt and all its versions

func (*PromptService) DeletePromptVersion

func (s *PromptService) DeletePromptVersion(ctx context.Context, projectID uuid.UUID, promptName string, version int) error

DeletePromptVersion deletes a specific prompt version

func (*PromptService) GetLatestPromptVersion

func (s *PromptService) GetLatestPromptVersion(ctx context.Context, projectID uuid.UUID, promptName string) (*PromptVersionWithPrompt, error)

GetLatestPromptVersion retrieves the latest version of a prompt by name

func (*PromptService) GetPrompt

func (s *PromptService) GetPrompt(ctx context.Context, projectID uuid.UUID, promptName string) (*PromptWithLatestVersion, error)

GetPrompt retrieves a prompt by name (returns with latest version info)

func (*PromptService) GetPromptVersion

func (s *PromptService) GetPromptVersion(ctx context.Context, projectID uuid.UUID, promptName string, version int) (*PromptVersionWithPrompt, error)

GetPromptVersion retrieves a specific prompt version

func (*PromptService) GetPromptVersionByID added in v0.1.11

func (s *PromptService) GetPromptVersionByID(ctx context.Context, projectID uuid.UUID, promptVersionID uuid.UUID) (*PromptVersionWithPrompt, error)

GetPromptVersionByID retrieves a prompt version by its id

func (*PromptService) GetPromptVersionByLabel

func (s *PromptService) GetPromptVersionByLabel(ctx context.Context, projectID uuid.UUID, promptName, label string) (*PromptVersionWithPrompt, error)

GetPromptVersionByLabel retrieves a prompt version by label

func (*PromptService) GetPromptVersionByVersion added in v0.1.11

func (s *PromptService) GetPromptVersionByVersion(ctx context.Context, projectID uuid.UUID, promptID uuid.UUID, version int) (*PromptVersionWithPrompt, error)

GetPromptVersionByLabel retrieves a prompt version by label

func (*PromptService) ListPromptVersions

func (s *PromptService) ListPromptVersions(ctx context.Context, projectID uuid.UUID, promptName string) ([]*PromptVersion, error)

ListPromptVersions retrieves all versions for a specific prompt

func (*PromptService) ListPromptVersionsByID added in v0.1.11

func (s *PromptService) ListPromptVersionsByID(ctx context.Context, projectID uuid.UUID, promptID uuid.UUID) ([]*PromptVersion, error)

ListPromptVersionsByID retrieves all versions for a specific prompt

func (*PromptService) ListPrompts

func (s *PromptService) ListPrompts(ctx context.Context, projectID uuid.UUID) ([]*PromptWithLatestVersion, error)

ListPrompts retrieves all prompts with their latest version information

func (*PromptService) UpdatePromptVersionLabel

func (s *PromptService) UpdatePromptVersionLabel(ctx context.Context, projectID uuid.UUID, promptName string, version int, req *UpdatePromptVersionLabelRequest) (*PromptVersion, error)

UpdatePromptVersionLabel updates the label of a prompt version

type PromptVersion

type PromptVersion struct {
	ID            uuid.UUID `json:"id" db:"id"`
	PromptID      uuid.UUID `json:"prompt_id" db:"prompt_id"`
	Version       int       `json:"version" db:"version"`
	Template      string    `json:"template" db:"template"`
	CommitMessage string    `json:"commit_message" db:"commit_message"`
	Label         *string   `json:"label,omitempty" db:"label"`
	CreatedAt     time.Time `json:"created_at" db:"created_at"`
	UpdatedAt     time.Time `json:"updated_at" db:"updated_at"`
}

PromptVersion represents a version of a prompt template

type PromptVersionWithPrompt

type PromptVersionWithPrompt struct {
	PromptVersion
	PromptName string `json:"prompt_name" db:"prompt_name"`
}

PromptVersionWithPrompt combines a prompt version with its prompt information

type PromptWithLatestVersion

type PromptWithLatestVersion struct {
	Prompt
	LatestVersion   *int    `json:"latest_version,omitempty"`
	LatestCommitMsg *string `json:"latest_commit_message,omitempty"`
	LatestLabel     *string `json:"latest_label,omitempty"`
}

PromptWithLatestVersion combines a prompt with its latest version information

type UpdatePromptVersionLabelRequest

type UpdatePromptVersionLabelRequest struct {
	Label *string `json:"label,omitempty" validate:"omitempty,oneof=production latest"`
}

UpdatePromptVersionLabelRequest represents the request to update a prompt version label

Jump to

Keyboard shortcuts

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