Skip to content

Commit

Permalink
fix non-localhost javascript error
Browse files Browse the repository at this point in the history
  • Loading branch information
binary-husky committed Dec 22, 2024
1 parent 4ec87fb commit 734c40b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion themes/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -938,10 +938,27 @@ function gpt_academic_gradio_saveload(
}
}

function generateUUID() {
// Generate a random number and convert it to a hexadecimal string
function randomHexDigit() {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).slice(1);
}

// Construct the UUID using the randomHexDigit function
return (
randomHexDigit() + randomHexDigit() + '-' +
randomHexDigit() + '-' +
'4' + randomHexDigit().slice(0, 3) + '-' + // Version 4 UUID
((Math.floor(Math.random() * 4) + 8).toString(16)) + randomHexDigit().slice(0, 3) + '-' +
randomHexDigit() + randomHexDigit() + randomHexDigit()
);
}

function update_conversation_metadata() {
// Create a conversation UUID and timestamp
try {
const conversationId = crypto.randomUUID();
const conversationId = generateUUID();
console.log('Create conversation ID:', conversationId);
const timestamp = new Date().toISOString();
const conversationData = {
id: conversationId,
Expand Down

0 comments on commit 734c40b

Please sign in to comment.