Add user defined system message

This commit is contained in:
dwrz
2026-05-28 00:53:08 +00:00
parent a06833bb8b
commit 9ea4005e96
26 changed files with 652 additions and 222 deletions

View File

@@ -311,6 +311,8 @@ type Request struct {
Messages []openai.ChatCompletionMessage `json:"messages"`
// Model is the LLM model ID. If empty, the default model is used.
Model string `json:"model,omitempty"`
// SystemMessage overrides the configured system message for this request.
SystemMessage string `json:"system_message,omitempty"`
// Voice is the voice ID for TTS.
Voice string `json:"voice,omitempty"`
}
@@ -455,7 +457,7 @@ func (svc *Service) voice(w http.ResponseWriter, r *http.Request) {
if model == "" {
model = svc.llm.DefaultModel()
}
msgs, err := svc.llm.Query(ctx, messages, model)
msgs, err := svc.llm.Query(ctx, messages, model, req.SystemMessage)
if err != nil {
log.ErrorContext(
ctx,
@@ -731,7 +733,7 @@ func (svc *Service) voiceStream(w http.ResponseWriter, r *http.Request) {
llmErr error
)
go func() {
llmErr = svc.llm.QueryStream(ctx, messages, model, events)
llmErr = svc.llm.QueryStream(ctx, messages, model, req.SystemMessage, events)
}()
// Consume events and send as SSE.