Documentation ¶
Index ¶
- func GetPngMetadata(r io.Reader) (map[string]string, error)
- type ComfyClient
- func (c *ComfyClient) CheckConnection() error
- func (c *ComfyClient) ClientID() string
- func (c *ComfyClient) EraseHistory() error
- func (c *ComfyClient) EraseHistoryItem(promptID string) error
- func (c *ComfyClient) GetEmbeddings() ([]string, error)
- func (c *ComfyClient) GetExtensions() ([]string, error)
- func (c *ComfyClient) GetImage(image_data DataOutput) (*[]byte, error)
- func (c *ComfyClient) GetObjectInfos() (*graphapi.NodeObjects, error)
- func (c *ComfyClient) GetPromptHistoryByID() (map[string]PromptHistoryItem, error)
- func (c *ComfyClient) GetPromptHistoryByIndex() ([]PromptHistoryItem, error)
- func (c *ComfyClient) GetQueueExecutionInfo() (*QueueExecInfo, error)
- func (c *ComfyClient) GetQueuedItem(prompt_id string) *QueueItem
- func (c *ComfyClient) GetSharedNodeObject() *graphapi.NodeObjects
- func (c *ComfyClient) GetSystemStats() (*SystemStats, error)
- func (c *ComfyClient) GetViewMetadata(folder string, file string) (string, error)
- func (c *ComfyClient) Init() error
- func (c *ComfyClient) Interrupt() error
- func (c *ComfyClient) IsInitialized() bool
- func (c *ComfyClient) NewGraphFromJsonFile(path string) (*graphapi.Graph, *[]string, error)
- func (c *ComfyClient) NewGraphFromJsonReader(r io.Reader) (*graphapi.Graph, *[]string, error)
- func (c *ComfyClient) NewGraphFromJsonString(path string) (*graphapi.Graph, *[]string, error)
- func (c *ComfyClient) NewGraphFromPNGFile(path string) (*graphapi.Graph, *[]string, error)
- func (c *ComfyClient) NewGraphFromPNGReader(r io.Reader) (*graphapi.Graph, *[]string, error)
- func (cc *ComfyClient) OnMessage(message string)
- func (c *ComfyClient) OnWindowSocketMessage(msg string)
- func (c *ComfyClient) QueuePrompt(graph *graphapi.Graph) (*QueueItem, error)
- func (c *ComfyClient) SetSharedNodeObject(sharedNodeObject *graphapi.NodeObjects)
- func (c *ComfyClient) UploadFileFromPath(filePath string, overwrite bool, filetype ImageType, subfolder string, ...) (string, error)
- func (c *ComfyClient) UploadFileFromReader(r io.Reader, filename string, overwrite bool, filetype ImageType, ...) (string, error)
- func (c *ComfyClient) UploadImage(img image.Image, filename string, overwrite bool, filetype ImageType, ...) (string, error)
- type ComfyClientCallbacks
- type DataOutput
- type GPU
- type ImageType
- type PromptError
- type PromptErrorMessage
- type PromptHistoryItem
- type PromptMessage
- func (p *PromptMessage) ToPromptMessageData() *PromptMessageData
- func (p *PromptMessage) ToPromptMessageExecuting() *PromptMessageExecuting
- func (p *PromptMessage) ToPromptMessageProgress() *PromptMessageProgress
- func (p *PromptMessage) ToPromptMessageQueued() *PromptMessageQueued
- func (p *PromptMessage) ToPromptMessageStarted() *PromptMessageStarted
- func (p *PromptMessage) ToPromptMessageStopped() *PromptMessageStopped
- type PromptMessageData
- type PromptMessageExecuting
- type PromptMessageProgress
- type PromptMessageQueued
- type PromptMessageStarted
- type PromptMessageStopped
- type PromptMessageStoppedException
- type QueueExecInfo
- type QueueItem
- type QueuedItemStoppedReason
- type System
- type SystemStats
- type WSMessageDataExecuted
- type WSMessageDataExecuting
- type WSMessageDataExecutionCached
- type WSMessageDataExecutionStart
- type WSMessageDataProgress
- type WSMessageDataStatus
- type WSMessageExecutionError
- type WSMessageExecutionInterrupted
- type WSStatusMessage
- type WebSocketCallback
- type WebSocketConnection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ComfyClient ¶
type ComfyClient struct {
// contains filtered or unexported fields
}
ComfyClient is the top level object that allows for interaction with the ComfyUI backend
func NewComfyClient ¶
func NewComfyClient(server_address string, server_port int, callbacks *ComfyClientCallbacks) *ComfyClient
NewComfyClient creates a new instance of a Comfy2go client
func NewComfyClientWithTimeout ¶
func NewComfyClientWithTimeout(server_address string, server_port int, callbacks *ComfyClientCallbacks, timeout int, retry int) *ComfyClient
NewComfyClientWithTimeout creates a new instance of a Comfy2go client with a connection timeout
func (*ComfyClient) CheckConnection ¶
func (c *ComfyClient) CheckConnection() error
CheckConnection checks if the websocket connection is still active and tries to reinitialize if not
func (*ComfyClient) ClientID ¶
func (c *ComfyClient) ClientID() string
ClientID returns the unique client ID for the connection to the ComfyUI backend
func (*ComfyClient) EraseHistory ¶
func (c *ComfyClient) EraseHistory() error
func (*ComfyClient) EraseHistoryItem ¶
func (c *ComfyClient) EraseHistoryItem(promptID string) error
func (*ComfyClient) GetEmbeddings ¶
func (c *ComfyClient) GetEmbeddings() ([]string, error)
GetEmbeddings retrieves the list of Embeddings models installed on the ComfyUI server.
func (*ComfyClient) GetExtensions ¶
func (c *ComfyClient) GetExtensions() ([]string, error)
GetExtensions retrieves the list of extensions installed on the ComfyUI server.
func (*ComfyClient) GetImage ¶
func (c *ComfyClient) GetImage(image_data DataOutput) (*[]byte, error)
GetImage
func (*ComfyClient) GetObjectInfos ¶
func (c *ComfyClient) GetObjectInfos() (*graphapi.NodeObjects, error)
func (*ComfyClient) GetPromptHistoryByID ¶
func (c *ComfyClient) GetPromptHistoryByID() (map[string]PromptHistoryItem, error)
func (*ComfyClient) GetPromptHistoryByIndex ¶
func (c *ComfyClient) GetPromptHistoryByIndex() ([]PromptHistoryItem, error)
func (*ComfyClient) GetQueueExecutionInfo ¶
func (c *ComfyClient) GetQueueExecutionInfo() (*QueueExecInfo, error)
func (*ComfyClient) GetQueuedItem ¶
func (c *ComfyClient) GetQueuedItem(prompt_id string) *QueueItem
GetQueuedItem returns a QueueItem that was queued with the ComfyClient, that has not been processed yet or is currently being processed. Once a QueueItem has been processed, it will not be available with this method.
func (*ComfyClient) GetSharedNodeObject ¶ added in v1.0.4
func (c *ComfyClient) GetSharedNodeObject() *graphapi.NodeObjects
func (*ComfyClient) GetSystemStats ¶
func (c *ComfyClient) GetSystemStats() (*SystemStats, error)
func (*ComfyClient) GetViewMetadata ¶
func (c *ComfyClient) GetViewMetadata(folder string, file string) (string, error)
GetViewMetadata retrieves the '__metadata__' field in a safetensors file. checkpoints vae loras clip unet controlnet style_models clip_vision gligen configs hypernetworks upscale_models onnx fonts
func (*ComfyClient) Init ¶
func (c *ComfyClient) Init() error
Init starts the websocket connection (if not already connected) and retrieves the collection of node objects
func (*ComfyClient) Interrupt ¶
func (c *ComfyClient) Interrupt() error
func (*ComfyClient) IsInitialized ¶
func (c *ComfyClient) IsInitialized() bool
IsInitialized returns true if the client's websocket is connected and initialized
func (*ComfyClient) NewGraphFromJsonFile ¶
NewGraphFromJsonFile creates a new graph from a JSON file
func (*ComfyClient) NewGraphFromJsonReader ¶
NewGraphFromJsonReader creates a new graph from the data read from an io.Reader
func (*ComfyClient) NewGraphFromJsonString ¶
NewGraphFromJsonString creates a new graph from a JSON string
func (*ComfyClient) NewGraphFromPNGFile ¶
NewGraphFromPNGReader extracts the workflow from PNG data read from a file and creates a new graph
func (*ComfyClient) NewGraphFromPNGReader ¶
NewGraphFromPNGReader extracts the workflow from PNG data read from an io.Reader and creates a new graph
func (*ComfyClient) OnMessage ¶
func (cc *ComfyClient) OnMessage(message string)
func (*ComfyClient) OnWindowSocketMessage ¶
func (c *ComfyClient) OnWindowSocketMessage(msg string)
OnWindowSocketMessage processes each message received from the websocket connection to ComfyUI. The messages are parsed, and translated into PromptMessage structs and placed into the correct QueuedItem's message channel.
func (*ComfyClient) QueuePrompt ¶
func (c *ComfyClient) QueuePrompt(graph *graphapi.Graph) (*QueueItem, error)
func (*ComfyClient) SetSharedNodeObject ¶ added in v1.0.3
func (c *ComfyClient) SetSharedNodeObject(sharedNodeObject *graphapi.NodeObjects)
func (*ComfyClient) UploadFileFromPath ¶
func (c *ComfyClient) UploadFileFromPath(filePath string, overwrite bool, filetype ImageType, subfolder string, targetProperty *graphapi.ImageUploadProperty) (string, error)
func (*ComfyClient) UploadFileFromReader ¶
func (*ComfyClient) UploadImage ¶
type ComfyClientCallbacks ¶
type ComfyClientCallbacks struct { ClientQueueCountChanged func(*ComfyClient, int) QueuedItemStarted func(*ComfyClient, *QueueItem) QueuedItemStopped func(*ComfyClient, *QueueItem, QueuedItemStoppedReason) QueuedItemDataAvailable func(*ComfyClient, *QueueItem, *PromptMessageData) }
type DataOutput ¶
type PromptError ¶
type PromptErrorMessage ¶
type PromptErrorMessage struct { Error PromptError `json:"error"` NodeErrors []interface{} `json:"node_errors"` }
type PromptHistoryItem ¶
type PromptMessage ¶
type PromptMessage struct { Type string Message interface{} }
func (*PromptMessage) ToPromptMessageData ¶
func (p *PromptMessage) ToPromptMessageData() *PromptMessageData
func (*PromptMessage) ToPromptMessageExecuting ¶
func (p *PromptMessage) ToPromptMessageExecuting() *PromptMessageExecuting
func (*PromptMessage) ToPromptMessageProgress ¶
func (p *PromptMessage) ToPromptMessageProgress() *PromptMessageProgress
func (*PromptMessage) ToPromptMessageQueued ¶
func (p *PromptMessage) ToPromptMessageQueued() *PromptMessageQueued
func (*PromptMessage) ToPromptMessageStarted ¶
func (p *PromptMessage) ToPromptMessageStarted() *PromptMessageStarted
func (*PromptMessage) ToPromptMessageStopped ¶
func (p *PromptMessage) ToPromptMessageStopped() *PromptMessageStopped
type PromptMessageData ¶
type PromptMessageData struct { NodeID int Data map[string][]DataOutput }
type PromptMessageExecuting ¶
type PromptMessageProgress ¶
type PromptMessageQueued ¶
type PromptMessageQueued struct { }
type PromptMessageStarted ¶
type PromptMessageStarted struct {
PromptID string `json:"prompt_id"`
}
type PromptMessageStopped ¶
type PromptMessageStopped struct { QueueItem *QueueItem Exception *PromptMessageStoppedException }
type QueueExecInfo ¶
type QueueExecInfo struct { ExecInfo struct { QueueRemaining int `json:"queue_remaining"` } `json:"exec_info"` }
type QueuedItemStoppedReason ¶
type QueuedItemStoppedReason string
const ( QueuedItemStoppedReasonFinished QueuedItemStoppedReason = "finished" QueuedItemStoppedReasonInterrupted QueuedItemStoppedReason = "interrupted" QueuedItemStoppedReasonError QueuedItemStoppedReason = "error" )
type SystemStats ¶
type WSMessageDataExecuted ¶
type WSMessageDataExecuted struct { Node int `json:"node"` Output map[string]*[]DataOutput `json:"output"` PromptID string `json:"prompt_id"` }
func (*WSMessageDataExecuted) UnmarshalJSON ¶
func (mde *WSMessageDataExecuted) UnmarshalJSON(b []byte) error
type WSMessageDataExecuting ¶
func (*WSMessageDataExecuting) UnmarshalJSON ¶
func (mde *WSMessageDataExecuting) UnmarshalJSON(b []byte) error
type WSMessageDataExecutionCached ¶
type WSMessageDataExecutionCached struct { Nodes []interface{} `json:"nodes"` PromptID string `json:"prompt_id"` }
type WSMessageDataExecutionStart ¶
type WSMessageDataExecutionStart struct {
PromptID string `json:"prompt_id"`
}
type WSMessageDataProgress ¶
type WSMessageDataStatus ¶
type WSMessageDataStatus struct { Status struct { ExecInfo struct { QueueRemaining int `json:"queue_remaining"` } `json:"exec_info"` } `json:"status"` }
type WSMessageExecutionError ¶
type WSMessageExecutionError struct { PromptID string `json:"prompt_id"` Node string `json:"node_id"` NodeType string `json:"node_type"` Executed []string `json:"executed"` ExceptionMessage string `json:"exception_message"` ExceptionType string `json:"exception_type"` Traceback []string `json:"traceback"` CurrentInputs map[string]interface{} `json:"current_inputs"` CurrentOutputs map[int]interface{} `json:"current_outputs"` }
type WSStatusMessage ¶
type WSStatusMessage struct { Type string `json:"type"` Data interface{} `json:"Data"` }
func (*WSStatusMessage) UnmarshalJSON ¶
func (sm *WSStatusMessage) UnmarshalJSON(b []byte) error
type WebSocketCallback ¶
type WebSocketCallback interface {
OnMessage(message string)
}
Callback interface for handling incoming WebSocket messages
type WebSocketConnection ¶
type WebSocketConnection struct { WebSocketURL string Conn *websocket.Conn ConnectionDone chan bool IsConnected bool MaxRetry int RetryCount int ManagerStarted bool Callback WebSocketCallback // Exponential backoff configuration BaseDelay time.Duration // The initial delay, e.g., 1 second MaxDelay time.Duration // The maximum delay, e.g., 1 minute // contains filtered or unexported fields }
func (*WebSocketConnection) ConnectWithManager ¶
func (w *WebSocketConnection) ConnectWithManager(timeoutSeconds int) error
ConnectWithManager connects to the WebSocket using a connection manager timeoutSeconds is the maximum time to wait for a successful connection (0 for no timeout)
func (*WebSocketConnection) LockRead ¶
func (w *WebSocketConnection) LockRead()
func (*WebSocketConnection) Ping ¶
func (w *WebSocketConnection) Ping() error
func (*WebSocketConnection) UnlockRead ¶
func (w *WebSocketConnection) UnlockRead()