Documentation
Configuring Ollama
Ollama allows you to run LLMs locally on your computer or in a Kubernetes cluster. Configuring Ollama in kagent follows the same pattern as for other providers.
Let's give an example of how to run Ollama on a Kubernetes cluster:
- Create a namespace for Ollama deployment and service:
kubectl create ns ollama
- Create the deployment and service:
apiVersion: apps/v1kind: Deploymentmetadata:name: ollamanamespace: ollamaspec:selector:matchLabels:name: ollamatemplate:metadata:labels:name: ollamaspec:containers:- name: ollamaimage: ollama/ollama:latestports:- name: httpcontainerPort: 11434protocol: TCP---apiVersion: v1kind: Servicemetadata:name: ollamanamespace: ollamaspec:type: ClusterIPselector:name: ollamaports:- port: 80name: httptargetPort: httpprotocol: TCP
You can run kubectl get pod -n ollama
and wait until the pod has started.
Once the pod has started, you can port-forward to the Ollama service and use ollama run [model-name]
to download/run the model. You can download Ollama binary here.
As kagent relies on calling tools, sure you're using a model that allows function calling.
Let's assume we've downloaded the llama3
model, you can then use the following ModelConfig to configure the model:
apiVersion: kagent.dev/v1alpha1kind: ModelConfigmetadata:name: llama3-model-confignamespace: kagentspec:apiKeySecretKey: OPENAI_API_KEYapiKeySecretRef: kagent-openaimodel: llama3provider: Ollamaollama:host: http://ollama.ollama.svc.cluster.local