mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
28 lines
871 B
JavaScript
28 lines
871 B
JavaScript
import { DefaultToolCloudService, ToolManager } from 'chaite'
|
|
import ChatGPTConfig from '../../config/config.js'
|
|
import { createToolsSettingsStorage } from './tool_settings_storage.js'
|
|
const ChatGPTToolCloudService = new DefaultToolCloudService(ChatGPTConfig.cloudBaseUrl, '', {})
|
|
/**
|
|
* @type {import('chaite').ToolManager}
|
|
*/
|
|
let ChatGPTToolManager
|
|
ToolManager.getInstance(ChatGPTConfig.toolsDirPath, createToolsSettingsStorage(), ChatGPTToolCloudService).then((manager) => {
|
|
ChatGPTToolManager = manager
|
|
})
|
|
|
|
/**
|
|
* 认证,以便共享上传
|
|
* @param apiKey
|
|
* @returns {Promise<import('chaite').User>}
|
|
*/
|
|
export async function authCloud (apiKey) {
|
|
const user = await ChatGPTToolCloudService.authenticate(apiKey)
|
|
ChatGPTToolManager.setCloudService(ChatGPTToolCloudService)
|
|
return user
|
|
}
|
|
|
|
export default {
|
|
ChatGPTToolCloudService,
|
|
ChatGPTToolManager
|
|
}
|
|
|