Skip to content

Commit 0c88426

Browse files
committed
Automatically retry the OpenAI API when it errors
Signed-off-by: Michael Yuan <michael@secondstate.io>
1 parent b77faeb commit 0c88426

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ anyhow = "1"
1717
flowsnet-platform-sdk = "0.1.2"
1818
lazy_static = "1.4.0"
1919
regex = "1.7.1"
20-
openai-flows = "0.3"
20+
openai-flows = "0.4"
2121
http_req_wasi = { version = "0.10.2", features = ["wasmedge_ssl"] }
2222
words-count = "0.1.4"

src/github-pr-summary.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ async fn handler(
147147
model: ChatModel::GPT35Turbo,
148148
restart: true,
149149
system_prompt: Some(system),
150+
retry_times: 3,
150151
};
151152
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;
152153
if let Some(r) = chat_completion(openai_key_name, &chat_id, &question, &co) {
@@ -169,6 +170,7 @@ async fn handler(
169170
model: ChatModel::GPT35Turbo,
170171
restart: true,
171172
system_prompt: Some(system),
173+
retry_times: 3,
172174
};
173175
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;
174176
if let Some(r) = chat_completion(openai_key_name, &chat_id, &question, &co) {

0 commit comments

Comments
 (0)