Don't include system message when generating conversation title
This commit is contained in:
parent
4f37ed046b
commit
c64bc370f4
@ -31,7 +31,7 @@ func (m *Message) FriendlyRole() string {
|
||||
|
||||
func (c *Conversation) GenerateTitle() error {
|
||||
const header = "Generate a consise 4-5 word title for the conversation below."
|
||||
prompt := fmt.Sprintf("%s\n\n---\n\n%s", header, c.FormatForExternalPrompting())
|
||||
prompt := fmt.Sprintf("%s\n\n---\n\n%s", header, c.FormatForExternalPrompting(false))
|
||||
|
||||
messages := []Message{
|
||||
{
|
||||
@ -50,13 +50,16 @@ func (c *Conversation) GenerateTitle() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Conversation) FormatForExternalPrompting() string {
|
||||
func (c *Conversation) FormatForExternalPrompting(system bool) string {
|
||||
sb := strings.Builder{}
|
||||
messages, err := store.Messages(c)
|
||||
if err != nil {
|
||||
Fatal("Could not retrieve messages for conversation %v", c)
|
||||
}
|
||||
for _, message := range messages {
|
||||
if message.Role == MessageRoleSystem && !system {
|
||||
continue
|
||||
}
|
||||
sb.WriteString(fmt.Sprintf("<%s>\n", message.FriendlyRole()))
|
||||
sb.WriteString(fmt.Sprintf("\"\"\"\n%s\n\"\"\"\n\n", message.OriginalContent))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user