feat: trim llm response
This commit is contained in:
@ -173,8 +173,12 @@ func (m *ForgeManager) GeneratePullRequest(ctx context.Context, user *model.User
|
|||||||
|
|
||||||
body := res.Message().Content()
|
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, 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...))
|
res, err = m.llmClient.ChatCompletion(ctx, llm.WithMessages(messages...))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -184,7 +188,7 @@ func (m *ForgeManager) GeneratePullRequest(ctx context.Context, user *model.User
|
|||||||
title := toTitle(res.Message().Content())
|
title := toTitle(res.Message().Content())
|
||||||
|
|
||||||
messages = append(messages, res.Message())
|
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...))
|
res, err = m.llmClient.ChatCompletion(ctx, llm.WithMessages(messages...))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -300,8 +304,12 @@ func (m *ForgeManager) GenerateIssue(ctx context.Context, user *model.User, proj
|
|||||||
|
|
||||||
body := res.Message().Content()
|
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, 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...))
|
res, err = m.llmClient.ChatCompletion(ctx, llm.WithMessages(messages...))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -311,7 +319,7 @@ func (m *ForgeManager) GenerateIssue(ctx context.Context, user *model.User, proj
|
|||||||
title := toTitle(res.Message().Content())
|
title := toTitle(res.Message().Content())
|
||||||
|
|
||||||
messages = append(messages, res.Message())
|
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...))
|
res, err = m.llmClient.ChatCompletion(ctx, llm.WithMessages(messages...))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
Write a formatted issue/request based on the following informations:
|
Write a formatted issue/request based on the following informations.
|
||||||
|
|
||||||
|
Do not write any output other than the issue.
|
||||||
|
|
||||||
## Request Summary
|
## Request Summary
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
Write a formatted pull request based on the following informations:
|
Write a formatted pull request based on the following informations.
|
||||||
|
|
||||||
|
Do not write any output other than the pull request.
|
||||||
|
|
||||||
## Pull Request Summary
|
## Pull Request Summary
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user