If you want to associate multiple LLMs with the same trigger, you have a couple of options. The simplest way is to keep your trigger_config table structure as is, but allow multiple rows with the same trigger and different LLMs.

Here’s what that might look like:

id llm_model type trigger prompt
1 OpenAI type1 trigger1 prompt1
2 Bard type1 trigger1 prompt1
3 OpenAI type2 trigger2 prompt2
4 Bard type2 trigger2 prompt2
In this table, id is a unique identifier for each row. trigger1 is associated with both OpenAI and Bard, and each combination has its own row in the table.

However, if you want to ensure that each trigger has a single unique ID regardless of how many LLMs it’s associated with, you’ll need to structure your data differently.

One way to do this is to create a third table, llm_trigger_assoc, that associates triggers with LLMs. Here’s what that might look like:

trigger_config:

id type trigger prompt
1 type1 trigger1 prompt1
2 type2 trigger2 prompt2

llm_trigger_assoc:

id trigger_id llm_model
1 1 OpenAI
2 1 Bard
3 2 OpenAI
4 2 Bard
In this setup, each trigger has a single row in the trigger_config table, and each LLM associated with that trigger has a separate row in the llm_trigger_assoc table. This way, each trigger has a unique ID, but can still be associated with multiple LLMs.

Note that you will also need to modify your queries and application logic to accommodate this new structure. When you want to get the data for a particular trigger, you’ll need to first get the row from trigger_config, and then get all associated LLMs from llm_trigger_assoc.

The idea is to use the config_json field to store a JSON object that contains all the specific configuration parameters for a particular language model.

Here’s an example of what that could look like:

config table

id llm_model api_key endpoint config_json
1 OpenAI xxxxxxx yyyyyyy {“prompt”:“Hello, world!”, “temperature”:0.5, “max_tokens”:100}
2 Bard xxxxxxx yyyyyyy {“bard_specific_field”:“some value”}
3 Llama xxxxxxx yyyyyyy {“llama_specific_field”:“some value”}
The config_json field allows you to store any set of configuration parameters, regardless of which LLM they belong to. When you retrieve this data from the database, you would parse the JSON into a data structure that your application can use.

The sequence of implementing these components will largely depend on your priorities and the dependencies of your application components. However, I’d suggest the following general approach:

  1. Backend Functionality: Start with the core functionality of your application, which seems to be the backend part in your case. This would involve setting up your AI models, defining your triggers, and ensuring that the main functionalities of your app are working as expected. The main reason to start here is that these core features are the backbone of your app and they don’t necessarily depend on the presence of a user system. You can test and tweak them without needing any authentication or user management system in place.
  2. User Management with Supabase: Once your core functionality is solid, you can start integrating the user management system using Supabase. This includes setting up the user registration, login, and session management functionalities. At this point, you will also define the roles or tiers (free trial, basic, premium) for your users.
  3. Role-Based Access Control: After your user management system is up and running, you can start working on enforcing access control based on user roles. This is where you restrict or allow access to certain features of your app based on the user’s subscription level. You will implement the checks in your application code to ensure that a user can only access the features that their subscription level allows.

This order allows you to build and test the most fundamental parts of your application first, before adding the complexity of user management and access control. However, keep in mind that this is a general suggestion and you should adapt it to fit your specific needs and circumstances.