Changeset 0.10.1 (#57)

This commit is contained in:
2026-02-24 16:51:08 +00:00
parent ea03f956ca
commit 13772ebd6c
11 changed files with 472 additions and 159 deletions

View File

@@ -1,6 +1,7 @@
package handlers
import (
"context"
"database/sql"
"encoding/json"
"fmt"
@@ -480,14 +481,25 @@ func (h *CompletionHandler) resolveConfig(userID string, channelID string, req c
// active path through the message tree. Only the current branch is sent —
// sibling branches are never included in context.
func (h *CompletionHandler) loadConversation(channelID, userID, presetSystemPrompt string) ([]providers.Message, error) {
// Load system prompt from channel
messages := make([]providers.Message, 0)
// ── Admin system prompt (always injected first, no opt out) ──
adminPrompt, err := h.stores.GlobalConfig.Get(context.Background(), "system_prompt")
if err == nil {
if content, ok := adminPrompt["content"].(string); ok && content != "" {
messages = append(messages, providers.Message{
Role: "system",
Content: content,
})
}
}
// ── User/preset system prompt (appended after admin prompt) ──
var systemPrompt *string
_ = database.DB.QueryRow(
`SELECT system_prompt FROM channels WHERE id = $1`, channelID,
).Scan(&systemPrompt)
messages := make([]providers.Message, 0)
// Preset system prompt takes priority; channel system prompt is fallback
if presetSystemPrompt != "" {
messages = append(messages, providers.Message{