Skip to main content

Create a Dynamic Model List for Connector

The Connector Dynamic Model List allows retrieving a list of available model names that can be used with the connector. This list is got dynamically based on the models currently compatible with the connector.

Prerequisites

Before implementing dynamic model lists for a connector, be sure to read the documentation on creating custom connectors. This will provide essential background on:

  • The structure and requirements for connectors.
  • Exporting the main and config functions.
  • Packaging and distributing custom connectors.

Referring to the custom connector documentation first will help ensure you have the core knowledge needed to properly implement the model list functionality.

Steps for Creating a Dynamic Model List

Step 1: Clone the connector repository you want to update to support a dynamic model list, or use your own existing connector repository:

git clone <connector-repo-url>

This will allow you to modify the connector source code to add support for retrieving the list of available models dynamically.

Step 2: Inside the main.ts file, define a new getDynamicModelList function:

function getDynamicModelList(settings?: ConnectorSettings): string[] {}
  • settings (optional): Connector configuration settings object, containing API keys or other credentials needed to retrieve the model list.

This function should retrieve the list of model names compatible with the connector dynamically at runtime. The implementation will depend on the specific API or source used to fetch the models.

It should return an array of string values, where each string is a model name available for the connector.

Step 3: Implement getDynamicModelList function

Install any required packages to call the API or access the model data source, the add logic.

Step 4: Export the getDynamicModelList function along with the main and config functions

export { main, config, getDynamicModelList };

Validate your build by running the following command:

npm run build

Step 5: Test Your Connector

  1. Test getDynamicModelList to ensure it properly retrieves the list of available models.

  2. Verify previous connector functionality still works as expected by testing functionality.

  3. Refer to the "Add a Custom Connector" documentation for additional tips on testing and troubleshooting your connector.

Step 6: Modify the README.md file

Update the README.md file for the connector with any additional documentation needed to use the new dynamic model list capability.

Step 7: Deploy your connector

Finalize your connector for deployment, ensuring it is ready for use in its target environment.