[PR #5207] [MERGED] add insert support to generate endpoint #37587

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

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/5207
Author: @mxyng
Created: 6/22/2024
Status: Merged
Merged: 7/16/2024
Merged by: @mxyng

Base: mainHead: mxyng/suffix


📝 Commits (1)

  • d290e87 add suffix support to generate endpoint

📊 Changes

6 files changed (+155 additions, -27 deletions)

View changed files

📝 api/types.go (+3 -0)
📝 server/images.go (+14 -3)
📝 server/routes.go (+25 -15)
📝 server/routes_generate_test.go (+69 -8)
📝 template/template.go (+9 -1)
📝 template/template_test.go (+35 -0)

📄 Description

this change is triggered by the presence of "suffix", particularly useful for code completion tasks

examples templates

codellama merged code completion and fill-in-middle template

{{- if .Suffix }}<PRE> {{ .Prompt }} <SUF>{{ .Suffix }} <MID>
{{- else }}{{ Prompt }}
{{- end }}

deepseek coder v2 merged messages #5126 and fill-in-middle template

{{- if .Suffix }}<|fim▁begin|>{{ .Prompt }}
<|fim▁hole|>
{{ .Suffix }}<|fim▁end|>
{{- else }}
{{- range .Messages }}
{{- if eq .Role "user" }}
{{- if and (eq (index $.Messages (sub (len $.Messages) 1)) .) $.System }}{{ $.System }}{{ "\n\n" }}
{{- end }}User: {{ .Content }}{{ "\n\n" }}
{{- else if eq .Role "assistant" }}Assistant: {{ .Content }}<|end▁of▁sentence|>
{{- end }}
{{- end }}Assistant:
{{- end }}

example request

curl 127.0.0.1:11434/api/generate -d '{
    "model": "deepseek-coder-v2",
    "prompt": "def add(",
    "suffix": "return c",
    "stream": false,
    "options": {
        "temperature": 0
    }
}'

models that do no support suffix will return error model does not support [suffix]

an example fill-in-middle model is mike/deepseek-coder-v2

resolves #496
resolves #3869
resolves #5403


🔄 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/5207 **Author:** [@mxyng](https://github.com/mxyng) **Created:** 6/22/2024 **Status:** ✅ Merged **Merged:** 7/16/2024 **Merged by:** [@mxyng](https://github.com/mxyng) **Base:** `main` ← **Head:** `mxyng/suffix` --- ### 📝 Commits (1) - [`d290e87`](https://github.com/ollama/ollama/commit/d290e87513664be8ca3120348614d124991ccb86) add suffix support to generate endpoint ### 📊 Changes **6 files changed** (+155 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `api/types.go` (+3 -0) 📝 `server/images.go` (+14 -3) 📝 `server/routes.go` (+25 -15) 📝 `server/routes_generate_test.go` (+69 -8) 📝 `template/template.go` (+9 -1) 📝 `template/template_test.go` (+35 -0) </details> ### 📄 Description this change is triggered by the presence of "suffix", particularly useful for code completion tasks examples templates codellama merged code completion and fill-in-middle template ``` {{- if .Suffix }}<PRE> {{ .Prompt }} <SUF>{{ .Suffix }} <MID> {{- else }}{{ Prompt }} {{- end }} ``` deepseek coder v2 merged messages #5126 and fill-in-middle template ``` {{- if .Suffix }}<|fim▁begin|>{{ .Prompt }} <|fim▁hole|> {{ .Suffix }}<|fim▁end|> {{- else }} {{- range .Messages }} {{- if eq .Role "user" }} {{- if and (eq (index $.Messages (sub (len $.Messages) 1)) .) $.System }}{{ $.System }}{{ "\n\n" }} {{- end }}User: {{ .Content }}{{ "\n\n" }} {{- else if eq .Role "assistant" }}Assistant: {{ .Content }}<|end▁of▁sentence|> {{- end }} {{- end }}Assistant: {{- end }} ``` example request ``` curl 127.0.0.1:11434/api/generate -d '{ "model": "deepseek-coder-v2", "prompt": "def add(", "suffix": "return c", "stream": false, "options": { "temperature": 0 } }' ``` models that do no support `suffix` will return error `model does not support [suffix]` an example fill-in-middle model is [mike/deepseek-coder-v2](https://ollama.com/mike/deepseek-coder-v2) resolves #496 resolves #3869 resolves #5403 --- <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-22 22:16:08 -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#37587