ollama / ollama-python

Ollama Python library
https://ollama.com
MIT License
2.71k stars 223 forks source link

:pray: Feature request > Create model from file path with SDK #53

Closed adriens closed 4 months ago

adriens commented 5 months ago

:grey_question: 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)'''

: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:

modelfile='./customModelFile'

ollama.create(model='example',
    modelfilepath = modelfile)
mxyng commented 4 months ago

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())