[GH-ISSUE #2597] Suggestion - Custom Model Actions #48042

Closed
opened 2026-04-28 06:32:10 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @Subie1 on GitHub (Feb 19, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/2597

Providing an LLM with actions!

  • Putting it simply just giving an LLM the power to have actions it can use which the developer programs themselves.

The request:

  • The request that is sent & provides the LLM with the knowledge of it having actions it can use.
curl http://localhost:11434/api/generate -d '{
  "model": "llama2",
  "system": "You are a librarian",
  "prompt": "How many books do you have?",
  "actions": [{ "name": "get_books", "description": "Get the amount of books you currently have" }]
}'

The response:

  • The simple response which the user detects for a string in the response

    {
      "model": "llama2",
      "created_at": "2023-08-04T08:52:19.385406455-07:00",
      "response": "Sure! Here is how many books I have {\"action\":\"get_books\"}"
    }
    
  • The less simple response but way more intuitive to work with where the actions it tried to use are sent in an array and %0 in the response corresponds to the relation between the first element of the array "get_books" having an index of 0

    {
      "model": "llama2",
      "created_at": "2023-08-04T08:52:19.385406455-07:00",
      "response": "Sure! Here is how many books I have %0",
      "actions": ["get_books"]
    }
    

    Creating actions

  • The format for an action is a simple JSON that explains everything to the LLM:

{
  "name": "get_books", // [REQUIRED] This field is what the LLM will send when it wants to use the action.
  "description": "Get the amount of books you currently have", // [REQUIRED] This field will explain to the LLM what the action does when used.
  "type": "response" // [OPTIONAL] This field explains to the LLM if the response from the action will be added to the response (For example the 0%) or if it'll be an action that doesn't give out a response. (default "response") (values "response"|"silent") 
}

Actions could also be created in a Modelfile:

FROM llama2

SYSTEM """
You are a librarian
"""

ACTIONS """
[
  {
    "name": "get_books", // [REQUIRED] This field is what the LLM will send when it wants to use the action.
    "description": "Get the amount of books you currently have", // [REQUIRED] This field will explain to the LLM what the action does when used.
    "type": "response" // [OPTIONAL] This field explains to the LLM if the response from the action will be added to the response (For example the 0%) or if it'll be an action that doesn't give out a response. (default "response") (values "response"|"silent") 
  }
]
"""
Originally created by @Subie1 on GitHub (Feb 19, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/2597 # Providing an LLM with actions! - Putting it simply just giving an LLM the power to have actions it can use which the developer programs themselves. ### The request: - The request that is sent & provides the LLM with the knowledge of it having actions it can use. ```shell curl http://localhost:11434/api/generate -d '{ "model": "llama2", "system": "You are a librarian", "prompt": "How many books do you have?", "actions": [{ "name": "get_books", "description": "Get the amount of books you currently have" }] }' ``` ### The response: - The simple response which the user detects for a string in the response ```json { "model": "llama2", "created_at": "2023-08-04T08:52:19.385406455-07:00", "response": "Sure! Here is how many books I have {\"action\":\"get_books\"}" } ``` - The less simple response but way more intuitive to work with where the actions it tried to use are sent in an array and `%0` in the response corresponds to the relation between the first element of the array `"get_books"` having an index of `0` ```json { "model": "llama2", "created_at": "2023-08-04T08:52:19.385406455-07:00", "response": "Sure! Here is how many books I have %0", "actions": ["get_books"] } ``` ### Creating actions - The format for an action is a simple JSON that explains everything to the LLM: ```js { "name": "get_books", // [REQUIRED] This field is what the LLM will send when it wants to use the action. "description": "Get the amount of books you currently have", // [REQUIRED] This field will explain to the LLM what the action does when used. "type": "response" // [OPTIONAL] This field explains to the LLM if the response from the action will be added to the response (For example the 0%) or if it'll be an action that doesn't give out a response. (default "response") (values "response"|"silent") } ``` #### Actions could also be created in a Modelfile: ``` FROM llama2 SYSTEM """ You are a librarian """ ACTIONS """ [ { "name": "get_books", // [REQUIRED] This field is what the LLM will send when it wants to use the action. "description": "Get the amount of books you currently have", // [REQUIRED] This field will explain to the LLM what the action does when used. "type": "response" // [OPTIONAL] This field explains to the LLM if the response from the action will be added to the response (For example the 0%) or if it'll be an action that doesn't give out a response. (default "response") (values "response"|"silent") } ] """ ```
GiteaMirror added the feature requestapi labels 2026-04-28 06:32:10 -05:00
Author
Owner

@Subie1 commented on GitHub (Dec 10, 2024):

Added in the form of format with Release v0.5.0

<!-- gh-comment-id:2532504695 --> @Subie1 commented on GitHub (Dec 10, 2024): Added in the form of `format` with [Release v0.5.0](https://github.com/ollama/ollama/releases/tag/v0.5.0)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#48042