🙏 Feature request > Create model from file path with SDK #23

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

Originally created by @adriens on GitHub (Feb 3, 2024).

About

Currently we can create model from sdk this way;

modelfile='''
FROM llama2
SYSTEM You are mario from super mario bros.

ollama.create(model='example', modelfile=modelfile)'''

🤔 Sometimes, it could be even easier to load a file directly by provding the model file (possibly generated by third party process) path to the SDK so the code would become:

modelfile='./customModelFile'

ollama.create(model='example',
    modelfilepath = modelfile)
Originally created by @adriens on GitHub (Feb 3, 2024). # :grey_question: About Currently we can [create model from sdk](https://github.com/ollama/ollama-python?tab=readme-ov-file#create) this way; ```python modelfile=''' FROM llama2 SYSTEM You are mario from super mario bros. ollama.create(model='example', modelfile=modelfile)''' ``` :thinking: Sometimes, it could be even easier to load a file **directly by provding the model file (possibly generated by third party process) path to the SDK** so the code would become: ```python modelfile='./customModelFile' ollama.create(model='example', modelfilepath = modelfile) ```
yindo closed this issue 2026-02-15 16:27:32 -05:00
Author
Owner

@mxyng commented on GitHub (Feb 5, 2024):

This is possible in a couple ways. Here are some examples:

Using the path keyword argument:

ollama.create(model='name', path=modelfilepath)

Reading the file explicitly:

with open(modelfilepath) as f:
  ollama.create(model='name', modelfile=f.read())
@mxyng commented on GitHub (Feb 5, 2024): This is possible in a couple ways. Here are some examples: Using the `path` keyword argument: ```python ollama.create(model='name', path=modelfilepath) ``` Reading the file explicitly: ```python with open(modelfilepath) as f: ollama.create(model='name', modelfile=f.read()) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#23