mirror of https://github.com/jlelse/GoBlog
Update aitldr plugin to use newer model and better system prompt
This commit is contained in:
parent
869d0c84ed
commit
7c6d0354fb
|
@ -136,10 +136,12 @@ func (p *plugin) summarize(post plugintypes.Post) {
|
||||||
Method(http.MethodPost).
|
Method(http.MethodPost).
|
||||||
Header("Authorization", "Bearer "+apikey).
|
Header("Authorization", "Bearer "+apikey).
|
||||||
BodyJSON(map[string]any{
|
BodyJSON(map[string]any{
|
||||||
"model": "gpt-3.5-turbo",
|
"model": "gpt-3.5-turbo-1106",
|
||||||
"temperature": 0,
|
|
||||||
"max_tokens": 200,
|
|
||||||
"messages": []apiMessage{
|
"messages": []apiMessage{
|
||||||
|
{
|
||||||
|
Role: "system",
|
||||||
|
Content: p.systemMessage(),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Role: "user",
|
Role: "user",
|
||||||
Content: p.createPrompt(post),
|
Content: p.createPrompt(post),
|
||||||
|
@ -170,21 +172,27 @@ func (p *plugin) summarize(post plugintypes.Post) {
|
||||||
p.app.PurgeCache()
|
p.app.PurgeCache()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *plugin) systemMessage() string {
|
||||||
|
prompt := "You are a summary writing plugin in a blogging system. " +
|
||||||
|
"Your task is to generate concise and effective summaries for long blog posts. " +
|
||||||
|
"When given a full blog post, extract the key points and present them in a clear, brief format. " +
|
||||||
|
"The summary must be in the same language as the blog post, have a maximum length of 250 characters, contain no linebreaks, and be plain text. " +
|
||||||
|
"Importantly, the summary should be written in the first person perspective, as if the blog author themselves are summarizing the post. " +
|
||||||
|
"Avoid phrases like 'The author states' or 'The blogger argues', and instead write as if the author is speaking. " +
|
||||||
|
"Maintain the original intent and tone of the blog post in your summary. " +
|
||||||
|
"Always respond with just the summary content."
|
||||||
|
return prompt
|
||||||
|
}
|
||||||
|
|
||||||
func (p *plugin) createPrompt(post plugintypes.Post) string {
|
func (p *plugin) createPrompt(post plugintypes.Post) string {
|
||||||
lang := "en"
|
prompt := ""
|
||||||
if blog, ok := p.app.GetBlog(post.GetBlog()); ok {
|
|
||||||
if blogLang := blog.GetLanguage(); lang != "" {
|
|
||||||
lang = blogLang
|
|
||||||
}
|
|
||||||
}
|
|
||||||
prompt := "Summarize the content of following blog post in one sentence in the language \"" + lang + "\". Answer with just the summary.\n\n\n"
|
|
||||||
if title, err := p.app.RenderMarkdownAsText(post.GetTitle()); err == nil && title != "" {
|
if title, err := p.app.RenderMarkdownAsText(post.GetTitle()); err == nil && title != "" {
|
||||||
prompt += title + "\n\n"
|
prompt += title + "\n\n"
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
log.Println("aitldr plugin: Rendering markdown as text failed:", err.Error())
|
log.Println("aitldr plugin: Rendering markdown as text failed:", err.Error())
|
||||||
}
|
}
|
||||||
if text, err := p.app.RenderMarkdownAsText(post.GetContent()); err == nil && text != "" {
|
if text, err := p.app.RenderMarkdownAsText(post.GetContent()); err == nil && text != "" {
|
||||||
prompt += text + "\n\n"
|
prompt += text
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
log.Println("aitldr plugin: Rendering markdown as text failed:", err.Error())
|
log.Println("aitldr plugin: Rendering markdown as text failed:", err.Error())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue