Skip to content

Commit 3f469b0

Browse files
committed
Fix https_proxy
Signed-off-by: adshao <tjusgj@gmail.com>
1 parent f6d3892 commit 3f469b0

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

dist/index.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39190,15 +39190,13 @@ const axios = __nccwpck_require__(73565);
3919039190
const detect = __nccwpck_require__(46397);
3919139191
const httpsProxyAgent = __nccwpck_require__(81908);
3919239192

39193-
function configWithProxy(url) {
39193+
function configWithProxy(config) {
3919439194
if (process.env.HTTPS_PROXY) {
39195-
return {
39196-
url: url,
39197-
proxy: false,
39198-
httpsAgent: new httpsProxyAgent(process.env.HTTPS_PROXY)
39199-
}
39195+
config.proxy = false;
39196+
config.httpsAgent = new httpsProxyAgent(process.env.HTTPS_PROXY);
39197+
return config;
3920039198
}
39201-
return url;
39199+
return config || {};
3920239200
}
3920339201

3920439202
async function run() {
@@ -39228,7 +39226,7 @@ async function run() {
3922839226
if (content == fullReviewComment) {
3922939227
// Get the content of the pull request
3923039228
if (!code) {
39231-
const response = await axios.get(configWithProxy(issue.pull_request.diff_url));
39229+
const response = await axios.get(issue.pull_request.diff_url, configWithProxy());
3923239230
code = response.data;
3923339231
}
3923439232

@@ -39242,7 +39240,7 @@ async function run() {
3924239240
if (programmingLanguage == 'auto') {
3924339241
// Get the content of the pull request
3924439242
if (!code) {
39245-
const response = await axios.get(configWithProxy(issue.pull_request.diff_url));
39243+
const response = await axios.get(issue.pull_request.diff_url, configWithProxy());
3924639244
code = response.data;
3924739245
}
3924839246
const detectedLanguage = detect(code);
@@ -39261,15 +39259,15 @@ async function run() {
3926139259
core.debug(`content: ${content}`);
3926239260

3926339261
// Call the OpenAI ChatGPT API to analyze the code
39264-
const response = await axios.post(configWithProxy('https://api.openai.com/v1/chat/completions'), {
39262+
const response = await axios.post('https://api.openai.com/v1/chat/completions', {
3926539263
"model": "gpt-3.5-turbo",
3926639264
"messages": messages
39267-
}, {
39265+
}, configWithProxy({
3926839266
headers: {
3926939267
'Content-Type': 'application/json',
3927039268
'Authorization': `Bearer ${openaiToken}`
3927139269
}
39272-
});
39270+
}));
3927339271

3927439272
core.debug(`openai response: ${response.data.choices[0].message.content}`);
3927539273

index.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ const axios = require('axios');
44
const detect = require('language-detect');
55
const httpsProxyAgent = require('https-proxy-agent');
66

7-
function configWithProxy(url) {
7+
function configWithProxy(config) {
88
if (process.env.HTTPS_PROXY) {
9-
return {
10-
url: url,
11-
proxy: false,
12-
httpsAgent: new httpsProxyAgent(process.env.HTTPS_PROXY)
13-
}
9+
config.proxy = false;
10+
config.httpsAgent = new httpsProxyAgent(process.env.HTTPS_PROXY);
11+
return config;
1412
}
15-
return url;
13+
return config || {};
1614
}
1715

1816
async function run() {
@@ -42,7 +40,7 @@ async function run() {
4240
if (content == fullReviewComment) {
4341
// Get the content of the pull request
4442
if (!code) {
45-
const response = await axios.get(configWithProxy(issue.pull_request.diff_url));
43+
const response = await axios.get(issue.pull_request.diff_url, configWithProxy());
4644
code = response.data;
4745
}
4846

@@ -56,7 +54,7 @@ async function run() {
5654
if (programmingLanguage == 'auto') {
5755
// Get the content of the pull request
5856
if (!code) {
59-
const response = await axios.get(configWithProxy(issue.pull_request.diff_url));
57+
const response = await axios.get(issue.pull_request.diff_url, configWithProxy());
6058
code = response.data;
6159
}
6260
const detectedLanguage = detect(code);
@@ -75,15 +73,15 @@ async function run() {
7573
core.debug(`content: ${content}`);
7674

7775
// Call the OpenAI ChatGPT API to analyze the code
78-
const response = await axios.post(configWithProxy('https://api.openai.com/v1/chat/completions'), {
76+
const response = await axios.post('https://api.openai.com/v1/chat/completions', {
7977
"model": "gpt-3.5-turbo",
8078
"messages": messages
81-
}, {
79+
}, configWithProxy({
8280
headers: {
8381
'Content-Type': 'application/json',
8482
'Authorization': `Bearer ${openaiToken}`
8583
}
86-
});
84+
}));
8785

8886
core.debug(`openai response: ${response.data.choices[0].message.content}`);
8987

0 commit comments

Comments
 (0)