-
-
Save tronghieu60s/591650f690dc5dd1bd941cd510d40b4a to your computer and use it in GitHub Desktop.
Revisions
-
tronghieu60s revised this gist
Jun 11, 2024 . 2 changed files with 32 additions and 30 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ // Author: JUNO_OKYO - J2TEAM (EDITED Gemini By Trong Hieu) const API_KEY = "EDIT_ME"; // CHÚ Ý: sửa key của bạn trước khi sử dụng!!! const URL = "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent"; function askGPT(prompt) { const payload = { contents: [ { parts: [ { text: prompt, }, ], }, ], }; const options = { method: "post", contentType: "application/json", payload: JSON.stringify(payload), }; try { const response = UrlFetchApp.fetch(`${URL}?key=${API_KEY}`, options); const json = JSON.parse(response.getContentText()); return json.candidates[0].content.parts[0].text; } catch (e) { return `Error: ${e.message}`; } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,30 +0,0 @@ -
J2TEAM revised this gist
Jun 10, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ // Author: JUNO_OKYO - J2TEAM const API_KEY = 'EDIT_ME'; // CHÚ Ý: sửa key của bạn trước khi sử dụng!!! const URL = 'https://api.openai.com/v1/chat/completions'; function askGPT(prompt) { -
J2TEAM created this gist
Jun 10, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ // Author: JUNO_OKYO - J2TEAM const API_KEY = 'EDIT_ME'; const URL = 'https://api.openai.com/v1/chat/completions'; function askGPT(prompt) { const payload = { model: "gpt-4o", messages: [ { role: "system", content: "You are a helpful assistant. Your name is J2TEAM GPT." }, { role: "user", content: prompt } ] }; const options = { method: 'post', contentType: 'application/json', headers: { Authorization: `Bearer ${API_KEY}` }, payload: JSON.stringify(payload) }; try { const response = UrlFetchApp.fetch(URL, options); const json = JSON.parse(response.getContentText()); return json.choices[0].message.content.trim(); } catch (e) { return `Error: ${e.message}`; } }