• CTO AI Insights
  • Posts
  • Cheese Chingu's Step-by-Step Guide to Setting Up a TypingMind Plugin for Non-Vectorized RAG

Cheese Chingu's Step-by-Step Guide to Setting Up a TypingMind Plugin for Non-Vectorized RAG

Retrieval-Augmented Generation (RAG) to query a non-vectorised database via an API schema

The Use Case of Chingu

I have a vision for a line of B2C assistants and agents (previously Apps) called "Chingu" which in Korean means "friend."
Cheese Chingu is one, as I am a Certified Cheese Professional (seriously).

For selfish reasons, I'd love to build my Recipe Chingu, which can retrieve recipes I've stored or linked to cookbook knowledge bases and just send me options based on what I have (shared via voice, text chat, or image/video)

How does this help businesses? No clue. But it helps me.

Cheese Chingu created by the Master of Cheese herself, Vanessa Chang (tiktok.com/@sovcurious)

Cheese Chingu is an AI-powered app designed to make discovering, pairing, and enjoying cheese approachable and fun for everyone. Whether you're a seasoned cheese enthusiast or a curious beginner, the app acts as your personalized cheese companion. Users can input preferences like "nutty, semi-hard, and aged" to receive tailored recommendations, scan barcodes or upload images to identify cheeses, or even get pairing suggestions for specific cheeses. The AI leverages a growing database of flavor profiles, dietary filters, and pairing options—including non-alcoholic beverages—to provide personalized advice. With features like voice interaction and translator mode for cheesemonger visits, Cheese Chingu transforms every cheese moment into an opportunity to explore with confidence. This guide focuses on enabling the app's AI Agent to use Retrieval-Augmented Generation (RAG) via TypingMind plugins to dynamically query external data sources for pairing suggestions and more.

Here’s a detailed guide to setting up a TypingMind plugin that enables an AI Agent to use Retrieval-Augmented Generation (RAG) to query a non-vectorized database via an API schema, such as the one provided in the JSON example.

Step-by-Step Guide to Setting Up a TypingMind Plugin for Non-Vectorized RAG

This guide assumes your data source is accessible via an API and follows a schema similar to the JSON provided. The TypingMind plugin will send HTTP requests to this API, retrieve the necessary data, and use it to generate responses.

Table of Contents

1. Understand the Workflow

The plugin will:

  1. Accept user queries (e.g., "What pairs well with Brie?").

  2. Extract the relevant parameter (e.g., cheese_name = "Brie").

  3. Send an HTTP request to the external API using the provided schema.

  4. Receive the response from the API (e.g., pairing suggestions).

  5. Pass this data as context to the AI Agent for response generation.

2. Prepare Your API

Ensure your external API is ready and adheres to the following:

  • Accepts HTTP requests with parameters as specified in your schema.

  • Returns structured JSON responses with the required data.

Example API Endpoint:

  • Endpoint: https://api.cheesedata.com/get_cheese_pairings

  • Method: POST

  • Request Body:

    {
      "cheese_name": "Brie"
    }
    
  • Response:

    {
      "pairings": ["crusty bread", "green apples", "sparkling cider"]
    }
    

3. Create a New Plugin in TypingMind

a. Access the Plugin Section

  1. Open TypingMind's Admin Panel.

  2. Navigate to the Plugins section.

  3. Click on Create New Plugin.

b. Define Plugin Metadata

Provide basic details about your plugin:

  • Name: Cheese Pairing Finder

  • Description: Helps users find pairing suggestions for specific cheeses by querying an external database.

c. Define OpenAI Function Specification

Define how TypingMind will interact with your plugin using OpenAI Function Calling.

Example Function Spec:

{
  "name": "get_cheese_pairings",
  "description": "Retrieve pairing suggestions for a specific cheese.",
  "parameters": {
    "type": "object",
    "properties": {
      "cheese_name": {
        "type": "string",
        "description": "The name of the cheese."
      }
    },
    "required": ["cheese_name"]
  }
}

4. Implement HTTP Request Logic

TypingMind plugins allow you to write custom code or configure HTTP actions for external API calls.

a. Write HTTP Request Logic

Use JavaScript or another supported language to send requests and handle responses.

Example Code (JavaScript):

async function getCheesePairings(input) {
    const response = await fetch('https://api.cheesedata.com/get_cheese_pairings', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ cheese_name: input.cheese_name })
    });
    if (!response.ok) {
        throw new Error(`API call failed with status ${response.status}`);
    }
    return await response.json();
}

b. Map Results Back to AI

Once data is retrieved, format it for the AI Agent to use in generating responses.

Example Mapping:

const result = await getCheesePairings({ cheese_name: "Brie" });
return `Brie pairs well with ${result.pairings.join(", ")}.`;

5. Configure Plugin in TypingMind

  1. In the plugin settings, specify:

    • The function name (get_cheese_pairings).

    • The endpoint URL (https://api.cheesedata.com/get_cheese_pairings).

    • The HTTP method (POST).

    • Required headers (e.g., Content-Type: application/json).

  2. Test the configuration by sending sample queries and verifying that the correct data is returned.

6. Test Your Plugin

  1. Open a conversation with your AI Agent in TypingMind.

  2. Enter a query like "What pairs well with Brie?".

  3. Verify that:

    • The plugin extracts cheese_name from the query.

    • The plugin sends a valid request to the API.

    • The AI generates a response using the retrieved data.

Example Response: "Brie pairs well with crusty bread, green apples, and sparkling cider."

7. Deploy and Optimize

Once testing is complete:

  1. Enable the plugin for all users or specific groups as needed.

  2. Monitor performance and refine logic based on user feedback.

  3. Add error handling for scenarios like invalid cheese names or API downtime.

8. Future Enhancements

  • Add support for additional parameters (e.g., dietary preferences).

  • Integrate fallback mechanisms if the API fails (e.g., preloaded default pairings).

  • Expand functionality to include other use cases like nutritional information or storage tips.

TypingMind Plugins can make API calls, but the implementation depends on whether you are using Client Plugins or Server Plugins. Here’s how it works based on the TypingMind documentation:

Understanding API Calls for Plugins

1. API Calls in TypingMind Plugins

TypingMind Plugins can make API calls, but the implementation depends on whether you are using Client Plugins or Server Plugins.

TypingMind supports making API calls through HTTP Actions, which are explicitly designed for this purpose. These HTTP Actions allow plugins to interact with external APIs to retrieve or send data.

Key Points:

  • Client Plugins: Run in the user's browser and can make HTTP requests directly from the client side.

  • Server Plugins: Run on TypingMind's server (available in the Team version, TypingMind Custom) and also support HTTP Actions for API calls.

Both types of plugins can interact with external APIs, provided they are properly configured.

2. How to Implement API Calls in Plugins

a. Define the OpenAI Function Spec

The first step is to define the OpenAI Function Spec for your plugin. This defines what parameters the plugin will accept and how it will process user input.

Example for your use case:

{
  "name": "get_cheese_pairings",
  "description": "Retrieve pairing suggestions for a specific cheese.",
  "parameters": {
    "type": "object",
    "properties": {
      "cheese_name": {
        "type": "string",
        "description": "The name of the cheese."
      }
    },
    "required": ["cheese_name"]
  }
}

b. Add HTTP Action Logic

For making API calls, you can define an HTTP Action in your plugin. This involves specifying:

  • The HTTP method (e.g., GET, POST).

  • The endpoint URL.

  • Headers (e.g., Content-Type: application/json).

  • The request body (if required).

Example:

async function getCheesePairings(input) {
    const response = await fetch('https://api.cheesedata.com/get_cheese_pairings', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ cheese_name: input.cheese_name })
    });
    if (!response.ok) {
        throw new Error(`API call failed with status ${response.status}`);
    }
    return await response.json();
}

c. Configure Plugin Settings

Once the logic is implemented:

  1. Navigate to the Admin Panel in TypingMind.

  2. Select Plugins > Create New Plugin.

  3. Enter details such as the plugin name, description, and function spec.

  4. Add your HTTP Action code or configuration.

3. Limitations and Considerations

Client Plugins

  • Run in the user's browser and may face cross-origin restrictions (CORS) depending on the external API's configuration.

  • Best suited for APIs that allow client-side access without sensitive authentication.

Server Plugins

  • Available only in TypingMind Custom (Team version).

  • Run on TypingMind's server, which avoids CORS issues and allows secure handling of sensitive data like API keys.

  • Recommended for scenarios where secure API interactions are required.

4. Summary

TypingMind Plugins can indeed make API calls using HTTP Actions, allowing you to query external data sources like your cheese pairing database. Whether you use Client or Server Plugins depends on your setup:

  • Use Client Plugins for simpler integrations where security is not a concern.

  • Use Server Plugins (TypingMind Custom) for more robust and secure integrations.

This flexibility makes it possible to implement Retrieval-Augmented Generation workflows with external APIs, even without vectorized data stores.

TypingMind References

By following this guide, you can set up a TypingMind plugin that uses RAG principles to query non-vectorized databases via APIs and provide accurate, contextually relevant responses tailored to user queries!

1  Cheese Chingu is an AI-powered app designed to make discovering, pairing, and enjoying cheese approachable and fun for everyone. Whether you're a seasoned cheese enthusiast or a curious beginner, the app acts as your personalized cheese companion. Users can input preferences like "nutty, semi-hard, and aged" to receive tailored recommendations, scan barcodes or upload images to identify cheeses, or even get pairing suggestions for specific cheeses. The AI leverages a growing database of flavor profiles, dietary filters, and pairing options—including non-alcoholic beverages—to provide personalized advice. With features like voice interaction and translator mode for cheesemonger visits, Cheese Chingu transforms every cheese moment into an opportunity to explore with confidence. This guide focuses on enabling the app's AI Agent to use Retrieval-Augmented Generation (RAG) via TypingMind plugins to dynamically query external data sources for pairing suggestions and more.

Reply

or to participate.