Advertisement
A_GUES

Bookmark ChatGPT

Jul 23rd, 2023
1,345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. javascript:(function(){
  2.     var text = window.getSelection().toString();
  3.     if (!text) {
  4.         text = prompt('Please enter the text you want to process with GPT-3.5');
  5.     }
  6.     if (text) {
  7.         fetch('https://api.openai.com/v1/engines/davinci-codex/completions', {
  8.             method: 'POST',
  9.             headers: {
  10.                 'Content-Type': 'application/json',
  11.                 'Authorization': 'Bearer your-api-key'
  12.             },
  13.             body: JSON.stringify({
  14.                 'prompt': text,
  15.                 'max_tokens': 60
  16.             })
  17.         })
  18.         .then(response => response.json())
  19.         .then(data => {
  20.             alert('GPT-3.5 response: ' + data.choices[0].text.trim());
  21.         })
  22.         .catch(error => {
  23.             console.error('Error:', error);
  24.         });
  25.     }
  26. })();
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement