genai-query-engine
Reactive icon

GenAI Query Engine

Stable version 1.0.0 (Compatible with OutSystems 11)
Uploaded
 on 28 Apr (yesterday)
 by 
0.0
 (0 ratings)
genai-query-engine

GenAI Query Engine

Documentation
1.0.0

Refrence

For a detailed exploration of the Gen AI Query Engine, including its integration process and benefits, check out the Medium post : Gen AI Query Engine


Prerequisites

Before setting up the Gen AI Query Engine, ensure the following:

Snowflake Credentials – Retrieve credentials from the referenced Forge asset documentation Snowflake Connector. For authentication, key-pair authentication will be used, but alternative methods can be opted for as per the Forge documentation.
Google AI API Key – Obtain the API key from Google AI Studio (https://aistudio.google.com/app/apikey).
OutSystems Configuration – Configure Snowflake credentials and Google AI API key in the site properties of the Gen AI Query Engine for seamless integration.

How It Works

The Gen AI Query Engine follows a structured process to convert natural language prompts into accurate SQL queries while ensuring data security.

Step 1: Metadata Retrieval from Snowflake

  • Before generating a query, the system first retrieves metadata from Snowflake, ensuring accurate query mapping.
    Action: The system fetches metadata about the tables, columns, and relationships in the database.

Step 2: User Input (Natural Language Prompt)

  • Users enter a query through the OutSystems UI, expressing their request in natural language.
    Example Prompt: "Which is the highest valued order & who placed that?"
    Action: Users click "Run", triggering the backend process.

Step 3: Query Generation using Gemini Query Generator

  • The natural language input is processed by GeminiQueryGeneratorWrapper(Action), generating a SQL query using metadata retrieved from Snowflake and user's input prompt.
    Action: Gemini AI maps the user’s request to the database schema and formulates a valid SQL query.

Step 4: Query Execution in Snowflake

  • Once the SQL query is generated, it is executed within Snowflake, retrieving data in JSON format.
    Action: Snowflake processes the SQL query and returns structured data relevant to the request.

Step 5: Natural Language Response Creation

  • The GeminiSentenceCrafterWrapper(Action) refines the JSON response, transforming raw data into a human-readable summary.
    Action: Gemini AI generates a structured natural language response based on the query results.

Final Step: Display the Answer

The system presents the natural language response in the user interface, ensuring a user-friendly experience.