Ollama
The ollama provider is compatible with Ollama,
which enables access to Llama2, Codellama, Orca, Vicuna, Nous-Hermes, Wizard Vicuna, and more.
You can use its /api/generate endpoint
by specifying any of the following providers from the Ollama library:
ollama:llama2ollama:llama2:13bollama:llama2:70bollama:llama2-uncensoredollama:codellamaollama:orca-mini- and so on...
Also supported is the /api/embeddings endpoint via ollama:embeddings:<model name>.
Supported environment variables:
OLLAMA_BASE_URL- protocol, host name, and port (defaults tohttp://localhost:11434)
To pass configuration options to Ollama, use the config key like so:
providers:
- id: ollama:llama2
config:
num_predict: 1024
localhost and IPv4 vs IPv6
If locally developing with localhost (promptfoo's default),
and Ollama API calls are failing with ECONNREFUSED,
then there may be an IPv4 vs IPv6 issue going on with localhost.
Ollama's default host uses 127.0.0.1,
which is an IPv4 address.
The possible issue here arises from localhost being bound to an IPv6 address,
as configured by the operating system's hosts file.
To investigate and fix this issue, there's a few possible solutions:
- Change Ollama server to use IPv6 addressing by running
export OLLAMA_HOST=":11434"before starting the Ollama server. Note this IPv6 support requires Ollama version0.0.20or newer. - Change promptfoo to directly use an IPv4 address by configuring
export OLLAMA_BASE_URL="http://127.0.0.1:11434". - Update your OS's
hostsfile to bindlocalhostto IPv4.