MCPcopy Create free account
hub / github.com/Hello-Application-XH/HelloGML / removeConversation

Function removeConversation

src/chat.ts:294–318  ·  view source on GitHub ↗
(convId: string, refreshToken: string, assistantId = DEFAULT_ASSISTANT_ID)

Source from the content-addressed store, hash-verified

292}
293
294async function removeConversation(convId: string, refreshToken: string, assistantId = DEFAULT_ASSISTANT_ID) {
295 const token = await acquireToken(refreshToken);
296 const sign = await generateSign();
297 const controller = new AbortController();
298 const timeoutId = setTimeout(() => controller.abort(), 15000);
299 try {
300 const response = await fetch("https://chatglm.cn/chatglm/backend-api/assistant/conversation/delete", {
301 method: "POST",
302 headers: {
303 Authorization: `Bearer ${token}`,
304 Referer: "https://chatglm.cn/main/alltoolsdetail",
305 "X-Device-Id": uuid(false),
306 "X-Request-Id": uuid(false),
307 "X-Sign": sign.sign,
308 "X-Timestamp": sign.timestamp,
309 "X-Nonce": sign.nonce,
310 ...getHeaders(),
311 },
312 body: JSON.stringify({ assistant_id: assistantId, conversation_id: convId }),
313 signal: controller.signal,
314 });
315 await checkResult(response, refreshToken);
316 } catch {}
317 finally { clearTimeout(timeoutId); }
318}
319
320async function checkResult(response: Response, refreshToken: string): Promise<any> {
321 const data: any = await response.json().catch(() => null);

Callers 3

createCompletionFunction · 0.85
createCompletionStreamFunction · 0.85
generateImagesFunction · 0.85

Calls 6

uuidFunction · 0.90
acquireTokenFunction · 0.85
generateSignFunction · 0.85
fetchFunction · 0.85
getHeadersFunction · 0.85
checkResultFunction · 0.85

Tested by

no test coverage detected