Skip to content

Commit

Permalink
Fix https_proxy
Browse files Browse the repository at this point in the history
Signed-off-by: adshao <[email protected]>
  • Loading branch information
adshao committed Mar 3, 2023
1 parent f6d3892 commit 3f469b0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
22 changes: 10 additions & 12 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39190,15 +39190,13 @@ const axios = __nccwpck_require__(73565);
const detect = __nccwpck_require__(46397);
const httpsProxyAgent = __nccwpck_require__(81908);

function configWithProxy(url) {
function configWithProxy(config) {
if (process.env.HTTPS_PROXY) {
return {
url: url,
proxy: false,
httpsAgent: new httpsProxyAgent(process.env.HTTPS_PROXY)
}
config.proxy = false;
config.httpsAgent = new httpsProxyAgent(process.env.HTTPS_PROXY);
return config;
}
return url;
return config || {};
}

async function run() {
Expand Down Expand Up @@ -39228,7 +39226,7 @@ async function run() {
if (content == fullReviewComment) {
// Get the content of the pull request
if (!code) {
const response = await axios.get(configWithProxy(issue.pull_request.diff_url));
const response = await axios.get(issue.pull_request.diff_url, configWithProxy());
code = response.data;
}

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

// Call the OpenAI ChatGPT API to analyze the code
const response = await axios.post(configWithProxy('https://api.openai.com/v1/chat/completions'), {
const response = await axios.post('https://api.openai.com/v1/chat/completions', {
"model": "gpt-3.5-turbo",
"messages": messages
}, {
}, configWithProxy({
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${openaiToken}`
}
});
}));

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

Expand Down
22 changes: 10 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ const axios = require('axios');
const detect = require('language-detect');
const httpsProxyAgent = require('https-proxy-agent');

function configWithProxy(url) {
function configWithProxy(config) {
if (process.env.HTTPS_PROXY) {
return {
url: url,
proxy: false,
httpsAgent: new httpsProxyAgent(process.env.HTTPS_PROXY)
}
config.proxy = false;
config.httpsAgent = new httpsProxyAgent(process.env.HTTPS_PROXY);
return config;
}
return url;
return config || {};
}

async function run() {
Expand Down Expand Up @@ -42,7 +40,7 @@ async function run() {
if (content == fullReviewComment) {
// Get the content of the pull request
if (!code) {
const response = await axios.get(configWithProxy(issue.pull_request.diff_url));
const response = await axios.get(issue.pull_request.diff_url, configWithProxy());
code = response.data;
}

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

// Call the OpenAI ChatGPT API to analyze the code
const response = await axios.post(configWithProxy('https://api.openai.com/v1/chat/completions'), {
const response = await axios.post('https://api.openai.com/v1/chat/completions', {
"model": "gpt-3.5-turbo",
"messages": messages
}, {
}, configWithProxy({
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${openaiToken}`
}
});
}));

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

Expand Down

0 comments on commit 3f469b0

Please sign in to comment.