Implementing AI Copywriting with ChatGPT in Elixir
Building on our previous exploration of creating a crypto news website using AI-generated content, we are now turning our focus towards the application of that parsed data. The goal of this next phase is to leverage the capabilities of OpenAI’s language model, ChatGPT, to copywrite the parsed information.
Previous article:An Experiment in Creating a Crypto News Website
In this article, we will delve into the technicalities of how we can make this happen, using the versatile Elixir library, Tesla, to create a client module for making HTTP requests. Our client module will consist of two main methods. The first method aims to rewrite paragraph text with a specific prompt, effectively transforming the original information into an AI-generated version. The second method is designed to generate a copywritten description from the first paragraph of each parsed post.
The beauty of working with the Elixir Tesla library is that it simplifies the process of creating HTTP requests, making the implementation of our AI copywriting module far from complex. With a solid understanding of Elixir and the Tesla library, you’ll find that building the copywriter api module is a relatively straightforward process. So, without further ado, let’s dive into the code!
In this next phase of our journey, we delve into the implementation of the Copywriter GenServer process. This is where the magic really starts to happen.
Upon initialization, this process fetches a batch of parsed posts from the database, setting a limit to control the workload. It then meticulously processes these posts one by one, ensuring careful and accurate copywriting. After every post is processed, the GenServer sets a timer for a specified interval before proceeding to the next chunk, thereby controlling the pace of the operation.
The parsed posts are stored in the database, and their content is represented as a list of tuples, each containing an HTML tag and its corresponding binary content. Copywriter takes each post and reduces the content, copywriting each paragraph by calling upon our previously discussed CopywriterAPI.
But it doesn’t stop there. It also uses the CopywriterAPI to generate a captivating description from the first paragraph of the post. This description plays a pivotal role in capturing the attention of potential readers on the website.
Once the copywriting is done, the GenServer creates a new post in the database, ready to be displayed on the website. To increase the reach, it also publishes a message with this post in a Telegram channel, ensuring that our content reaches as many interested readers as possible. Lastly, it refreshes the sitemap.xml file, keeping our website up-to-date for web crawlers and consequently, improving our SEO.
Through the combination of Elixir, the Tesla library, and the Copywriter GenServer process, we have a well-oiled machine that transforms parsed data into SEO-friendly, AI-generated content. The possibilities are, indeed, exciting!
We’ve successfully published over 500 posts, all curated and copywritten by our AI. Maintaining affordability with copywriting costs around $60. In terms of search engine visibility: 77 pages indexed by Google and 66 by Bing.
In conclusion, leveraging the power of Elixir, the Tesla library, and ChatGPT, we’ve implemented modules for transforming parsed data into AI-generated content for our crypto news website. Implementing the CopywriterAPI and the Copywriter process has demonstrated how AI copywriting can be a streamlined, efficient process with immense potential.