requests

package
v0.0.0-...-11c28d2 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 19 Imported by: 6

Documentation

Overview

* Requests initiated by logged in users

* Requests initiated by logged in users

* Requests initiated by admins

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiTokenQueryFilters

type ApiTokenQueryFilters struct {
	ApiTokenType ApiTokenType `json:"api_token_type"`
}

func (*ApiTokenQueryFilters) ParseURLQueryParameters

func (filters *ApiTokenQueryFilters) ParseURLQueryParameters(urlValues url.Values) error

Parse all filters into a QueryGenerationFilters struct

type ApiTokenType

type ApiTokenType string

Filters for querying

const (
	ApiTokenAny ApiTokenType = "any"
	// Only auth client
	ApiTokenClient ApiTokenType = "client"
	// Only created by user manually
	ApiTokenManual ApiTokenType = "manual"
)

type BanAction

type BanAction string
const (
	BanActionBan   BanAction = "ban"
	BanActionUnban BanAction = "unban"
)

type BanUsersRequest

type BanUsersRequest struct {
	Action     BanAction   `json:"action"`
	DeleteData bool        `json:"delete_data"`
	UserIDs    []uuid.UUID `json:"user_ids"`
}

type BaseCogRequest

type BaseCogRequest struct {
	SkipSafetyChecker bool `json:"skip_safety_checker"`
	SkipTranslation   bool `json:"skip_translation"`
	// These fields are irrelevant to sc-worker, just used to identify the request when it comes back
	ID                 uuid.UUID               `json:"id"`
	UserID             *uuid.UUID              `json:"user_id,omitempty"`
	IP                 string                  `json:"ip,omitempty"`
	ThumbmarkID        string                  `json:"thumbmark_id,omitempty"`
	UIId               string                  `json:"ui_id,omitempty"`
	GenerationOutputID string                  `json:"generation_output_id,omitempty"` // Specific to upscale requests
	LivePageData       *shared.LivePageMessage `json:"live_page_data,omitempty"`
	StreamID           string                  `json:"stream_id,omitempty"`
	DeviceInfo         utils.ClientDeviceInfo  `json:"device_info,omitempty"`
	Internal           bool                    `json:"internal,omitempty"`    // Used to indicate if the request is internal or not
	APIRequest         bool                    `json:"api_request,omitempty"` // Used to indicate if the request is from token or not
	WasAutoSubmitted   bool                    `json:"was_auto_submitted,omitempty"`
	// Generate specific
	UploadPathPrefix       string             `json:"upload_path_prefix,omitempty"`
	OriginalPrompt         string             `json:"original_prompt,omitempty"`
	Prompt                 string             `json:"prompt,omitempty"`
	OriginalNegativePrompt string             `json:"original_negative_prompt,omitempty"`
	NegativePrompt         string             `json:"negative_prompt,omitempty"`
	Width                  *int32             `json:"width,omitempty"`
	Height                 *int32             `json:"height,omitempty"`
	OutputImageExtension   string             `json:"output_image_extension,omitempty"`
	OutputImageQuality     *int               `json:"output_image_quality,omitempty"`
	NumInferenceSteps      *int32             `json:"num_inference_steps,omitempty"`
	GuidanceScale          *float32           `json:"guidance_scale,omitempty"`
	Model                  string             `json:"model,omitempty"`
	ModelId                uuid.UUID          `json:"model_id,omitempty"`
	Scheduler              string             `json:"scheduler,omitempty"`
	SchedulerId            uuid.UUID          `json:"scheduler_id,omitempty"`
	InitImageUrl           string             `json:"init_image_url,omitempty"`
	MaskImageUrl           string             `json:"mask_image_url,omitempty"`
	MaskImageUrlS3         string             `json:"mask_image_url_s3,omitempty"`
	InitImageUrlS3         string             `json:"init_image_url_s3,omitempty"`
	PromptStrength         *float32           `json:"prompt_strength,omitempty"`
	Mask                   string             `json:"mask,omitempty"`
	Seed                   *int               `json:"seed,omitempty"`
	NumOutputs             *int32             `json:"num_outputs,omitempty"`
	ProcessType            shared.ProcessType `json:"process_type"`
	PromptFlores           string             `json:"prompt_flores_200_code,omitempty"`
	NegativePromptFlores   string             `json:"negative_prompt_flores_200_code,omitempty"`
	SubmitToGallery        bool               `json:"submit_to_gallery,omitempty"`
	WebhookToken           uuid.UUID          `json:"webhook_token"`
	// Upscale specific
	Image        string             `json:"image_to_upscale,omitempty"`
	Images       []string           `json:"images,omitempty"`
	Type         UpscaleRequestType `json:"type,omitempty"`
	UpscaleModel string             `json:"upscale_model,omitempty"`
	// Voiceover specific
	Speaker           string    `json:"speaker,omitempty"`
	Temp              *float32  `json:"temperature,omitempty"`
	DenoiseAudio      *bool     `json:"denoise_audio,omitempty"`
	RemoveSilence     *bool     `json:"remove_silence,omitempty"`
	SpeakerId         uuid.UUID `json:"speaker_id,omitempty"`
	SignedUrls        []string  `json:"signed_urls,omitempty"`
	WebhookPrivateUrl string    `json:"webhook_private_url,omitempty"`
	RunpodEndpoint    *string   `json:"runpod_endpoint,omitempty"`
}

