Make --model optional when --audio-model or --image-model are specified

- --model is now optional if using audio or image models only
- Shows helpful error message with examples if no model specified
- Prints available models at startup
parent 3ae1869a
...@@ -2999,7 +2999,7 @@ def parse_args(): ...@@ -2999,7 +2999,7 @@ def parse_args():
"--model", "--model",
type=str, type=str,
default=None, default=None,
help="Model name or path. For NVIDIA: HuggingFace model. For Vulkan: GGUF file path or HF repo", help="Model name, path, or URL for text-to-text LLM. Optional if only using --audio-model or --image-model",
) )
parser.add_argument( parser.add_argument(
"--backend", "--backend",
...@@ -3186,8 +3186,10 @@ def main(): ...@@ -3186,8 +3186,10 @@ def main():
# Get model name from args or prompt interactively # Get model name from args or prompt interactively
model_name = args.model model_name = args.model
if model_name is None:
print("No model specified. Please enter a model name.") # Validate: must have at least one model specified
if model_name is None and args.audio_model is None and args.image_model is None:
print("Error: At least one of --model, --audio-model, or --image-model must be specified.")
print("") print("")
print("For NVIDIA backend (HuggingFace models):") print("For NVIDIA backend (HuggingFace models):")
print(" - microsoft/DialoGPT-medium") print(" - microsoft/DialoGPT-medium")
...@@ -3197,11 +3199,13 @@ def main(): ...@@ -3197,11 +3199,13 @@ def main():
print("For Vulkan backend (GGUF models):") print("For Vulkan backend (GGUF models):")
print(" - Local path: ./phi-3-mini-4k-instruct-q4_k_m.gguf") print(" - Local path: ./phi-3-mini-4k-instruct-q4_k_m.gguf")
print(" - HuggingFace: microsoft/Phi-3-mini-4k-instruct-gguf") print(" - HuggingFace: microsoft/Phi-3-mini-4k-instruct-gguf")
print(" - URL: https://huggingface.co/.../model.gguf")
print("") print("")
model_name = input("Enter model name: ").strip() print("For audio transcription:")
print(" - --audio-model base")
if not model_name: print("")
print("Error: Model name is required") print("For image generation:")
print(" - --image-model stabilityai/stable-diffusion-xl-base-1.0")
sys.exit(1) sys.exit(1)
# Detect available backends # Detect available backends
...@@ -3212,7 +3216,8 @@ def main(): ...@@ -3212,7 +3216,8 @@ def main():
print(f" [{status}] {name}") print(f" [{status}] {name}")
print("") print("")
# Load the main model # Load the main model (only if specified)
if model_name:
load_kwargs = { load_kwargs = {
'offload_dir': args.offload_dir, 'offload_dir': args.offload_dir,
'load_in_4bit': args.load_in_4bit, 'load_in_4bit': args.load_in_4bit,
...@@ -3236,6 +3241,7 @@ def main(): ...@@ -3236,6 +3241,7 @@ def main():
# Register with multi_model_manager # Register with multi_model_manager
multi_model_manager.set_default_model(model_name, load_kwargs) multi_model_manager.set_default_model(model_name, load_kwargs)
multi_model_manager.add_model(model_name, model_manager) multi_model_manager.add_model(model_name, model_manager)
print(f"\nMain text model loaded: {model_name}")
except Exception as e: except Exception as e:
print(f"\nError loading model: {e}") print(f"\nError loading model: {e}")
error_str = str(e).lower() error_str = str(e).lower()
...@@ -3258,6 +3264,8 @@ def main(): ...@@ -3258,6 +3264,8 @@ def main():
print("\n Example Vulkan command:") print("\n Example Vulkan command:")
print(f" coderai --backend vulkan --model {model_name}") print(f" coderai --backend vulkan --model {model_name}")
sys.exit(1) sys.exit(1)
else:
print("\nNo main text model specified (--model). Running with audio/image models only.")
# Set up audio model if specified # Set up audio model if specified
if args.audio_model: if args.audio_model:
...@@ -3291,6 +3299,7 @@ def main(): ...@@ -3291,6 +3299,7 @@ def main():
import uvicorn import uvicorn
print(f"\nStarting server on http://{args.host}:{args.port}") print(f"\nStarting server on http://{args.host}:{args.port}")
print(f"API documentation available at http://{args.host}:{args.port}/docs") print(f"API documentation available at http://{args.host}:{args.port}/docs")
if model_manager.backend is not None:
print(f"Using backend: {model_manager.backend_type}") print(f"Using backend: {model_manager.backend_type}")
# Print available models # Print available models
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment