feat: #响应式 (#22)
* feat: #响应式 * fix: #兼容node 16 * feat: #接口代理 * fix: #延长超时时长到30秒 * fix: #for node 16 * fix: #node 16 * Update settings.json * Update package.json * Update index.vue * Update Layout.vue --------- Co-authored-by: Redon <790348264@qq.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import * as dotenv from 'dotenv'
|
||||
import type { SendMessageOptions } from 'chatgpt'
|
||||
import { ChatGPTAPI } from 'chatgpt'
|
||||
import 'isomorphic-fetch'
|
||||
import type { ChatGPTAPI, SendMessageOptions } from 'chatgpt'
|
||||
import { sendResponse } from './utils'
|
||||
|
||||
export interface ChatContext {
|
||||
@@ -18,7 +18,14 @@ if (apiKey === undefined)
|
||||
/**
|
||||
* More Info: https://github.com/transitive-bullshit/chatgpt-api
|
||||
*/
|
||||
const api = new ChatGPTAPI({ apiKey, debug: false })
|
||||
let api: ChatGPTAPI
|
||||
// To use ESM in CommonJS, you can use a dynamic import
|
||||
(async () => {
|
||||
const { ChatGPTAPI } = await import('chatgpt')
|
||||
|
||||
api = new ChatGPTAPI(
|
||||
{ apiKey: process.env.OPENAI_API_KEY })
|
||||
})()
|
||||
|
||||
async function chatReply(
|
||||
message: string,
|
||||
|
||||
Reference in New Issue
Block a user