Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
igorbkz authored Jun 8, 2024
1 parent 093c854 commit d176591
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
}

function buildPrompt() {
const maxHistoryLength = 10; // Reduzir o histórico para evitar repetições
const maxHistoryLength = 50; // Manter mais histórico
const promptHistory = conversationHistory.slice(-maxHistoryLength);
let prompt = `<s>[INST] Você é um bom assistente que responde em português. [/INST]\n`;

Expand Down Expand Up @@ -227,7 +227,7 @@
max_new_tokens: 500,
temperature: 0.7,
top_p: 0.9,
repetition_penalty: 1.2, // Aumentar a penalidade de repetição
repetition_penalty: 1.2,
return_full_text: false
}
};
Expand Down Expand Up @@ -287,33 +287,35 @@

const debouncedHandleUserInput = debounce(handleUserInput, 300);

function encryptData(data) {
return btoa(JSON.stringify(data)); // Simples criptografia base64
}

function decryptData(data) {
return JSON.parse(atob(data));
}

function saveConversationHistory() {
try {
const compactedData = btoa(JSON.stringify(conversationHistory));
localStorage.setItem('conversationHistory', compactedData);
const encryptedData = encryptData(conversationHistory);
localStorage.setItem('conversationHistory', encryptedData);
} catch (error) {
console.error('Erro ao salvar histórico de conversa:', error);
}
}

function loadConversationHistory() {
try {
const storedData = localStorage.getItem('conversationHistory');
if (storedData) {
const decompressedData = JSON.parse(atob(storedData));
conversationHistory = decompressedData;
const storedHistory = localStorage.getItem('conversationHistory');
if (storedHistory) {
conversationHistory = decryptData(storedHistory);
conversationHistory.forEach(msg => addMessage(msg.content, msg.role === 'user'));
}
} catch (error) {
console.error('Erro ao carregar histórico de conversa:', error);
}
}

function summarizeConversation(history) {
// Função de resumo a ser implementada conforme necessidade
return history.slice(-10); // Exemplo simples: manter as últimas 10 mensagens
}

sendButton.addEventListener('click', debouncedHandleUserInput);

userInput.addEventListener('input', () => {
Expand Down

0 comments on commit d176591

Please sign in to comment.