mirror of
https://github.com/karl0ss/ai_image_frame_server.git
synced 2025-08-12 20:58:28 +01:00
show queue count
This commit is contained in:
parent
14e69f7608
commit
ff5dfbcbce
@ -194,3 +194,17 @@ def create_image(prompt: str | None = None, model: str = "Random Image Model") -
|
||||
generate_image("image", comfy_prompt=prompt, model=model)
|
||||
|
||||
logging.info(f"{selected_workflow} generation started with prompt: {prompt}")
|
||||
|
||||
def get_queue_count() -> int:
|
||||
"""Fetches the current queue count from ComfyUI (pending + running jobs)."""
|
||||
url = user_config["comfyui"]["comfyui_url"] + "/queue"
|
||||
try:
|
||||
response = requests.get(url)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
pending = len(data.get("queue_pending", []))
|
||||
running = len(data.get("queue_running", []))
|
||||
return pending + running
|
||||
except Exception as e:
|
||||
logging.error(f"Error fetching queue count: {e}")
|
||||
return 0
|
||||
|
@ -1,6 +1,6 @@
|
||||
from flask import Blueprint, request, render_template, redirect, url_for, session
|
||||
import threading
|
||||
from libs.comfyui import create_image, select_model, get_available_models
|
||||
from libs.comfyui import create_image, select_model, get_available_models, get_queue_count
|
||||
from libs.openwebui import create_prompt_on_openwebui
|
||||
from libs.generic import load_models_from_config, load_topics_from_config, load_openrouter_models_from_config, load_openwebui_models_from_config, create_prompt_with_random_model
|
||||
import os
|
||||
@ -40,13 +40,15 @@ def create():
|
||||
openwebui_models = load_openwebui_models_from_config()
|
||||
openrouter_models = load_openrouter_models_from_config()
|
||||
|
||||
queue_count = get_queue_count()
|
||||
return render_template("create_image.html",
|
||||
sdxl_models=sdxl_models,
|
||||
sdxx_models=sdxl_models,
|
||||
flux_models=flux_models,
|
||||
qwen_models=qwen_models,
|
||||
openwebui_models=openwebui_models,
|
||||
openrouter_models=openrouter_models,
|
||||
topics=load_topics_from_config())
|
||||
topics=load_topics_from_config(),
|
||||
queue_count=queue_count)
|
||||
|
||||
@bp.route("/image_queued")
|
||||
def image_queued():
|
||||
@ -68,13 +70,15 @@ def create_image_page():
|
||||
openwebui_models = load_openwebui_models_from_config()
|
||||
openrouter_models = load_openrouter_models_from_config()
|
||||
|
||||
queue_count = get_queue_count()
|
||||
return render_template("create_image.html",
|
||||
sdxl_models=sdxl_models,
|
||||
flux_models=flux_models,
|
||||
qwen_models=qwen_models,
|
||||
openwebui_models=openwebui_models,
|
||||
openrouter_models=openrouter_models,
|
||||
topics=load_topics_from_config())
|
||||
topics=load_topics_from_config(),
|
||||
queue_count=queue_count)
|
||||
|
||||
|
||||
def init_app(config):
|
||||
|
@ -135,6 +135,9 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div style="position: fixed; top: 20px; right: 20px; background: #333; padding: 5px 10px; border-radius: 5px; z-index: 1000;">
|
||||
Queue: {{ queue_count | default(0) }}
|
||||
</div>
|
||||
<h1 style="margin-bottom: 20px;">Create An Image</h1>
|
||||
|
||||
<textarea id="prompt-box" placeholder="Enter your custom prompt here..."></textarea>
|
||||
|
Loading…
x
Reference in New Issue
Block a user