HTML and Python Coding With ChatGPT Vision (Chatbot Battle GUI)

💻 Themes: AI

🤖 Chatbots: ChatGPT

⚙️ Prompt engineering: Coding, Image Analysis

[Related – Is Philosophy a Science? Introducing SCBN Chatbot Battles ] [GitHub repository]


Tabulating and Formatting Text in HTML

Image displaying a comparison of three chatbots: #HuggingChat (Llama), #Bard, and #ChatGPT, with emojis rating each on Specificity, Coherency, Brevity, and Novelty. Each category has a scale of one to four robots, indicating performance level. The hashtags #ChatbotBattle and a question 'Is philosophy a science?' are also present. Links are provided beneath each chatbot’s name, presumably to view the conversations or results.
Comparative performance scores of chatbots HuggingChat, Bard, and ChatGPT in a Reddgr ChatbotBattle, evaluated on Specificity, Coherency, Brevity, and Novelty (SCBN).

😎 Suggest a simple HTML table format where I can include this information in a tabulated way, eliminating the hashtags of the social media post, and pulling the links in text (so the URLs are not shown). The table should be titled “Chatbot Battle: Is Philosophy a Science?“. I want to keep the emojis for the scoring system (i.e. 🤖🕹️🕹️), but the ranking represented by the emoji medals can now be represented in a more formal way (such as winner, challenger, laggard… be creative with that)

🤖 [Preliminary code. Final version available on GitHub]

This is a simple HTML structure for the provided information, and it presents the chatbots’ performance in a tabulated manner. The emojis are retained for scoring, and the rankings are represented with descriptive titles such as “Winner,” “Runner-up,” and “Contender”.

😎 Can we make the font Josefin Sans and use a color palette similar to the one in the attached screen capture? For example, we could use #c9c1f2 for headings background, and the links can be #c171f4

A screenshot of the reddgr.com website showcasing a clean and organized layout. The main content area displays a blog post prompt with an associated date and tags. A sidebar on the right lists a variety of other blog topics. The color scheme is primarily soft purples and whites, giving the website a modern and elegant feel. Emojis are used within the blog post to add a touch of playfulness.

🤖 A screenshot of the reddgr.com website showcasing a clean and organized layout. The main content area displays a blog post prompt with an associated date and tags. A sidebar on the right lists a variety of other blog topics. The color scheme is primarily soft purples and whites.

🤖 … Got it. Here’s the modified HTML code with the “Josefin Sans” font and the specified color palette:

[Preliminary code. Final version available on GitHub]

[routine iterations and error fixing]

😎 I will make two more minor modifications. I think it’s good to add an emoji medal after the winner, runner-up, contender (gold, silver, bronze… looks cool). Also, I’m calling the ranking SCBN, so instead of “Rank”, the column heading would be Rank (SCBN)

🤖 Absolutely! Here’s your updated code:

[Preliminary code. Final version available on GitHub]

😎 Would this HTML chart look good on a mobile device? Do you have any suggestions if I want to make it mobile-friendly? [preliminary code]

🤖 To ensure the HTML chart is mobile-friendly, consider the following suggestions:

  1. Responsive Font Size: Use relative units like em, rem, or viewport units (vw, vh) instead of fixed px for font sizes. This will make the text scale according to device size.
  2. Table Overflow: On smaller screens, tables might overflow. You can wrap the table within a div with overflow-x: auto;, so users can scroll horizontally if needed.
  3. Reduce Padding for Mobile: Reduce padding and margins on smaller screens to utilize the screen space more efficiently.
  4. Break Words: If any table cell content is too long and doesn’t fit, use word-wrap: break-word; to prevent overflow.
  5. Use Media Queries: Media queries allow you to apply styles based on the device characteristics, especially its width.

Here’s a modified version incorporating these suggestions:

[Preliminary code. Final version available on GitHub]

😎 [iterations]

🤖 …Here’s the modified code:

Screenshot of a conversation in a chat interface with a dark mode theme. The chat includes two participants: a user and ChatGPT. The user asks if only the 'Chatbot' column in a table can be made 'breakable' to allow long text to wrap to the next line, suggesting a shorter name as an alternative. ChatGPT responds affirmatively, detailing a solution that involves assigning a class to the 'Chatbot' column and specifying the 'white-space' property. The code snippet provided shows HTML and CSS code, including a style import from Google Fonts and CSS rules for an h2 element and a table.
Dialogue with ChatGPT on customizing HTML code to make a specific table column text wrap, showing the process of coding with ChatGPT’s guidance

[SCBN Chatbot Battle project on Github]

Graphical User Interface Design with Tkinter

😎 Now I would like to design a simple user interface where I would enter the main elements of the table (chatbot, links, and a score of 0 to 3 for each parameter). The UI script would calculate the rank based on my scores, convert the scores into the visual emoji form with 🤖 and 🕹️, and build the whole HTML code. That would obviously require more than just HTML and more than just WordPress. I don’t care too much about which type of application to use for the user interface, it can be anything I can easily run on my Windows computer (I could convert it into a website functionality in the future, but not yet). For handling the code you write, I would be comfortable using Python

🤖 Understood! Let’s create a simple Python application with a graphical user interface (GUI) for this task. We’ll use the Tkinter library which is bundled with most standard Python installations.

The basic idea is:

  1. Create input fields for Chatbot name, link, and scores.
  2. Calculate the rank based on scores.
  3. Convert scores to emojis.
  4. Generate the HTML code.

Here’s a basic prototype of the application:

Screen capture of Python code in a chat interface with a dark background. The code is a prototype of a 'Chatbot Ranking Generator' application using the Tkinter library. It includes imports, a class definition with an initializer method, creation of GUI elements for chatbot name and link inputs, and a loop to create score categories with associated ComboBox widgets. A button to generate HTML is also coded
Prototype snippet of Python code for a ‘Chatbot Ranking Generator’ GUI application, showcasing the coding collaboration with ChatGPT

[preliminary code. Final version available on GitHub]

Instructions:

  1. Ensure you have Python installed on your Windows machine.
  2. Copy and paste the above code into a Python file, say chatbot_ranking_app.py.
  3. Run the script: python chatbot_ranking_app.py.

The script will launch a simple GUI where you can enter chatbot details and scores. When you press the “Generate HTML” button, the appropriate HTML will be displayed in a text box below. You can then copy this HTML and use it in your table.

Note: The ranking is marked as “TBD” (To Be Determined) for now, as calculating ranks might require additional logic based on all chatbot scores.

Screenshot of a computer screen displaying a graphical user interface for a Chatbot Ranking Generator application. The application window has input fields for 'Chatbot Name', 'Link', and drop-down menus for 'Specificity', 'Coherency', 'Brevity', and 'Novelty'. Below the input fields, there's a 'Generate HTML' button and a preview of the generated HTML code snippet showing inputted data for a chatbot named 'Bard'.
Preliminary design of the Chatbot Ranking Generator application, showcasing the input interface and the HTML output preview.

😎 This looks promising. The next step is to update the Python code so that, when I hit the “Generate HTML” button, the whole HTML code is generated including all correctly sorted and filled table rows (chatbots). Below is the original HTML you created for three rows:

[Code available on GitHub]

🤖 Sure! I’ll modify the generate_html method to include the CSS styles, the header, and the table structure in the generated HTML. Additionally, the chatbots will be inserted into the table rows based on their rankings. Here’s the updated code:

[More iterations oncode]

😎 This looks very good. There are a few more details I either forgot to define or are better to add now that we are near completing the work:

1. We should also add a text box to customize the title of the HTML. The HTML title will always have the format “Chatbot Battle: …”, and the space will be filled with what the user enters as “Chatbot Battle Title” in the UI. This text box can be above all others, noticing it shouldn’t be wiped out when we click on “Add Chatbot”.

