mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Allow direct prompting of the image generation pipeline
This commit is contained in:
@@ -9216,6 +9216,11 @@ def UI_2_generate_image_from_story(data):
|
|||||||
|
|
||||||
generate_story_image(", ".join(keys), art_guide=art_guide)
|
generate_story_image(", ".join(keys), art_guide=art_guide)
|
||||||
|
|
||||||
|
@socketio.on("generate_image_from_prompt")
|
||||||
|
@logger.catch
|
||||||
|
def UI_2_generate_image_from_prompt(prompt: str):
|
||||||
|
eventlet.sleep(0)
|
||||||
|
generate_story_image(prompt)
|
||||||
|
|
||||||
def generate_story_image(prompt: str, art_guide: str = "") -> None:
|
def generate_story_image(prompt: str, art_guide: str = "") -> None:
|
||||||
# This function is a wrapper around generate_image() that integrates the
|
# This function is a wrapper around generate_image() that integrates the
|
||||||
|
@@ -5092,8 +5092,14 @@ function sendScratchpadPrompt(prompt) {
|
|||||||
socket.emit("scratchpad_prompt", prompt);
|
socket.emit("scratchpad_prompt", prompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function finderSendImgPrompt(prompt) {
|
||||||
|
closePopups();
|
||||||
|
$el("#image-loading").classList.remove("hidden");
|
||||||
|
socket.emit("generate_image_from_prompt", prompt);
|
||||||
|
}
|
||||||
|
|
||||||
function updateSearchListings() {
|
function updateSearchListings() {
|
||||||
if (finder_mode === "scratchpad") return;
|
if (["scratchpad", "imgPrompt"].includes(finder_mode)) return;
|
||||||
if (this.value === finder_last_input) return;
|
if (this.value === finder_last_input) return;
|
||||||
finder_last_input = this.value;
|
finder_last_input = this.value;
|
||||||
finder_selection_index = -1;
|
finder_selection_index = -1;
|
||||||
@@ -5130,8 +5136,13 @@ function updateFinderMode(mode) {
|
|||||||
const finderInput = document.querySelector("#finder-input");
|
const finderInput = document.querySelector("#finder-input");
|
||||||
const finderScratchpad = document.querySelector("#finder-scratchpad");
|
const finderScratchpad = document.querySelector("#finder-scratchpad");
|
||||||
|
|
||||||
finderIcon.innerText = {ui: "search", wi: "auto_stories", scratchpad: "speaker_notes"}[mode];
|
finderIcon.innerText = {ui: "search", wi: "auto_stories", scratchpad: "speaker_notes", "imgPrompt": "image"}[mode];
|
||||||
finderInput.placeholder = {ui: "Search for something...", wi: "Search for a World Info entry...", scratchpad: "Prompt the AI..."}[mode];
|
finderInput.placeholder = {
|
||||||
|
ui: "Search for something...",
|
||||||
|
wi: "Search for a World Info entry...",
|
||||||
|
scratchpad: "Prompt the AI...",
|
||||||
|
imgPrompt: "Generate an image..."
|
||||||
|
}[mode];
|
||||||
finderScratchpad.classList.add("hidden");
|
finderScratchpad.classList.add("hidden");
|
||||||
|
|
||||||
finder_mode = mode;
|
finder_mode = mode;
|
||||||
@@ -5139,7 +5150,7 @@ function updateFinderMode(mode) {
|
|||||||
|
|
||||||
function cycleFinderMode() {
|
function cycleFinderMode() {
|
||||||
// Initiated by clicking on icon
|
// Initiated by clicking on icon
|
||||||
updateFinderMode({ui: "wi", wi: "scratchpad", scratchpad: "ui"}[finder_mode]);
|
updateFinderMode({ui: "wi", wi: "scratchpad", scratchpad: "imgPrompt", imgPrompt: "ui"}[finder_mode]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function open_finder() {
|
function open_finder() {
|
||||||
@@ -5406,7 +5417,7 @@ process_cookies();
|
|||||||
let delta = 0;
|
let delta = 0;
|
||||||
const actions = document.getElementsByClassName("finder-result");
|
const actions = document.getElementsByClassName("finder-result");
|
||||||
|
|
||||||
let newMode = {">": "wi", "#": "ui", "!": "scratchpad"}[event.key];
|
let newMode = {">": "wi", "#": "ui", "!": "scratchpad", "?": "imgPrompt"}[event.key];
|
||||||
if (newMode && !finderInput.value) {
|
if (newMode && !finderInput.value) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
updateFinderMode(newMode);
|
updateFinderMode(newMode);
|
||||||
@@ -5417,6 +5428,9 @@ process_cookies();
|
|||||||
if (finder_mode === "scratchpad") {
|
if (finder_mode === "scratchpad") {
|
||||||
sendScratchpadPrompt(finderInput.value);
|
sendScratchpadPrompt(finderInput.value);
|
||||||
return;
|
return;
|
||||||
|
} else if (finder_mode === "imgPrompt") {
|
||||||
|
finderSendImgPrompt(finderInput.value);
|
||||||
|
return;
|
||||||
} else if (finder_mode === "ui") {
|
} else if (finder_mode === "ui") {
|
||||||
let index = finder_selection_index >= 0 ? finder_selection_index : 0;
|
let index = finder_selection_index >= 0 ? finder_selection_index : 0;
|
||||||
if (!actions[index]) return;
|
if (!actions[index]) return;
|
||||||
|
Reference in New Issue
Block a user