[PR #466] [CLOSED] template extra args #10166

Closed
opened 2026-04-12 22:53:16 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/466
Author: @mxyng
Created: 9/3/2023
Status: Closed

Base: mainHead: mxyng/extra-args


📝 Commits (1)

📊 Changes

2 files changed (+8 additions, -5 deletions)

View changed files

📝 api/types.go (+6 -5)
📝 server/images.go (+2 -0)

📄 Description

User defined arguments to the template, making things like infilling easier:

FROM codellama:7b-code
TEMPLATE "<PRE> {{ .Args.Prefix }} <SUF> {{- .Args.Suffix }} <MID>"

Request:

$ curl -s localhost:11434/api/generate -d '{"model":"codellama-infill","args":{"Prefix":"def remove_non_ascii(s: str) -> str:\n\t\"\"\"","Suffix":"return result"}}' | jq -r -j 'select(.response != null) | .response'

    Remove non-ASCII characters from a string.

    Parameters
    ----------
    s : str
        The input string.

    Returns
    -------
    str
        The output string.
    """
        result = ""
        for char in s:
                if ord(char) < 128:
                        result += char

Or messages:

FROM llama2:7b

TEMPLATE """{{ range .Args.Messages }}[INST] {{ if .System -}}
<<SYS>>{{ .System }}<</SYS>>
{{- end }}

{{ range .Request }} [/INST] {{ .Response }} {{ end }}"""
$ curl -s localhost:11434/api/generate -d '{"model":"llama2","args": {"Messages": [{"System":"you are a good robot","Request":"tell me a joke","Response":"why is the sky blue?"},{"Request":"why did you say that?","Response":"i don't know"},{"Request":"do it again"}]'

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/466 **Author:** [@mxyng](https://github.com/mxyng) **Created:** 9/3/2023 **Status:** ❌ Closed **Base:** `main` ← **Head:** `mxyng/extra-args` --- ### 📝 Commits (1) - [`cdc9aa1`](https://github.com/ollama/ollama/commit/cdc9aa14ed5862fb19ff1620c8d8f7043e00d2f4) template extra args ### 📊 Changes **2 files changed** (+8 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `api/types.go` (+6 -5) 📝 `server/images.go` (+2 -0) </details> ### 📄 Description User defined arguments to the template, making things like infilling easier: ``` FROM codellama:7b-code TEMPLATE "<PRE> {{ .Args.Prefix }} <SUF> {{- .Args.Suffix }} <MID>" ``` Request: ``` $ curl -s localhost:11434/api/generate -d '{"model":"codellama-infill","args":{"Prefix":"def remove_non_ascii(s: str) -> str:\n\t\"\"\"","Suffix":"return result"}}' | jq -r -j 'select(.response != null) | .response' Remove non-ASCII characters from a string. Parameters ---------- s : str The input string. Returns ------- str The output string. """ result = "" for char in s: if ord(char) < 128: result += char ``` Or messages: ``` FROM llama2:7b TEMPLATE """{{ range .Args.Messages }}[INST] {{ if .System -}} <<SYS>>{{ .System }}<</SYS>> {{- end }} {{ range .Request }} [/INST] {{ .Response }} {{ end }}""" ``` ``` $ curl -s localhost:11434/api/generate -d '{"model":"llama2","args": {"Messages": [{"System":"you are a good robot","Request":"tell me a joke","Response":"why is the sky blue?"},{"Request":"why did you say that?","Response":"i don't know"},{"Request":"do it again"}]' ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-12 22:53:16 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#10166