Yesterday, the ChatGPT has been integrated to Steem Blockchain, but the initial design has problems and so other bot commands e.g. !bing, !price, !info and !thumbup. The applications are written in NodeJs and run by `pm2` manager on a single VPS (Virtual Private Server).
The Design Flaws
Previously:
- process `blockchain` listens the comments posted to steem blockchain on real time – and push the known commands to MySQL database.
- process `ask` or other commands take the corresponding record from MySQL and process them immediately – and post to steem blockchain (synchronously) in the same process.
There is a fault (problem) – there could be multiple bots dealing with the message and posting to steem blockchain at the same time under the same account aka @witnesstools. As you may know, a STEEM account can post a comment every 3 seconds, and thus, there is going to be a problem for a large scale simultaneous processing.
We can have a retry at each process when the final comment posting fails – but this increases overhead and complexity. And also, this can cause code duplication for each bot.
The New Design
Thus, with a refactor and redesign – I have added a `comments` process which does one thing: read comments from MySQL, post them and mark them done, every 3 seconds.
Here is the overall design for the components:
The comments are pushed to the MySQL for each bot when they finish processing, for example, when ChatGPT API returns the answer, instead of posting it directly to the steem blockchain, it will be stored in the MySQL, and be picked up by `comments` process. All the processed comments (successfully posted onto the blockchain) will be logged in Table `logs`.
This has several advantages:
- Decouple the components: the `blockchain` reads transactions, the `ask` takes messages and calls ChatGPT, pushes the answer to database. The `comments` reads the comments and post them to the chain.
- Code reuse: all processing bots share the same code except the process part. e.g. `ask` calls ChatGPT, `thumbup` retrieves a random thumbup gif, `bing` returns a random wallpaper etc.
- Less bugs: previously, the records are marked processed only after the comments are posted, but this has delays which may trigger another round of processing meaning the same message may be processed in parallel more than once.
With this design, the message taken out will be marked processed immediately, the comments will be posted separately without being affected by this status.
After refactoring and re-design, the ChatGPT Dapp on Steem Blockchain has improved a lot in terms of availability and robustness. The following shows the processes running happily by `pm2` manager.
Retry Logics/Strategy
Currently, the system does not have a retry strategy. For example, posting on Steem Blockchain may trigger an error – due to Out of Resource Unit, or simply the network issues. When that occurs, we can re-queue the record back to the comments table – or simply update the timestamp so that it can be picked up later (in the order of First-In-First-Out so that other new messages can be picked before the “retrying” messages).
On peak times, the ChatGPT (free plan) may take a while or even minutes to return the response. Currently, the ChatGPT DApp on Steem Blockchain is set to 120 seconds timeout. In case of failure, a malform JSON may be returned (SyntaxError: Unexpected end of JSON input), then we have to put the request back to database (queue) with a updated timestamp. We may abort the request and fail it completedly after a certain number of retries.
Single Point of Failures
This design is subject to Single Point of Failures, please read the improved design: Avoid Single Point of Failures by Introducing Multiple Master Backup Reader Node on Steem Bot Applications
Conclusion
This post describes the current system design of the Bots (commands) on steem blockchain. The Database (MySQL) is used for both purposes of persistence and Message Queue. If the performance is an issue, we may need to consider High Performant Message Queue instead of Database.
The current design overcomes the limitation of posting 1 comment on steem blockchain every 3 seconds, and allows multiple bots processing at the same time.
Steem to the Moon🚀!
- You can rent Steem Power via rentsp!
- You can swap the TRON:TRX/USDT/USDD to STEEM via tron2steem!
- You can swap the STEEM/SBD to SUI via steem2sui!
- You can swap the STEEM/SBD to SOL (Solana) via steem2sol!
- You can swap the STEEM/SBD to ETH (Ethereum) via steem2eth!
- You can swap the STEEM/SBD to Tether USDT (TRC-20) via steem2usdt!
- You can swap the STEEM/SBD to TRX (TRON) via steem2trx!
- You can swap the STEEM/SBD to BTS (BitShares) via steem2bts!
- Register a free STEEM account at SteemYY!
- Steem Block Explorer
- ChatGPT/Steem Integration: You can type !ask command to invoke ChatGPT
- Steem Witness Table and API
- Other Steem Tools
ChatGPT Use Cases
- ChatGPT writes a Python Script to Interact with Grok LLM from x.ai (Free $25 Credit)
- ChatGPT Use Case for Software Engineer: Review Pull Requests (Code Reviews)
- How ChatGPT Solves a Math Puzzle?
- ChatGPT Designs a Health Check Tool in Node.Js to Run on Free VPS Instance
- ChatGPT-4 uses Math Wolfram Plugin to Solve a Math Brain Teaser Question
- ChatGPT Refactors/Rewrites the Code using Promise.All - Sending Requests in Parallel
- ChatGPT Use Case: A Good Personal AI Assistant to Help You Write Emails
- Programming Language Conversion Tool based on ChatGPT AI
- ChatGPT4: integrated with DALL.E: Generate a Merry Christmas theme girl in Red Dress
- Have you started using ChatGPT-4o?
- From Idea to GitHub Pages: Building Tools with AI and Vibe Coding
ChatGPT - AGI (Artificial General Intelligence)
- Blog Traffic Declines after ChatGPT is Widely Adopted
- What is going to be the next trend in technology in the next 10 years?
- Asking ChatGPT the Price of a Bitcoin (Does ChatGPT Predict or Estimate?)
- On Waiting List of ChatGPT 4 API
- The System Design of Steem Blockchain (ChatGPT DApps) Bots
- Integrating ChatGPT Prompt AI to STEEM blockchain
- ChatGPT Gives a Correct Leetcode Solution (Rust: Binary Search Algorithm) after Several Attempts
- ChatGPT Fails to Solve the Sudoku
- OpenAI Text Classifier Fails to Detect ChatGPT Text
- Quantum Computing in Simple Terms (ChatGPT vs Notion AI)
- How ChatGPT Impacts UGC (User Generate Content)?
- The Young Prompt Engineers
Grok 3 AI
ChatGPT Fails to
- ChatGPT Fails to Read the Text from Image
- ChatGPT AI is not able to solve this Math Problem: Rhombus inside Sqaure
–EOF (The Ultimate Computing & Technology Blog) —
Last Post: Integrating ChatGPT Prompt AI to STEEM blockchain
Next Post: On Waiting List of ChatGPT 4 API