Skip to content

Commit 1a19af2

Browse files
committed
Use default API key
Signed-off-by: Michael Yuan <michael@secondstate.io>
1 parent d7d6d43 commit 1a19af2

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/github-pr-summary.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use http_req::{
99
request::{Method, Request},
1010
uri::Uri,
1111
};
12-
use openai_flows::{chat_completion, ChatModel, ChatOptions};
12+
use openai_flows::{chat_completion_default_key, ChatModel, ChatOptions};
1313
use std::env;
1414

1515
#[no_mangle]
@@ -20,7 +20,6 @@ pub async fn run() -> anyhow::Result<()> {
2020
let login = env::var("login").unwrap_or("juntao".to_string());
2121
let owner = env::var("owner").unwrap_or("juntao".to_string());
2222
let repo = env::var("repo").unwrap_or("test".to_string());
23-
let openai_key_name = env::var("openai_key_name").unwrap_or("global.free.trial".to_string());
2423
let trigger_phrase = env::var("trigger_phrase").unwrap_or("flows summarize".to_string());
2524

2625
let events = vec!["pull_request", "issue_comment"];
@@ -29,7 +28,6 @@ pub async fn run() -> anyhow::Result<()> {
2928
&login,
3029
&owner,
3130
&repo,
32-
&openai_key_name,
3331
&trigger_phrase,
3432
payload,
3533
)
@@ -43,7 +41,6 @@ async fn handler(
4341
login: &str,
4442
owner: &str,
4543
repo: &str,
46-
openai_key_name: &str,
4744
trigger_phrase: &str,
4845
payload: EventPayload,
4946
) {
@@ -150,7 +147,7 @@ async fn handler(
150147
retry_times: 3,
151148
};
152149
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;
153-
if let Some(r) = chat_completion(openai_key_name, &chat_id, &question, &co) {
150+
if let Some(r) = chat_completion_default_key(&chat_id, &question, &co) {
154151
write_error_log!("Got a patch summary");
155152
if reviews_text.len() < 9000 {
156153
reviews_text.push_str("------\n");
@@ -173,7 +170,7 @@ async fn handler(
173170
retry_times: 3,
174171
};
175172
let question = "Here is a set of summaries for software source code patches. Each summary starts with a ------ line. Please write an overall summary considering all the individual summary. Please present the potential issues and errors first, following by the most important findings, in your summary.\n\n".to_string() + &reviews_text;
176-
if let Some(r) = chat_completion(openai_key_name, &chat_id, &question, &co) {
173+
if let Some(r) = chat_completion_default_key(&chat_id, &question, &co) {
177174
write_error_log!("Got the overall summary");
178175
resp.push_str(&r.choice);
179176
resp.push_str("\n\n## Details\n\n");

0 commit comments

Comments
 (0)