MCPcopy Create free account
hub / github.com/alibaba/open-code-review / BuildReLocationMessages

Function BuildReLocationMessages

internal/diff/relocation.go:28–42  ·  view source on GitHub ↗

BuildReLocationMessages renders the re-location prompt for cm against d. Returns nil when the task template is absent or empty, which the caller treats as "no re-location attempt": no session record, no request. This is split out of ReLocateComment so the caller can create the ReLocationTask sessio

(cm *model.LlmComment, d *model.Diff, task *template.LlmConversation)

Source from the content-addressed store, hash-verified

26// request identity. Keeping it that way is what stops observability concerns
27// from sinking into package diff.
28func BuildReLocationMessages(cm *model.LlmComment, d *model.Diff, task *template.LlmConversation) []llm.Message {
29 if task == nil || len(task.Messages) == 0 {
30 return nil
31 }
32
33 messages := make([]llm.Message, 0, len(task.Messages))
34 for _, m := range task.Messages {
35 content := m.Content
36 content = strings.ReplaceAll(content, "{diff}", d.Diff)
37 content = strings.ReplaceAll(content, "{existing_code}", cm.ExistingCode)
38 content = strings.ReplaceAll(content, "{suggestion_content}", cm.Content)
39 messages = append(messages, llm.NewTextMessage(m.Role, content))
40 }
41 return messages
42}
43
44// ReLocateComment calls the LLM to regenerate a precise existing_code snippet
45// when text-based matching fails, then retries ResolveComment with the new

Calls 1

NewTextMessageFunction · 0.92