feat: trim llm response

This commit is contained in:
2025-08-07 12:25:39 +02:00
parent 0c57663f5f
commit b20b657008

View File

@ -173,8 +173,12 @@ func (m *ForgeManager) GeneratePullRequest(ctx context.Context, user *model.User
body := res.Message().Content()
body = strings.TrimSpace(body)
body = strings.TrimPrefix(body, "```markdown")
body = strings.TrimSuffix(body, "```")
messages = append(messages, res.Message())
messages = append(messages, llm.NewMessage(llm.RoleUser, "Generate a title for this issue. Keep it descriptive, simple and short. Do not write anything else."))
messages = append(messages, llm.NewMessage(llm.RoleUser, "Generate a title for this pull request. Keep it descriptive, simple and short. Do not write anything else. Use the same language."))
res, err = m.llmClient.ChatCompletion(ctx, llm.WithMessages(messages...))
if err != nil {
@ -184,7 +188,7 @@ func (m *ForgeManager) GeneratePullRequest(ctx context.Context, user *model.User
title := toTitle(res.Message().Content())
messages = append(messages, res.Message())
messages = append(messages, llm.NewMessage(llm.RoleUser, "Give me a list of questions as Markdown that could help clarify the request. Only write the list without additional headings."))
messages = append(messages, llm.NewMessage(llm.RoleUser, "Give me a list of questions as Markdown that could help clarify the request. Only write the list without additional headings. Use the same language."))
res, err = m.llmClient.ChatCompletion(ctx, llm.WithMessages(messages...))
if err != nil {
@ -300,8 +304,12 @@ func (m *ForgeManager) GenerateIssue(ctx context.Context, user *model.User, proj
body := res.Message().Content()
body = strings.TrimSpace(body)
body = strings.TrimPrefix(body, "```markdown")
body = strings.TrimSuffix(body, "```")
messages = append(messages, res.Message())
messages = append(messages, llm.NewMessage(llm.RoleUser, "Generate a title for this issue. Keep it descriptive, simple and short. Do not write anything else."))
messages = append(messages, llm.NewMessage(llm.RoleUser, "Generate a title for this issue. Keep it descriptive, simple and short. Do not write anything else. Use the same language."))
res, err = m.llmClient.ChatCompletion(ctx, llm.WithMessages(messages...))
if err != nil {
@ -311,7 +319,7 @@ func (m *ForgeManager) GenerateIssue(ctx context.Context, user *model.User, proj
title := toTitle(res.Message().Content())
messages = append(messages, res.Message())
messages = append(messages, llm.NewMessage(llm.RoleUser, "Give me a list of questions as Markdown that could help clarify the request. Only write the list without additional headings."))
messages = append(messages, llm.NewMessage(llm.RoleUser, "Give me a list of questions as Markdown that could help clarify the request. Only write the list without additional headings. Use the same language."))
res, err = m.llmClient.ChatCompletion(ctx, llm.WithMessages(messages...))
if err != nil {