This article introduces a sample application showcasing the capabilities of GeneXus Next in building intelligent, agentic applications.
Developed using the first December 2024 build of GeneXus Next, the sample application heavily leverages AI-assisted development, demonstrating cutting-edge features for modern application design.
It's simply about using AI for Products and Categories CRUD and Search.
- Agent object
- Text Expansion: Automatically generate a product description based on its name.
- Context-Based Categorization: Assign a category to a product using its description and a predefined context of valid categories.
- Embedding data type
- Enables semantic search within a product catalog, using vector-based similarity.
- Download the Sample File
Download the sample application: GeneXus Next Agents Sample
- Create a Knowledge Base
Select a target environment:
- Local: Java or .NET with PostgreSQL.
- Prototyping Cloud: .NET with PostgreSQL.
- Import and Initialize
- Import the downloaded XPZ file into your Knowledge Base.
- Run the following objects:
If you prefer not to build the application yourself, you can try it out directly here: https://next101.genexus.ai/Id5bb169495a7907222f8bd9925703fa61/home
- Semantic Product Search
- Use natural language to search for products, even with terms that aren’t explicitly in the database.
- The system prioritizes products that best match your intent.
- Product CRUD Operations
- When adding a new product:
- The Product Description is generated by an AI Agent based on the entered Product Name.
- The Category is automatically assigned based on the Product Description.
GeneXus Next automates the entire lifecycle of the application, generating all layers, including:
- UI layer
- Business logic layer
- AI agents access layer
- Data access layer
Globant Enterprise AI acts as a runtime platform for AI Agents, and behind the scenes it does the following:
- Allows the system to connect securely to the LLMs,
- Handles versioning of the agents,
- Controls and logs all LLM requests,
- Allows the management of the underlying LLM access costs, etc.
- AI Agents
Defined in GeneXus and deployed via Globant Enterprise AI for:
- Text expansion.
- Contextual categorization.
- Database
- Powered by PostgreSQL with pgvector for vector support.
- Supports semantic search through vector embeddings.
1. Semantic Product Search
When a user searches for a product:
-
Text to Vector Transformation:
The input string is converted into a vector using a Large Language Model (LLM) via Globant Enterprise AI.
-
Vector-Based Search:
The vector is compared against the ProductEmbedding column in PostgreSQL using cosine distance. This is facilitated by the pgvector extension.
#Rules
order(ProductEmbedding.Distance(&ProductEmbedding));
#End
#Events
Event Start
&SearchText = "I'm looking for something that is powered by electricity"
EndEvent
Event Refresh
&ProductEmbedding = ProductEmbedding.GenerateEmbedding(&SearchText,&Messages)
EndEvent
#End
2. Vector Definition in the data model and population using declarative programming
The ProductEmbedding field has been defined as an attribute of Embedding type in the Product transaction and stores vectors representing each record.
ProductEmbedding
[
DataType = 'Embedding'
]
Related Product Transaction rules:
ProductEmbedding = ProductEmbedding.GenerateEmbedding(format("Product: %1, Description: %2, Price: %3, Category: %4", ProductName, ProductDescription, ProductPrice.ToString(), CategoryName) ) on aftervalidate;
3. Default Product Description generation
When validating the Product Name, an AI Agent generates a default description via Globant Enterprise AI.
The agent's definition in GeneXus is as follows:
Agent ProductDescriber
{
Expand the product name "{{&ProductName}}" into a detailed product description of maximum 200 characters.
Return just the string with the suggested description.
#Rules
parm(in:&ProductName, out: &ProductDescription);
#End
}
Related Product Transaction rules:
call(ProductDescriber,ProductName, &ProductDescriberCallResult, &ProductDescription) if insert;
default(ProductDescription, &ProductDescription);
Similar to the description, the category is also generated by an AI Agent, which considers the product description and available categories.
Agent CategoryMatcher
{
Determine the best matching category for the product description: "{{&ProductDescription}}" using the provided categories: $context.
Return just the value of the Id of the category.
#Rules
parm(in:&ProductDescription, out: &MatchedCategory);
context(GetCategoryCollection());
#End
}
Related Product Transaction rules:
call(CategoryMatcher,&ProductDescription,&CategoryMatcherCallResult, &CategoryMatch ) if insert;
default(CategoryId, &CategoryMatch.ToNumeric());
GeneXus Next significantly expands the scope of business modeling by:
- Supporting AI Agents that unlock new, previously unthinkable scenarios.
- Enabling semantic searches with embeddings and vector databases.
In summary, GeneXus automates the end-to-end creation of a complete AI-powered application.