|
| 1 | +!!! pied-piper ":bulb: TL;DR - GENAI leverages AI for 'hands-free' project creation" |
| 2 | + |
| 3 | + ChatGPT APIs enable API Logic Server to submit prompts and obtain data model class responses. |
| 4 | + |
| 5 | + API Logic Server can use these to create databases and projects, from single command. |
| 6 | + |
| 7 | +## Project Creation |
| 8 | + |
| 9 | +You can explore genai using the [Manager](Manager.md){:target="_blank" rel="noopener"}. Optionally, you can sign-up for ChatGPT API and Copilot, or simulate the process as described below. |
| 10 | + |
| 11 | +1. If you have signed up for , this will create and open a project called `genai_demo` from `genai_demo.prompt`: |
| 12 | + |
| 13 | +```bash |
| 14 | +als genai --using=genai_demo.prompt |
| 15 | +``` |
| 16 | + |
| 17 | + |
| 18 | +2. ***Or,*** you can simulate the process using: |
| 19 | + |
| 20 | + |
| 21 | +```bash |
| 22 | +als genai --using=genai_demo.prompt --gen-using-file=system/genai/temp/chatgpt_retry.txt |
| 23 | +``` |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +## What Just Happened? |
| 28 | + |
| 29 | +`genai` processing is shown below (internal steps denoted in grey): |
| 30 | + |
| 31 | +1. You create your.prompt file, and invoke `als genai --using=your.prompt`. genai then creates your project as follows: |
| 32 | + |
| 33 | + a. Submits your prompt to the `ChatGPT API` |
| 34 | + |
| 35 | + b. Writes the response to file, so you can correct and retry if anything goes wrong |
| 36 | + |
| 37 | + c. Extracts model.py from the response |
| 38 | + |
| 39 | + d. Invokes `als create-from-model`, which creates the database and your project |
| 40 | + |
| 41 | +2. Your created project is opened in your IDE, ready to execute and customize |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | +] |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | +## AI somtimes fails - here's how to recover |
| 51 | + |
| 52 | +AI results are not consistent, so the model file may need corrections. You can find it at `system/genai/temp/model.py`. You can correct the model file, and then run: |
| 53 | + |
| 54 | +```bash |
| 55 | +als create --project-name=genai_demo --from-model=system/genai/temp/model.py --db-url=sqlite |
| 56 | +``` |
| 57 | + |
| 58 | +Or, correct the chatgpt response, and |
| 59 | + |
| 60 | +```bash |
| 61 | +als genai --using=genai_demo.prompt --gen-using-file=system/genai/temp/chatgpt_retry.txt |
| 62 | +``` |
| 63 | + |
| 64 | +We have seen failures such as: |
| 65 | + |
| 66 | +* duplicate definition of `DECIMAL` |
| 67 | +* use of `Decimal` vs. `DECIMAL` (latter required, work-around in place) |
| 68 | +* unclosed parentheses |
| 69 | +* data type errors in test data creation |
| 70 | +* wrong engine import: from logic_bank import Engine, constraint |
| 71 | +* bogus test data creation: with Engine() as engine... |
| 72 | +* Numeric --> String (fixed product bug) |
| 73 | +* Bad load code (no session) |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | +**Postgresql Example** |
| 79 | + |
| 80 | +You can test this as follows: |
| 81 | + |
| 82 | +1. Use [our docker image](Database-Docker.md){:target="_blank" rel="noopener"} |
| 83 | +2. And: |
| 84 | + |
| 85 | +```bash |
| 86 | +als create --project-name=genai_demo_pg.prompt --db-url=postgresql://postgres:p@localhost/genai_demo |
| 87 | +``` |
| 88 | + |
| 89 | +Provisos: |
| 90 | + |
| 91 | +* You have to create the database first |
0 commit comments