Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear auto-generated conversations #17

Closed
benny502 opened this issue Mar 17, 2023 · 3 comments
Closed

Clear auto-generated conversations #17

benny502 opened this issue Mar 17, 2023 · 3 comments

Comments

@benny502
Copy link

Is your feature request related to a problem? Please describe.
新功能是否与解决某个问题相关, 请描述
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
希望每次执行之后能自动删除会话,目前每查询一次,翻译一次就会在列表里留下一个新会话,得自己一个一个删除
A clear and concise description of what you want to happen.

Additional context
其他
Add any other context or screenshots about the feature request here.

@josStorer
Copy link
Owner

josStorer commented Mar 17, 2023

Edit:

v2.3.1

Now it is possible to automatically clear conversations, and you can turn it on/off in advanced settings

image

Actually, I have implemented this functionality, but it has to be active in the background in order to trigger, and many browsers do not allow extensions to keep active in the background, so it often fails to clean up correctly. And it's difficult to predict when users don't need a session, and providing a button for users to click and delete is sometimes inconvenient, as many people may forget to click it. And continuing to use the same session can lead to context issues and slow response time.

Currently, I suggest using this method: wong2/chatgpt-google-extension#301 (comment).
On the chatGPT official web page, open the browser console, paste and execute the following code to perform automatic cleaning.

其实目前我做了这个功能, 但是必须是后台活跃, 才能触发, 而许多浏览器不允许插件后台一直保持活动, 所以很多时候没能正确清理
而同时用户什么时候不需要会话是难以预测的, 主动提供一个按钮让用户点击删除, 可能很多时候也显得很麻烦, 很多人不会想起来去点
一直使用同一个会话又会导致上下文问题及响应缓慢

目前我建议你可以用此方法: wong2/chatgpt-google-extension#301 (comment)
在chatgpt官方页面, 开启浏览器控制台, 粘贴执行以下代码, 进行自动清理

async function getToken() {
	const session = await (await fetch('https://chat.openai.com/api/auth/session')).json();
	return session.accessToken;
}	

var TOKEN = await getToken();

async function getConversations() {
	return (await (await fetch('https://chat.openai.com/backend-api/conversations?offset=0&limit=100', { headers: {'authorization': `Bearer ${TOKEN}`} })).json()).items;
}

async function deleteConversation(id) {
	const response = await fetch(`https://chat.openai.com/backend-api/conversation/${id}`, { 
		method: 'PATCH', 
		headers: {
			'authorization': `Bearer ${TOKEN}`,
			'content-type': 'application/json',
		},
		body: JSON.stringify({"is_visible": false}),
	})
	return await response.json();
}

conversations = await getConversations();
toClear = conversations.filter(c => c.title === 'New chat')
await Promise.allSettled(toClear.map(c => deleteConversation(c.id)))

@benny502
Copy link
Author

好吧,也许完美的解决方法是切换成api方式233

@josStorer
Copy link
Owner

v2.3.1

Now it is possible to automatically clear conversations, and you can turn it on/off in advanced settings

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants