Configure

Integrate Dify Enterprise Edition with Oracle AI Database 26ai to leverage multimodal vector storage and efficient retrieval. To activate Oracle AI Database 26ai's vector storage and retrieval capabilities, preconfigure the database and modify parameters in Dify to ensure that vector data can be written and retrieved seamlessly through the integration of Dify application and Oracle AI Database 26ai vector management.

Preconfigure a Dedicated Oracle AI Database 26ai Environment

In Dify Enterprise Edition (EE), install and configure the Oracle Pluggable Database (PDB) database.
You must first create a database access user in Oracle PDB. Then configure the database connection user and password in the Dify EE configuration file. Using the PDB service name is sufficient. Follow these steps:
  1. Log in to Oracle AI Database 26ai.
  2. Switch to the target PDB.
    1. Run the show pdbs command to view all available PDBs (such as PDB1).
    2. Switch to the target PDB container using the following example command:
      alter session set container=PDB1
  3. Create a Dify user and authorize.
    1. Run the following command to create a dedicated user:
      create user dify identified by password default tablespace users quota unlimited on users
    2. Run the following command to grant database development permissions to the user:
      grant db_developer_role to dify
    This ensures that the user has table creation and vector index operations permissions.
  4. Create a vector search tokenizer.
    Run PL/SQL statements to create a multilingual word breaker. For example:
    BEGIN CTX_DDL.CREATE_PREFERENCE('dify.world_ lexer ','WORLD_LEXER');
    END; /.
    This word breaker can process text in multiple languages, including Chinese and English, to ensure accurate text retrieval.

Connect Dify to Oracle AI Database

Follow these steps to codify Dify Helm values and templates, then apply and verify the configuration to connect to Oracle AI Database 26ai.
  1. Modify the values.yaml configuration.
    Add Oracle vector database parameters to Dify's Helm configuration file to specify database connection information and authentication method.
    vectorDB:
      externalType: "oracle"
      externalOracleVectoRS:
        dsn: "Oracle_IP:1521/PDB1"  # Database address and PDB
        user: "dify"                # Dify dedicated username
        password: "dify_1234"       # Password
        config_dir: "/app/api/storage/wallet"
        wallet_location: "/app/api/storage/wallet"
        is_autonomous: "false"      # Is it an autonomous database?
  2. Modify the Dify template file. Adjust the configuration template under the Dify installation directory to ensure that the Oracle environment variables and keys can be mounted correctly.
    1. Add the Oracle environment variable declaration in vectordb-config.yaml.
      {{- else if eq .Values.vectorDB.externalType "oracle" }}
      ORACLE_DSN: {{ .Values.vectorDB.externalOracleVectoRS.dsn | quote }}
      ORACLE_USER: {{ .Values.vectorDB.externalOracleVectoRS.user | quote }}
      ORACLE_CONFIG_DIR: {{ .Values.vectorDB.externalOracleVectoRS.wallet_location | quote }}
      ORACLE_WALLET_LOCATION: {{ .Values.vectorDB.externalOracleVectoRS.wallet_location | quote }}
      ORACLE_IS_AUTONOMOUS: {{ .Values.vectorDB.externalOracleVectoRS.is_autonomous | quote }}
    2. Add password encryption configuration to vectordb-secret.yaml to avoid storing credentials in plain text.
      {{- else if eq .Values.vectorDB.externalType "oracle" }}
      ORACLE_PASSWORD: {{ .Values.vectorDB.externalOracleVectoRS.password | b64enc | quote }}
      ORACLE_WALLET_PASSWORD: {{ .Values.vectorDB.externalOracleVectoRS.wallet_password | b64enc | quote }}
  3. Apply the configuration and verify.
    1. Run Helm upgrade to update the Dify configuration.
    2. Run kubectl in the API Pod to verify that environment variables are effective and ensure VECTOR_STORE=oracle.
    3. Repeat the verification in the Worker Pod to confirm that all business components can read the Oracle configuration.