MindsDB provides the LLM() function that lets users incorporate the LLM-generated output directly into the data queries.

Prerequisites

To use the LLM() function with MindsDB, choosing one of the available model providers and define the following environment variables.

Usage

You can use the LLM() function to simply ask a question and get an answer.

SELECT LLM('How many planets are there in the solar system?');

Here is the output:

+------------------------------------------+
| llm                                      |
+------------------------------------------+
| There are 8 planets in the solar system. |
+------------------------------------------+

Moreover, you can the LLM() function with your data to swiftly complete tasks such as text generation or summarization.

SELECT
    comment,
    LLM('Describe the comment''s category in one word: ' || comment) AS category
FROM example_db.user_comments;

Here is the output:

+--------------------------+----------+
| comment                  | category |
+--------------------------+----------+
| I hate tacos             | Dislike  |
| I want to dance          | Desire   |
| Baking is not a big deal | Opinion  |
+--------------------------+----------+