Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- javascript:(function(){
- var text = window.getSelection().toString();
- if (!text) {
- text = prompt('Please enter the text you want to process with GPT-3.5');
- }
- if (text) {
- fetch('https://api.openai.com/v1/engines/davinci-codex/completions', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': 'Bearer your-api-key'
- },
- body: JSON.stringify({
- 'prompt': text,
- 'max_tokens': 60
- })
- })
- .then(response => response.json())
- .then(data => {
- alert('GPT-3.5 response: ' + data.choices[0].text.trim());
- })
- .catch(error => {
- console.error('Error:', error);
- });
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement