You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# <palign="center">GPT Nitro for Github PR</p>
1
+
# <palign="center">ChatGPT/4 code reviewer for Github PR</p>
2
2
3
3
<palign="center">
4
4
<ahref="https://discord.gg/ccZn9ZMfFf">
@@ -26,6 +26,12 @@ This flow function (or 🤖) will be triggered and executed when a new PR is rai
26
26
27
27
The GitHub repo is connected to the flow function via the [flows.network](https://flows.network/) platform. The "trigger phrase" can also be configured in [flows.network](https://flows.network/).
28
28
29
+
### Deploy your own code review bot in 3 simple steps
30
+
31
+
1. Fork this repo. It contains the source code for the GitHub bot.
32
+
2. Import the forked repo on [flows.network](https://flows.network/) as a flow function.
33
+
3. Connect the flow function to the GitHub repo you want to deploy the bot on [flows.network](https://flows.network/) UI.
let patch_uri = Uri::try_from(patch_url.as_str()).unwrap();
97
-
letmut writer = Vec::new();
98
-
let _ = Request::new(&patch_uri)
99
-
.method(Method::GET)
100
-
.header("Accept","application/vnd.github+json")
101
-
.header("User-Agent","Flows Network Connector")
102
-
.send(&mut writer)
103
-
.map_err(|_e| {})
104
-
.unwrap();
105
-
let patch_as_text = String::from_utf8_lossy(&writer);
106
-
89
+
let pulls = octo.pulls(owner, repo);
90
+
91
+
let patch_as_text = pulls.get_patch(pull_number).await.unwrap();
107
92
letmut current_commit = String::new();
108
93
letmut commits:Vec<String> = Vec::new();
109
94
for line in patch_as_text.lines(){
@@ -116,10 +101,8 @@ async fn handler(
116
101
// Start a new commit
117
102
current_commit.clear();
118
103
}
119
-
// Append the line to the current commit if the current commit is less than 18000 chars
120
-
// the max token size or word count for GPT4 is 8192
121
-
// the max token size or word count for GPT35Turbo is 4096
122
-
if current_commit.len() < 9000{
104
+
// Append the line to the current commit if the current commit is less than CHAR_SOFT_LIMIT
105
+
if current_commit.len() < CHAR_SOFT_LIMIT{
123
106
current_commit.push_str(line);
124
107
current_commit.push('\n');
125
108
}
@@ -128,17 +111,17 @@ async fn handler(
128
111
// Store the last commit
129
112
commits.push(current_commit.clone());
130
113
}
131
-
// write_error_log!(&format!("Num of commits = {}", commits.len()));
132
114
133
115
if commits.is_empty(){
134
116
write_error_log!("Cannot parse any commit from the patch file");
135
117
return;
136
118
}
137
119
120
+
let chat_id = format!("PR#{pull_number}");
121
+
let system = &format!("You are an experienced software developer. You will act as a reviewer for a GitHub Pull Request titled \"{}\".", title);
138
122
letmut reviews:Vec<String> = Vec::new();
139
123
letmut reviews_text = String::new();
140
124
for(_i, commit)in commits.iter().enumerate(){
141
-
let system = "You are an experienced software developer. You will act as a reviewer for GitHub Pull Requests.";
142
125
let co = ChatOptions{
143
126
// model: ChatModel::GPT4,
144
127
model:ChatModel::GPT35Turbo,
@@ -148,8 +131,7 @@ async fn handler(
148
131
};
149
132
let question = "The following is a GitHub patch. Please summarize the key changes and identify potential problems. Start with the most important findings.\n\n".to_string() + commit;
resp.push_str("Hello, I am a [serverless review bot](https://github.com/flows-network/github-pr-summary/) on [flows.network](https://flows.network/). Here are my reviews of code commits in this PR.\n\n------\n\n");
163
145
if reviews.len() > 1{
164
-
let system = "You are a helpful assistant and an experienced software developer.";
0 commit comments