mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-04-08 07:25:51 +00:00
fix: resolve TypeScript errors in GitHub Actions build
Fix type issues and update import syntax for better compatibility. Co-authored-by: Jason <159670257+Jasonzhu1207@users.noreply.github.com>
This commit is contained in:
@@ -17,7 +17,7 @@ import https from 'https'
|
|||||||
import http from 'http'
|
import http from 'http'
|
||||||
import { URL } from 'url'
|
import { URL } from 'url'
|
||||||
import { ConfigService } from './config'
|
import { ConfigService } from './config'
|
||||||
import { chatService, type ChatSession, type Message } from './chatService'
|
import { chatService, ChatSession, Message } from './chatService'
|
||||||
import { showNotification } from '../windows/notificationWindow'
|
import { showNotification } from '../windows/notificationWindow'
|
||||||
|
|
||||||
// ─── 常量 ────────────────────────────────────────────────────────────────────
|
// ─── 常量 ────────────────────────────────────────────────────────────────────
|
||||||
@@ -106,20 +106,21 @@ function callApi(
|
|||||||
stream: false
|
stream: false
|
||||||
})
|
})
|
||||||
|
|
||||||
const options: https.RequestOptions = {
|
const options = {
|
||||||
hostname: urlObj.hostname,
|
hostname: urlObj.hostname,
|
||||||
port: urlObj.port || (urlObj.protocol === 'https:' ? 443 : 80),
|
port: urlObj.port || (urlObj.protocol === 'https:' ? 443 : 80),
|
||||||
path: urlObj.pathname + urlObj.search,
|
path: urlObj.pathname + urlObj.search,
|
||||||
method: 'POST',
|
method: 'POST' as const,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Content-Length': Buffer.byteLength(body),
|
'Content-Length': Buffer.byteLength(body).toString(),
|
||||||
Authorization: `Bearer ${apiKey}`
|
Authorization: `Bearer ${apiKey}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const isHttps = urlObj.protocol === 'https:'
|
const isHttps = urlObj.protocol === 'https:'
|
||||||
const req = (isHttps ? https : http).request(options, (res) => {
|
const requestFn = isHttps ? https.request : http.request
|
||||||
|
const req = requestFn(options, (res) => {
|
||||||
let data = ''
|
let data = ''
|
||||||
res.on('data', (chunk) => { data += chunk })
|
res.on('data', (chunk) => { data += chunk })
|
||||||
res.on('end', () => {
|
res.on('end', () => {
|
||||||
@@ -431,7 +432,7 @@ class InsightService {
|
|||||||
const time = new Date(Number(m.createTime) * 1000).toLocaleString('zh-CN')
|
const time = new Date(Number(m.createTime) * 1000).toLocaleString('zh-CN')
|
||||||
return `[${time}] ${sender}:${content}`
|
return `[${time}] ${sender}:${content}`
|
||||||
})
|
})
|
||||||
contextSection = `\n\n近期对话记录(最近 ${msgLines.length} 条):\n${msgLines.join('\n')}`
|
contextSection = `\n\n<EFBFBD><EFBFBD>期对话记录(最近 ${msgLines.length} 条):\n${msgLines.join('\n')}`
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('[InsightService] 拉取上下文失败:', e)
|
console.warn('[InsightService] 拉取上下文失败:', e)
|
||||||
|
|||||||
Reference in New Issue
Block a user