1 min read 90 words Updated Sep 24, 2026 Created Sep 24, 2026
#AI#LLM#ml

Ollama can be used as a model provider for LangChain. Here is a quick example on how to build agents:

from langchain_ollama import ChatOllama
from langchain.agents import create_agent
from langchain.tools import tool


@tool
def get_weather(location: str) -> str:
    """Get weather information for a location."""
    return f"Weather in {location}: Sunny, 72°F"

llm = ChatOllama(
    model="mistral:7b",
    temperature=0
)

agent = create_agent(llm, tools=[get_weather])

print(agent.invoke(
       {"messages": [{"role": "user", "content": "What is the weather in Madrid?"}]},
))

Mistral 7B is a good alternative to the Ministral 8B model, available on the Mistral API