Parse model string into provider and model name. Format: "provider:model_name" or "model_name" (defaults to ollama) Raises: ValueError: If provider is not supported
(model: str)
| 35 | |
| 36 | |
| 37 | def parse_model_string(model: str) -> tuple[str, str]: |
| 38 | """ |
| 39 | Parse model string into provider and model name. |
| 40 | Format: "provider:model_name" or "model_name" (defaults to ollama) |
| 41 | |
| 42 | Raises: |
| 43 | ValueError: If provider is not supported |
| 44 | """ |
| 45 | if provider_delimiter not in model: |
| 46 | # Default to ollama if no provider specified |
| 47 | return "ollama", model |
| 48 | |
| 49 | provider, *model_parts = model.split(provider_delimiter) |
| 50 | model_name = provider_delimiter.join(model_parts) |
| 51 | |
| 52 | # Validate provider |
| 53 | supported_providers = [ |
| 54 | "ollama", |
| 55 | "anthropic", |
| 56 | "deepseek", |
| 57 | "openai", |
| 58 | "gemini", |
| 59 | "fireworks", |
| 60 | # "mlx", |
| 61 | # "groq", |
| 62 | ] |
| 63 | if provider not in supported_providers: |
| 64 | raise ValueError( |
| 65 | f"Unsupported provider: {provider}. " |
| 66 | f"Supported providers are: {', '.join(supported_providers)}" |
| 67 | ) |
| 68 | |
| 69 | return provider, model_name |
| 70 | |
| 71 | |
| 72 | # ------------------------- File Operations ------------------------- |
no outgoing calls
no test coverage detected