Playback speed
×
Share post
Share post at current time
0:00
/
0:00
Transcript

Chatbot Platform #4 - Multi-tenancy

A step-by-step guide to add multi-tenancy support to the chatbot platform

Hi folks,

Thanks for joining me. Today, I'm diving deeper into the exciting world of multi-tenancy as I continue to refine my chatbot platform.

Debugging the Files Tab

The journey begins where I left off last time - the files tab wasn't yet fully equipped for multi-tenancy. Previously, accessing the files tab fetched and displayed a list of files directly from OpenAI, which wasn't ideal. Now, I've revamped the code to pull these files from the database instead. However, after making this change, I encountered an error message: "failed to upload file." To troubleshoot, I looked into the issue and found that while the file was getting uploaded to OpenAI, it wasn't being added to my database. It turned out that the user ID being fetched wasn't correct. After checking and rectifying this problem, things seemed to work smoothly. A quick look at the files table confirmed - an entry had been added.

Next, I logged out and tried the process with a different user. I noticed the same file was showing up. To solve this, I uploaded a second file. The upload went through, but it became clear the files list was incorrect - it was displaying files like "mega guide" and "golden rules" across different users. I'd instructed the system to show files specifically for the logged-in user, prompting another round of code revisions. After these adjustments, each user could now see their respective files: user one saw "mega guide," and another user saw "golden rules."

Fixing the Bot's Endpoint and Navigation

While reviewing, I encountered an issue with the bot's endpoint and noted that the navigation panel looked awkward as it was only half the length. I made some modifications, extending the navigation to full length and fixing the bot's tab link. Both now work as intended.

Enhancing the Files Tab

Another task was to refine the associate feature within the files tab. The associate functionality was supposed to add the feature to the database, but wasn't doing so. Upon examining the issue, I discovered it was attempting to associate the same file twice in OpenAI, causing an error. Cursor was tasked to address this issue for me.

Furthermore, I wanted to ensure if a bot was removed from an association, it would also be erased from the vector store. This process would extend to bots too - deleting a bot should remove it from the database, the assistant, and the vector store. I pasted relevant code snippets to avoid confusion for Cursor. Subsequently, deleting Gym bot 2 confirmed the success of these steps, as it vanished from both the database and the vector store.

Reaching the Goal

With these hurdles overcome, my chatbot platform now stands fully functional. Users can log in, register, create bots, upload files, associate these files with multiple bots, and then interact with the bots to get responses. I feel I am one step closer to developing something genuinely impactful. I look forward to sharing more updates in the next episode.

Thank you for joining me on this journey.

Discussion about this podcast

Build With Anant
Build in Action
Step-by-step videos of full software builds using AI tools like Cursor, v0, Replit, ChatGPT Canvas and more. Watch and learn as I tackle real-world coding challenges.