forked from coderabbitai/ai-pr-reviewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinputs.ts
102 lines (99 loc) · 2.55 KB
/
inputs.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
export class Inputs {
systemMessage: string
title: string
description: string
rawSummary: string
shortSummary: string
filename: string
fileContent: string
fileDiff: string
patches: string
diff: string
commentChain: string
comment: string
constructor(
systemMessage = '',
title = 'no title provided',
description = 'no description provided',
rawSummary = '',
shortSummary = '',
filename = '',
fileContent = 'file contents cannot be provided',
fileDiff = 'file diff cannot be provided',
patches = '',
diff = 'no diff',
commentChain = 'no other comments on this patch',
comment = 'no comment provided'
) {
this.systemMessage = systemMessage
this.title = title
this.description = description
this.rawSummary = rawSummary
this.shortSummary = shortSummary
this.filename = filename
this.fileContent = fileContent
this.fileDiff = fileDiff
this.patches = patches
this.diff = diff
this.commentChain = commentChain
this.comment = comment
}
clone(): Inputs {
return new Inputs(
this.systemMessage,
this.title,
this.description,
this.rawSummary,
this.shortSummary,
this.filename,
this.fileContent,
this.fileDiff,
this.patches,
this.diff,
this.commentChain,
this.comment
)
}
render(content: string): string {
if (!content) {
return ''
}
if (this.systemMessage) {
content = content.replace('$system_message', this.systemMessage)
}
if (this.title) {
content = content.replace('$title', this.title)
}
if (this.description) {
content = content.replace('$description', this.description)
}
if (this.rawSummary) {
content = content.replace('$raw_summary', this.rawSummary)
}
if (this.shortSummary) {
content = content.replace('$short_summary', this.shortSummary)
}
if (this.filename) {
content = content.replace('$filename', this.filename)
}
if (this.fileContent) {
content = content.replace('$file_content', this.fileContent)
}
if (this.fileDiff) {
content = content.replace('$file_diff', this.fileDiff)
}
if (this.patches) {
content = content.replace('$patches', this.patches)
}
if (this.diff) {
content = content.replace('$diff', this.diff)
}
if (this.commentChain) {
content = content.replace('$comment_chain', this.commentChain)
}
if (this.comment) {
content = content.replace('$comment', this.comment)
}
return content
}
}