-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from ProWorksCorporation/feature/TINY-18-upgra…
…de-v12-latest Feature/tiny 18 upgrade v12 latest
- Loading branch information
Showing
12 changed files
with
69 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="12.0" encoding="utf-8"?> | ||
<?xml version="12.3.7" encoding="utf-8"?> | ||
<umbPackage> | ||
<info> | ||
<package> | ||
|
35 changes: 35 additions & 0 deletions
35
...yMCE.Umbraco.Premium/wwwroot/App_Plugins/TinyMCE.Umbraco.Premium/Defaults/ai.templates.js
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
(function (config, undefined) { | ||
|
||
config.ai_request = { | ||
ai_request: (request, respondWith) => { | ||
const openAiOptions = { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Authorization': `Bearer ${Umbraco.Sys.ServerVariables.tinymcepremium.openAiApikey}` | ||
}, | ||
body: JSON.stringify({ | ||
model: 'gpt-3.5-turbo', | ||
temperature: 0.7, | ||
max_tokens: 800, | ||
messages: [{ role: 'user', content: request.prompt }], | ||
}) | ||
}; | ||
respondWith.string((signal) => window.fetch('https://api.openai.com/v1/chat/completions', { signal, ...openAiOptions }) | ||
.then(async (response) => { | ||
if (response) { | ||
const data = await response.json(); | ||
if (data.error) { | ||
throw new Error(`${data.error.type}: ${data.error.message}`); | ||
} else if (response.ok) { | ||
// Extract the response content from the data returned by the API | ||
return data?.choices[0]?.message?.content?.trim(); | ||
} | ||
} else { | ||
throw new Error('Failed to communicate with the ChatGPT API'); | ||
} | ||
}) | ||
); | ||
} | ||
}; | ||
}(window.tinymcepremium.Config = window.tinymcepremium.Config || {})); |
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters