Skip to main content

Setting up Kuroco RAG

Overview

Kuroco RAG is a service that enhances the accuracy and reliability of generated AI models using information obtained from external sources.

This document aims to understand what can be achieved with Kuroco RAG by creating a GPT that generates answers by referencing content information stored in Kuroco.
The explanation will proceed using a Kuroco account, so if you do not have a Kuroco account, please register for an account from the free trial.

info

If you wish to use Kuroco RAG, please contact us below.

What You Will Learn

In the following steps, we will create a custom GPT that generates answers by referencing content information stored in Kuroco.

Prerequisites

You will need the following accounts, so please create them if you do not have them.

  • Kuroco Account: You need a valid Kuroco account. If you do not have an account yet, please register for an account from the free trial.

  • ChatGPT Plus, Team, or Enterprise Plan: To use GPTs (customized ChatGPT features), you need to have either the ChatGPT Plus, ChatGPT Team, or ChatGPT Enterprise plan.
    If you do not have one, please consider upgrading.

Setting Up Kuroco

Enabling OpenAI

Click on [External System Integration] -> [AI].

Image from Gyazo

Enable "OpenAI" by checking the checkbox and click [Update].
The API key field can be left blank as we will be using Kuroco's API key.

Image from Gyazo

Registering Content

Register the content that ChatGPT will reference in Kuroco.
The registered content will be set up so that it can only be accessed via the API by the customized ChatGPT and cannot be referenced by others externally.

Creating the Content Structure

Click [Add] on the Content structure list page.

Image from Gyazo

Configure the settings with the following details.

General

FieldSetting
NameRAG demo

Image from Gyazo

Field Settings

FieldSlugField NameField Setting
ext_1NoneWYSIWYGWYSIWYG

Image from Gyazo

Search Settings

ItemSetting
Convert to vector dataEnable
Embedding modeltext-embedding-3-small
Keyword template (AI/Vector)Default

Image from Gyazo

Once the settings are done, click on [Add] to add the content definition.

Adding the contents

Register information for OpenAI to use as content.

Click on [Add] from the Content list screen. Image from Gyazo

Here, we have added the following 3 contents as examples.

Remote Work Guidelines Image from Gyazo

Employee Benefits Guidebook Image from Gyazo

Contact Information Image from Gyazo

info

The example shows the registration of internal documents for an AI assistant intended for internal use.
In the tutorial, there are only three contents, but in actual operation, the entire employment regulations will be saved and used to allow the AI to search and check desired items from a large amount of text on behalf of the user.

Checking Vector Data

When a content is added or updated, it is automatically converted to vector data.
Click on [More] -> [Vector Template] from the content editing screen to check the generated keywords.

Image from Gyazo

Additionally, you can check the progress and results of vector data generation on the [External System Integration] -> [AI] page.

Image from Gyazo

Setting up the API

Next, prepare the API for the custom ChatGPT to retrieve content information.

Adding the API

Click "Add" from the API section in the Kuroco admin panel.

Image from Gyazo

In the API creation screen, enter the following and click on "Add".

ItemSetting
TitleRAG demo
Version1.0
DescriptionThis API allows you to retrieve information about the work regulations of Kuroco RAG Demo Corporation.
Order0

Image from Gyazo

info

These settings will be used in ChatGPT later, so please write descriptions that explain what this API is for.

Security Settings

Next, configure the security settings.
Click on [Security] in the API page.

Image from Gyazo

Set the security to [Static Access Token] and click on [Save].

Image from Gyazo

CORS Configuration

Next, configure CORS settings.
Click on [Operation CORS].

Image from Gyazo

Click on [Add Origin] for CORS_ALLOW_ORIGINS and add the following:

  • Admin panel URL
  • https://chatgpt.com/

Click on [Add Method] for CORS_ALLOW_METHODS and add the following:

  • GET

Click on [Add Header] for CORS_ALLOW_HEADERS and add the following:

  • x-rcms-api-access-token

Enable [Allow Credentials] in CORS_ALLOW_CREDENTIALS

Verify that the checkbox for [Allow Credentials] is checked.

Image from Gyazo

If everything is correct, click on [Save].

Issuing a Static Access Token

Click on [Swagger UI].

Image from Gyazo

Set the expiration date for the static access token and click on [Generate].

Image from Gyazo

Once the static access token is issued, make a note of the value.

Image from Gyazo

Creating an Endpoint

Click on [Add a new endpoint] from the RAG demo API.

Image from Gyazo

Create the following endpoint:

FieldSetting
Pathsearch
CategoryContent
ModelTopics
Operationlist
topics_group_idID of the content structure created earlier
cntSet to 3 to limit the number of entries returned in the API response
required_paramvector_search

Image from Gyazo

Image from Gyazo

Image from Gyazo

Once configured, click on [Add] to add the endpoint.

Exporting the OpenAPI Configuration File

Kuroco has the functionality to export OpenAPI, allowing you to output API information in a format compliant with OpenAPI specifications.

From the endpoint list screen, click on [Export OpenAPI].

Image from Gyazo

A popup for the OpenAPI schema file download will appear.
Select the format as YAML, select the desired endpoints, and click [Export].

Image from Gyazo

The downloaded YAML file contains all the settings for the endpoint URL and available parameters.
We will need to make some adjustments so that we are only allowing the vector_search parameter for ChatGPT by remove all parameters except vector_search from the parameters section.

Image from Gyazo

Also, set the required field for vector_search to true.

Image from Gyazo

The YAML file will look like the following example.

openapi: 3.1.0
info:
title: 'RAG demo'
version: '1.0'
description: 'This API allows you to retrieve information about the work regulations of Kuroco RAG Demo Corporation.'
servers:
-
url: 'https://your-domain-here.g.kuroco.app'
description: 'API Backend'
paths:
/rcms-api/8/search:
get:
tags:
- Content
summary: ''
description: |

### **Topics::list (v1)**


## Controller parameters

> **topics_group_id** `27`

> **cnt** `3`

> **required_param** `vector_search`

parameters:
-
name: vector_search
schema:
type: string
format: ''
in: query
required: true
style: form
explode: true
description: 'Vector search'
responses:
'200':
description: 'Topics data successfully fetched'
'404':
description: 'Topics data could not be found'
security:
-
Token-Auth: []
operationId: getRcmsApi8Search
components:
schemas: { }
securitySchemes:
Token-Auth:
type: apiKey
in: header
name: X-RCMS-API-ACCESS-TOKEN

Once this is done, the preparation on the Kuroco side is complete.

ChatGPT Configuration

Creating GPT

Access https://chat.openai.com/ and log in.

Click on [Explore GPTs] in the sidebar, then click on [+ Create] in the top right corner of the page.

Image from Gyazo

The GPT creation screen will open, configure it as follows in the [Configure] tab:

FieldValue
NameKuroco RAG Demo Co., Ltd. Internal Rules Assistant
DescriptionAnswers questions based on the employment regulations of Kuroco RAG Demo Co., Ltd.
InstructionsTo provide efficient and accurate responses, follow the guidelines below when interacting with users:
1. Always send a request to the specified endpoint before answering.
2. Guessing answers based on information not obtained from the endpoint is prohibited.
3. Do not answer questions that are deemed irrelevant to the business.

Image from Gyazo

Scroll down to the bottom of the screen and click on [Create new action].

Image from Gyazo

Paste the content of the modified openapi.yaml file that was downloaded from Kuroco earlier, then click on the gear icon next to Authentication.

Image from Gyazo

Configure as follows and click on [Save]:

FieldValue
Authentication TypeAPI Key
API KeyStatic access token issued by Kuroco
Authentication TypeCustom
Custom Header NameX-RCMS-API-ACCESS-TOKEN

Image from Gyazo

Click on [Test].

Image from Gyazo

GPT will attempt to communicate with Kuroco, click on [Allow].
Verify that the data is retrieved to complete this configuration.

Image from Gyazo

Click [Create] and specify the publish settings to complete the creation of the GPT.

Verification of Operation

When you access the GPT you have created and ask a question, you can see that it will answer by referring to the content you have stored in Kuroco.
If the answer is not as intended, you can update and adjust the instructions for the GPT.

Image from Gyazo

With this, the creation of GPT using Kuroco RAG is now complete.
Kuroco RAG plays a role in facilitating the management and coordination of information provided to GPT, while GPT enhances the accuracy of the generated AI by referencing external content.


Support

If you have any other questions, please contact us or check out Our Slack Community.