Skip to content

Commit 8d9c098

Browse files
committed
take ai out to the wood shed
1 parent 0b02f11 commit 8d9c098

File tree

1 file changed

+93
-3
lines changed

1 file changed

+93
-3
lines changed

docs/index.md

Lines changed: 93 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ Then, **1 command** creates the project (you can also create from an existing da
7070
als genai --using=genai_demo.prompt
7171
```
7272

73-
 
7473

7574
<details markdown>
7675

@@ -88,19 +87,110 @@ The system creates the database, and an executable project providing API and App
8887

8988
You can then **customize the project with Python in your IDE.** Create executable **spreadsheet-like rules** from our prompt - 40X more concise than code. Use Python to extend the rules (e.g, to send a Kafka message), and use the framework to create a custom endpoint:
9089

90+
<details markdown>
91+
92+
<summary>Customize the Logic and API</summary>
93+
9194
![Flexibility of a Framework](images/sample-ai/copilot/customize.png)
9295

96+
</details>
97+
9398
&nbsp;
9499

95100
# Pick Up Where Others Leave Off
96101

97102
API Logic Server **differentiates** from traditional approaches:
98103

104+
* Unlike Frameworks, API Logic Servers preserves full flexibility and standard Dev Tools, with **automation** to eliminate weeks-to-months of complex development.
105+
106+
* Unlike Low Code, API Logic Server provides **logic automation,** and preserves the **framework flexibility.**
107+
108+
* For systems providing update, logic automation is critical. It's nearly half the effort. The promise of Low Code *requires logic automation.*
109+
99110
* Unlike basic GenAI, API Logic Server creates systems from prompts **at the business level**, instead of low-level framework details.
100111

101-
* Unlike frameworks, API Logic Servers preserves full flexibility and standard Dev Tools, with **automation** to eliminate weeks-to-months of complex development.
112+
<details markdown>
113+
114+
<summary>Comparing GenAI with GenAI Automation</summary>
115+
116+
As noted above, nearly half the effort in a system is the logic. GenAI provides a simple way to create databases, but does not provide the automation to create the logic.
117+
118+
In most cases, AI responses simply ignore the logic requirement. Attempts to address it fall in 2 categories: triggers and Logic Bank code.
119+
120+
&nbsp;
121+
122+
**Triggers**
123+
124+
&nbsp;
125+
126+
The trigger solution typically looks something like this:
127+
128+
```sql
129+
-- Note: The enforcement of the Check Credit requirement is complex and might be better handled in application logic.
130+
-- However, you can create a stored procedure or use triggers to enforce these rules, keeping in mind the performance implications.
131+
132+
-- Example of a trigger to enforce Customer.balance <= credit_limit (simplified version)
133+
DELIMITER //
134+
CREATE TRIGGER CheckCreditBeforeCustomerUpdate
135+
BEFORE UPDATE ON Customers
136+
FOR EACH ROW
137+
BEGIN
138+
IF NEW.Balance > NEW.Credit_Limit THEN
139+
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Customer balance exceeds credit limit.';
140+
END IF;
141+
END;
142+
//
143+
DELIMITER ;
144+
```
145+
146+
This is simply not a solution: it does not address the triggering event - some change to the order. By contrast, our logic automates about a dozen Use Cases, including:
102147

103-
* Unlike Low Code, API Logic Server provides **logic automation,** and preserves the **framework flexibility.**
148+
* Customer balance is adjusted when the order is inserted, deleted, shipped, or re-assigned.
149+
150+
* The orders is adjusted when items are inserted, deleted, or updated with new quantities or different products.
151+
152+
Addressing this level of logic is why rules are 40X more concise than code.
153+
154+
155+
&nbsp;
156+
157+
**Logic Bank Code**
158+
159+
&nbsp;
160+
161+
If we engineer prompt to suggest using Logic Bank (a component of API Logic Server), we get a response like this:
162+
163+
```python
164+
def declare_logic():
165+
LogicBank.activate(session=session, activator=logic_bank_util.register_rules)
166+
167+
@LogicBank.rule("order", "before_flush")
168+
def order_amount_total(row: LogicRow):
169+
row.amount_total = sum([item.quantity * item.unit_price for item in row.items])
170+
171+
@LogicBank.rule("customer", "before_flush")
172+
def customer_balance(row: LogicRow):
173+
row.balance = sum([order.amount_total for order in row.orders if order.date_shipped is None])
174+
175+
@LogicBank.rule("item", "before_flush")
176+
def item_amount(row: LogicRow):
177+
row.amount = row.quantity * row.unit_price
178+
179+
@LogicBank.rule("item", "before_flush")
180+
def copy_unit_price_from_product(row: LogicRow):
181+
row.unit_price = row.product.unit_price
182+
183+
@LogicBank.rule("customer", "before_flush")
184+
def check_credit_limit(row: LogicRow):
185+
if row.balance > row.credit_limit:
186+
raise Exception(f"Customer {row.name}'s balance exceeds their credit limit.")
187+
```
188+
189+
This code does not use Logic Bank APIs. It does not even compile, much less run.
190+
191+
</details>
192+
193+
&nbsp;
104194

105195
# Video - 1 minute
106196

0 commit comments

Comments
 (0)