Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/cpp/llama-cpp/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

LLAMA_VERSION?=fd1234cb468935ea087d6929b2487926c3afff4b
LLAMA_VERSION?=e725a1a982ca870404a9c4935df52466327bbd02
LLAMA_REPO?=https://github.com/ggerganov/llama.cpp

CMAKE_ARGS?=
Expand Down
4 changes: 3 additions & 1 deletion backend/cpp/llama-cpp/grpc-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,11 @@ static void params_parse(const backend::ModelOptions* request,
params.pooling_type = LLAMA_POOLING_TYPE_RANK;
}


if (request->ropescaling() == "none") { params.rope_scaling_type = LLAMA_ROPE_SCALING_TYPE_NONE; }
else if (request->ropescaling() == "yarn") { params.rope_scaling_type = LLAMA_ROPE_SCALING_TYPE_YARN; }
else { params.rope_scaling_type = LLAMA_ROPE_SCALING_TYPE_LINEAR; }
else if (request->ropescaling() == "linear") { params.rope_scaling_type = LLAMA_ROPE_SCALING_TYPE_LINEAR; }

if ( request->yarnextfactor() != 0.0f ) {
params.yarn_ext_factor = request->yarnextfactor();
}
Expand Down
2 changes: 1 addition & 1 deletion core/http/endpoints/openai/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func ChatEndpoint(cl *config.BackendConfigLoader, ml *model.ModelLoader, evaluat
// If we are using the tokenizer template, we don't need to process the messages
// unless we are processing functions
if !config.TemplateConfig.UseTokenizerTemplate || shouldUseFn {
predInput = evaluator.TemplateMessages(input.Messages, config, funcs, shouldUseFn)
predInput = evaluator.TemplateMessages(*input, input.Messages, config, funcs, shouldUseFn)

log.Debug().Msgf("Prompt (after templating): %s", predInput)
if config.Grammar != "" {
Expand Down
12 changes: 8 additions & 4 deletions core/http/endpoints/openai/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ func CompletionEndpoint(cl *config.BackendConfigLoader, ml *model.ModelLoader, e
predInput := config.PromptStrings[0]

templatedInput, err := evaluator.EvaluateTemplateForPrompt(templates.CompletionPromptTemplate, *config, templates.PromptTemplateData{
Input: predInput,
SystemPrompt: config.SystemPrompt,
Input: predInput,
SystemPrompt: config.SystemPrompt,
ReasoningEffort: input.ReasoningEffort,
Metadata: input.Metadata,
})
if err == nil {
predInput = templatedInput
Expand Down Expand Up @@ -160,8 +162,10 @@ func CompletionEndpoint(cl *config.BackendConfigLoader, ml *model.ModelLoader, e

for k, i := range config.PromptStrings {
templatedInput, err := evaluator.EvaluateTemplateForPrompt(templates.CompletionPromptTemplate, *config, templates.PromptTemplateData{
SystemPrompt: config.SystemPrompt,
Input: i,
SystemPrompt: config.SystemPrompt,
Input: i,
ReasoningEffort: input.ReasoningEffort,
Metadata: input.Metadata,
})
if err == nil {
i = templatedInput
Expand Down
8 changes: 5 additions & 3 deletions core/http/endpoints/openai/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ func EditEndpoint(cl *config.BackendConfigLoader, ml *model.ModelLoader, evaluat

for _, i := range config.InputStrings {
templatedInput, err := evaluator.EvaluateTemplateForPrompt(templates.EditPromptTemplate, *config, templates.PromptTemplateData{
Input: i,
Instruction: input.Instruction,
SystemPrompt: config.SystemPrompt,
Input: i,
Instruction: input.Instruction,
SystemPrompt: config.SystemPrompt,
ReasoningEffort: input.ReasoningEffort,
Metadata: input.Metadata,
})
if err == nil {
i = templatedInput
Expand Down
4 changes: 4 additions & 0 deletions core/schema/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ type OpenAIRequest struct {
Backend string `json:"backend" yaml:"backend"`

ModelBaseName string `json:"model_base_name" yaml:"model_base_name"`

ReasoningEffort string `json:"reasoning_effort" yaml:"reasoning_effort"`

Metadata map[string]string `json:"metadata" yaml:"metadata"`
}

type ModelsDataResponse struct {
Expand Down
6 changes: 5 additions & 1 deletion core/templates/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type PromptTemplateData struct {
Instruction string
Functions []functions.Function
MessageIndex int
ReasoningEffort string
Metadata map[string]string
}

type ChatMessageTemplateData struct {
Expand Down Expand Up @@ -133,7 +135,7 @@ func (e *Evaluator) evaluateJinjaTemplateForPrompt(templateType TemplateType, te
return e.cache.evaluateJinjaTemplate(templateType, templateName, conversation)
}

func (e *Evaluator) TemplateMessages(messages []schema.Message, config *config.BackendConfig, funcs []functions.Function, shouldUseFn bool) string {
func (e *Evaluator) TemplateMessages(input schema.OpenAIRequest, messages []schema.Message, config *config.BackendConfig, funcs []functions.Function, shouldUseFn bool) string {

if config.TemplateConfig.JinjaTemplate {
var messageData []ChatMessageTemplateData
Expand Down Expand Up @@ -283,6 +285,8 @@ func (e *Evaluator) TemplateMessages(messages []schema.Message, config *config.B
SuppressSystemPrompt: suppressConfigSystemPrompt,
Input: predInput,
Functions: funcs,
ReasoningEffort: input.ReasoningEffort,
Metadata: input.Metadata,
})
if err == nil {
predInput = templatedInput
Expand Down
6 changes: 3 additions & 3 deletions core/templates/evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ var _ = Describe("Templates", func() {
for key := range chatMLTestMatch {
foo := chatMLTestMatch[key]
It("renders correctly `"+key+"`", func() {
templated := evaluator.TemplateMessages(foo["messages"].([]schema.Message), foo["config"].(*config.BackendConfig), foo["functions"].([]functions.Function), foo["shouldUseFn"].(bool))
templated := evaluator.TemplateMessages(schema.OpenAIRequest{}, foo["messages"].([]schema.Message), foo["config"].(*config.BackendConfig), foo["functions"].([]functions.Function), foo["shouldUseFn"].(bool))
Expect(templated).To(Equal(foo["expected"]), templated)
})
}
Expand All @@ -232,7 +232,7 @@ var _ = Describe("Templates", func() {
for key := range llama3TestMatch {
foo := llama3TestMatch[key]
It("renders correctly `"+key+"`", func() {
templated := evaluator.TemplateMessages(foo["messages"].([]schema.Message), foo["config"].(*config.BackendConfig), foo["functions"].([]functions.Function), foo["shouldUseFn"].(bool))
templated := evaluator.TemplateMessages(schema.OpenAIRequest{}, foo["messages"].([]schema.Message), foo["config"].(*config.BackendConfig), foo["functions"].([]functions.Function), foo["shouldUseFn"].(bool))
Expect(templated).To(Equal(foo["expected"]), templated)
})
}
Expand All @@ -245,7 +245,7 @@ var _ = Describe("Templates", func() {
for key := range jinjaTest {
foo := jinjaTest[key]
It("renders correctly `"+key+"`", func() {
templated := evaluator.TemplateMessages(foo["messages"].([]schema.Message), foo["config"].(*config.BackendConfig), foo["functions"].([]functions.Function), foo["shouldUseFn"].(bool))
templated := evaluator.TemplateMessages(schema.OpenAIRequest{}, foo["messages"].([]schema.Message), foo["config"].(*config.BackendConfig), foo["functions"].([]functions.Function), foo["shouldUseFn"].(bool))
Expect(templated).To(Equal(foo["expected"]), templated)
})
}
Expand Down
43 changes: 18 additions & 25 deletions gallery/harmony.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@ config_file: |
mmap: true
backend: "llama-cpp"
template:
chat_message: |
<|start|>{{ if .FunctionCall -}}functions.{{ .FunctionCall.Name }} to=assistant{{ else if eq .RoleName "assistant"}}<|channel|>final<|message|>{{else}}{{ .RoleName }}{{end}}<|message|>
{{ if .Content -}}
{{.Content }}
{{ end -}}
{{ if .FunctionCall -}}
{{toJson .FunctionCall}}
{{ end -}}<|end|>
function: |
<|im_start|>system
You are a function calling AI model. You are provided with functions to execute. You may call one or more functions to assist with the user query. Don't make assumptions about what values to plug into functions. Here are the available tools:

chat_message: |-
<|start|>{{ if .FunctionCall -}}functions.{{ .FunctionCall.Name }} to=assistant{{ else if eq .RoleName "assistant"}}assistant<|channel|>final<|message|>{{else}}{{ .RoleName }}{{end}}<|message|>
{{- if .Content -}}
{{- .Content -}}
{{- end -}}
{{- if .FunctionCall -}}
{{- toJson .FunctionCall -}}
{{- end -}}<|end|>
function: |-
<|start|>system<|message|>You are ChatGPT, a large language model trained by OpenAI.
Knowledge cutoff: 2024-06
Current date: {{ now | date }}
Current date: {{ now | date "Mon Jan 2 15:04:05 MST 2006" }}

Reasoning: {{if eq .ReasoningEffort ""}}medium{{else}}{{.ReasoningEffort}}{{end}}

Reasoning: medium
# {{with .Metadata}}{{ if ne .system_prompt "" }}{{ .system_prompt }}{{ end }}{{else}}You are a friendly and helpful assistant.{{ end }}<|end|>{{- .Input -}}<|start|>assistant

# Tools

Expand Down Expand Up @@ -49,21 +48,15 @@ config_file: |

# Instructions

<|end|>
{{.Input -}}
<|start|>assistant
chat: |
<|end|>{{.Input -}}<|start|>assistant
chat: |-
<|start|>system<|message|>You are ChatGPT, a large language model trained by OpenAI.
Knowledge cutoff: 2024-06
Current date: {{ now | date }}
Current date: {{ now | date "Mon Jan 2 15:04:05 MST 2006" }}

Reasoning: medium

# Instructions
Reasoning: {{if eq .ReasoningEffort ""}}medium{{else}}{{.ReasoningEffort}}{{end}}

<|end|>
{{.Input -}}
<|im_start|>assistant
# {{with .Metadata}}{{ if ne .system_prompt "" }}{{ .system_prompt }}{{ end }}{{else}}You are a friendly and helpful assistant.{{ end }}<|end|>{{- .Input -}}<|start|>assistant
completion: |
{{.Input}}
context_size: 8192
Expand Down
24 changes: 24 additions & 0 deletions gallery/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,30 @@
- filename: gpt-oss-120b-mxfp4-00003-of-00003.gguf
sha256: b326bfd8ac696c4b9a14e9e84d5529b2bb86847aea0e65443cbf075accba8b71
uri: huggingface://ggml-org/gpt-oss-120b-GGUF/gpt-oss-120b-mxfp4-00003-of-00003.gguf
- !!merge <<: *gptoss
name: "openai_gpt-oss-20b-neo"
icon: https://huggingface.co/DavidAU/Openai_gpt-oss-20b-NEO-GGUF/resolve/main/matrix1.gif
urls:
- https://huggingface.co/DavidAU/Openai_gpt-oss-20b-NEO-GGUF
description: |
These are NEO Imatrix GGUFs, NEO dataset by DavidAU.

NEO dataset improves overall performance, and is for all use cases.

Example output below (creative), using settings below.

Model also passed "hard" coding test too (6 experts); no issues (IQ4_NL).

(Forcing the model to create code with no dependencies and limits of coding short cuts, with multiple loops, and in real time with no blocking in a language that does not support it normally.)

Due to quanting issues with this model (which result in oddball quant sizes / mixtures), only TESTED quants will be uploaded (at the moment).
overrides:
parameters:
model: OpenAI-20B-NEO-MXFP4_MOE4.gguf
files:
- filename: OpenAI-20B-NEO-MXFP4_MOE4.gguf
sha256: 066c84a0844b1f1f4515e5c64095fe4c67e86d5eb70db4e368e283b1134d9c1e
uri: huggingface://DavidAU/Openai_gpt-oss-20b-NEO-GGUF/OpenAI-20B-NEO-MXFP4_MOE4.gguf
- &afm
name: "arcee-ai_afm-4.5b"
url: "github:mudler/LocalAI/gallery/chatml.yaml@master"
Expand Down Expand Up @@ -2090,7 +2114,7 @@
- gemma3
- gemma-3
overrides:
#mmproj: gemma-3-27b-it-mmproj-f16.gguf

Check warning on line 2117 in gallery/index.yaml

View workflow job for this annotation

GitHub Actions / Yamllint

2117:6 [comments] missing starting space in comment
parameters:
model: gemma-3-27b-it-Q4_K_M.gguf
files:
Expand All @@ -2108,7 +2132,7 @@
description: |
google/gemma-3-12b-it is an open-source, state-of-the-art, lightweight, multimodal model built from the same research and technology used to create the Gemini models. It is capable of handling text and image input and generating text output. It has a large context window of 128K tokens and supports over 140 languages. The 12B variant has been fine-tuned using the instruction-tuning approach. Gemma 3 models are suitable for a variety of text generation and image understanding tasks, including question answering, summarization, and reasoning. Their relatively small size makes them deployable in environments with limited resources such as laptops, desktops, or your own cloud infrastructure.
overrides:
#mmproj: gemma-3-12b-it-mmproj-f16.gguf

Check warning on line 2135 in gallery/index.yaml

View workflow job for this annotation

GitHub Actions / Yamllint

2135:6 [comments] missing starting space in comment
parameters:
model: gemma-3-12b-it-Q4_K_M.gguf
files:
Expand All @@ -2126,7 +2150,7 @@
description: |
Gemma is a family of lightweight, state-of-the-art open models from Google, built from the same research and technology used to create the Gemini models. Gemma 3 models are multimodal, handling text and image input and generating text output, with open weights for both pre-trained variants and instruction-tuned variants. Gemma 3 has a large, 128K context window, multilingual support in over 140 languages, and is available in more sizes than previous versions. Gemma 3 models are well-suited for a variety of text generation and image understanding tasks, including question answering, summarization, and reasoning. Their relatively small size makes it possible to deploy them in environments with limited resources such as laptops, desktops or your own cloud infrastructure, democratizing access to state of the art AI models and helping foster innovation for everyone. Gemma-3-4b-it is a 4 billion parameter model.
overrides:
#mmproj: gemma-3-4b-it-mmproj-f16.gguf

Check warning on line 2153 in gallery/index.yaml

View workflow job for this annotation

GitHub Actions / Yamllint

2153:6 [comments] missing starting space in comment
parameters:
model: gemma-3-4b-it-Q4_K_M.gguf
files:
Expand Down Expand Up @@ -5592,7 +5616,7 @@
sha256: 2756551de7d8ff7093c2c5eec1cd00f1868bc128433af53f5a8d434091d4eb5a
uri: huggingface://Triangle104/Nano_Imp_1B-Q8_0-GGUF/nano_imp_1b-q8_0.gguf
- &qwen25
name: "qwen2.5-14b-instruct" ## Qwen2.5

Check warning on line 5619 in gallery/index.yaml

View workflow job for this annotation

GitHub Actions / Yamllint

5619:32 [comments] too few spaces before comment: expected 2
icon: https://avatars.githubusercontent.com/u/141221163
url: "github:mudler/LocalAI/gallery/chatml.yaml@master"
license: apache-2.0
Expand Down Expand Up @@ -7553,7 +7577,7 @@
sha256: 0fec82625f74a9a340837de7af287b1d9042e5aeb70cda2621426db99958b0af
uri: huggingface://bartowski/Chuluun-Qwen2.5-72B-v0.08-GGUF/Chuluun-Qwen2.5-72B-v0.08-Q4_K_M.gguf
- &smollm
url: "github:mudler/LocalAI/gallery/chatml.yaml@master" ## SmolLM

Check warning on line 7580 in gallery/index.yaml

View workflow job for this annotation

GitHub Actions / Yamllint

7580:59 [comments] too few spaces before comment: expected 2
name: "smollm-1.7b-instruct"
icon: https://huggingface.co/datasets/HuggingFaceTB/images/resolve/main/banner_smol.png
tags:
Expand Down
9 changes: 9 additions & 0 deletions swagger/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,12 @@ const docTemplate = `{
"$ref": "#/definitions/schema.Message"
}
},
"metadata": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"mode": {
"description": "Image (not supported by OpenAI)",
"type": "integer"
Expand Down Expand Up @@ -1567,6 +1573,9 @@ const docTemplate = `{
"quality": {
"type": "string"
},
"reasoning_effort": {
"type": "string"
},
"ref_images": {
"description": "Reference images for models that support them (e.g., Flux Kontext)",
"type": "array",
Expand Down
9 changes: 9 additions & 0 deletions swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,12 @@
"$ref": "#/definitions/schema.Message"
}
},
"metadata": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"mode": {
"description": "Image (not supported by OpenAI)",
"type": "integer"
Expand Down Expand Up @@ -1560,6 +1566,9 @@
"quality": {
"type": "string"
},
"reasoning_effort": {
"type": "string"
},
"ref_images": {
"description": "Reference images for models that support them (e.g., Flux Kontext)",
"type": "array",
Expand Down
6 changes: 6 additions & 0 deletions swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,10 @@ definitions:
items:
$ref: '#/definitions/schema.Message'
type: array
metadata:
additionalProperties:
type: string
type: object
mode:
description: Image (not supported by OpenAI)
type: integer
Expand All @@ -514,6 +518,8 @@ definitions:
description: Prompt is read only by completion/image API calls
quality:
type: string
reasoning_effort:
type: string
ref_images:
description: Reference images for models that support them (e.g., Flux Kontext)
items:
Expand Down
Loading