mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-07-18 12:20:15 +08:00
@@ -27,6 +27,10 @@ export async function setConversationProperty(token, conversationId, propertyObj
|
||||
await request(token, 'PATCH', `/conversation/${conversationId}`, propertyObject)
|
||||
}
|
||||
|
||||
export async function deleteConversation(token, conversationId) {
|
||||
if (conversationId) await setConversationProperty(token, conversationId, { is_visible: false })
|
||||
}
|
||||
|
||||
export async function sendModerations(token, question, conversationId, messageId) {
|
||||
await request(token, 'POST', `/moderations`, {
|
||||
conversation_id: conversationId,
|
||||
@@ -48,10 +52,6 @@ export async function getModels(token) {
|
||||
* @param {string} accessToken
|
||||
*/
|
||||
export async function generateAnswersWithChatgptWebApi(port, question, session, accessToken) {
|
||||
const deleteConversation = () => {
|
||||
setConversationProperty(accessToken, session.conversationId, { is_visible: false })
|
||||
}
|
||||
|
||||
const controller = new AbortController()
|
||||
const stopListener = (msg) => {
|
||||
if (msg.stop) {
|
||||
@@ -65,7 +65,7 @@ export async function generateAnswersWithChatgptWebApi(port, question, session,
|
||||
port.onDisconnect.addListener(() => {
|
||||
console.debug('port disconnected')
|
||||
controller.abort()
|
||||
deleteConversation()
|
||||
deleteConversation(accessToken, session.conversationId)
|
||||
})
|
||||
|
||||
const models = await getModels(accessToken).catch(() => {
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import Browser from 'webextension-polyfill'
|
||||
import ExpiryMap from 'expiry-map'
|
||||
import { generateAnswersWithChatgptWebApi, sendMessageFeedback } from './apis/chatgpt-web'
|
||||
import {
|
||||
deleteConversation,
|
||||
generateAnswersWithChatgptWebApi,
|
||||
sendMessageFeedback,
|
||||
} from './apis/chatgpt-web'
|
||||
import { generateAnswersWithBingWebApi } from './apis/bing-web.mjs'
|
||||
import {
|
||||
generateAnswersWithChatgptApi,
|
||||
@@ -126,6 +130,10 @@ Browser.runtime.onMessage.addListener(async (message) => {
|
||||
if (message.type === 'FEEDBACK') {
|
||||
const token = await getChatGptAccessToken()
|
||||
await sendMessageFeedback(token, message.data)
|
||||
} else if (message.type === 'DELETE_CONVERSATION') {
|
||||
const token = await getChatGptAccessToken()
|
||||
const data = message.data
|
||||
await deleteConversation(token, data.conversationId)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user