Skip to main content

Prompt Management

The Prompt Management section provides guidance on how to manage and configure prompts for analytics and semantic analysis tasks within FlockMTL. Prompts guide models in generating specific outputs for tasks like content generation, summarization, and ranking. Each database is configured with its own prompt management table during the initial load.

1. Prompt Table Structure

Column NameDescription
prompt_nameUnique identifier for the prompt
promptInstruction content for the model
updated_atTimestamp of the last update
versionVersion number of the prompt

2. Management Commands

  • Retrieve all available prompts
GET PROMPTS;
  • Retrieve details of a specific prompt
GET PROMPT 'prompt_name';
  • Create a new prompt
CREATE PROMPT('prompt_name', 'prompt');
  • Modify an existing prompt
UPDATE PROMPT('prompt_name', 'prompt');
  • Remove a prompt
DELETE PROMPT 'prompt_name';

3. SQL Query Examples

Semantic Text Completion

Generate a description for products using a predefined prompt:

SELECT llm_complete(
{'model_name': 'gpt-4'},
{'prompt_name': 'product-description'},
{'input_text': product_description}
) AS generated_description
FROM products;

Review Summary

Generate a summary for customer reviews using a specific prompt version:

SELECT llm_complete(
{'model_name': 'semantic_search_model'},
{'prompt_name': 'customer-review-summary', 'version': 3},
{'customer_review': review_text}
) AS review_summary
FROM reviews;

4. Global and Local Prompts

Prompt creation is database specific if you want it to be available irrespective of the database then make it a GLOBAL mode. Note that previously, the creation was specific to the running database, which is LOCAL by default and the keyword LOCAL is optional.

Create Prompts

  • Create a global prompt:
CREATE GLOBAL PROMPT('prompt_name', 'prompt');
  • Create a local prompt (default if no type is specified):
CREATE LOCAL PROMPT('prompt_name', 'prompt');
CREATE PROMPT('prompt_name', 'prompt');

Toggle Prompt State

  • Toggle a prompt's state between global and local:
UPDATE PROMPT 'prompt_name' TO GLOBAL;
UPDATE PROMPT 'prompt_name' TO LOCAL;

All the other queries remain the same for both global and local prompts.