From a945223037552bbc972598361a8d349ec10ea22f Mon Sep 17 00:00:00 2001 From: Matt Low Date: Tue, 29 Jul 2025 15:13:53 +0000 Subject: [PATCH] Add conversations.titleGenerationPrompt configuration --- pkg/cmd/util/util.go | 16 ++++++++++++++-- pkg/lmcli/config.go | 3 ++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/pkg/cmd/util/util.go b/pkg/cmd/util/util.go index 9d56541..63f608d 100644 --- a/pkg/cmd/util/util.go +++ b/pkg/cmd/util/util.go @@ -162,8 +162,7 @@ func FormatForExternalPrompt(messages []conversation.Message, system bool) strin return sb.String() } -func GenerateTitle(ctx *lmcli.Context, messages []conversation.Message) (string, error) { - const systemPrompt = `You will be shown a conversation between a user and an AI assistant. Your task is to generate a short title (8 words or less) for the provided conversation that reflects the conversation's topic. Your response is expected to be in JSON in the format shown below. +const defaultTitleGenerationPrompt = `You will be shown a conversation between a user and an AI assistant. Your task is to generate a short title (8 words or less) for the provided conversation that reflects the conversation's topic. Your response is expected to be in JSON in the format shown below. Example conversation: @@ -173,6 +172,19 @@ Example response: {"title": "Help with math homework"} ` + +func GenerateTitle(ctx *lmcli.Context, messages []conversation.Message) (string, error) { + if ctx.Config.Conversations.TitleGenerationModel == nil { + return "", nil + } + + var systemPrompt string + if ctx.Config.Conversations.TitleGenerationPrompt != nil { + systemPrompt = *ctx.Config.Conversations.TitleGenerationPrompt + } else { + systemPrompt = defaultTitleGenerationPrompt + } + type msg struct { Role string Content string diff --git a/pkg/lmcli/config.go b/pkg/lmcli/config.go index e790457..8a817a9 100644 --- a/pkg/lmcli/config.go +++ b/pkg/lmcli/config.go @@ -41,7 +41,8 @@ type Config struct { Agent string `yaml:"agent"` } `yaml:"defaults"` Conversations *struct { - TitleGenerationModel *string `yaml:"titleGenerationModel" default:"gpt-3.5-turbo"` + TitleGenerationModel *string `yaml:"titleGenerationModel,omitempty"` + TitleGenerationPrompt *string `yaml:"titleGenerationPrompt,omitempty"` } `yaml:"conversations"` Chroma *struct { Style *string `yaml:"style" default:"onedark"`