From ae573b1c51d7d6ef927c089de6eedb8eca6f553f Mon Sep 17 00:00:00 2001 From: Laura Date: Fri, 3 Oct 2025 01:30:40 +0200 Subject: [PATCH] transformation methods --- chat.go | 2 ++ env.go | 7 +++++++ example.config.yml | 2 ++ 3 files changed, 11 insertions(+) diff --git a/chat.go b/chat.go index 431a550..5fa3c38 100644 --- a/chat.go +++ b/chat.go @@ -116,6 +116,8 @@ func (r *Request) Parse() (*openrouter.ChatCompletionRequest, int, error) { request.Modalities = append(request.Modalities, openrouter.ModalityImage) } + request.Transforms = append(request.Transforms, env.Settings.Transformation) + if r.Iterations < 1 || r.Iterations > 50 { return nil, 0, fmt.Errorf("invalid iterations (1-50): %d", r.Iterations) } diff --git a/env.go b/env.go index c5c8867..574b712 100644 --- a/env.go +++ b/env.go @@ -22,6 +22,7 @@ type EnvSettings struct { CleanContent bool `json:"cleanup"` TitleModel string `json:"title-model"` ImageGeneration bool `json:"image-generation"` + Transformation string `json:"transformation"` } type EnvUI struct { @@ -118,6 +119,11 @@ func (e *Environment) Init() error { e.Settings.TitleModel = "google/gemini-2.5-flash-lite" } + // default transformation method + if e.Settings.Transformation == "" { + e.Settings.Transformation = "middle-out" + } + // create user lookup map e.Authentication.lookup = make(map[string]*EnvUser) @@ -169,6 +175,7 @@ func (e *Environment) Store() error { "$.settings.cleanup": {yaml.HeadComment(" normalize unicode in assistant output (optional; default: true)")}, "$.settings.title-model": {yaml.HeadComment(" model used to generate titles (needs to have structured output support; default: google/gemini-2.5-flash-lite)")}, "$.settings.image-generation": {yaml.HeadComment(" allow image generation (optional; default: true)")}, + "$.settings.transformation": {yaml.HeadComment(" what transformation method to use for too long contexts (optional; default: middle-out)")}, "$.ui.reduced-motion": {yaml.HeadComment(" disables things like the floating stars in the background (optional; default: false)")}, diff --git a/example.config.yml b/example.config.yml index 8e703f5..1bee720 100644 --- a/example.config.yml +++ b/example.config.yml @@ -18,6 +18,8 @@ settings: title-model: google/gemini-2.5-flash-lite # allow image generation (optional; default: true) image-generation: true + # what transformation method to use for too long contexts (optional; default: middle-out) + transformation: "middle-out" ui: # disables things like the floating stars in the background (optional; default: false)