-
Notifications
You must be signed in to change notification settings - Fork 716
/
init-session.mjs
91 lines (81 loc) · 2.5 KB
/
init-session.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { Models } from '../config/index.mjs'
import { v4 as uuidv4 } from 'uuid'
/**
* @typedef {object} Session
* @property {string|null} question
* @property {Object[]|null} conversationRecords
* @property {string|null} sessionName
* @property {string|null} sessionId
* @property {string|null} createdAt
* @property {string|null} updatedAt
* @property {string|null} aiName
* @property {string|null} modelName
* @property {boolean|null} autoClean
* @property {boolean} isRetry
* @property {string|null} conversationId - chatGPT web mode
* @property {string|null} messageId - chatGPT web mode
* @property {string|null} parentMessageId - chatGPT web mode
* @property {string|null} wsRequestId - chatGPT web mode
* @property {string|null} bingWeb_encryptedConversationSignature
* @property {string|null} bingWeb_conversationId
* @property {string|null} bingWeb_clientId
* @property {string|null} bingWeb_invocationId
* @property {string|null} bingWeb_jailbreakConversationId
* @property {string|null} bingWeb_parentMessageId
* @property {Object|null} bingWeb_jailbreakConversationCache
* @property {number|null} poe_chatId
* @property {object|null} bard_conversationObj
* @property {object|null} claude_conversation
* @property {object|null} moonshot_conversation
*/
/**
* @param {string|null} question
* @param {Object[]|null} conversationRecords
* @param {string|null} sessionName
* @param {string|null} modelName
* @param {boolean|null} autoClean
* @returns {Session}
*/
export function initSession({
question = null,
conversationRecords = [],
sessionName = null,
modelName = null,
autoClean = false,
} = {}) {
return {
// common
question,
conversationRecords,
sessionName,
sessionId: uuidv4(),
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
aiName: modelName ? Models[modelName].desc : null,
modelName,
autoClean,
isRetry: false,
// chatgpt-web
conversationId: null,
messageId: null,
parentMessageId: null,
wsRequestId: null,
// bing
bingWeb_encryptedConversationSignature: null,
bingWeb_conversationId: null,
bingWeb_clientId: null,
bingWeb_invocationId: null,
// bing sydney
bingWeb_jailbreakConversationId: null,
bingWeb_parentMessageId: null,
bingWeb_jailbreakConversationCache: null,
// poe
poe_chatId: null,
// bard
bard_conversationObj: null,
// claude.ai
claude_conversation: null,
// kimi.moonshot.cn
moonshot_conversation: null,
}
}