Skip to content

Commit d029d69

Browse files
committed
logic editor
1 parent d1a1bbe commit d029d69

File tree

6 files changed

+71
-18
lines changed

6 files changed

+71
-18
lines changed

docs/Architecture-Internals-BLT.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ If you don't wish to install or run the docker databases, edit your `tests/build
108108

109109
## Windows Issues
110110

111-
I was able to build in Windows (12/27/2024), with the following non-trivial provisos.
111+
I was able to build in Windows (12/27/2024), with the following issues.
112112

113113
### Path Length
114114

@@ -122,6 +122,4 @@ For many Windows installs, the path length exceeds the max.
122122

123123
* So, you can *build* on Windows, but you cannot *release*.
124124

125-
### Logging in genai_svcs
126125

127-
Recent changes (as of 12/27/2024) in logging in `api_logic_server_cli/genai/genai_svcs.py` must be commented out. This is a serious bug which must be addressed before we can release another version.

docs/Sample-Genai.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ To create a microservice, identify an existing database, or provide a natural la
2424

2525
Include a notes field for orders.
2626

27-
Use LogicBank to create declare_logic() to enforce the Check Credit requirement (do not generate check constraints):
27+
Enforce Check Credit:
2828
1. Customer.balance <= credit_limit
2929
2. Customer.balance = Sum(Order.amount_total where date_shipped is null)
3030
3. Order.amount_total = Sum(Item.amount)

docs/WebGenAI-logic-editor.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
!!! pied-piper ":bulb: TL;DR - Edit Logic in Natural Language"
2+
3+
Backend Logic is nearly half the effort in a transactional system. Instead of procedural code, WeGenAI provides declarative rules that are 40X more concise. They can be expressed in Python, or Natural Language as described here.
4+
5+
&nbsp;
6+
7+
## Overview: Adding Logic
8+
9+
It's usually a good idea to create your project with an initial focus on structure: tables, columns, relationships. As you review and iterate, you will likely want to introduce multi-table derivations and constraints.
10+
11+
You can use normal iterations, or the Logic Editor.
12+
13+
&nbsp;
14+
15+
### Using Iterations
16+
17+
You can iterate your project, and declare your logic:
18+
19+
```
20+
Enforce Check Credit:
21+
1. Customer.balance <= credit_limit
22+
2. Customer.balance = Sum(Order.amount_total where date_shipped is null)
23+
3. Order.amount_total = Sum(Item.amount)
24+
4. Item.amount = quantity * unit_price
25+
5. Store the Item.unit_price as a copy from Product.unit_price
26+
```
27+
28+
&nbsp;
29+
30+
### Using the Logic Editor
31+
32+
You can also the the Logic Editor:
33+
34+
![logic Editor](images/web_genai/logic/logic-editor.png)
35+
36+
Create logic by clicking **Rule Prompt**, or **Suggest**. For each element, you can **reject** or **accept**.
37+
38+
* When you accept, the system translates the logic prompt (Natural Language) into Code (a Logic Bank Rule expressed in Python), shown in back.
39+
40+
Errors shown in red. Correct errors in Natural Language using the **black icon button** by providing a new / altered prompt.
41+
42+
Logic may introduce new attributes. These must be added to the data model, using **Update Data Model**. When you run, this will update the database and test data.
43+
44+
&nbsp;
45+
46+
## Debugging Logic
47+
48+
Logic can fail to load at runtime. The system will
49+
50+
* restart the project with rules disabled, so you can still see your data. You should generally not update when logic is in error.
51+
52+
* report the errors back to the Logic Editor, where you can correct them.
53+
54+
Logic can also fail when you make an update. Review the log to see the state of the row(s) as each rule fires.

docs/WebGenAI.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
---
22
title: Web GenAI
3-
hide:
4-
- navigation
53
Description: Instantly Create and Run Database Projects - GenAI, Flask, APIs, SQLAlchemy, React Apps, Rules, Low-Code, Python, Docker, Azure, Web Apps, Microservice, Declarative
64
---
7-
<style>
8-
.md-typeset h1,
9-
.md-content__button {
10-
display: none;
11-
}
12-
</style>
13-
[![Downloads](https://static.pepy.tech/badge/apilogicserver)](https://pepy.tech/project/apilogicserver)
14-
[![Latest Version](https://img.shields.io/pypi/v/apilogicserver.svg)](https://pypi.python.org/pypi/apilogicserver/)
15-
[![Supported Python versions](https://img.shields.io/pypi/pyversions/apilogicserver.svg)](https://pypi.python.org/pypi/apilogicserver/)
165

176

18-
[![API Logic Server Intro](images/hero-banner-wg.png)](https://apifabric.ai/admin-app/ "Click to enter Web/GenAI site")
7+
!!! pied-piper ":bulb: WebGenAI - Web Interface for GenAI-Logic"
8+
9+
Access WebGenAI via your browser to
10+
11+
* Create systems from a Natural Language prompt: databases, APIs, an Admin Web App
12+
* Iterate them (add new tables, columns etc)
13+
* Add Logic
14+
* Download the project to your local desktop
15+
* Execute the project in GitHub Codespaces
1916

2017

2118
&nbsp;
@@ -147,7 +144,8 @@ Create a system with customers, orders, items and products.
147144

148145
Include a notes field for orders.
149146

150-
Use LogicBank to create declare_logic() to enforce the Check Credit requirement (do not generate check constraints):
147+
Use LogicBank to enforce the Check Credit:
148+
151149
1. Customer.balance <= credit_limit
152150
2. Customer.balance = Sum(Order.amount_total where date_shipped is null)
153151
3. Order.amount_total = Sum(Item.amount)
@@ -159,6 +157,8 @@ You can verify this by altering a sample order/item with a very high quantity, a
159157

160158
> Note: at the time of this writing, the sample data sometimes does not totally reflect the derivation rules. This is under investigation. You can sometimes resolve this using iterations, eg, `please initialize the customer balance properly`.
161159
160+
For more, see the [logic editor](WebGenAI-logic-editor.md){:target="_blank" rel="noopener"}.
161+
162162
&nbsp;
163163

164164
### Iterations
377 KB
Loading

mkdocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ theme:
1515
nav:
1616
- " ": index.md
1717
- GenAI:
18-
- "GenAI Website": WebGenAI.md
18+
- "WebGenAI Website": WebGenAI.md
19+
- "WebGenAI Logic Editor": WebGenAI-logic-editor.md
1920
- "GenAI CLI": WebGenAI-CLI.md
2021
- "Sample": Sample-Genai.md
2122
- Quick Start:

0 commit comments

Comments
 (0)