Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit 26d98cd

Browse files
Optimize prompts to use fewer tokens (#110)
Co-authored-by: Harjot Gill <[email protected]>
1 parent 373123c commit 26d98cd

File tree

8 files changed

+2686
-2719
lines changed

8 files changed

+2686
-2719
lines changed

action.yml

Lines changed: 53 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@ inputs:
5353
!**/_gen/**
5454
!**/generated/**
5555
!**/vendor/**
56-
openai_model:
56+
openai_summary_model:
5757
required: false
58-
description: 'Model to use'
58+
description: 'Model to use for summarization'
59+
default: 'gpt-3.5-turbo'
60+
openai_review_model:
61+
required: false
62+
description: 'Model to use for review'
5963
default: 'gpt-3.5-turbo'
6064
openai_model_temperature:
6165
required: false
@@ -78,37 +82,26 @@ inputs:
7882
required: false
7983
description: 'System message to be sent to OpenAI'
8084
default: |
81-
You are `@openai` (aka `github-actions[bot]`), a highly
82-
experienced software engineer with a strong ability to review
83-
code changes thoroughly.
84-
85-
Your role today is to conduct code and documentation reviews, and
86-
generate code and documentation if asked to do so. You will point
87-
out potential issues such as security (e.g. XSS), logic errors,
88-
syntax errors, out of bound errors, data races, livelocks, starvation,
89-
suspension, order violation, atomicity violation, consistency,
90-
complexity, error handling, typos, grammar, and more.
91-
summarize_beginning:
85+
You are `@openai` (aka `github-actions[bot]`), a language model
86+
trained by OpenAI. You have been designed to act as a highly
87+
experienced software engineer today. Your main task is to review
88+
code and documentation, provide suggestions, and write new code
89+
or documentation when requested. Please ensure that your responses
90+
are focused on assisting with code and documentation concerns,
91+
following best practices and industry standards.
92+
summarize_file_diff:
9293
required: false
9394
description: 'The prompt for the whole pull request'
9495
default: |
95-
$system_message
96-
97-
In this session, we will summarize a pull request.
96+
In this session, we will summarize a pull request and a diff alltogether.
9897
9998
The pull request has the title "$title" and the following description:
10099
101100
```
102101
$description
103102
```
104-
105-
Reply "OK" to confirm that you are ready.
106-
summarize_file_diff:
107-
required: false
108-
description: 'The prompt for each file diff'
109-
default: |
110103
I am providing diff for `$filename` below. I would like you to summarize
111-
the diff within 30 words.
104+
the diff within 50 words.
112105
113106
```diff
114107
$file_diff
@@ -148,16 +141,10 @@ inputs:
148141
Below the release notes, generate a short, celebratory poem about the
149142
changes in this PR and add this poem as a quote (> symbol). You can
150143
use emojis in the poem, where they are relevant.
151-
review_beginning:
144+
review_file_diff:
152145
required: false
153-
description: 'The beginning prompt of a code review dialog'
146+
description: 'The prompt for each file'
154147
default: |
155-
$system_message
156-
157-
I will provide you with some files and the entire diff to help you build
158-
context, unless the content is too large. Then, I will send you each patch
159-
from the diff for review.
160-
161148
The pull request has the title "$title" and the following description:
162149
163150
```
@@ -170,68 +157,55 @@ inputs:
170157
$summary
171158
```
172159
173-
Reply "OK" to confirm.
174-
review_file:
175-
required: false
176-
description: 'The prompt for each file'
177-
default: |
178-
Here is the content of `$filename` for context. Please use this context
179-
when reviewing patches.
160+
Content of `$filename` is follows.
180161
181162
```
182163
$file_content
183164
```
184165
185-
Reply "LGTM!" if the existing code in this file looks correct. If there
186-
are serious issues in the existing code please let me know and I will
187-
add your comment on the pull request for this file.
188-
review_file_diff:
189-
required: false
190-
description: 'The prompt for each file diff'
191-
default: |
192-
Here is the entire diff for `$filename` for context. Please use this context
193-
when reviewing patches.
166+
Below is the format for diff patches. `---`
167+
separator is used between patches.
194168
169+
<line_number>:
170+
```text
171+
<review comments on patch, if any>
172+
```
195173
```diff
196-
$file_diff
174+
<patch>
197175
```
176+
---
177+
...
198178
199-
Reply "OK" to confirm.
200-
review_patch_begin:
201-
required: false
202-
description: 'The prompt for each file diff'
203-
default: |
204-
Next, I will send you a series of patches. Each patch consists of a diff snippet,
205-
and your task is to review every patch. Identify any bug risks or provide
206-
improvement suggestions. Otherwise, if the patch is acceptable, please reply
207-
"LGTM!" with a short comment.
179+
Patches for review -
208180
209-
Your responses will be recorded as review comments on the pull request.
210-
Markdown format is preferred for your responses.
181+
$patches
211182
212-
Reply "OK" to confirm.
213-
review_patch:
214-
required: false
215-
description: 'The prompt for each chunks/patches'
216-
default: |
217-
$filename
183+
Your review for each patch should be the following format
184+
with `---` separator between review comments. Make sure
185+
to use the line numbers exactly as provided above:
218186
219-
Existing comments on the patch, though some of them may be outdated.
220-
Please use them as additional context.
221-
```
222-
$comment_chain
223-
```
187+
<line_number>:
188+
<review>
189+
---
190+
...
224191
225-
Diff for review:
226-
```diff
227-
$patch
228-
```
229-
comment_beginning:
192+
Reflect on the provided code at least 3 times to identify any bug risks
193+
or provide improvement suggestions in these patches.
194+
You will point out potential issues such as security, logic errors,
195+
syntax errors, out of bound errors, data races, consistency,
196+
complexity, error handling, typos, grammar, code style, maintainability,
197+
performance, and so on.
198+
199+
If there are no issues or suggestions and the patch is acceptable
200+
as-is, please include "LGTM!" (exact word) in your short
201+
review comment.
202+
203+
Your responses will be recorded as review comments on the
204+
pull request. Markdown format is preferred for your responses.
205+
comment:
230206
required: false
231207
description: 'Prompt for comment'
232208
default: |
233-
$system_message
234-
235209
A comment was made on a review for a diff patch on file
236210
`$filename`. I would like you to follow the instructions
237211
in that comment.
@@ -252,33 +226,18 @@ inputs:
252226
$summary
253227
```
254228
255-
Reply "OK" to confirm.
256-
comment_file:
257-
required: false
258-
description: 'Prompt for file'
259-
default: |
260-
Here is the content of `$filename` for context.
229+
Here is the content of file.
261230
262231
```
263232
$file_content
264233
```
265234
266-
Reply "OK" to confirm.
267-
comment_file_diff:
268-
required: false
269-
description: 'Prompt for file diff'
270-
default: |
271-
Here is the entire diff for `$filename` for context.
235+
Here is the entire diff.
272236
273237
```diff
274238
$file_diff
275239
```
276240
277-
Reply "OK" to confirm.
278-
comment:
279-
required: false
280-
description: 'Prompt for comment'
281-
default: |
282241
I would like you to follow the instructions in the new
283242
comment made on a conversation chain on a code review diff.
284243

0 commit comments

Comments
 (0)