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 5, 2024
1 parent 1e16b19 commit 007eda9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
const clearChatButton = document.getElementById('clear-chat');

let conversationHistory = [];
let isProcessing = false;

async function queryAPI(data) {
try {
Expand Down Expand Up @@ -197,7 +198,7 @@
}

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

Expand All @@ -217,13 +218,16 @@
}

async function processBotResponse(typingIndicator) {
if (isProcessing) return;
isProcessing = true;

const requestData = {
inputs: buildPrompt(),
parameters: {
max_new_tokens: 500,
temperature: 0.7,
top_p: 0.9,
repetition_penalty: 1.1,
repetition_penalty: 1.2, // Aumentar a penalidade de repetição
return_full_text: false
}
};
Expand Down Expand Up @@ -254,6 +258,7 @@
} finally {
sendButton.disabled = false;
userInput.focus();
isProcessing = false;
}
}

Expand All @@ -263,7 +268,6 @@

conversationHistory.push({ role: 'user', content: userMessage });
saveConversationHistory();

addMessage(userMessage, true);
userInput.value = '';

Expand Down

0 comments on commit 007eda9

Please sign in to comment.