userSessionId after useChat hooks
This commit is contained in:
parent
dce3a9eca0
commit
d7c716f2b7
1 changed files with 14 additions and 0 deletions
|
|
@ -121,6 +121,18 @@ const checkConfig = async (
|
|||
if (!embeddingModel || !embeddingModelProvider) {
|
||||
const embeddingModelProviders = providers.embeddingModelProviders;
|
||||
|
||||
let userSessionId = localStorage.getItem('userSessionId');
|
||||
if (!userSessionId) {
|
||||
userSessionId = crypto.randomBytes(20).toString('hex');
|
||||
localStorage.setItem('userSessionId', userSessionId!)
|
||||
}
|
||||
|
||||
let maxRecordLimit = localStorage.getItem('maxRecordLimit');
|
||||
if (!maxRecordLimit) {
|
||||
maxRecordLimit = '20';
|
||||
localStorage.setItem('maxRecordLimit', maxRecordLimit);
|
||||
}
|
||||
|
||||
if (
|
||||
!embeddingModelProviders ||
|
||||
Object.keys(embeddingModelProviders).length === 0
|
||||
|
|
@ -435,6 +447,7 @@ export const ChatProvider = ({
|
|||
let added = false;
|
||||
|
||||
messageId = messageId ?? crypto.randomBytes(7).toString('hex');
|
||||
let userSessionId = localStorage.getItem('userSessionId');
|
||||
|
||||
setMessages((prevMessages) => [
|
||||
...prevMessages,
|
||||
|
|
@ -561,6 +574,7 @@ export const ChatProvider = ({
|
|||
messageId: messageId,
|
||||
chatId: chatId!,
|
||||
content: message,
|
||||
userSessionId: userSessionId,
|
||||
},
|
||||
chatId: chatId!,
|
||||
files: fileIds,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue