ollama.create How to create models from local files without modelfile? #208

Closed
opened 2026-02-15 16:28:46 -05:00 by yindo · 1 comment
Owner

Originally created by @winternewt on GitHub (Jan 28, 2025).

It seems there was a breaking change in API since 0.4.5, because my code calling model.create to load local models ggufs no longer works, modelfile= keyword disappeared, seemingly without any deprecation warnings (at least not in pydantic model,modelfile wasn't marked as deprecated field ).

I'm hesitant to downgrade, since I'm looking forward to DeepSeek R1 support, but I'm having trouble adapting my code:

    model_dir = Path(config['gguf_path'])
    model_files = sorted(model_dir.glob('*.gguf'))
    if not model_files:
        raise FileNotFoundError(f"No GGUF model files found in {model_dir}")
    else:
        print(model_files)

    modelfile = f'''
    FROM {model_files[0]}
    SYSTEM {config['system_prompt']}
    '''

    print("Model creation started")
    await client.create(config['model_name'], modelfile=modelfile)
    print("Model creation request complete!")

Neither attempt at a direct use of the same fields,

   await client.create(config['model_name'], from_=str(model_files[0]) ,system=config['system_prompt'])

Nor an attempt to use files keyword

    await client.create(config['model_name'], files=[str(model) for model in model_files] ,system=config['system_prompt'])

https://github.com/ollama/ollama-python/blob/0561f427011cf93e65f3f4b0de60d814cc7a754a/ollama/_types.py#L415

Pydantic model hints it expects a dict, instead, but what should I put as key-value?
"something":path?
I haven't found any example use, description, or API reference for the field, please kindly assist

Originally created by @winternewt on GitHub (Jan 28, 2025). It seems there was a breaking change in API since 0.4.5, because my code calling `model.create` to load local models ggufs no longer works, `modelfile=` keyword disappeared, seemingly without any deprecation warnings (at least not in pydantic model,modelfile wasn't marked as deprecated field ). I'm hesitant to downgrade, since I'm looking forward to DeepSeek R1 support, but I'm having trouble adapting my code: ``` model_dir = Path(config['gguf_path']) model_files = sorted(model_dir.glob('*.gguf')) if not model_files: raise FileNotFoundError(f"No GGUF model files found in {model_dir}") else: print(model_files) modelfile = f''' FROM {model_files[0]} SYSTEM {config['system_prompt']} ''' print("Model creation started") await client.create(config['model_name'], modelfile=modelfile) print("Model creation request complete!") ``` Neither attempt at a direct use of the same fields, ``` await client.create(config['model_name'], from_=str(model_files[0]) ,system=config['system_prompt']) ``` Nor an attempt to use `files` keyword ``` await client.create(config['model_name'], files=[str(model) for model in model_files] ,system=config['system_prompt']) ``` https://github.com/ollama/ollama-python/blob/0561f427011cf93e65f3f4b0de60d814cc7a754a/ollama/_types.py#L415 Pydantic model hints it expects a dict, instead, but what should I put as key-value? "something":path? I haven't found any example use, description, or API reference for the field, please kindly assist
yindo closed this issue 2026-02-15 16:28:46 -05:00
Author
Owner

@ParthSareen commented on GitHub (Jan 28, 2025):

Hi @winternewt! Really sorry about that - we realized that we should've marked it as a breaking change. Apologies for the confusion.

I think this should solve your issue but let me know if it doesn't: https://github.com/ollama/ollama/blob/2ef3c803a151a0a9b1776c9ebe6a7e86b3971660/docs/api.md#create-a-model-from-gguf

@ParthSareen commented on GitHub (Jan 28, 2025): Hi @winternewt! Really sorry about that - we realized that we should've marked it as a breaking change. Apologies for the confusion. I think this should solve your issue but let me know if it doesn't: https://github.com/ollama/ollama/blob/2ef3c803a151a0a9b1776c9ebe6a7e86b3971660/docs/api.md#create-a-model-from-gguf
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#208