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
Copy file name to clipboardExpand all lines: docs/Sample-Genai.md
+74-54Lines changed: 74 additions & 54 deletions
Original file line number
Diff line number
Diff line change
@@ -1,68 +1,34 @@
1
1
!!! pied-piper ":bulb: TL;DR - GenAI leverages AI and Microservice Automation for 'hands-free' project creation"
2
2
3
-
API Logic Server uses ChatGPT APIs, to submit prompts and obtain data model class responses.
3
+
To create projects, the system (either WebGenAI or API Logic Server CLI - for more information, [click here](https://apilogicserver.github.io/Docs/Architecture-What-Is/){:target="_blank" rel="noopener"}) performs the following:
4
4
5
-
API Logic Server uses these to create a database and project, from a single `genai` command.
6
-
7
-
This document illustrates how to create, run and customize the genai_demo project.
8
-
9
-
> Note: if you have already created the project, proceed to "What Just Happened?".
To create a microservice, identify an existing database, or provide a natural language "prompt" description. For example, here is the `genai_demo.prompt` file:
20
-
21
-
!!! pied-piper ":bulb: TL;DR - GenAI Prompt"
22
-
23
-
Create a system with customers, orders, items and products.
5
+
1. Uses ChatGPT APIs to submit prompts and obtain data model class responses
6
+
7
+
2. It then uses these to create a database and project
24
8
25
-
Include a notes field for orders.
9
+
This document presumes you have already created the project, and are using VSCode or GitHub to explore it. It illustrates how to run and customize the genai_demo project.
26
10
27
-
Enforce Check Credit:
28
-
1. Customer.balance <= credit_limit
29
-
2. Customer.balance = Sum(Order.amount_total where date_shipped is null)
30
-
3. Order.amount_total = Sum(Item.amount)
31
-
4. Item.amount = quantity * unit_price
32
-
5. Store the Item.unit_price as a copy from Product.unit_price
11
+
> Note: if you *not* already created the project, proceed to [the Appendix](#creating-the-genai_demo-project)
33
12
34
13
35
14
36
-
## 2. GenAI Creation
37
-
38
-
You can explore genai_demo using the [Manager](https://apilogicserver.github.io/Docs/Manager/){:target="_blank" rel="noopener"}. Optionally, you can sign-up for ChatGPT API and Copilot, or simulate the process as described below.
39
-
40
-
1. If you have signed up for ChatGPT API and Copilot, this command will create and open a project called `genai_demo` from `genai_demo.prompt`:
41
-
42
-
```bash
43
-
als genai --using=genai_demo.prompt
44
-
```
15
+
## Setup Codespaces
45
16
46
-
47
-
2.***Or,*** if you have not signed up, you can simulate the process using a pre-installed response file:
48
-
49
-
```bash
50
-
als genai --using=genai_demo.prompt --gen-using-file=system/genai/temp/chatgpt_retry.txt
51
-
```
17
+
Coming soon.
52
18
53
19
54
20
55
-
###What Just Happened?
21
+
## What Just Happened?
56
22
57
23
`genai` processing is shown below (internal steps denoted in grey):
58
24
59
25
1. You create your.prompt file, and invoke `als genai --using=your.prompt`. genai then creates your database and project as follows:
60
26
61
27
a. Submits your prompt to the `ChatGPT API`
62
28
63
-
b. Writes the response to file, so you can correct and retry if anything goes wrong
29
+
b. Writes the response to file (`system/genai/temp/response.json`), so you can correct and retry if anything goes wrong
64
30
65
-
c. Extracts model.py from the response
31
+
c. Extracts `system/genai/temp/create_db_models.py` from the response
66
32
67
33
d. Invokes `als create-from-model`, which creates the database and your project
68
34
@@ -74,25 +40,23 @@ als genai --using=genai_demo.prompt --gen-using-file=system/genai/temp/chatgpt_r
74
40
75
41
76
42
77
-
###API/App Automation
43
+
##1. API/App Automation
78
44
79
45
API/App Automation means the created project is executable. To run:
80
46
81
47
1. Press **F5** to run
82
-
2. Start your [Browser](http://localhost:5656/) to view:
48
+
2. Start your Browser (use the codespaces button, or [locally](http://localhost:5656/)) to view:
83
49
* App Automation: the Admin App, and
84
50
* API Automation: JSON:API, with Swagger
85
51
3. Stop the server when you are done (red box on VSCode Debugger panel)
It's a modern, 3-tiered architecture, using standard Python libraries. For more information, [click here - slide 2](https://www.genai-logic.com/architecture).
56
+
93
57
94
58
95
-
## 3. Customize: Rules and Python
59
+
## 2. Customize: Rules and Python
96
60
97
61
The development environment is also standard: your IDE, standard languages, standard libraries, standard source control, etc. You customize API Logic Project in two ways, both performed in your IDE:
98
62
@@ -144,7 +108,7 @@ Note: Kafka is not activated in this example. To explore a running Tutorial for
144
108
145
109
146
110
147
-
## 4. Deployment: Containers, Cloud
111
+
## 3. Deployment: Containers, Cloud
148
112
149
113
One of the best ways to de-risk projects is to verify the sponsors are in sync with what is happening. This is best addressed with *working software*, which often occurs late in project development. Surprises here can result in considerable rework... and frustrations.
150
114
@@ -210,6 +174,62 @@ It's usage create the sqlite database, but running it in this mode can provide m
210
174
211
175
If you are using [Web/GenAI](WebGenAI.md){:target="_blank" rel="noopener"}, project files are always under /projects/gen_$ID.
To create a microservice, identify an existing database, or provide a natural language "prompt" description.
193
+
194
+
You can explore genai_demo using the [Manager](https://apilogicserver.github.io/Docs/Manager/){:target="_blank" rel="noopener"}. Optionally, you can sign-up for ChatGPT API and Copilot, or simulate the process as described below.
195
+
196
+
1. If you have signed up for ChatGPT API and Copilot, this command will create and open a project called `genai_demo` from `system/genai/examples/genai_demo/genai_demo.prompt`:
197
+
198
+
```bash
199
+
als genai --using=system/genai/examples/genai_demo/genai_demo.prompt
200
+
```
201
+
202
+
203
+
2.***Or,*** if you have not signed up, you can simulate the process using a pre-installed response file:
204
+
205
+
```bash
206
+
als genai --using=genai_demo.prompt --gen-using-file=system/genai/temp/chatgpt_retry.txt
207
+
```
208
+
209
+
Here is the `system/genai/examples/genai_demo/genai_demo.prompt` file:
210
+
211
+
!!! pied-piper ":bulb: TL;DR - GenAI Prompt"
212
+
213
+
Create a system with customers, orders, items and products.
214
+
215
+
Include a notes field for orders.
216
+
217
+
Use LogicBank to enforce business logic.
218
+
219
+
Use case: Check Credit
220
+
1. The Customer's balance is less than the credit limit
221
+
2. The Customer's balance is the sum of the Order amount_total where date_shipped is null
222
+
3. The Order's amount_total is the sum of the Item amount
223
+
4. The Item amount is the quantity * unit_price
224
+
5. The Item unit_price is copied from the Product unit_price
225
+
226
+
Ensure each customer has a unique name.
227
+
228
+
Ensure each Item quantity is not null.
229
+
230
+
Ensure each order has a valid customer_id that exists in the Customer table.
0 commit comments