We want to reimagine the blog authoring experience powered by AI. Our objective is to augment blog authoring activities with AI so that the blog author can save time authoring posts, enable more "creative focus" for the author, increase "flow" for the author leading to publishing more posts as a result, and ultimately leading to more eyeballs and monetization benefits.
Today with the launch of ChatGPT from OpenAI entire blog posts can be generated by an AI. The challenge with this approach is that the human author involvement is negligible. We want to take the best of human-AI partnership approach with PromptxAI. We want AI to augment the authoring process guided by human author opinions, enhancing creative focus, and increasing authoring flow.
That is why we created this notebook. We want to share our journey in creating a Python library PromptxAI Blogger which can be used for "human and AI in partnership for low-code blog authoring automation". We are sharing this notebook in a tutorial style so that others can join the exploration. The tutorial walks through basics of API design and OpenAI. Another objective of this notebook is to act as an interactive documentation and playground for the PromptxAI library.
Authoring Flow¶
The flow we are expecting to achieve with PromptxAI Blogger API is as follows: Ideate => Research (Topic) => Write (Title, Tags) => Enhance (Q&A, Quote) => Illustrate (Feature Image) => Publish
- Ideate: AI combines concepts human provides and generates blog post ideas. Human selects the best idea
- Research: AI generates topic description based on the idea. Human iterates few variations of topic descriptions generated and choose the most appropriate
- Write: This step involves AI helping identify an SEO friendly title for the post and tags based on the topic. AI could further help in grammar correction, research, generating code, and other activities, which are not included in current scope.
- Enhance: We can further enhance the blog post with Fequently Asked Questions, Leaderboard, and Quotable Quotes also generated by AI.
- Illustrate: We are then ready to generate custom illustrations or imagery for our post using AI. This we believe is the coolest part of the process!
- Publish: We are automating the post publishing by generating HTML and Markdown. AI could help further by generating layout templates, code for value added micro-apps for the blog post like a custom chatbot, and so on. This is not in scope at the moment.
Structure of this Notebook¶
We have built the Blogger API with somewhat opinionated defaults (e.g., generate tags as only single word nouns) to make the API usage as intuitive as possible and keep it low code. This also enables automation using single call the API to generate an entire blog post. The notebook tests this API out on an example. We have purposely created the notebook with default options simulating the human opinions so that you can run the example 100% using the AI and simulation. This exhibits AI's current state of the art and encourages debate around what is the evolved role of an author if AI can automate to this extent. This notebook demonstrates creation of a relatively complex blog post with title, subtitle, tags, topic content, feature image, questions and answers, quotable quote, and leaderboard of top X entities, in HTML and Markdown formats using only 11 API calls, almost one API call per blog feature.
The paradox this presents is the unfortunate possibility of misuse, where AI can be used to generate "realistic" blogs which seem to be human written. It is somewhat "addictive" to re-run the notebook several times to see what unique variations does the AI generate with only three simple words (or fewer, or more) as seed input! Can the reader think of ways this automation can be put to good use - like an exploratory online education or an infinite digital museum or visual search results?
Blogger API¶
Let us introduce the Blogger API. We start with choice of dependencies or technologies which enable Blogger API. We use OpenAI as the "brains" of Blogger API. Specifically, we use GPT3 Large Language Model which powers the famous ChatGPT. Next we import a few utility libraries to perform file operations and cleanup of results. Finally we rely on libraries for image, HTML, and markdown.
from promptxai import blogger
No-code Auto Generation¶
We start with a "no-code" demo of the API where we generate the entire blog post with a single API call. The post image and html file will be stored in the same folder as this notebook.
keywords = 'Mars, Earth, Travel'
image_file, html_file, md_file = blogger.auto_generate(keywords=keywords, verbose=True, folder='generated')
print('Auto Generated image: ', image_file)
print('Auto Generated html: ', html_file)
print('Auto Generated markdown: ', md_file)
1. Interplanetary Travel between Earth and Mars 2. Mars Exploration Tours from Earth 3. Simulated Mars Travel Experiences on Earth 4. Rover Exchanges between Earth and Mars 5. Telescopic Viewing of Mars from Earth 6. Earth-Mars Exchange Programs for Scientists 7. Mars Habitat Builds on Earth 8. Interplanetary Cultural Exchange Programs 9. Earth-Mars Joint Space Research Projects 10. Mars Tourism Packages from Earth Earth-Mars Joint Space Research Projects The joint Earth-Mars space research projects have been ongoing for over a decade, and have yielded some incredible scientific advances. Both our planets have seen the benefits of improved communication, collaboration and the development of new technologies that have helped us better understand the universe we live in. One of the most exciting projects to date is the Mars Exploration Rover. Working together, scientists from Earth and from Mars have been able to send a spacecraft to the Red Planet to explore its surface and atmosphere. The rover has been exploring Martian sites for over six years and has provided us with valuable data about the planet's atmosphere and geology. The next step in the project is the International Mars Sample Return mission, which will allow us to extract and bring back samples of the planet's rocks and soil to Earth. This would provide an unprecedented insight into the history and evolution of the Red Planet, further deepening our understanding of how our own world came to be. Other projects, such as the Moon-Mars Communications Network and the Search for Extraterrestrial Intelligence, aim to further improve communication and understanding between the two planets, while providing new opportunities to search for evidence of life. 1. "Unraveling the Mysteries of Mars: An Insider's Look at the Rover Project" 2. "Exploring the Universe: Earth & Mars Join Forces to Unlock its Secrets" 3. "Connecting Two Worlds: The Mars Exploration Rover and International Sample Return Mission" 4. "Understanding Our Origins: How the Earth-Mars Research Projects are Changing our World" 5. "The Red Planet Awaits: An Overview of the Joint Mars Research Projects" 6. "Discovering the Universe: How Earth-Mars Cooperation is Unlocking its Secrets" 7. "Exploring Mars: How the International Sample Return Mission is Uncovering Its Secrets" 8. "Unlocking the Mysteries of Mars: The Joint Earth-Mars Projects Unveiled" 9. "Communicating Across Worlds: Earth and Mars Join Forces to Unlock New Discoveries" 10. "A World Beyond: How the Moon-Mars Network is Expanding Our "Understanding Our Origins: How the Earth-Mars Research Projects are Changing our World" ['Mars Exploration Rover ', 'International Mars Sample Return ', 'Earth-Mars Space Research Projects ', 'Moon-Mars Communications Network ', 'Search for Extraterrestrial Intelligence ', 'New Technologies ', 'Improved Communication ', 'Collaboration ', 'Martian Sites Exploration ', 'Evidence of Life Search'] {'Is this concept Moon-Mars Communications Network International Mars Sample Return a thing?': 'The concept of a Moon-Mars Communications Network and International Mars Sample Return is not currently in development, but it has been proposed as a potential future project. The idea is to create a network of communication satellites between the Moon and Mars, which would enable the exchange of data and samples between the two planets. This could potentially enable the exploration of Mars and the return of samples to Earth for further study.', 'What is the importance of New Technologies ?': 'New technologies are important because they can help to improve efficiency, reduce costs, and increase productivity. They can also help to create new products and services, and open up new markets. New technologies can also help to improve communication, collaboration, and access to information. Finally, new technologies can help to create new jobs and economic opportunities.', 'Is there a relationship between Earth-Mars Space Research Projects and Collaboration ?': 'Yes, there is a relationship between Earth-Mars space research projects and collaboration. Collaboration is essential for successful space research projects, as it allows for the sharing of resources, knowledge, and expertise. Collaboration also helps to ensure that the project is completed in a timely and cost-effective manner. Additionally, collaboration can help to foster a sense of camaraderie and team spirit among the project participants, which can be beneficial for morale and motivation.'} {'Movies': '1. The Martian (2015) \n2. Apollo 13 (1995) \n3. Mars Attacks! (1996)\n4. Mission to Mars (2000)\n5. Red Planet (2000)', 'Music Albums': '1. Mars Exploration Rover - A Space Odyssey (2021) \n2. Moon-Mars Communications Network (2021) \n3. International Mars Sample Return Mission (2022) \n4. Search for Extraterrestrial Intelligence (2022) \n5. Beyond the Red Planet (2023)', 'Famous People': '1. Stephen Hawking - British theoretical physicist, cosmologist, and author \n2. Neil deGrasse Tyson - American astrophysicist, author, and science communicator\n3. Buzz Aldrin - American astronaut and former United States Air Force pilot who was the Lunar Module Pilot on Apollo 11 \n4. Elon Musk - American entrepreneur and founder of Tesla, SpaceX, and the Boring Company\n5. Margaret Hamilton - American computer scientist, systems engineer, and business'} "By working together, we have the power to explore and understand the universe, and expand our knowledge of our place in it." - Neil deGrasse Tyson Joint EarthMars research yields scientific advances communication development exploration data understanding sampling international mission communication network search for life Joint EarthMars research yields scientific advances communication development exploration data understanding sampling international mission communication network search for life 20230210161938.png Auto Generated image: Joint EarthMars research yields scientific advances communication development exploration data understanding sampling international mission communication network search for life 20230210161938.png Auto Generated html: Mars-Earth-Travel-20230210161941.html Auto Generated markdown: Mars-Earth-Travel-20230210161941.md
Low-code Authoring Flow¶
This section demonstrates the authoring flow enabled by PromptxAI API. We start by initializing a post object from the BlogPost class. We will use this to store completions returned by our authoring flow and publish the post in the end of this demo.
post = blogger.BlogPost()
post.set_keywords(keywords)
Set auto
value to True
when using AI for auto generating the entire blog without any human author partnership. This adds a disclaimer on top of the generated HTML that this is an AI generated page.
post.set_auto(True)
Set this full_feature
value to True
when generating blog post layout with full feature 1024x1024 image. Otherwise the feature image is 356x356 left aligned to topic text.
post.set_full_feature(False)
Ideate¶
To begin our authoring flow, we first start by brainstorming 10 ideas based on few concepts we are thinking for our next blog post. As we are using high value for temperature
parameter by default, we can re-run this API (notebook cell) and evaluate creative variations of completion results, before we pick the best one for continuing our authoring flow. We have noticed that three concepts which are seemingly unrelated or somewhat related generate more creative ideas than two concepts which are more related.
response, response_list = blogger.ideas(post.get_keywords())
print(response)
1. Interplanetary travel between Mars and Earth 2. Human colonization of Mars and Earth 3. Developing rockets for faster interplanetary travel 4. Robots with 3D-printed parts to explore both Mars and Earth 5. Constructing a space station between Mars and Earth 6. Developing new space suits to explore both Mars and Earth 7. Creating an interplanetary currency payment system 8. Planning for a joint Mars-Earth research mission 9. Designing and launching satellites for communication between Mars and Earth 10. Developing a plan for long-term research and development projects between Earth and Mars
Next we select one of the ideas we like and save this in our post object. Just replace the randrange(len(response_list)-1)
random number generator placeholder for auto-demo with an integer from 0-9, noting that Python list numbering starts with 0 so relates to 1 in the completion result list, 1 is 2, and so on.
post.set_concept(response_list[3])
print(post.get_concept())
Robots with 3D-printed parts to explore both Mars and Earth
Research¶
Now we are ready to use GPT3 as a research tool. We can research the idea we just selected and describe it as a topic for our blog post. Note the token limits described in prior section. You can experiment with words to settle on a variation that satisfies your blog content length and audience.
Future releases of the PromptxAI API will introduce editing features so that you can edit and add your own content as well as use the AI to auto-complete partial edits.
topic = blogger.elaborate(post.get_concept(), words=200)
post.set_topic(topic)
print(post.get_topic())
Robots with 3D-printed parts are quickly becoming an invaluable tool for exploring both Mars and Earth. 3D-printed parts, also known as additive manufacturing, provide a whole host of benefits not found in traditional manufacturing methods, including ease of production and lightweight materials. Additionally, they are much more affordable than other manufacturing techniques and can be used to make complex shapes and structures. This flexibility has been key to robotic exploration of both Mars and Earth. On Mars, 3D-printed robot parts have been used to explore the planet's surface with unprecedented detail, allowing researchers to map out terrain and collect samples with greater precision. On Earth, 3D-printed parts have enabled robots to explore and investigate areas that would otherwise have been too dangerous or treacherous for human exploration. In addition to exploration, 3D-printed parts have also allowed robots to complete tasks that would normally require intense manual labor. For example, 3D-printed parts can be used to assemble and maintain structures, construct bridges and roads, and search for and retrieve objects. The possibilities for 3D-printed robots are endless, and their potential for exploration, both on Mars and Earth, is only just beginning to be realized.
Write¶
Next step in the authoring flow is to take the topic we described above and generate catchy, SEO friendly titles for our blog post. Note the difference between ideas generated and post titles. All the magic is in the prompt engineering.
response, response_list = blogger.titles(post.get_topic())
print(response)
1. Unlocking the Secrets of Mars & Earth: Exploring with 3D-Printed Parts 3. Exploring Our World & Beyond: The Benefits of 3D Printing for Robotics 4. Robots Exploring Where Humans Cannot: 3D-Printed Parts in Mars & Earth Exploration 5. Uncovering the Unknown: Robot Exploration with 3D-Printed Parts 6. Beyond Human Capabilities: Using 3D-Printed Parts to Explore Mars & Earth 7. Pioneering Exploration: 3D-Printed Parts Enabling Robot Progress 8. Exploring New Depths: Robots and 3D-Printed Parts in Mars & Earth Exploration 9. Far-Reaching Possibilities: 3D-Printed Parts Revolutionizing Robot Exploration 10. Unlock your Exploration Potential: 3D-Printed Parts and Robot Exploration of Mars & Earth
You can replace the randrange
random generator with a number to choose your title.
post.set_title(response_list[5])
print(post.get_title())
Pioneering Exploration: 3D-Printed Parts Enabling Robot Progress
Same way we can also generate tags from the topic.
response, response_list = blogger.tags(post.get_topic())
post.set_tags(response_list)
print(post.get_tags())
['Printing ', 'Robotics ', 'Additive Manufacturing ', 'Mars Exploration ', 'Lightweight Materials ', 'Affordable Manufacturing ', 'Complex Shapes ', 'Mapping Terrain ', 'Manual Labor ', 'Structural Maintenance']
Enhance¶
Now we are ready to enhance our blog post with more features, starting with Questions and Answers. You can replace the question with your own. It is not required to associate the question with the tags as we have done for the Auto-Demo. Framing the question based on the topic will help generate completions which are relevant for the blog. You are also not limited to only three question-answer pairs, go for more or fewer as required for your blog post.
Note that the way the first question combines two tags into a concept is a good test of truthful completions. Sometimes the combined concepts are not real concepts. GPT3 completion recognizes these.
question = 'Is this concept ' + post.get_tags()[3] + ' ' + post.get_tags()[1] + ' a thing?'
post.set_qna(question, blogger.qna(question))
question = 'What is the importance of ' + post.get_tags()[5] + '?'
post.set_qna(question, blogger.qna(question))
question = 'Is there a relationship between ' + post.get_tags()[2] + ' and ' + post.get_tags()[7] + '?'
post.set_qna(question, blogger.qna(question))
print(post.get_qna())
{'Is this concept Mars Exploration Robotics a thing?': 'Yes, Mars Exploration Robotics is a real concept. It is the use of robotic technology to explore the surface of Mars and to collect data about the planet. This includes the use of rovers, landers, and other robotic devices to explore the planet and to collect data about its environment, geology, and potential for human habitation.', 'What is the importance of Affordable Manufacturing ?': 'Affordable manufacturing is important because it helps to reduce the cost of production, making products more accessible and affordable for consumers. It also helps to create jobs and stimulate economic growth. Additionally, it can help to reduce environmental impacts by reducing the amount of resources used in production.', 'Is there a relationship between Additive Manufacturing and Mapping Terrain ?': 'No, there is no direct relationship between additive manufacturing and mapping terrain. Additive manufacturing is a process of creating three-dimensional objects from a digital file, while mapping terrain is the process of creating a two-dimensional representation of a physical landscape.'}
Another feature PromptxAI API supports is leaderboard of top X recommendations based on the topic and entity of your choice.
Future releases of the leaderboard API will include affiliate linking capability to help monetize your blog.
response, reponse_list = blogger.leaderboard(topic, 'Movies', count=5)
post.set_leaderboard('Movies', response)
response, reponse_list = blogger.leaderboard(topic, 'Music Albums', count=5)
post.set_leaderboard('Music Albums', response)
response, reponse_list = blogger.leaderboard(topic, 'Famous People', count=5)
post.set_leaderboard('Famous People', response)
print(post.get_leaderboard())
{'Movies': '1. WALL-E (2008)\n2. Transformers (2007)\n3. Iron Man (2008)\n4. RoboCop (1987)\n5. Pacific Rim (2013)', 'Music Albums': '1. Daft Punk – Random Access Memories\n2. Kraftwerk – The Man-Machine \n3. Radiohead – Kid A \n4. Kanye West – My Beautiful Dark Twisted Fantasy \n5. Boards of Canada – Music Has the Right to Children', 'Famous People': '1. Elon Musk - Co-founder of SpaceX, pioneering the use of 3D-printed parts in spacecrafts and other technologies.\n\n2. Hiroshi Ishiguro - Japanese roboticist who created Geminoid robot, one of the first robots to incorporate 3D-printed parts.\n\n3. Andrew Rush - CEO of 3D Systems, leading 3D printer manufacturer.\n\n4. Cynthia Breazeal - Robotics professor at MIT, who developed one of the'}
You can further enhance your blog post with a relevant quotable quote.
quote_text = blogger.quote(post.get_topic())
post.set_quote(quote_text)
print(post.get_quote())
"The possibilities are endless with 3D-printed robots, allowing us to explore and investigate both Mars and Earth with unprecedented detail.” - unknown
Illustrate¶
We are now ready to add some life to the text in our blog post. We first generate an image description from topic.
image_description = blogger.core.strip_filename(blogger.summarize(post.get_topic(), words=20))
print(image_description)
Dprinted parts offer cheap reliable and versatile solutions for robotic exploration and task completion on Mars and Earth
Next we use the DALL.E Image generation API to create an image appropriate for our blog. We can then save the image to a local file and add it as feature image to our blog post object.
image_url=blogger.artist.image_from_description('a 3d photo realistic painting of topic ' + image_description)
from IPython.display import Image
local_image = blogger.artist.save_image(url=image_url, description=image_description, folder='generated')
post.set_feature_image(local_image)
Image(filename='generated/' + local_image)
Publish¶
Final step in our authoring flow is to generate the blog post as HTML. Note that for Auto-Demo we have attempted to keep the text and features of the blog post minimal to avoid a scrolling output. Some of the styles of the generated HTML conflict with the Jupyter Notebook styles so the notebook rendered HTML may not look same as browser rendered.
This last step is somewhat magical in the Auto-Demo mode. Re-run the notebook a few times to see that no two blog posts are exactly the same, ever!
Our final step is to generate a local copy of HTML and Markdown formats of the blog post so that we can integrate this will our blog system of choice.
NOTE: When rendering the HTML in Jupyter notebook the image won't show up as it looks for a local copy of the image instead of resolving to the generated
folder. View the generated HTML in brower to see the complete post with image.
from IPython.core.display import HTML
post_html = blogger.generate_html(post)
HTML(post_html)
Pioneering Exploration: 3D-Printed Parts Enabling Robot Progress
Robots with 3D-printed parts to explore both Mars and Earth
Robots with 3D-printed parts are quickly becoming an invaluable tool for exploring both Mars and Earth. 3D-printed parts, also known as additive manufacturing, provide a whole host of benefits not found in traditional manufacturing methods, including ease of production and lightweight materials. Additionally, they are much more affordable than other manufacturing techniques and can be used to make complex shapes and structures. This flexibility has been key to robotic exploration of both Mars and Earth. On Mars, 3D-printed robot parts have been used to explore the planet's surface with unprecedented detail, allowing researchers to map out terrain and collect samples with greater precision. On Earth, 3D-printed parts have enabled robots to explore and investigate areas that would otherwise have been too dangerous or treacherous for human exploration. In addition to exploration, 3D-printed parts have also allowed robots to complete tasks that would normally require intense manual labor. For example, 3D-printed parts can be used to assemble and maintain structures, construct bridges and roads, and search for and retrieve objects. The possibilities for 3D-printed robots are endless, and their potential for exploration, both on Mars and Earth, is only just beginning to be realized.
"The possibilities are endless with 3D-printed robots, allowing us to explore and investigate both Mars and Earth with unprecedented detail.” - unknown
Yes, Mars Exploration Robotics is a real concept. It is the use of robotic technology to explore the surface of Mars and to collect data about the planet. This includes the use of rovers, landers, and other robotic devices to explore the planet and to collect data about its environment, geology, and potential for human habitation.
What is the importance of Affordable Manufacturing ?Affordable manufacturing is important because it helps to reduce the cost of production, making products more accessible and affordable for consumers. It also helps to create jobs and stimulate economic growth. Additionally, it can help to reduce environmental impacts by reducing the amount of resources used in production.
Is there a relationship between Additive Manufacturing and Mapping Terrain ?No, there is no direct relationship between additive manufacturing and mapping terrain. Additive manufacturing is a process of creating three-dimensional objects from a digital file, while mapping terrain is the process of creating a two-dimensional representation of a physical landscape.
Leaderboard
Movies | Music Albums | Famous People |
---|---|---|
1. WALL-E (2008) 2. Transformers (2007) 3. Iron Man (2008) 4. RoboCop (1987) 5. Pacific Rim (2013) | 1. Daft Punk – Random Access Memories 2. Kraftwerk – The Man-Machine 3. Radiohead – Kid A 4. Kanye West – My Beautiful Dark Twisted Fantasy 5. Boards of Canada – Music Has the Right to Children | 1. Elon Musk - Co-founder of SpaceX, pioneering the use of 3D-printed parts in spacecrafts and other technologies. 2. Hiroshi Ishiguro - Japanese roboticist who created Geminoid robot, one of the first robots to incorporate 3D-printed parts. 3. Andrew Rush - CEO of 3D Systems, leading 3D printer manufacturer. 4. Cynthia Breazeal - Robotics professor at MIT, who developed one of the |
html_path, markdown_path = blogger.publish(post_html=post_html,
filename=post.get_keywords().replace(' ', '').replace(',', '-'),
folder='generated')
print(html_path, markdown_path)
Mars-Earth-Travel-20230210164407.html Mars-Earth-Travel-20230210164407.md