Skip to content

Commit de8a7ef

Browse files
committed
Update code defaults and docs
Signed-off-by: Michael Yuan <[email protected]>
1 parent 74110a5 commit de8a7ef

File tree

2 files changed

+38
-33
lines changed

2 files changed

+38
-33
lines changed

README.md

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,48 +31,66 @@ This bot **summarizes commits in the PR**. Alternatively, you can use [this bot]
3131

3232
## How it works
3333

34-
This flow function (or 🤖) will be triggered when a new PR is raised in the designated GitHub repo. The flow function collects the content in the PR, and asks ChatGPT/4 to review and summarize it. The result is then posted back to the PR as a comment. The flow functions are written in Rust and run in hosted [WasmEdge Runtimes](https://github.com/wasmedge) on [flows.network](https://flows.network/).
34+
This flow function will be triggered when a new PR is raised in the designated GitHub repo. The flow function collects the content in the PR, and asks ChatGPT/4 to review and summarize it. The result is then posted back to the PR as a comment. The flow functions are written in Rust and run in hosted [WasmEdge Runtimes](https://github.com/wasmedge) on [flows.network](https://flows.network/).
3535

36-
* The code review comment is updated automatically every time a new commit is pushed to this PR.
37-
* A new code review could be triggered when someone says a magic *trigger phrase* in the PR's comments section. The default trigger phrase is "flows summarize".
36+
* The PR summary comment is updated automatically every time a new commit is pushed to this PR.
37+
* A new summary could be triggered when someone says a magic *trigger phrase* in the PR's comments section. The default trigger phrase is "flows summarize".
3838

39-
## Deploy your own code review bot in 2 simple steps
39+
## Deploy your own code review bot in 3 simple steps
4040

41-
1. Create a bot from a template
42-
2. Configure the bot to review PRs on a specified GitHub repo
41+
1. Create a bot from your own GitHub repo
42+
2. Configure the bot to review PRs
43+
3. Connect to GitHub for access to the target repo
4344

4445
### 0 Prerequisites
4546

4647
You will also need to sign into [flows.network](https://flows.network/) from your GitHub account. It is free.
4748

48-
### 1 Create a bot from a template
49+
### 1 Create a bot from your own GitHub repo
4950

50-
[**Just click here**](https://flows.network/flow/createByTemplate/Summarize-Pull-Request)
51+
Just fork this repo to your own GitHub account.
5152

52-
Review the `trigger_phrase` variable. It is the magic words you type in a PR comment to manually summon the review bot.
53+
Then, from [flows.network](https://flows.network/), you can "Create a Flow" and select your forked repo.
54+
It will create a flow function based on the code in your forked repo.
5355

54-
Click on the **Create and Build** button.
56+
Click on the "Advanced" button to see configuration options for the flow function.
5557

56-
### 2 Configure the bot to access GitHub
58+
### 2 Configure the bot to review PRs
59+
60+
<img src="https://raw.githubusercontent.com/flows-network/github-pr-summary/main/images/config.png" width="450"/>
5761

5862
Next, you will tell the bot which GitHub repo it needs to monitor for upcoming PRs to review.
5963

60-
* `github_owner`: GitHub org for the repo *you want to deploy the 🤖 on*.
61-
* `github_repo` : GitHub repo *you want to deploy the 🤖 on*.
64+
* `github_owner`: GitHub org for the repo *you want to review PRs*
65+
* `github_repo` : GitHub repo *you want to review PRs*
66+
* `trigger_phrase` : The magic words to write in a PR comment to summon the bot. It defaults to "flows summarize".
6267

6368
> Let's see an example. You would like to deploy the bot to review code in PRs on `WasmEdge/wasmedge_hyper_demo` repo. Here `github_owner = WasmEdge` and `github_repo = wasmedge_hyper_demo`.
6469
65-
Click on the **Connect** or **+ Add new authentication** button to give the function access to the GitHub repo to deploy the 🤖. You'll be redirected to a new page where you must grant [flows.network](https://flows.network/) permission to the repo.
70+
And the LLM API service you want to use to review the PRs.
71+
72+
* `llm_api_endpoint` : The OpenAI compatible API service endpoint for the LLM to conduct code reviews.
73+
* `llm_model_name` : The model name required by the API service.
74+
* `llm_api_key` : Optional: The API key if required by the LLM service provider.
75+
76+
Click on the **Build** button.
77+
78+
### 3 Connect to GitHub for access to the target repo
79+
80+
Finally, the GitHub repo will need to give you access so that the flow function can
81+
access and review its PRs! In this next screen, you will connect to GitHub and authorize access.
82+
83+
Click on the **Connect** or **+ Add new authentication** button to give the function access to the GitHub repo. You'll be redirected to a new page where you must grant [flows.network](https://flows.network/) permission to the repo.
6684

67-
[<img width="450" alt="image" src="https://github.com/flows-network/github-pr-summary/assets/45785633/6cefff19-9eeb-4533-a20b-03c6a9c89473">](https://github.com/flows-network/github-pr-summary/assets/45785633/6cefff19-9eeb-4533-a20b-03c6a9c89473)
85+
<img src="https://raw.githubusercontent.com/flows-network/github-pr-summary/main/images/github_integration.png" width="450"/>
6886

6987
Close the tab and go back to the flow.network page once you are done. Click on **Deploy**.
7088

7189
### Wait for the magic!
7290

7391
This is it! You are now on the flow details page waiting for the flow function to build. As soon as the flow's status became `running`, the bot is ready to give code reviews! The bot is summoned by every new PR, every new commit, as well as magic words (i.e., `trigger_phrase`) in PR comments.
7492

75-
[<img width="450" alt="image" src="https://user-images.githubusercontent.com/45785633/229329247-16273aec-f89b-4375-bf2b-4ffce5e35a33.png">](https://user-images.githubusercontent.com/45785633/229329247-16273aec-f89b-4375-bf2b-4ffce5e35a33.png)
93+
<img src="https://raw.githubusercontent.com/flows-network/github-pr-summary/main/images/success.png" width="450"/>
7694

7795
## FAQ
7896

src/github-pr-summary.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,9 @@ async fn handler(payload: EventPayload) {
3939
let owner = env::var("github_owner").unwrap_or("juntao".to_string());
4040
let repo = env::var("github_repo").unwrap_or("test".to_string());
4141
let trigger_phrase = env::var("trigger_phrase").unwrap_or("flows summarize".to_string());
42-
let llm_api_endpoint = env::var("llm_api_endpoint").unwrap_or("https://codestral-01-22b.us.gaianet.network/v1".to_string());
43-
let llm_model_name = env::var("llm_model_name").unwrap_or("Codestral-22B-v0.1-hf-Q5_K_M".to_string());
44-
45-
/*
46-
if let EventPayload::IssueCommentEvent(e) = payload {
47-
let comment_id = e.comment.id.0;
48-
49-
// installed app login
50-
let octo = get_octo(&GithubLogin::Provided(String::from("some_login")));
51-
52-
let _reaction = octo
53-
.issues("some_owner", "some_repo")
54-
.create_comment_reaction(comment_id, ReactionContent::Rocket)
55-
.await
56-
.unwrap();
57-
};
58-
*/
42+
let llm_api_endpoint = env::var("llm_api_endpoint").unwrap_or("https://api.openai.com/v1".to_string());
43+
let llm_model_name = env::var("llm_model_name").unwrap_or("gpt-4o".to_string());
44+
let llm_api_key = env::var("llm_api_key").unwrap_or("LLAMAEDGE".to_string());
5945

6046
let mut new_commit : bool = false;
6147
let (title, pull_number, _contributor) = match payload {
@@ -170,6 +156,7 @@ async fn handler(payload: EventPayload) {
170156
let chat_id = format!("PR#{pull_number}");
171157
let system = &format!("You are an experienced software developer. You will act as a reviewer for a GitHub Pull Request titled \"{}\". Please be as concise as possible while being accurate.", title);
172158
let mut lf = LLMServiceFlows::new(&llm_api_endpoint);
159+
lf.set_api_key(&llm_api_key);
173160
// lf.set_retry_times(3);
174161

175162
let mut reviews: Vec<String> = Vec::new();

0 commit comments

Comments
 (0)