[Python] How do I use my own Ollama model I created?

Discussão em 'Python' iniciado por Stack, Junho 29, 2025.

  1. Stack

    Stack Membro Participativo

    I created an Ollama model from a Modelfile and updated the System prompt to mimic Jarvis from Iron Man (which is also named Jarvis). I'm currently importing Ollama into a python file, but I don't know how to run my code and have it use the Jarvis model I created.

    This is all I have right now:

    from ollama import chat

    stream = chat(
    model='llama3.2',
    messages=[{'role': 'user', 'content': 'What is my favorite color?'}],
    stream=True,
    )

    for chunk in stream:
    print(chunk['message']['content'], end='', flush=True)


    I just started fiddling around with llms and Ollama, however I have a feeling that it is something really simple that I'm missing. Any help would be appreciated.

    Continue reading...

Compartilhe esta Página