Base request data sc-worker uses to process request

type ChangeSystemBackendRequest

type ChangeSystemBackendRequest struct {
	Backend shared.BackendType `json:"backend"`
}

type ChangeUsernameRequest

type ChangeUsernameRequest struct {
	Username string `json:"username"`
}

type ClipApiEmbeddingRequest

type ClipApiEmbeddingRequest struct {
	Text           string `json:"text,omitempty"`
	Image          string `json:"image,omitempty"`
	CalculateScore bool   `json:"calculate_score,omitempty"`
	CheckNsfw      bool   `json:"check_nsfw,omitempty"`
	ID             string `json:"id,omitempty"`
}

type CogEventFilter

type CogEventFilter string

Filters specify what events we want sc-worker to send to our webhook

const (
	CogEventFilterStart     CogEventFilter = "start"
	CogEventFilterOutput    CogEventFilter = "output"
	CogEventFilterCompleted CogEventFilter = "completed"
)

type CogQueueRequest

type CogQueueRequest struct {
	WebhookUrl          string           `json:"webhook_url,omitempty"`
	WebhookEventsFilter []CogEventFilter `json:"webhook_events_filter"`
	Input               BaseCogRequest   `json:"input"`
}

Data type is what we actually send to the cog, includes some additional metadata beyond BaseCogRequest

func (CogQueueRequest) MarshalBinary

func (i CogQueueRequest) MarshalBinary() (data []byte, err error)

type CogTaskStatus

type CogTaskStatus string
const (
	CogSucceeded  CogTaskStatus = "succeeded"
	CogFailed     CogTaskStatus = "failed"
	CogProcessing CogTaskStatus = "processing"
)

type CogWebhookMessage

type CogWebhookMessage struct {
	Webhook   string           `json:"webhook"`
	Input     BaseCogRequest   `json:"input"`
	Status    CogTaskStatus    `json:"status"`
	Error     string           `json:"error"`
	Output    CogWebhookOutput `json:"output"`
	NSFWCount int32            `json:"nsfw_count"`
}

type CogWebhookOutput

type CogWebhookOutput struct {
	Images     []CogWebhookOutputImage `json:"images"`
	AudioFiles []CogWebhookOutputAudio `json:"audio_files"`
}

type CogWebhookOutputAudio

type CogWebhookOutputAudio struct {
	AudioFile     string    `json:"audio_file"`
	AudioDuration float32   `json:"audio_duration"`
	VideoFile     string    `json:"video_file"`
	AudioArray    []float64 `json:"audio_array"`
}

type CogWebhookOutputImage

type CogWebhookOutputImage struct {
	Image string `json:"image"`
}

Msg from sc-worker to redis channel

type CreateGenerationRequest

