You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a system with customers, orders, items and products.
122
+
123
+
Include a notes field for orders.
124
+
125
+
Use LogicBank to enforce the Check Credit requirement:
126
+
1. Customer.balance <= credit_limit
127
+
2. Customer.balance = Sum(Order.amount_total where date_shipped is null)
128
+
3. Order.amount_total = Sum(Item.amount)
129
+
4. Item.amount = quantity * unit_price
130
+
5. Store the Item.unit_price as a copy from Product.unit_price
131
+
```
132
+
133
+
134
+
135
+
#### Informal Rules
136
+
137
+
You can also use a more relaxed declaration. For example, you can create a system (database, API, Admin App and Logic) with the following prompt (see `system/genai/examples/genai_demo/genai_demo_informal.prompt`):
138
+
139
+
```bash title='Prompt With Informal Logic'
140
+
Create a system with customers, orders, items and products.
141
+
142
+
Include a notes field for orders.
143
+
144
+
Use LogicBank to enforce the Check Credit requirement:
145
+
1. The Customer's balance is less than the credit limit
146
+
2. The Customer's balance is the sum of the Order amount_total where date_shipped is null
147
+
3. The Order's amount_total is the sum of the Item amount
148
+
4. The Item amount is the quantity * unit_price
149
+
5. The Item unit_price is copied from the Product unit_price
150
+
```
151
+
152
+
153
+
154
+
#### Multi-rule Logic
155
+
156
+
You can even declare logic that is transformed into 2 rules:
157
+
158
+
```bash title='Prompt with Multi-Rule Logic'
159
+
System for Departments and Employees.
160
+
161
+
LogicBank:
162
+
1. Sum of employee salaries cannot exceed department budget
163
+
```
164
+
165
+
This creates a running system: a database, an API, an Admin App, and logic. From the Manager:
166
+
167
+
```bash title='CLI Command to Create a microservice, with logic'
168
+
als genai --using=system/genai/examples/emp_depts/emp_dept.prompt
169
+
```
170
+
171
+
The logic is non-trivial:
172
+
173
+
1. A `Department.total_salaries` is created
174
+
2. Two rules are created in `logic/declare_logic.py`
175
+
176
+
```python title='Logic Creates 2 Rules'
177
+
# Logic from GenAI: (or, use your IDE w/ code completion)
178
+
179
+
# Aggregate the total salaries of employees for each department.
0 commit comments