goose icon indicating copy to clipboard operation
goose copied to clipboard

feat: ollama tool shim

Open alicehau opened this issue 9 months ago • 0 comments

Tool shim that uses ollama models to "interpret" LLM responses generated by other models particularly without native tool calling e.g., deepseek. The shim is currently a feature in the openrouter and ollama providers.

The shim instructs the primary model to output json for intended tool usage, the interpretive model uses ollama structured outputs to translate the primary model's message into valid json, and then that json is translated into valid tool calls to be invoked.

To use, set the env var GOOSE_TOOLSHIM=1

The default interpreter model is mistral, but you can override this with the env var GOOSE_TOOLSHIM_MODEL=[name of ollama model].

GOOSE_TOOLSHIM=1 GOOSE_TOOLSHIM_MODEL=llama3.2 cargo run --bin goose session

Recommend running ollama server with env var OLLAMA_CONTEXT_LENGTH set to something higher than the 2048 default limit. e.g., OLLAMA_CONTEXT_LENGTH=50000 ollama serve. This feature is only available from the ollama source build as it hasn't been released yet.

The most promising combination right now seems to be full deepseek-r1 via openrouter + toolshim.

alicehau avatar Feb 28 '25 22:02 alicehau