type CreateGenerationRequest struct {
	Prompt               string                `json:"prompt"`
	NegativePrompt       string                `json:"negative_prompt,omitempty"`
	Width                *int32                `json:"width,omitempty"`
	Height               *int32                `json:"height,omitempty"`
	InferenceSteps       *int32                `json:"inference_steps,omitempty"`
	GuidanceScale        *float32              `json:"guidance_scale,omitempty"`
	ModelId              *uuid.UUID            `json:"model_id,omitempty"`
	SchedulerId          *uuid.UUID            `json:"scheduler_id,omitempty"`
	Seed                 *int                  `json:"seed,omitempty"`
	NumOutputs           *int32                `json:"num_outputs,omitempty"`
	StreamID             string                `json:"stream_id"` // Corresponds to SSE stream
	UIId                 string                `json:"ui_id"`     // Corresponds to UI identifier
	InitImageUrl         string                `json:"init_image_url,omitempty"`
	MaskImageUrl         string                `json:"mask_image_url,omitempty"`
	PromptStrength       *float32              `json:"prompt_strength,omitempty"`
	SubmitToGallery      bool                  `json:"submit_to_gallery"`
	ProcessType          shared.ProcessType    `json:"process_type"`
	OutputImageExtension shared.ImageExtension `json:"output_image_extension"`
	WasAutoSubmitted     bool
}

HTTP Request for creating a new generation

func (*CreateGenerationRequest) ApplyDefaults

func (t *CreateGenerationRequest) ApplyDefaults()

Apply defaults for missing parameters

func (*CreateGenerationRequest) Cost

func (t *CreateGenerationRequest) Cost() int32

func (*CreateGenerationRequest) Validate

func (t *CreateGenerationRequest) Validate(api bool) error

type CreateUpscaleRequest

type CreateUpscaleRequest struct {
	Type     *UpscaleRequestType `json:"type,omitempty"`
	Input    string              `json:"input"`
	ModelId  *uuid.UUID          `json:"model_id,omitempty"`
	StreamID string              `json:"stream_id"`
	UIId     string              `json:"ui_id"` // Corresponds to UI identifier
	OutputID *uuid.UUID
}

Can be initiated with either an image_url or a generation_output_id

func (*CreateUpscaleRequest) ApplyDefaults

func (t *CreateUpscaleRequest) ApplyDefaults()

func (*CreateUpscaleRequest) Cost

func (t *CreateUpscaleRequest) Cost() int32

func (*CreateUpscaleRequest) Validate

func (t *CreateUpscaleRequest) Validate(api bool) error

type CreateVoiceoverRequest

type CreateVoiceoverRequest struct {
	Prompt           string     `json:"prompt"`
	ModelId          *uuid.UUID `json:"model_id,omitempty"`
	SpeakerId        *uuid.UUID `json:"speaker_id,omitempty"`
	Seed             *int       `json:"seed,omitempty"`
	Temperature      *float32   `json:"temperature,omitempty"`
	DenoiseAudio     *bool      `json:"denoise_audio,omitempty"`
	RemoveSilence    *bool      `json:"remove_silence,omitempty"`
	StreamID         string     `json:"stream_id"`
	SubmitToGallery  bool       `json:"submit_to_gallery"`
	UIId             string     `json:"ui_id"` // Corresponds to UI identifier
	WasAutoSubmitted bool
}

func (*CreateVoiceoverRequest) ApplyDefaults

func (t *CreateVoiceoverRequest) ApplyDefaults()

func (*CreateVoiceoverRequest) Cost

func (t *CreateVoiceoverRequest) Cost() int32

func (*CreateVoiceoverRequest) Validate

func (t *CreateVoiceoverRequest) Validate(api bool) error

type CreditAddRequest

type CreditAddRequest struct {
	CreditTypeID uuid.UUID `json:"credit_type_id"`
	UserID       uuid.UUID `json:"user_id"`
}

type DeactiveApiTokenRequest

type DeactiveApiTokenRequest struct {
	ID uuid.UUID `json:"id"`
}

type DeleteGenerationRequest

type DeleteGenerationRequest struct {
	GenerationOutputIDs []uuid.UUID `json:"generation_output_ids"`
}

type DeleteUserRequest

type DeleteUserRequest struct {
	Action ScheduleForDeleteAction `json:"action"`
}

type DeleteVoiceoverRequest

type DeleteVoiceoverRequest struct {
	OutputIDs []uuid.UUID `json:"output_ids"`
}

