[GH-ISSUE #5885] llama3.1 template needs to be updated to include tools #50185

Closed
opened 2026-04-28 14:36:30 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @rick-github on GitHub (Jul 23, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/5885

What is the issue?

The current version of llama3.1 doesn't support tool use:

$ curl -s http://aitoolkit:11434/v1/chat/completions -d '{"model": "llama3.1","tools":[{"type":"function","function": {}}], "messages": [{"role":"user","content":"weather in zurich"}], "stream": false}' | jq
{
  "error": {
    "message": "llama3.1 does not support tools",
    "type": "api_error",
    "param": null,
    "code": null
  }
}

I was able to make it work by using the template from llama3-groq-tool-use:

$ curl -s http://aitoolkit:11434/v1/chat/completions -d '{"model": "llama3.1-tool","tools":[{"type":"function","function": {}}], "messages": [{"role":"user","content":"weather in zurich"}], "stream": false}' | jq
{
  "id": "chatcmpl-43",
  "object": "chat.completion",
  "created": 1721758820,
  "model": "llama3.1-tool",
  "system_fingerprint": "fp_ollama",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "",
        "tool_calls": [
          {
            "id": "call_bftkcsk3",
            "type": "function",
            "function": {
              "name": "get_weather",
              "arguments": "{}"
            }
          }
        ]
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 139,
    "completion_tokens": 20,
    "total_tokens": 159
  }
}

OS

Linux

GPU

Nvidia

CPU

Intel

Ollama version

0.2.8

Originally created by @rick-github on GitHub (Jul 23, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/5885 ### What is the issue? The current version of llama3.1 doesn't support tool use: ``` $ curl -s http://aitoolkit:11434/v1/chat/completions -d '{"model": "llama3.1","tools":[{"type":"function","function": {}}], "messages": [{"role":"user","content":"weather in zurich"}], "stream": false}' | jq { "error": { "message": "llama3.1 does not support tools", "type": "api_error", "param": null, "code": null } } ``` I was able to make it work by using the template from llama3-groq-tool-use: ``` $ curl -s http://aitoolkit:11434/v1/chat/completions -d '{"model": "llama3.1-tool","tools":[{"type":"function","function": {}}], "messages": [{"role":"user","content":"weather in zurich"}], "stream": false}' | jq { "id": "chatcmpl-43", "object": "chat.completion", "created": 1721758820, "model": "llama3.1-tool", "system_fingerprint": "fp_ollama", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "", "tool_calls": [ { "id": "call_bftkcsk3", "type": "function", "function": { "name": "get_weather", "arguments": "{}" } } ] }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 139, "completion_tokens": 20, "total_tokens": 159 } } ``` ### OS Linux ### GPU Nvidia ### CPU Intel ### Ollama version 0.2.8
GiteaMirror added the bug label 2026-04-28 14:36:31 -05:00
Author
Owner

@endyjasmi commented on GitHub (Jul 24, 2024):

Maybe we can use this page https://llama.meta.com/docs/model-cards-and-prompt-formats/llama3_1/ as a reference for the tool calling template?

<!-- gh-comment-id:2246803361 --> @endyjasmi commented on GitHub (Jul 24, 2024): Maybe we can use this page https://llama.meta.com/docs/model-cards-and-prompt-formats/llama3_1/ as a reference for the tool calling template?
Author
Owner

@rick-github commented on GitHub (Jul 24, 2024):

$ ollama pull llama3.1:latest
#...
$ curl -s http://aitoolkit:11434/v1/chat/completions -d '{"model": "llama3.1","tools":[{"type":"function","function": {}}], "messages": [{"role":"user","content":"weather in zurich"}], "stream": false}' | jq
{
  "id": "chatcmpl-427",
  "object": "chat.completion",
  "created": 1721838691,
  "model": "llama3.1",
  "system_fingerprint": "fp_ollama",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "",
        "tool_calls": [
          {
            "id": "call_cj44qz59",
            "type": "function",
            "function": {
              "name": "get_weather",
              "arguments": "{\"location\":\"Zurich\"}"
            }
          }
        ]
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 127,
    "completion_tokens": 61,
    "total_tokens": 188
  }
}

<!-- gh-comment-id:2248455924 --> @rick-github commented on GitHub (Jul 24, 2024): ``` $ ollama pull llama3.1:latest #... $ curl -s http://aitoolkit:11434/v1/chat/completions -d '{"model": "llama3.1","tools":[{"type":"function","function": {}}], "messages": [{"role":"user","content":"weather in zurich"}], "stream": false}' | jq { "id": "chatcmpl-427", "object": "chat.completion", "created": 1721838691, "model": "llama3.1", "system_fingerprint": "fp_ollama", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "", "tool_calls": [ { "id": "call_cj44qz59", "type": "function", "function": { "name": "get_weather", "arguments": "{\"location\":\"Zurich\"}" } } ] }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 127, "completion_tokens": 61, "total_tokens": 188 } } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#50185