From 008fdc0d37ded36a49d7670191f2f8c0f6ed7c63 Mon Sep 17 00:00:00 2001 From: Matt Low Date: Thu, 23 May 2024 05:59:46 +0000 Subject: [PATCH] Update title generation prompt --- pkg/cmd/util/util.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/cmd/util/util.go b/pkg/cmd/util/util.go index f249a5f..7c4b962 100644 --- a/pkg/cmd/util/util.go +++ b/pkg/cmd/util/util.go @@ -149,7 +149,9 @@ func FormatForExternalPrompt(messages []model.Message, system bool) string { } func GenerateTitle(ctx *lmcli.Context, messages []model.Message) (string, error) { - const prompt = `Above is an excerpt from a conversation between a user and AI assistant. Please reply with a short title (no more than 8 words) that reflects the topic of the conversation, read from the user's perspective. + const prompt = `Above is an excerpt from a conversation between a user and AI assistant. + +Reply with a short title (no more than 8 words) that reflects the topic of the conversation, read from the user's perspective. Example conversation: @@ -163,11 +165,13 @@ Assistant: Hello! How may I assist you? """ -Example response: +Your response: """ Title: A brief introduction """ + +Respond only as shown above. ` conversation := FormatForExternalPrompt(messages, false) @@ -193,9 +197,10 @@ Title: A brief introduction return "", err } - response = strings.TrimPrefix(response, "Title: ") - response = strings.Trim(response, "\"") + // TODO: validate response format + response = strings.TrimPrefix(response, "Title:") response = strings.TrimSpace(response) + response = strings.Trim(response, "\"") return response, nil }