Skip to content

iamwavecut/go-sd-webui-a1111-prompt-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-sd-webui-a1111-prompt-parser

Inspired by StableCanvas/sd-webui-a1111-prompt-parser written in TypeScript.

Introduction

go-sd-webui-a1111-prompt-parser is a Stable Diffusion webUI (A1111) prompt parser package for Go. It parses Stable Diffusion model prompts into structured data for easy analysis and manipulation by developers.

Features

  • Parses A1111 format prompts, supporting the following syntax:
    • Plain text
    • Emphasis (parentheses)
    • Weight (brackets)
    • Lora models
    • Hypernetwork models
    • Negative prompts (square brackets)
    • Step Control (scheduling)
  • Converts parsed results into JavaScript objects for easy manipulation and use
  • Supports regenerating A1111 format prompts from JavaScript objects

Installation

go get github.com/iamwavecut/go-sd-webui-a1111-prompt-parser

Usage

import (
	"github.com/iamwavecut/go-sd-webui-a1111-prompt-parser"
)

// ...

    // Parse a prompt
	parser := NewPromptParser()
	parsedNodes, err := parser.Parse("happy family, ([picnic]|beach day), [sunset:sunrise:0.5]")
    if err != nil {
        fmt.Println("Error parsing prompt:", err)
    }
    fmt.Println(parsedNodes)


    // Generate a prompt from the nodes slice
    prompt := GeneratePrompt(parsedNodes)
    fmt.Println(prompt)

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Go parser of A1111 SD-WEBUI prompts.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages