Deploy Dify with Tablestore on Compute Nest

更新时间:
复制 MD 格式

Dify is an open-source platform for developing AI applications powered by Large Language Models (LLMs). Tablestore is an Alibaba Cloud structured data storage and retrieval service that features built-in multi-availability zone disaster recovery. It delivers large-scale, low-cost, and high-performance multimodal search capabilities, including full-text, vector, and hybrid search. By integrating Tablestore with Dify, you can quickly build AI knowledge bases and intelligent applications. This topic shows how to use Compute Nest to deploy a Dify application integrated with Tablestore in just a few clicks.

Deploy the Dify application

Currently, only the High-availability Edition of the Dify Community Edition supports Tablestore. After you configure the deployment parameters, Compute Nest automatically deploys the entire cluster.

  1. Log on to the Compute Nest console. In the service catalog, search for Dify Community Edition and click Start Deployment.

  2. On the Create Service Instance page, configure the following parameters:

    • Select Template: Select High-availability Edition. After you select this edition, the page automatically checks for dependencies. If any dependencies are not met, follow the on-screen instructions to resolve them.

    • Kubernetes Configurations: You can select Existing Container Cluster or New Container Cluster. For a new cluster, you can keep the default settings or adjust them as needed.

    • Postgres Database Configurations: Enter the PostgreSQL Database Password. You can keep the default settings for other options or adjust them as needed.

    • Redis Database Configurations: Enter the Redis Instance Password.

    • Tablestore Configurations: Only CU-mode high-performance instances are currently supported. You can change the instance name.

    • Basic Configurations: Select Availability Zone 1 and Availability Zone 2. If you select an existing container cluster under Kubernetes Configurations or an existing VPC under Basic Configurations, you must follow the on-screen instructions to select the VPC Instance ID and VSwitch Instance ID.

  3. Click Next: Confirm Order. After you confirm the information is correct, click Create Now. Once the task is submitted, you can view the deployment progress in the service instance list. The entire deployment process takes about 15 minutes.

Access Dify and configure the model

After deployment, you need to perform the initial setup and configure a Large Language Model (LLM) to serve as the brain for your AI application.

  1. Click the service instance ID or Details to go to the service instance details page. Follow the on-screen instructions to configure DNS resolution or your hosts file. After configuring your DNS or hosts file, click the Dify access page URL to open Dify.

    This panel displays the Dify Access Page URL (for example, http://dify-example.local/install), the mapping entry to add to your hosts file (in the format IP address domain), and a link to view the Service Deployment and Usage Instructions.

  2. On your first visit, follow the prompts to set up an administrator account. After completing the setup, you are automatically redirected to the logon page and logged on.

  3. In the upper-right corner of the page, click Avatar > Settings > Model Provider. In the Install a model provider list, select and install a provider (this topic uses Qwen as an example). After installation, click Settings and follow the on-screen instructions to obtain and set the API-KEY. Dify automatically sets the system model, but you can set a different default model if needed.

    A green dot next to API-KEY on the Qwen card indicates a successful connection.

Create a knowledge base using Tablestore

After configuring the model, you need to create a knowledge base and upload documents. The vectorized data from the parsed documents is stored in your Tablestore instance, enabling the AI application to perform knowledge retrieval.

  1. On the knowledge base page, click Create Knowledge Base > Create an empty knowledge base, enter a Knowledge Base Name, and click Create.

  2. In the new knowledge base, click Add File. Select a file and click Next to configure text chunking and cleaning. For Indexing Method, select High Quality. We recommend changing the Retrieval Settings to Hybrid Search. You can configure other options as needed. Then, click Save and Process and wait for the document to be processed.

    After the document is processed, its status in the document list changes to Available.

  3. (Optional) To view the vector data, log on to the Tablestore console. In the Instance List, click the instance alias. On the Instance Management page, click the data table name in the Data Table List. Finally, on the Table Management page, click Data Management to view the vector data.

    On the Data Management tab, you can see that a data record has been written to the vector index table. This record contains columns such as id (primary key), metadata, metadata_tags, page_content, and vector. This confirms that the knowledge base content has been successfully vectorized and stored in Tablestore.

Build a chatbot to verify the setup

Finally, create a simple chatbot to verify that knowledge retrieval is working correctly.

  1. On the Studio page, click Create Blank App. For App Type, select For Beginners > Chatbot. Enter an App Name and click Create.

  2. In the chat box of the Debug and Preview window, ask a question, such as What models of Model Studio phones are available?. Because the application is not yet connected to a knowledge base, the chatbot cannot provide an accurate answer.

  3. Add a knowledge base to the chatbot.

    In the Context panel, click the + Add button in the upper-right corner and select the knowledge base you want to add.

  4. In the chat box of the Debug and Preview window, ask the question again. The chatbot can now provide an accurate answer by retrieving information from the knowledge base.

Use in a production environment

You have now successfully deployed a high-availability Dify application by using Compute Nest and configured Tablestore as its vector storage core. You can now add more data to the knowledge base or build more complex AI applications based on the Dify application examples.

Important

Before deleting the service instance in the Compute Nest console, you must first delete the data tables in the instance from the Tablestore console. Otherwise, the service instance deletion will fail because the Tablestore instance is not empty.