mirror of
https://github.com/Pull-Pal/pull-pal.git
synced 2024-09-07 12:34:16 -04:00
try newline stuff
This commit is contained in:
parent
dfef07a1c0
commit
be278a9162
@ -4,6 +4,10 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
newlineLiteral = "<|newline-literal|>"
|
||||
)
|
||||
|
||||
// File represents a file in a git repository.
|
||||
type File struct {
|
||||
Path string
|
||||
@ -56,6 +60,7 @@ func parseFiles(filesSection string) []File {
|
||||
|
||||
replacer := strings.NewReplacer(
|
||||
"\\n", "\n",
|
||||
newlineLiteral, "\\n",
|
||||
"\\\"", "\"",
|
||||
"```", "",
|
||||
)
|
||||
|
@ -26,6 +26,11 @@ func (req DiffCommentRequest) GetPrompt() (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
replacer := strings.NewReplacer(
|
||||
"\\n", newlineLiteral,
|
||||
)
|
||||
req.File.Contents = replacer.Replace(req.File.Contents)
|
||||
|
||||
var result bytes.Buffer
|
||||
err = tmpl.Execute(&result, req)
|
||||
if err != nil {
|
||||
|
10
llm/issue.go
10
llm/issue.go
@ -27,6 +27,16 @@ func (req CodeChangeRequest) GetPrompt() (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
replacer := strings.NewReplacer(
|
||||
"\\n", newlineLiteral,
|
||||
)
|
||||
newFiles := make([]File, len(req.Files))
|
||||
for i, f := range req.Files {
|
||||
f.Contents = replacer.Replace(f.Contents)
|
||||
newFiles[i] = f
|
||||
}
|
||||
req.Files = newFiles
|
||||
|
||||
var result bytes.Buffer
|
||||
err = tmpl.Execute(&result, req)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user