Slide 9
Slide 9 text
©2024 Databricks Inc. — All rights reserved 9
var fileDiffTemplate = MessageTemplate(` Here is the commit message terminated by --- for the context:
{{.Message}}
---
Do not hallucinate. You are Staff Software Engineer, and you are reviewing one file at a time in a
unified diff format. Do not use phrases like "In this diff", "In this pull request", or "In this
file". Do not mention file names, because they are not relevant for the feature description.
If new methods are added, explain what these methods are doing. If existing functionality is changed,
explain the scope of these changes. Please summarize the input as a single paragraph of text written
in American English. Your target audience is software engineers, who adopt your project. If the prompt
contains ordered or unordered lists, rewrite the entire response as a paragraph of text. `)
func (lln *llNotes) Commit(ctx context.Context, commit *github.RepositoryCommit) (History, error) {
…
err := lln.http.Do(ctx, "GET",
fmt.Sprintf("https://github.com/%s/%s/commit/%s.diff", lln.org, lln.repo, commit.SHA),
httpclient.WithResponseUnmarshal(&buf))
var httpErr *httpclient.HttpError
if errors.As(err, &httpErr) && httpErr.StatusCode == 404 {
return History{
AssistantMessage(fmt.Sprintf("Commit %s was not found", commit.SHA)),
}, nil
}
tokens := strings.Split(commit.Commit.Message, " ")
if len(tokens) > 15_000 {
commit.Commit.Message = strings.Join(tokens[:15_000], " ")
}
return lln.explainDiff(ctx, History{
fileDiffTemplate.AsSystem(commit.Commit),
}, &buf)