Hello there! Does anyone know how I can call the model Assistant tweaking this code below?
The code works well for model Davince-003 but not for model Assistant.
</style>
<div id="chatOutput"></div>
<br>
<form id="chatForm" autocomplete="new-password">
<input type="text" id="messageInput">
<button type="submit">Enviar</button>
</form>
<script>
function displayMessage(text, index) {
if (index < text.length) {
document.getElementById("chatOutput").innerHTML += text[index];
setTimeout(function() {
displayMessage(text, index + 1);
}, 50);
}
}
document.getElementById("chatForm").addEventListener("submit", function(event) {
event.preventDefault();
// Obter a mensagem do usuário
const message = document.getElementById("messageInput").value;
// Adicionar a mensagem do usuário à página
const questionDiv = document.createElement("div");
questionDiv.innerHTML = `<strong>Pergunta:</strong> ${message}`;
document.getElementById("chatOutput").appendChild(questionDiv);
// Enviar a mensagem para o GPT
fetch("https://api.openai.com/v1/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer THE API KEY"
},
body: JSON.stringify({
model: "assistant",
prompt: message,
max_tokens: 256
})
})
.then(response => response.json())
.then(data => {
});
});
</script>
Thanks!!!
Ricardo