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