ollamadiffuser 1.2.3__py3-none-any.whl → 2.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ollamadiffuser/__init__.py +1 -1
- ollamadiffuser/api/server.py +312 -312
- ollamadiffuser/cli/config_commands.py +119 -0
- ollamadiffuser/cli/lora_commands.py +169 -0
- ollamadiffuser/cli/main.py +85 -1233
- ollamadiffuser/cli/model_commands.py +664 -0
- ollamadiffuser/cli/recommend_command.py +205 -0
- ollamadiffuser/cli/registry_commands.py +197 -0
- ollamadiffuser/core/config/model_registry.py +562 -11
- ollamadiffuser/core/config/settings.py +24 -2
- ollamadiffuser/core/inference/__init__.py +5 -0
- ollamadiffuser/core/inference/base.py +182 -0
- ollamadiffuser/core/inference/engine.py +204 -1405
- ollamadiffuser/core/inference/strategies/__init__.py +1 -0
- ollamadiffuser/core/inference/strategies/controlnet_strategy.py +170 -0
- ollamadiffuser/core/inference/strategies/flux_strategy.py +136 -0
- ollamadiffuser/core/inference/strategies/generic_strategy.py +164 -0
- ollamadiffuser/core/inference/strategies/gguf_strategy.py +113 -0
- ollamadiffuser/core/inference/strategies/hidream_strategy.py +104 -0
- ollamadiffuser/core/inference/strategies/sd15_strategy.py +134 -0
- ollamadiffuser/core/inference/strategies/sd3_strategy.py +80 -0
- ollamadiffuser/core/inference/strategies/sdxl_strategy.py +131 -0
- ollamadiffuser/core/inference/strategies/video_strategy.py +108 -0
- ollamadiffuser/mcp/__init__.py +0 -0
- ollamadiffuser/mcp/server.py +184 -0
- ollamadiffuser/ui/templates/index.html +62 -1
- ollamadiffuser/ui/web.py +116 -54
- {ollamadiffuser-1.2.3.dist-info → ollamadiffuser-2.0.1.dist-info}/METADATA +317 -108
- ollamadiffuser-2.0.1.dist-info/RECORD +61 -0
- {ollamadiffuser-1.2.3.dist-info → ollamadiffuser-2.0.1.dist-info}/WHEEL +1 -1
- {ollamadiffuser-1.2.3.dist-info → ollamadiffuser-2.0.1.dist-info}/entry_points.txt +1 -0
- ollamadiffuser/core/models/registry.py +0 -384
- ollamadiffuser/ui/samples/.DS_Store +0 -0
- ollamadiffuser-1.2.3.dist-info/RECORD +0 -45
- {ollamadiffuser-1.2.3.dist-info → ollamadiffuser-2.0.1.dist-info}/licenses/LICENSE +0 -0
- {ollamadiffuser-1.2.3.dist-info → ollamadiffuser-2.0.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"""Configuration management CLI commands"""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
import click
|
|
7
|
+
from rich.console import Console
|
|
8
|
+
from rich.table import Table
|
|
9
|
+
from rich import print as rprint
|
|
10
|
+
|
|
11
|
+
from ..core.config.settings import settings
|
|
12
|
+
|
|
13
|
+
console = Console()
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@click.group(invoke_without_command=True)
|
|
17
|
+
@click.pass_context
|
|
18
|
+
def config(ctx):
|
|
19
|
+
"""Show or modify OllamaDiffuser configuration"""
|
|
20
|
+
if ctx.invoked_subcommand is None:
|
|
21
|
+
_show_config()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _show_config():
|
|
25
|
+
"""Display all current configuration values."""
|
|
26
|
+
# Paths section
|
|
27
|
+
rprint("[bold cyan]Paths[/bold cyan]")
|
|
28
|
+
table = Table(show_header=True)
|
|
29
|
+
table.add_column("Key", style="yellow")
|
|
30
|
+
table.add_column("Value", style="white")
|
|
31
|
+
|
|
32
|
+
default_models_dir = settings.config_dir / "models"
|
|
33
|
+
default_cache_dir = settings.config_dir / "cache"
|
|
34
|
+
|
|
35
|
+
table.add_row("config_dir", str(settings.config_dir))
|
|
36
|
+
table.add_row("config_file", str(settings.config_file))
|
|
37
|
+
|
|
38
|
+
models_label = str(settings.models_dir)
|
|
39
|
+
if settings.models_dir != default_models_dir:
|
|
40
|
+
models_label += " [dim](custom)[/dim]"
|
|
41
|
+
table.add_row("models_dir", models_label)
|
|
42
|
+
|
|
43
|
+
cache_label = str(settings.cache_dir)
|
|
44
|
+
if settings.cache_dir != default_cache_dir:
|
|
45
|
+
cache_label += " [dim](custom)[/dim]"
|
|
46
|
+
table.add_row("cache_dir", cache_label)
|
|
47
|
+
|
|
48
|
+
console.print(table)
|
|
49
|
+
|
|
50
|
+
# Server section
|
|
51
|
+
rprint("\n[bold cyan]Server[/bold cyan]")
|
|
52
|
+
server_table = Table(show_header=True)
|
|
53
|
+
server_table.add_column("Key", style="yellow")
|
|
54
|
+
server_table.add_column("Value", style="white")
|
|
55
|
+
server_table.add_row("server.host", settings.server.host)
|
|
56
|
+
server_table.add_row("server.port", str(settings.server.port))
|
|
57
|
+
server_table.add_row("server.max_queue_size", str(settings.server.max_queue_size))
|
|
58
|
+
server_table.add_row("server.timeout", str(settings.server.timeout))
|
|
59
|
+
server_table.add_row("server.enable_cors", str(settings.server.enable_cors))
|
|
60
|
+
console.print(server_table)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
# Map of settable keys to (type_hint, setter_function)
|
|
64
|
+
SETTABLE_KEYS = {
|
|
65
|
+
"models_dir": ("path", lambda v: _set_path("models_dir", v)),
|
|
66
|
+
"cache_dir": ("path", lambda v: _set_path("cache_dir", v)),
|
|
67
|
+
"server.host": ("str", lambda v: setattr(settings.server, "host", v)),
|
|
68
|
+
"server.port": ("int", lambda v: setattr(settings.server, "port", int(v))),
|
|
69
|
+
"server.max_queue_size": ("int", lambda v: setattr(settings.server, "max_queue_size", int(v))),
|
|
70
|
+
"server.timeout": ("int", lambda v: setattr(settings.server, "timeout", int(v))),
|
|
71
|
+
"server.enable_cors": ("bool", lambda v: setattr(settings.server, "enable_cors", v.lower() in ("true", "1", "yes"))),
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _set_path(attr: str, value: str):
|
|
76
|
+
"""Set a path attribute on settings, creating the directory."""
|
|
77
|
+
p = Path(value).expanduser().resolve()
|
|
78
|
+
p.mkdir(parents=True, exist_ok=True)
|
|
79
|
+
setattr(settings, attr, p)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@config.command("set")
|
|
83
|
+
@click.argument("key")
|
|
84
|
+
@click.argument("value")
|
|
85
|
+
def set_value(key: str, value: str):
|
|
86
|
+
"""Set a configuration value.
|
|
87
|
+
|
|
88
|
+
\b
|
|
89
|
+
Settable keys:
|
|
90
|
+
models_dir Custom model storage directory
|
|
91
|
+
cache_dir Custom cache directory
|
|
92
|
+
server.host Server bind address
|
|
93
|
+
server.port Server port number
|
|
94
|
+
server.max_queue_size Maximum request queue size
|
|
95
|
+
server.timeout Request timeout in seconds
|
|
96
|
+
server.enable_cors Enable CORS (true/false)
|
|
97
|
+
|
|
98
|
+
\b
|
|
99
|
+
Examples:
|
|
100
|
+
ollamadiffuser config set models_dir /mnt/ssd/models
|
|
101
|
+
ollamadiffuser config set server.port 9000
|
|
102
|
+
"""
|
|
103
|
+
if key not in SETTABLE_KEYS:
|
|
104
|
+
rprint(f"[red]Unknown key: {key}[/red]")
|
|
105
|
+
rprint(f"[dim]Settable keys: {', '.join(sorted(SETTABLE_KEYS))}[/dim]")
|
|
106
|
+
sys.exit(1)
|
|
107
|
+
|
|
108
|
+
type_hint, setter = SETTABLE_KEYS[key]
|
|
109
|
+
|
|
110
|
+
try:
|
|
111
|
+
if type_hint == "int":
|
|
112
|
+
int(value) # pre-validate
|
|
113
|
+
setter(value)
|
|
114
|
+
except (ValueError, OSError) as e:
|
|
115
|
+
rprint(f"[red]Invalid value for {key}: {e}[/red]")
|
|
116
|
+
sys.exit(1)
|
|
117
|
+
|
|
118
|
+
settings.save_config()
|
|
119
|
+
rprint(f"[green]Set {key} = {value}[/green]")
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"""LoRA management CLI commands"""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from typing import Optional
|
|
5
|
+
|
|
6
|
+
import click
|
|
7
|
+
from rich.console import Console
|
|
8
|
+
from rich.table import Table
|
|
9
|
+
from rich.progress import Progress, SpinnerColumn, TextColumn
|
|
10
|
+
from rich import print as rprint
|
|
11
|
+
|
|
12
|
+
from ..core.models.manager import model_manager
|
|
13
|
+
from ..core.config.settings import settings
|
|
14
|
+
|
|
15
|
+
console = Console()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@click.group()
|
|
19
|
+
def lora():
|
|
20
|
+
"""LoRA (Low-Rank Adaptation) management commands"""
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@lora.command()
|
|
25
|
+
@click.argument("repo_id")
|
|
26
|
+
@click.option("--weight-name", "-w", help="Specific weight file name")
|
|
27
|
+
@click.option("--alias", "-a", help="Local alias name for the LoRA")
|
|
28
|
+
def pull(repo_id: str, weight_name: Optional[str], alias: Optional[str]):
|
|
29
|
+
"""Download LoRA weights from Hugging Face Hub"""
|
|
30
|
+
from ..core.utils.lora_manager import lora_manager
|
|
31
|
+
|
|
32
|
+
rprint(f"[blue]Downloading LoRA: {repo_id}[/blue]")
|
|
33
|
+
with Progress(SpinnerColumn(), TextColumn("[progress.description]{task.description}"), console=console) as progress:
|
|
34
|
+
task = progress.add_task("Downloading LoRA...", total=None)
|
|
35
|
+
|
|
36
|
+
def cb(msg):
|
|
37
|
+
progress.update(task, description=msg)
|
|
38
|
+
|
|
39
|
+
if lora_manager.pull_lora(repo_id, weight_name=weight_name, alias=alias, progress_callback=cb):
|
|
40
|
+
rprint(f"[green]LoRA {repo_id} downloaded successfully![/green]")
|
|
41
|
+
else:
|
|
42
|
+
rprint(f"[red]LoRA {repo_id} download failed![/red]")
|
|
43
|
+
sys.exit(1)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@lora.command()
|
|
47
|
+
@click.argument("lora_name")
|
|
48
|
+
@click.option("--scale", "-s", default=1.0, type=float, help="LoRA scale (default: 1.0)")
|
|
49
|
+
def load(lora_name: str, scale: float):
|
|
50
|
+
"""Load LoRA weights into the current model"""
|
|
51
|
+
from ..core.utils.lora_manager import lora_manager
|
|
52
|
+
|
|
53
|
+
rprint(f"[blue]Loading LoRA: {lora_name} (scale: {scale})[/blue]")
|
|
54
|
+
if lora_manager.load_lora(lora_name, scale=scale):
|
|
55
|
+
rprint(f"[green]LoRA {lora_name} loaded![/green]")
|
|
56
|
+
else:
|
|
57
|
+
rprint(f"[red]Failed to load LoRA {lora_name}![/red]")
|
|
58
|
+
sys.exit(1)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@lora.command()
|
|
62
|
+
def unload():
|
|
63
|
+
"""Unload current LoRA weights"""
|
|
64
|
+
from ..core.utils.lora_manager import lora_manager
|
|
65
|
+
|
|
66
|
+
if lora_manager.unload_lora():
|
|
67
|
+
rprint("[green]LoRA unloaded![/green]")
|
|
68
|
+
else:
|
|
69
|
+
rprint("[red]Failed to unload LoRA![/red]")
|
|
70
|
+
sys.exit(1)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@lora.command()
|
|
74
|
+
@click.argument("lora_name")
|
|
75
|
+
@click.confirmation_option(prompt="Are you sure you want to delete this LoRA?")
|
|
76
|
+
def rm(lora_name: str):
|
|
77
|
+
"""Remove LoRA weights"""
|
|
78
|
+
from ..core.utils.lora_manager import lora_manager
|
|
79
|
+
|
|
80
|
+
if lora_manager.remove_lora(lora_name):
|
|
81
|
+
rprint(f"[green]LoRA {lora_name} removed![/green]")
|
|
82
|
+
else:
|
|
83
|
+
rprint(f"[red]Failed to remove LoRA {lora_name}![/red]")
|
|
84
|
+
sys.exit(1)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@lora.command()
|
|
88
|
+
def ps():
|
|
89
|
+
"""Show currently loaded LoRA status"""
|
|
90
|
+
from ..core.utils.lora_manager import lora_manager
|
|
91
|
+
|
|
92
|
+
server_running = lora_manager._is_server_running()
|
|
93
|
+
current_lora = lora_manager.get_current_lora()
|
|
94
|
+
|
|
95
|
+
if server_running:
|
|
96
|
+
rprint(f"[green]Server: Running on {settings.server.host}:{settings.server.port}[/green]")
|
|
97
|
+
try:
|
|
98
|
+
import requests
|
|
99
|
+
resp = requests.get(f"http://{settings.server.host}:{settings.server.port}/api/lora/status", timeout=2)
|
|
100
|
+
if resp.status_code == 200:
|
|
101
|
+
data = resp.json()
|
|
102
|
+
if data.get("loaded"):
|
|
103
|
+
info = data.get("info", {})
|
|
104
|
+
rprint(f"\n[bold green]LoRA: LOADED[/bold green]")
|
|
105
|
+
rprint(f" Repo: {info.get('repo_id', 'Unknown')}")
|
|
106
|
+
rprint(f" Scale: {info.get('scale', 'Unknown')}")
|
|
107
|
+
return
|
|
108
|
+
else:
|
|
109
|
+
rprint("[dim]No LoRA loaded on server[/dim]")
|
|
110
|
+
return
|
|
111
|
+
except Exception:
|
|
112
|
+
pass
|
|
113
|
+
elif not model_manager.is_model_loaded():
|
|
114
|
+
rprint("[yellow]No model loaded[/yellow]")
|
|
115
|
+
return
|
|
116
|
+
|
|
117
|
+
if current_lora:
|
|
118
|
+
info = lora_manager.get_lora_info(current_lora)
|
|
119
|
+
if info:
|
|
120
|
+
rprint(f"\n[bold green]LoRA: {current_lora}[/bold green]")
|
|
121
|
+
rprint(f" Repo: {info.get('repo_id', 'Unknown')}")
|
|
122
|
+
rprint(f" Size: {info.get('size', 'Unknown')}")
|
|
123
|
+
else:
|
|
124
|
+
rprint("[dim]No LoRA loaded[/dim]")
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
@lora.command()
|
|
128
|
+
def list():
|
|
129
|
+
"""List installed LoRA weights"""
|
|
130
|
+
from ..core.utils.lora_manager import lora_manager
|
|
131
|
+
|
|
132
|
+
installed = lora_manager.list_installed_loras()
|
|
133
|
+
current = lora_manager.get_current_lora()
|
|
134
|
+
|
|
135
|
+
if not installed:
|
|
136
|
+
rprint("[yellow]No LoRA weights installed.[/yellow]")
|
|
137
|
+
rprint("[dim]Use 'ollamadiffuser lora pull <repo_id>' to download[/dim]")
|
|
138
|
+
return
|
|
139
|
+
|
|
140
|
+
table = Table(title="Installed LoRA Weights")
|
|
141
|
+
table.add_column("Name", style="cyan")
|
|
142
|
+
table.add_column("Repository", style="blue")
|
|
143
|
+
table.add_column("Status", style="green")
|
|
144
|
+
table.add_column("Size", style="yellow")
|
|
145
|
+
|
|
146
|
+
for name, info in installed.items():
|
|
147
|
+
status = "Loaded" if name == current else "Available"
|
|
148
|
+
table.add_row(name, info.get("repo_id", "?"), status, info.get("size", "?"))
|
|
149
|
+
|
|
150
|
+
console.print(table)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
@lora.command()
|
|
154
|
+
@click.argument("lora_name")
|
|
155
|
+
def show(lora_name: str):
|
|
156
|
+
"""Show detailed LoRA information"""
|
|
157
|
+
from ..core.utils.lora_manager import lora_manager
|
|
158
|
+
|
|
159
|
+
info = lora_manager.get_lora_info(lora_name)
|
|
160
|
+
if not info:
|
|
161
|
+
rprint(f"[red]LoRA {lora_name} not found.[/red]")
|
|
162
|
+
sys.exit(1)
|
|
163
|
+
|
|
164
|
+
rprint(f"[bold cyan]LoRA: {lora_name}[/bold cyan]")
|
|
165
|
+
rprint(f"Repository: {info.get('repo_id', 'Unknown')}")
|
|
166
|
+
rprint(f"Weight File: {info.get('weight_name', 'Unknown')}")
|
|
167
|
+
rprint(f"Path: {info.get('path', 'Unknown')}")
|
|
168
|
+
rprint(f"Size: {info.get('size', 'Unknown')}")
|
|
169
|
+
rprint(f"Downloaded: {info.get('downloaded_at', 'Unknown')}")
|