From e183e31ce0a552a7f36a3ae0d1bbee6acb8f723c Mon Sep 17 00:00:00 2001 From: Jeffery Date: Mon, 11 May 2026 08:34:04 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BF=BD=E7=95=A5=20SSL=20=E6=86=91?= =?UTF-8?q?=E8=AD=89=E9=A9=97=E8=AD=89=EF=BC=88=E6=94=AF=E6=8F=B4=E8=87=AA?= =?UTF-8?q?=E7=B0=BD=E6=86=91=E8=AD=89=E7=9A=84=20Ollama/Gitea=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/gitea.js | 6 ++++-- app/llm.js | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/gitea.js b/app/gitea.js index 787f801..f8b4216 100644 --- a/app/gitea.js +++ b/app/gitea.js @@ -1,15 +1,17 @@ import axios from 'axios'; +import https from 'https'; import { GITEA_TOKEN, GITEA_SERVER_URL, GITEA_REPOSITORY, PR_NUMBER } from './config.js'; +const httpsAgent = new https.Agent({ rejectUnauthorized: false }); const headers = () => ({ Authorization: `token ${GITEA_TOKEN}`, 'Content-Type': 'application/json' }); const api = (path) => `${GITEA_SERVER_URL.replace(/\/$/, '')}/api/v1${path}`; export async function getPRDiff() { - const resp = await axios.get(api(`/repos/${GITEA_REPOSITORY}/pulls/${PR_NUMBER}.diff`), { headers: headers(), timeout: 60000 }); + const resp = await axios.get(api(`/repos/${GITEA_REPOSITORY}/pulls/${PR_NUMBER}.diff`), { headers: headers(), timeout: 60000, httpsAgent }); return resp.data; } export async function postComment(body) { - const resp = await axios.post(api(`/repos/${GITEA_REPOSITORY}/issues/${PR_NUMBER}/comments`), { body }, { headers: headers(), timeout: 30000 }); + const resp = await axios.post(api(`/repos/${GITEA_REPOSITORY}/issues/${PR_NUMBER}/comments`), { body }, { headers: headers(), timeout: 30000, httpsAgent }); return resp.data; } diff --git a/app/llm.js b/app/llm.js index f2521d3..db7217b 100644 --- a/app/llm.js +++ b/app/llm.js @@ -1,6 +1,9 @@ import axios from 'axios'; +import https from 'https'; import { getLLMConfig } from './config.js'; +const httpsAgent = new https.Agent({ rejectUnauthorized: false }); + export async function chat(systemPrompt, userContent) { const { provider, apiKey, baseURL, model } = getLLMConfig(); if (!provider) throw new Error('未設定任何 LLM API Key'); @@ -16,7 +19,7 @@ export async function chat(systemPrompt, userContent) { const resp = await axios.post( `${baseURL.replace(/\/$/, '')}/chat/completions`, { model, messages: [{ role: 'system', content: systemPrompt }, { role: 'user', content: userContent }], temperature: 0.2 }, - { headers, timeout: 120000 } + { headers, timeout: 120000, httpsAgent } ); return resp.data.choices[0].message.content; }