Queries LibraryImport post from WordPress RSS feed and rewrite its content with ChatGPT
Import post from WordPress RSS feed and rewrite its content with ChatGPT
This query fetches the post data from a WordPress RSS feed (including the title, content and excerpt), rewrites the content using ChatGPT, and stores it on the local WordPress site.
If the author with that username exists locally, it uses it, otherwise it replaces it with the one defined via variable $defaultAuthorUsername.
Variable $url receives the URL of the WordPress single post's RSS feed. It usually is the blog post URL + "/feed/rss/?withoutcomments=1". Eg:
To connect to the OpenAI API, you must provide variables $openAIAPIKey with the API key.
You can optionally provide the system message and prompt to rewrite the post's content. If not provided, the following values are used:
System message ($systemMessage): "You are an English Content rewriter and a grammar checker"
Prompt ($prompt): "Please rewrite the following English text (contained within HTML), by changing the simple A0-level words and sentences with more beautiful and elegant upper-level English words and sentences, while maintaining the original meaning: "
(The content string is appended at the end of the prompt.)
In addition, you can override the default value for variables $model ("gpt-3.5-turbo-instruct") and $temperature (0.7), and be aware to provide $maxTokens with a suitable number for the length of the content (50 by default).