Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions invokeai/app/api/routers/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ async def list_image_dtos(
board_id,
search_term,
current_user.user_id,
current_user.is_admin,
)

return image_dtos
Expand Down
2 changes: 1 addition & 1 deletion invokeai/app/api/routers/model_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ async def convert_model(

with TemporaryDirectory(dir=ApiDependencies.invoker.services.configuration.models_path) as tmpdir:
convert_path = pathlib.Path(tmpdir) / pathlib.Path(model_config.path).stem
converted_model = loader.load_model(model_config)
converted_model = loader.load_model(model_config, user_id=current_admin.user_id)
# write the converted file to the convert path
raw_model = converted_model.model
assert hasattr(raw_model, "save_pretrained")
Expand Down
12 changes: 7 additions & 5 deletions invokeai/app/api/routers/session_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,14 @@ async def get_queue_status(
current_user: CurrentUserOrDefault,
queue_id: str = Path(description="The queue id to perform this operation on"),
) -> SessionQueueAndProcessorStatus:
"""Gets the status of the session queue. Returns global counts; non-admin users additionally
get their own pending/in_progress counts (so the UI can show an X/Y badge) and cannot see the
current item's identifiers unless they own it."""
"""Gets the status of the session queue. Returns global counts; every user additionally gets
their own pending/in_progress counts (so the UI can show an X/Y badge and scope personal UI
like the progress bar to the user's own activity). Non-admin users cannot see the current
item's identifiers unless they own it."""
try:
user_id = None if current_user.is_admin else current_user.user_id
queue = ApiDependencies.invoker.services.session_queue.get_queue_status(queue_id, user_id=user_id)
queue = ApiDependencies.invoker.services.session_queue.get_queue_status(
queue_id, user_id=current_user.user_id, is_admin=current_user.is_admin
)
processor = ApiDependencies.invoker.services.session_processor.get_status()
return SessionQueueAndProcessorStatus(queue=queue, processor=processor)
except Exception as e:
Expand Down
10 changes: 6 additions & 4 deletions invokeai/app/api/routers/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def _resolve_model_path(model_config_path: str) -> Path:
return (base_models_path / model_path).resolve()


def _run_expand_prompt(prompt: str, model_key: str, max_tokens: int, system_prompt: str | None) -> str:
def _run_expand_prompt(prompt: str, model_key: str, max_tokens: int, system_prompt: str | None, user_id: str) -> str:
"""Run text LLM inference synchronously (called from thread)."""
model_manager = ApiDependencies.invoker.services.model_manager
model_config = model_manager.store.get_model(model_key)
Expand All @@ -112,7 +112,7 @@ def _run_expand_prompt(prompt: str, model_key: str, max_tokens: int, system_prom
raise ValueError(f"Model '{model_key}' is not a TextLLM model (got {model_config.type})")

with _model_load_lock:
loaded_model = model_manager.load.load_model(model_config)
loaded_model = model_manager.load.load_model(model_config, user_id=user_id)

with torch.no_grad(), loaded_model.model_on_device() as (_, model):
model_abs_path = _resolve_model_path(model_config.path)
Expand Down Expand Up @@ -147,6 +147,7 @@ async def expand_prompt(current_user: CurrentUserOrDefault, body: ExpandPromptRe
body.model_key,
body.max_tokens,
body.system_prompt,
current_user.user_id,
)
return ExpandPromptResponse(expanded_prompt=expanded)
except UnknownModelException:
Expand All @@ -172,7 +173,7 @@ class ImageToPromptResponse(BaseModel):
error: str | None = None


def _run_image_to_prompt(image_name: str, model_key: str, instruction: str) -> str:
def _run_image_to_prompt(image_name: str, model_key: str, instruction: str, user_id: str) -> str:
"""Run LLaVA OneVision inference synchronously (called from thread)."""
model_manager = ApiDependencies.invoker.services.model_manager
model_config = model_manager.store.get_model(model_key)
Expand All @@ -181,7 +182,7 @@ def _run_image_to_prompt(image_name: str, model_key: str, instruction: str) -> s
raise ValueError(f"Model '{model_key}' is not a LLaVA OneVision model (got {model_config.type})")

with _model_load_lock:
loaded_model = model_manager.load.load_model(model_config)
loaded_model = model_manager.load.load_model(model_config, user_id=user_id)

# Load the image from InvokeAI's image store
image = ApiDependencies.invoker.services.images.get_pil_image(image_name)
Expand Down Expand Up @@ -229,6 +230,7 @@ async def image_to_prompt(current_user: CurrentUserOrDefault, body: ImageToPromp
body.image_name,
body.model_key,
body.instruction,
current_user.user_id,
)
return ImageToPromptResponse(prompt=prompt)
except UnknownModelException:
Expand Down
Loading
Loading