type DiscordVerificationRequest

type DiscordVerificationRequest struct {
	Token  string `json:"platform_token"`
	UserID string `json:"platform_user_id"`
}

type EmailPreferencesRequest

type EmailPreferencesRequest struct {
	WantsEmail bool `json:"wants_email"`
}

type FavoriteAction

type FavoriteAction string
const (
	AddFavoriteAction    FavoriteAction = "add"
	RemoveFavoriteAction FavoriteAction = "remove"
)

type FavoriteGenerationRequest

type FavoriteGenerationRequest struct {
	GenerationOutputIDs []uuid.UUID    `json:"generation_output_ids"`
	Action              FavoriteAction `json:"action"`
}

type LikeUnlikeAction

type LikeUnlikeAction string
const (
	LikeAction   LikeUnlikeAction = "like"
	UnlikeAction LikeUnlikeAction = "unlike"
)

type LikeUnlikeActionRequest

type LikeUnlikeActionRequest struct {
	GenerationOutputIDs []uuid.UUID      `json:"generation_output_ids"`
	Action              LikeUnlikeAction `json:"action"`
}

type NewTokenRequest

type NewTokenRequest struct {
	Name string `json:"name"`
}

type OrderBy

type OrderBy string
const (
	OrderByCreatedAt         OrderBy = "created_at"
	OrderByUpdatedAt         OrderBy = "updated_at"
	OrderByLikeCount         OrderBy = "like_count"
	OrderByLikeCountTrending OrderBy = "like_count_trending"
)

type QueryGenerationFilters

type QueryGenerationFilters struct {
	ForHistory                bool                             `json:"-"`
	ForProfile                bool                             `json:"-"`
	ForAdmin                  bool                             `json:"-"`
	HideNsfw                  bool                             `json:"-"`
	ModelIDs                  []uuid.UUID                      `json:"model_ids"`
	SchedulerIDs              []uuid.UUID                      `json:"scheduler_ids"`
	MinHeight                 int32                            `json:"min_height"`
	MaxHeight                 int32                            `json:"max_height"`
	MinWidth                  int32                            `json:"min_width"`
	MaxWidth                  int32                            `json:"max_width"`
	Widths                    []int32                          `json:"widths"`
	Heights                   []int32                          `json:"heights"`
	MaxInferenceSteps         int32                            `json:"max_inference_steps"`
	MinInferenceSteps         int32                            `json:"min_inference_steps"`
	InferenceSteps            []int32                          `json:"inference_steps"`
	MaxGuidanceScale          float32                          `json:"max_guidance_scale"`
	MinGuidanceScale          float32                          `json:"min_guidance_scale"`
	GuidanceScales            []float32                        `json:"guidance_scales"`
	UpscaleStatus             UpscaleStatus                    `json:"upscale_status"`
	GalleryStatus             []generationoutput.GalleryStatus `json:"gallery_status"`
	Order                     SortOrder                        `json:"order"`
	StartDt                   *time.Time                       `json:"start_dt"`
	EndDt                     *time.Time                       `json:"end_dt"`
	UserID                    *uuid.UUID                       `json:"user_id"`
	OrderBy                   OrderBy                          `json:"order_by"`
	ScoreThreshold            *float32                         `json:"score_threshold,omitempty"`
	IsFavorited               *bool                            `json:"is_favorited,omitempty"`
	WasAutoSubmitted          *bool                            `json:"was_auto_submitted,omitempty"`
	PromptID                  *uuid.UUID                       `json:"prompt,omitempty"`
	IsPublic                  *bool                            `json:"is_public,omitempty"`
	IsLiked                   *bool                            `json:"is_liked,omitempty"`
	AestheticArtifactScoreLTE *float32                         `json:"aesthetic_artifact_score_lte,omitempty"`
	AestheticArtifactScoreGTE *float32                         `json:"aesthetic_artifact_score_gte,omitempty"`
	AestheticRatingScoreLTE   *float32                         `json:"aesthetic_rating_score_lte,omitempty"`
	AestheticRatingScoreGTE   *float32                         `json:"aesthetic_rating_score_gte,omitempty"`
	Username                  []string                         `json:"username,omitempty"`
	AspectRatio               []aspectratio.AspectRatio        `json:"aspect_ratio,omitempty"`
	Oversampling              *float32                         `json:"oversampling,omitempty"`
	AdminMode                 *bool                            `json:"admin_mode,omitempty"`
}

