Add conversations.titleGenerationPrompt configuration
This commit is contained in:
@@ -162,8 +162,7 @@ func FormatForExternalPrompt(messages []conversation.Message, system bool) strin
|
|||||||
return sb.String()
|
return sb.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func GenerateTitle(ctx *lmcli.Context, messages []conversation.Message) (string, error) {
|
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.
|
||||||
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.
|
|
||||||
|
|
||||||
Example conversation:
|
Example conversation:
|
||||||
|
|
||||||
@@ -173,6 +172,19 @@ Example response:
|
|||||||
|
|
||||||
{"title": "Help with math homework"}
|
{"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 {
|
type msg struct {
|
||||||
Role string
|
Role string
|
||||||
Content string
|
Content string
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ type Config struct {
|
|||||||
Agent string `yaml:"agent"`
|
Agent string `yaml:"agent"`
|
||||||
} `yaml:"defaults"`
|
} `yaml:"defaults"`
|
||||||
Conversations *struct {
|
Conversations *struct {
|
||||||
TitleGenerationModel *string `yaml:"titleGenerationModel" default:"gpt-3.5-turbo"`
|
TitleGenerationModel *string `yaml:"titleGenerationModel,omitempty"`
|
||||||
|
TitleGenerationPrompt *string `yaml:"titleGenerationPrompt,omitempty"`
|
||||||
} `yaml:"conversations"`
|
} `yaml:"conversations"`
|
||||||
Chroma *struct {
|
Chroma *struct {
|
||||||
Style *string `yaml:"style" default:"onedark"`
|
Style *string `yaml:"style" default:"onedark"`
|
||||||
|
|||||||
Reference in New Issue
Block a user