mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
Update index.html
This commit is contained in:
parent
04dab03a80
commit
24b60853c6
1 changed files with 31 additions and 0 deletions
|
@ -16,3 +16,34 @@
|
||||||
<div id="chatbot-response"></div>
|
<div id="chatbot-response"></div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const form = document.getElementById('chatbot-form');
|
||||||
|
const input = document.getElementById('chatbot-input');
|
||||||
|
const responseContainer = document.getElementById('chatbot-response');
|
||||||
|
|
||||||
|
form.addEventListener('submit', async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const message = input.value;
|
||||||
|
|
||||||
|
// Make the API call to GPT-3
|
||||||
|
const apiKey = 'YOUR_API_KEY';
|
||||||
|
const response = await fetch(`https://api.openai.com/v1/engines/davinci-codex/completions`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': `Bearer ${apiKey}`
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
prompt: message,
|
||||||
|
max_tokens: 128,
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
const json = await response.json();
|
||||||
|
const answer = json.choices[0].text;
|
||||||
|
|
||||||
|
// Display the response
|
||||||
|
responseContainer.innerHTML = answer;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
Loading…
Add table
Reference in a new issue