func (*QueryGenerationFilters) ParseURLQueryParameters

func (filters *QueryGenerationFilters) ParseURLQueryParameters(urlValues url.Values) error

Parse all filters into a QueryGenerationFilters struct

func (*QueryGenerationFilters) ToQdrantFilters

func (filters *QueryGenerationFilters) ToQdrantFilters(ignoreGalleryStatus bool) (f *qdrant.SearchRequest_Filter, scoreThreshold *float32)

type QueryUserFilters

type QueryUserFilters struct {
	Search string `json:"search"`
}

type QueryVoiceoverFilters

type QueryVoiceoverFilters struct {
	Order            SortOrder  `json:"order"`
	StartDt          *time.Time `json:"start_dt"`
	EndDt            *time.Time `json:"end_dt"`
	UserID           *uuid.UUID `json:"user_id"`
	OrderBy          OrderBy    `json:"order_by"`
	IsFavorited      *bool      `json:"is_favorited,omitempty"`
	WasAutoSubmitted *bool      `json:"was_auto_submitted,omitempty"`
	PromptID         *uuid.UUID `json:"prompt,omitempty"`
}

func (*QueryVoiceoverFilters) ParseURLQueryParameters

func (filters *QueryVoiceoverFilters) ParseURLQueryParameters(urlValues url.Values) error

Parse all filters into a QueryGenerationFilters struct

type ReviewGalleryAction

type ReviewGalleryAction string
const (
	GalleryApproveAction ReviewGalleryAction = "approve"
	GalleryRejectAction  ReviewGalleryAction = "reject"
)

type ReviewGalleryRequest

type ReviewGalleryRequest struct {
	// ! Deprecated, use gallery_status instead
	Action              ReviewGalleryAction            `json:"action"`
	GenerationOutputIDs []uuid.UUID                    `json:"generation_output_ids"`
	GalleryStatus       generationoutput.GalleryStatus `json:"gallery_status"`
}

type RunpodInput

type RunpodInput struct {
	Input BaseCogRequest `json:"input"`
}

Base request data runpod serverless uses to process request

type ScheduleForDeleteAction

type ScheduleForDeleteAction string
const (
	DeleteAction   ScheduleForDeleteAction = "schedule-for-deletion"
	UndeleteAction ScheduleForDeleteAction = "cancel-deletion"
)

type SortOrder

type SortOrder string

For filtering user's generations

const (
	SortOrderAscending  SortOrder = "asc"
	SortOrderDescending SortOrder = "desc"
)

type StripeCheckoutRequest

type StripeCheckoutRequest struct {
	TargetPriceID   string `json:"target_price_id"`
	Currency        string `json:"currency,omitempty"`
	SuccessUrl      string `json:"success_url"`
	CancelUrl       string `json:"cancel_url"`
	PromotionCodeID string `json:"promotion_code_id,omitempty"`
}

type StripeDowngradeRequest

type StripeDowngradeRequest struct {
	TargetPriceID string `json:"target_price_id"`
}

type StripePortalRequest

type StripePortalRequest struct {
	ReturnUrl string `json:"return_url"`
}

type SubmitGalleryRequest

type SubmitGalleryRequest struct {
	GenerationOutputIDs []uuid.UUID `json:"generation_output_ids"`
}

Request for submitting outputs to gallery

type UpscaleRequestType

type UpscaleRequestType string

Request for initiationg an upscale

const (
	UpscaleRequestTypeImage  UpscaleRequestType = "from_image"
	UpscaleRequestTypeOutput UpscaleRequestType = "from_output"
)

type UpscaleStatus

type UpscaleStatus string
const (
	// Include upscaled and not upscaled
	UpscaleStatusAny UpscaleStatus = "any"
	// Only upscaled
	UpscaleStatusOnly UpscaleStatus = "only"
	// Not upscaled
	UpscaleStatusNot UpscaleStatus = "not"
)

Jump to

Keyboard shortcuts

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