2. When there is a tie of two or more chatbots with the same score, the same medal title should be awarded to all of them. For example, if the maximum score is 12 and three chatbots have the same score, all three would get the “🥇 Winner” tag. If two chatbots are tied at the third place, the two of them would get 🥉 Contender…

3. Finally, it would be convenient to have one button for copying the HTML code to the clipboard, and another to clear the screen.

🤖 Sure, I’ll make those enhancements […]

Screenshot of an evolved graphical user interface for the Chatbot Ranking Generator. The window displays fields for 'Chatbot Battle Title', 'Chatbot Name', 'Link', and drop-down menus for 'Specificity', 'Coherency', 'Brevity', and 'Novelty'. Below are buttons labeled 'Add Chatbot', 'Generate HTML', 'Copy to Clipboard', and 'Clear Screen'. The lower part of the window shows a section of the generated HTML code with emoji ratings and hyperlinks for chatbot entries.
Enhanced version of the Chatbot Ranking Generator interface, now featuring additional functionality for inputting a battle title, ranking chatbots, resolving ties, and managing the generated HTML code.

[More iterations and fixes. Final version available on GitHub]

😎 This looks great. Thank you. Hopefully we can evolve it in the future. Question: could we also easily add a function that converts the HTML code into a PNG image, including a watermark with my website name?

🤖 Yes, converting the generated HTML into a PNG image is feasible using Python, but the process involves a few steps:

  1. Render HTML to an image: You can use a library called Selenium to open the HTML in a web browser and take a screenshot.
  2. Add a watermark: Once you have the image, you can use the PIL (or Pillow) library to overlay a watermark.

Here’s a rough approach:

A computer interface showing a conversation with ChatGPT, displaying Python code examples. The code snippets illustrate two functions: one for rendering HTML to an image using Selenium WebDriver and another for adding a watermark using the PIL library. The left panel shows a list of topics previously discussed with ChatGPT, such as 'Philosophers' McDonald's Response', 'Meme: Philosophers at Party', and 'Twitter Conversation about Aliens'
Display of a coding session with ChatGPT, where the user learns how to convert HTML content to an image file and how to apply a watermark to it using Python.

✍️ The code for rendering the HTML into an image is not yet developed, but I will be adding code to the GitHub repository as more functionalities are added, always with guidance from a chatbot. See below an Illustrative SCBN Chatbot Battle chart with the current functionality. Scores and chatbots are provisional, the topic is being worked on:

Chatbot Battle: Reality is what lies beneath our beliefs when we stop believing

Chatbot Rank (SCBN) Specificity Coherency Brevity Novelty Link
Reddgr Chat 🥇 Winner 🤖🤖🤖 🤖🤖🤖 🤖🤖🤖 🤖🤖🤖 View Chat
TalkingToChatBots.com 🥇 Winner 🤖🤖🤖 🤖🤖🤖 🤖🤖🤖 🤖🤖🤖 View Chat
😘Chat (Alpaca) 🥈 Runner-up 🤖🤖🤖 🤖🤖🤖 🤖🤖🕹️ 🤖🤖🕹️ View Chat
Bardo 🥉 Contender 🤖🤖🤖 🤖🤖🕹️ 🤖🤖🕹️ 🤖🤖🕹️ View Chat
ChatCCCP 🤖🤖🕹️ 🤖🤖🕹️ 🤖🤖🕹️ 🤖🤖🕹️ View Chat
Claudius 🤖🤖🤖 🤖🕹️🕹️ 🕹️🕹️🕹️ 🤖🤖🤖 View Chat
Casper 🤖🤖🕹️ 🤖🤖🕹️ 🕹️🕹️🕹️ 🤖🤖🤖 View Chat

More AI soon

Leave a Reply

Your email address will not be published. Required fields are marked *

*