ApiLogicServer 14.5.17__py3-none-any.whl → 15.0.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. api_logic_server_cli/add_cust/add_cust.py +8 -2
  2. api_logic_server_cli/api_logic_server.py +3 -2
  3. api_logic_server_cli/api_logic_server_info.yaml +3 -3
  4. api_logic_server_cli/create_from_model/__pycache__/dbml.cpython-312.pyc +0 -0
  5. api_logic_server_cli/create_from_model/dbml.py +1 -0
  6. api_logic_server_cli/genai/genai_svcs.py +5 -2
  7. api_logic_server_cli/prototypes/base/api/api_discovery/mcp_discovery.py +63 -24
  8. api_logic_server_cli/prototypes/base/config/logging.yml +5 -0
  9. api_logic_server_cli/prototypes/base/config/server_setup.py +73 -0
  10. api_logic_server_cli/prototypes/base/integration/mcp/examples/mcp_discovery_response.json +150 -0
  11. api_logic_server_cli/prototypes/base/integration/mcp/examples/mcp_request.prompt +46 -0
  12. api_logic_server_cli/prototypes/base/integration/mcp/examples/mcp_tool_context_response.json +34 -0
  13. api_logic_server_cli/prototypes/base/integration/mcp/examples/mcp_tool_context_response_get.json +18 -0
  14. api_logic_server_cli/prototypes/base/integration/mcp/mcp_client_executor.py +129 -275
  15. api_logic_server_cli/prototypes/basic_demo/customizations/logic/logic_discovery/email_request.py +2 -0
  16. api_logic_server_cli/prototypes/basic_demo/customizations/logic/logic_discovery/mcp_client_executor_request.py +15 -288
  17. api_logic_server_cli/prototypes/basic_demo/customizations/ui/admin/admin.yaml +3 -3
  18. api_logic_server_cli/prototypes/basic_demo/customizations/ui/admin/home.js +48 -0
  19. api_logic_server_cli/prototypes/manager/{REAMDE.md → README.md} +30 -2
  20. api_logic_server_cli/prototypes/manager/system/genai/mcp_learning/mcp.prompt +12 -0
  21. {apilogicserver-14.5.17.dist-info → apilogicserver-15.0.9.dist-info}/METADATA +3 -3
  22. {apilogicserver-14.5.17.dist-info → apilogicserver-15.0.9.dist-info}/RECORD +27 -34
  23. api_logic_server_cli/prototypes/base/integration/mcp/README_mcp.md +0 -15
  24. api_logic_server_cli/prototypes/base/integration/mcp/test_notes.txt +0 -37
  25. api_logic_server_cli/prototypes/basic_demo/customizations/api/api_discovery/mcp_discovery.py +0 -96
  26. api_logic_server_cli/prototypes/basic_demo/customizations/config/server_setup.py +0 -388
  27. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/.DS_Store +0 -0
  28. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/README_mcp.md +0 -15
  29. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/Zmcp_client_executor.py +0 -294
  30. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/mcp_schema.txt +0 -47
  31. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/mcp_server_discovery.json +0 -9
  32. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/mcp_tool_context.json +0 -25
  33. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/test_notes.txt +0 -37
  34. api_logic_server_cli/prototypes/manager/READMEz.md +0 -667
  35. /api_logic_server_cli/prototypes/base/integration/mcp/{mcp_schema.txt → examples/mcp_schema.txt} +0 -0
  36. {apilogicserver-14.5.17.dist-info → apilogicserver-15.0.9.dist-info}/WHEEL +0 -0
  37. {apilogicserver-14.5.17.dist-info → apilogicserver-15.0.9.dist-info}/entry_points.txt +0 -0
  38. {apilogicserver-14.5.17.dist-info → apilogicserver-15.0.9.dist-info}/licenses/LICENSE +0 -0
  39. {apilogicserver-14.5.17.dist-info → apilogicserver-15.0.9.dist-info}/top_level.txt +0 -0
@@ -1,667 +0,0 @@
1
- ---
2
- version info: 2.0 (05/24/2025)
3
- ---
4
- ## Welcome to GenAI-Logic
5
-
6
- 1. ***Instant microservices*** (APIs and Admin Apps) from a database or **GenAI prompt** -- 1 command
7
-
8
- 2. ***Customize*** with **Rules** and Python in your IDE: created projects use standard Python libraries (Flask, SQLAlchemy)
9
-
10
- </br>
11
-
12
- You are in the [API Logic Server Manager](https://apilogicserver.github.io/Docs/Manager/). This is a good place to manage projects, create notes and resources, etc.
13
-
14
- <details markdown>
15
-
16
- <summary>How to Run Projects from the Manager </summary>
17
-
18
- <br>You typically run projects by opening an IDE on the project folder, using provided Run Configurations.
19
-
20
- For a quick preview, you can also run from the Manager; there are 2 ways:
21
-
22
- 1. Use ***another instance of VSCode.*** You can *examine* them in this current instance, but *run* them in their own instance.
23
-
24
- * To do so, you probably want to acquire this extension: `Open Folder Context Menus for VS Code`. It will enable you to open the sample, tutorial or your own projects in another instance of VSCode.
25
-
26
- * This option provides more Run/Debug options (e.g., run without security, etc),
27
-
28
- 2. Or, use the Run/Debug Entry: `API Logic Server Run (run project from manager)`
29
-
30
- </details>
31
- </br>
32
-
33
- <details markdown>
34
-
35
- <summary>How API Logic Server provides GenAI Microservice Automation </summary>
36
-
37
- &nbsp;
38
-
39
- ## Using GenAI Microservice Automation
40
-
41
- Use the CLI (Command Language Interface, in your IDE) to create projects from either existing databases, or GenAI prompts. This creates a project you can open, run and customize in your IDE.
42
-
43
- [![GenAI Automation](https://github.com/ApiLogicServer/Docs/blob/main/docs/images/sample-ai/copilot/genai-automation-video.png?raw=true)](https://www.youtube.com/watch?v=LSh7mqGiT0k&t=5s "Microservice Automation")
44
-
45
- &nbsp;
46
-
47
- ## What Is API Logic Server
48
-
49
- It's an open source Python project consisting of a CLI to create projects, and runtime libraries to execute them.
50
-
51
- [![Architecture](https://github.com/ApiLogicServer/Docs/blob/main/docs/images/Architecture-What-Is.png?raw=true)](https://apilogicserver.github.io/Docs/Architecture-What-Is/#runtimes-and-cli)
52
-
53
- &nbsp;
54
-
55
- ## Modern Scalable Runtime Architecture
56
-
57
- Created projects use standard Flask and SQLAlchemy; automation is provided by Logic Bank (the rule engine) and SAFRS (JSON:APIs). Scripts are provided to containerize projects, and deploy to Azure.
58
-
59
- [![Architecture - Runtime](https://github.com/ApiLogicServer/Docs/blob/main/docs/images/Architecture-Runtime-Stack.png?raw=true)](https://apilogicserver.github.io/Docs/Architecture-What-Is/#key-runtime-components)
60
-
61
- &nbsp;
62
-
63
- </details>
64
-
65
- &nbsp;
66
-
67
- ## Explore Creating Projects
68
-
69
- **Evaluation Guide:** click on the disclosure buttons, below. Important: look for **readme files.**
70
- </br>
71
-
72
- <details markdown>
73
-
74
- <summary> 1. Existing Database - pre-installed sample databases </summary>
75
-
76
- <br>For a self-demo, use the CLI (**Terminal > New Terminal**), and try the pre-installed [**Basic Demo**](https://apilogicserver.github.io/Docs/Sample-Basic-Demo/):
77
-
78
- ```
79
- als create --project-name=basic_demo --db-url=basic_demo
80
- ```
81
-
82
- <br>The basic_demo project provides:
83
- 1. A quick look at logic, security and integration
84
- 2. Integration includes Kafka and MCP (**[Model Context Protocol](https://apilogicserver.github.io/Docs/Integration-MCP/)**)
85
-
86
- <br>To create a larger project, try the pre-installed [**northwind database**](https://apilogicserver.github.io/Docs/Tutorial/) (imagine your own database here):
87
-
88
- ```
89
- als create --project-name=nw_sample_nocust --db-url=sqlite:///nw.sqlite
90
- ```
91
-
92
- <br>See **with customizations** in the [pre-created sample apps](#explore-pre-created-samples). This is an **important learning resource**.
93
-
94
- Then, try your own databases [(db-url examples here)](https://apilogicserver.github.io/Docs/Database-Connectivity/), or experiment with [these Docker databases](https://apilogicserver.github.io/Docs/Database-Docker/).
95
-
96
- </details>
97
- </br>
98
-
99
- <details markdown>
100
-
101
- <summary> 2. New Database - using GenAI Microservice Automation (Experiment with AI - Signup optional)</summary>
102
-
103
- <br>You can do this with or without signup:
104
-
105
- 1. If you have signed up (see *To obtain a ChatGPT API Key*, below), this will create a new database and project called `genai_demo`, and open the project. It's created using `genai_demo.prompt`, visible in left Explorer pane:
106
-
107
- ```bash
108
- als genai --using=system/genai/examples/genai_demo/genai_demo.prompt --project-name=genai_demo
109
- ```
110
-
111
-
112
- 2. ***Or,*** you can simulate the process (no signup) using:
113
-
114
-
115
- ```bash
116
- als genai --repaired-response=system/genai/examples/genai_demo/genai_demo.response_example --project-name=genai_demo
117
- ```
118
-
119
- Verify it's operating properly:
120
-
121
- 1. Run Configurations are provided to start the server
122
- 2. Verify the logic by navigating to a Customer with an unshipped order, and altering one of the items to have a very large quantity
123
- 3. Observe the constraint operating on the rollup of order amount_totals.
124
- * View the logic in `logic/declare_logic.py`
125
- * Put a breakpoint on the `as_condition`. Observe the console log to see rule execution for this multi-table transaction.
126
-
127
- </br>
128
-
129
-
130
- <details markdown>
131
-
132
- <summary> To obtain a ChatGPT API Key</summary>
133
-
134
- <br>GenAI-Logic uses OpenAI, which requires an Open API Key:
135
-
136
- 1. Obtain one from [here](https://platform.openai.com/account/api-keys) or [here](https://platform.openai.com/api-keys)
137
- 2. Authorize payments [here](https://platform.openai.com/settings/organization/billing/overview)
138
-
139
- </details>
140
-
141
- </br>
142
-
143
- <details markdown>
144
-
145
- <summary> What Just Happened? &nbsp;&nbsp;&nbsp;Next Steps...</summary>
146
-
147
- <br>`genai` processing is shown below (internal steps denoted in grey):
148
-
149
- 1. You create your.prompt file, and invoke `als genai --using=your.prompt`. genai then creates your project as follows:
150
-
151
- a. Submits your prompt to the `ChatGPT API`
152
-
153
- b. Writes the response to file, so you can correct and retry if anything goes wrong
154
-
155
- c. Extracts model.py from the response
156
-
157
- d. Invokes `als create-from-model`, which creates the database and your project
158
-
159
- 2. Your created project is opened in your IDE, ready to execute and customize.
160
-
161
- a. Review `Tutorial.md`, Explore Customizations.
162
-
163
- ![GenAI Automation](system/images/genai.png)
164
-
165
- </details>
166
- </br>
167
-
168
- <details markdown>
169
-
170
- <summary> You can iterate the logic and data model</summary>
171
-
172
- <br>The approach for an iteration is to create a new project from an existing one:
173
-
174
- 1. add another prompt to an existing projects `docs` directory, specifying your changes
175
- 2. use `als genai`, specifying
176
- * `--using` existing projects `docs` directory, and
177
- * `--project-name` as the output project
178
-
179
- **Logic iterations** are particuarly useful. For example, here we take the basic check-credit logic, and add:
180
-
181
- > Provide a 10% discount when buying more than 10 carbon neutral products.<br><br>The Item carbon neutral is copied from the Product carbon neutral
182
-
183
- Explore [genai_demo_iteration_discount](system/genai/examples/genai_demo/genai_demo_iteration_discount). It's an iteration of basic_demo (see system/genai/examples/genai_demo/genai_demo_iteration_discount/002_create_db_models.prompt). This will add carbon_neutral to the data model, and update the logic to provide the discount:
184
-
185
- ```bash title='Iterate Business Logic'
186
- # Iterate with data model and logic
187
- als genai --project-name='genai_demo_with_discount' --using=system/genai/examples/genai_demo/genai_demo_iteration_discount
188
- # open Docs/db.dbml
189
- ```
190
-
191
- <br>
192
-
193
- You can perform **model iterations:** add new columns/tables, while keeping the prior model intact. First, we create a project with no logic, perhaps just to see the screens (this step is optional, provided just to illustrate that iterations create new projects from existing ones):
194
-
195
- ```bash title='Iterate Without Logic'
196
- # Step 1 - create without logic
197
- als genai --project-name='genai_demo_no_logic' --using=system/genai/examples/genai_demo/genai_demo_no_logic.prompt
198
- # open Docs/db.dbml
199
- ```
200
-
201
- Then, we would create another prompt in the docs directory with our model changes. We've already created these for you in `system/genai/examples/genai_demo/genai_demo_iteration` - we use that to alter the data model (see `system/genai/examples/genai_demo/genai_demo_iteration/004_iteration_renames_logic.prompt`):
202
-
203
- ```bash title='Iterate With Logic'
204
- # Iterate with data model and logic
205
- als genai --project-name='genai_demo_with_logic' --using=system/genai/examples/genai_demo/genai_demo_iteration
206
- # open Docs/db.dbml
207
- ```
208
-
209
- Explore [genai_demo_iteration](system/genai/examples/genai_demo/genai_demo_iteration) - observe the `--using` is a *directory* of prompts. These include the prompts from the first example, plus an *iteration prompt* (`004_iteration_renames_logic.prompt`) to rename tables and add logic.
210
-
211
-
212
- </details>
213
- </br>
214
-
215
- <details markdown>
216
-
217
- <summary> You can declare informal logic</summary>
218
-
219
- <br>You can declare rules using dot notation, or more informally:
220
-
221
- ```bash title="Informal Logic (no dot notation)"
222
- als genai --using=system/genai/examples/genai_demo/genai_demo_informal.prompt --project-name=genai_demo_informal
223
- ```
224
- </details>
225
- </br>
226
-
227
-
228
- <details markdown>
229
-
230
- <summary> Multi-Rule Logic</summary>
231
-
232
- <br>You can add new columns/tables, while keeping the prior model intact:
233
-
234
- ```bash title="Multi-Rule Logic"
235
- als genai --using=system/genai/examples/emp_depts/emp_dept.prompt
236
- ```
237
- </details>
238
- </br>
239
-
240
- <details markdown>
241
-
242
- <summary> You can ask AI to suggest logic (great way to learn!)</summary>
243
-
244
- <br>You can create a project, and ask GenAI for logic suggestions:
245
-
246
- ```bash title='1. Create Project, without Rules'
247
- # 1. Create Project, without Rules
248
- als genai --project-name='genai_demo_no_logic' --using=system/genai/examples/genai_demo/genai_demo_no_logic.prompt
249
- ```
250
-
251
- ```bash title="2. Request Rule Suggestions"
252
- # 2. Request Rule Suggestions
253
- cd genai_demo_no_logic
254
- als genai-logic --suggest
255
- ```
256
-
257
- You can review the [resultant logic suggestions](genai_demo_no_logic/docs/logic_suggestions) in the `genai_demo_no_logic` project:
258
-
259
- * See and edit: `docs/logic_suggestions/002_logic_suggestions.prompt` (used in step 3, below)
260
- * This corresponds to the Logic Editor - Logic View in the WebGenAI web app
261
-
262
- ```bash title="3. See the rules for the logic"
263
- # 3. See the rule code for the logic
264
- als genai-logic --suggest --logic='*'
265
- ```
266
-
267
- Important notes about suggestions and generated code:
268
- * `--suggest --logic='*'` is intended to enable you to identify logic that does not translate into proper code
269
- * The example above was pretty good, but sometimes the results are downright silly:
270
- * Just run suggest again, or
271
- * Repair `docs/logic_suggestions/002_logic_suggestions.prompt`
272
-
273
- Also...
274
- * It is not advised to paste the code into `logic/declare_logic.py`
275
- * The suggested logic may result in new data model attributes
276
- * These are created automatically by running `als genai` (next step)
277
-
278
- The [logic suggestions directory](genai_demo_no_logic/docs/logic_suggestions) now contains the prompts to create a new project with the suggested logic.
279
- When you are ready to proceed:
280
- 1. Execute the following to create a *new project* (iteration), with suggested logic:
281
-
282
- ```bash title="4. Create a new project with the Rule Suggestions"
283
- # 4. Create a new project with the Rule Suggestions
284
- cd .. # important - back to manager root dir
285
- als genai --project-name='genai_demo_with_logic' --using=genai_demo_no_logic/docs/logic_suggestions
286
- ```
287
-
288
- Observe:
289
- 1. The created project has the rule suggestions in `logic/declare_logic.py`
290
- 2. A revised Data Model in `database/models.py` that includes attributes introduced by the logic suggestions
291
- 3. Revised test database, initialized to reflect the derivations in the suggested logic
292
-
293
- Internal Note: this sequence available in the run configs (s1/s4).
294
-
295
- </details>
296
-
297
- </br>
298
-
299
- <details markdown>
300
-
301
- <summary>Fixup - update data model with new attributes from rules</summary>
302
-
303
- <br>Fixes project issues by updating the Data Model and Test Data:
304
- when adding rules, such as using suggestions, you may introduce new attributes.
305
- If these are missing, you will see exceptions when you start your project.
306
-
307
- The `genai-utils --fixup` fixes such project issues by updating the Data Model and Test Data:
308
-
309
- 1. Collects the latest model, rules, and test data from the project.
310
- 2. Calls ChatGPT (or similar) to resolve missing columns or data in the project.
311
- 3. Saves the fixup request/response under a 'fixup' folder.
312
- 4. You then use this to create a new project
313
-
314
- ***Setup***
315
-
316
- After starting the [Manager](https://apilogicserver.github.io/Docs/Manager):
317
-
318
- ```bash title="0. Create Project Requiring Fixup"
319
- # 0. Create a project requiring fixup
320
- als genai --repaired-response=system/genai/examples/genai_demo/genai_demo_fixup_required.json --project-name=genai_demo_fixup_required
321
- ```
322
-
323
- If you run this project, you will observe that it fails with:
324
- ```bash
325
- Logic Bank Activation Error -- see https://apilogicserver.github.io/Docs/WebGenAI-CLI/#recovery-options
326
- Invalid Rules: [AttributeError("type object 'Customer' has no attribute 'balance'")]
327
- Missing Attrs (try als genai-utils --fixup): ['Customer.balance: constraint']
328
- ```
329
- &nbsp;
330
-
331
- ***Fixup***
332
-
333
- To Fix it:
334
- ```bash title="1. Run FixUp to add missing attributes to the fixup response data model"
335
- # 1. Run FixUp to add missing attributes to the data model
336
- cd genai_demo_fixup_required
337
- als genai-utils --fixup
338
- ```
339
-
340
- Finally, use the created [fixup files](genai_demo_fixup_required/docs/fixup/) to rebuild the project:
341
- ```bash title="2. Rebuild the project from the fixup response data model"
342
- # 2. Rebuild the project from the fixup response data model
343
- cd ../
344
- als genai --repaired-response=genai_demo_fixup_required/docs/fixup/response_fixup.json --project-name=fixed_project
345
- ```
346
-
347
- &nbsp;
348
- The created project may still report some attributes as missing.
349
- (ChatGPT seems to often miss attributes mentioned in sum/count where clauses.) To fix:
350
-
351
- 1. Note the missing attributes(s) from the log
352
- 2. Add them to `docs/003_suggest.prompt`
353
- 3. Rebuild the project: `als genai --project-name='genai_demo_with_logic' --using=genai_demo_no_logic/docs`
354
-
355
-
356
- Internal Note: this sequence available in the run configs (f1/f2).
357
-
358
- </details>
359
-
360
-
361
- </br>
362
-
363
- <details markdown>
364
-
365
- <summary>Create from WebGenAI, and import (merge) subsequent changes</summary>
366
-
367
- <br>You can use [WebGenAI](https://apilogicserver.github.io/Docs/WebGenAI/) to create a project, and export it.
368
-
369
- You (or colleagues) can make changes to both the WebGenAI project (on the web), and your downloaded project. You can import the WebGenAI project, and the system will merge changes to the data model and rules automatically.
370
-
371
- This is possible since the logic is declarative, so ordering is automatic. This eliminates the troublesome merge issues so prevalent in procedural code. For more on import, [click here](https://apilogicserver.github.io/Docs/IDE-Import-WebGenAI/).
372
-
373
- The Manager pre-installs a sample project you can use to explore import:
374
-
375
- ```bash
376
- cd system/genai/examples/genai_demo/wg_dev_merge/dev_demo_no_logic_fixed
377
- als genai-utils --import-genai --using=../wg_demo_no_logic_fixed
378
- ```
379
- Observe:
380
- 1. The [data model](system/genai/examples/genai_demo/wg_dev_merge/dev_demo_no_logic_fixed/database) contains `Customer.balance` and `Product.carbon_neutral`
381
- 2. The test data has been updated to include these attributes, with proper values
382
-
383
- </details>
384
-
385
- </br>
386
-
387
- <details markdown>
388
-
389
- <summary>Rebuild the test data</summary>
390
-
391
- <br>Fixes project issues by rebuilding the database to conform to the derivation rules:
392
-
393
- 1. Create genai_demo:
394
- ```
395
- als genai --using=system/genai/examples/genai_demo/genai_demo.prompt --project-name=genai_demo
396
- ```
397
- 2. Rebuild:
398
- ```
399
- cd genai_demo
400
- als genai-utils --rebuild-test-data
401
- ```
402
-
403
- </details>
404
- </br>
405
-
406
- <details markdown>
407
-
408
- <summary> You can also execute directly, and iterate</summary>
409
-
410
- <br>You can add new columns/tables, while keeping the prior model intact:
411
-
412
- ```bash title="Iterate"
413
- # create project without creating a file...
414
- als genai-create --project-name='customer_orders' --using='customer orders'
415
-
416
- als genai-iterate --using='add Order Details and Products'
417
- # open Docs/db.dbml
418
- ```
419
-
420
- </details>
421
- </br>
422
-
423
- <details markdown>
424
-
425
- <summary> AI somtimes fails - here's how to recover</summary>
426
-
427
- <br>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:
428
-
429
- ```bash
430
- als create --project-name=genai_demo --from-model=system/genai/temp/create_db_models.py --db-url=sqlite
431
- ```
432
-
433
- Or, correct the chatgpt response, and
434
-
435
- ```bash
436
- als genai --repaired-response=system/genai/examples/genai_demo/genai_demo.response_example --project-name=genai_demo
437
- ```
438
-
439
- We have seen failures such as:
440
-
441
- * duplicate definition of `DECIMAL`
442
- * unclosed parentheses
443
- * data type errors in test data creation
444
- * wrong engine import: from logic_bank import Engine, constraint
445
- * bad test data creation: with Engine() as engine...
446
- * Bad load code (no session)
447
-
448
- </details>
449
- </br>
450
-
451
- <details markdown>
452
-
453
- <summary> Postgresql Example </summary>
454
-
455
- You can test this as follows:
456
-
457
- 1. Use [our docker image](https://apilogicserver.github.io/Docs/Database-Docker/):
458
- 2. And try:
459
-
460
- ```bash
461
- als genai --using=system/genai/examples/postgres/genai_demo_pg.prompt --db-url=postgresql://postgres:p@localhost/genai_demo
462
- ```
463
-
464
- Provisos:
465
-
466
- * You have to create the database first; we are considering automating that: https://stackoverflow.com/questions/76294523/why-cant-create-database-if-not-exists-using-sqlalchemy
467
-
468
- </details>
469
- </details>
470
- </br>
471
-
472
- <details markdown>
473
-
474
- <summary> 3. New Database - using Copilot (Signup optional) </summary>
475
-
476
- <br>You can use Copilot chat (if extension installed; if not, skip to step 3):
477
-
478
- 1. Create a model, eg:
479
-
480
- <details markdown>
481
-
482
- <summary> Show Me How to Use Copilot </summary>
483
-
484
- <br>>Paste this into the Copilot prompt:
485
-
486
- ```
487
- Use SQLAlchemy to create a sqlite database named sample_ai.sqlite, with customers, orders, items and product
488
-
489
- Hints: use autonum keys, allow nulls, Decimal types, foreign keys, no check constraints.
490
-
491
- Include a notes field for orders.
492
-
493
- Create a few rows of only customer and product data.
494
-
495
- Enforce the Check Credit requirement (do not generate check constraints):
496
-
497
- 1. Customer.Balance <= CreditLimit
498
- 2. Customer.Balance = Sum(Order.AmountTotal where date shipped is null)
499
- 3. Order.AmountTotal = Sum(Items.Amount)
500
- 4. Items.Amount = Quantity * UnitPrice
501
- 5. Store the Items.UnitPrice as a copy from Product.UnitPrice
502
- ```
503
-
504
- ![copilot](system/images/copilot.png)
505
- </details>
506
-
507
- <br>
508
-
509
- 2. Paste the copilot response into a new `sample_ai.py` file
510
-
511
- 3. Create your project:
512
-
513
- ```bash
514
- als create --project-name=sample_ai --from-model=sample_ai.py --db-url=sqlite
515
- ```
516
-
517
- 4. This will create your database, create an API Logic Project from it, and launch your IDE.
518
-
519
- 5. Create business logic
520
-
521
- * You can create logic with either your IDE (and code completion), or Natural Language
522
- * To use Natural Language:
523
-
524
- 1. Use the CoPilot chat,
525
- 2. Paste the logic above
526
- 3. Copy it to `logic/declare_logic.py` after `discover_logic()`
527
-
528
- * Alert: Table and Column Names may require correction to conform to the model
529
- * Alert: you may to apply [defaulting](https://apilogicserver.github.io/Docs/Logic-Use/#insert-defaulting), and initialize derived attributes in your database
530
-
531
- </details>
532
- </br>
533
-
534
- <details markdown>
535
-
536
- <summary> 4. New Database - using ChatGPT in the Browser (Signup not required)</summary>
537
-
538
- <br>A final option for GenAI is to use your Browser with ChatGPT.
539
-
540
- Please see [this doc](https://apilogicserver.github.io/Docs/Sample-AI-ChatGPT/)
541
-
542
- </details>
543
-
544
-
545
- &nbsp;
546
-
547
- ## Explore Pre-created Samples
548
-
549
- <details markdown>
550
-
551
- <summary> Explore Pre-created Samples</summary>
552
-
553
- <br>The `samples` folder has pre-created important projects you will want to review at some point (Important: look for **readme files**):
554
-
555
- * [nw_sample_nocust](https://apilogicserver.github.io/Docs/Tutorial/) - northwind (customers, orders...) database
556
-
557
- * This reflects the results you can expect with your own databases
558
-
559
- * [nw_sample](https://apilogicserver.github.io/Docs/Sample-Database/) - same database, but with ***with [customizations](https://apilogicserver.github.io/Docs/IDE-Customize/) added***. It's a great resource for exploring how to customize your projects.
560
-
561
- * Hint: use your IDE to search for `#als`
562
-
563
- * [tutorial](https://apilogicserver.github.io/Docs/Tutorial/) - short (~30 min) walk-through of using API Logic Server using the northwind (customers, orders...) database
564
-
565
- </br>
566
-
567
- <details markdown>
568
-
569
- <summary>You can always re-create the samples</summary>
570
-
571
- <br>Re-create them as follows:
572
-
573
- 1. Open a terminal window (**Terminal > New Terminal**), and paste the following CLI command:
574
-
575
- ```bash
576
- ApiLogicServer create --project-name=samples/tutorial --db-url=
577
- ApiLogicServer create --project-name=samples/nw_sample --db-url=nw+
578
- ApiLogicServer create --project-name=samples/nw_sample_nocust --db-url=nw
579
- ```
580
- </details>
581
-
582
-
583
- </details>
584
-
585
- &nbsp;
586
-
587
- ## Explore WebGenAI
588
-
589
- In addition to the CLI examples above, you can use [WebGenAI](https://apilogicserver.github.io/Docs/WebGenAI/) - a web interface for creating projects from prompts. You can install WebGenAI on a server, so that created projects are easy to review with colleagues.
590
-
591
- To try WebGenAI:
592
-
593
- ```bash
594
- cd webgenai
595
- docker compose up
596
- ```
597
-
598
- You will be directed to the registration process. You will also require a ChatGPT API Key as described above.
599
-
600
- &nbsp;
601
-
602
- &nbsp;
603
-
604
- ## Appendix: Quick Basic Demo
605
-
606
- This is a "cheat sheet" for experienced ALS users, e.g., to show your colleagues.
607
-
608
- <details markdown>
609
-
610
- <summary>Quick Basic Demo - Instructions</summary>
611
-
612
- <br>This demo creates and customizes a project, starting from a database:
613
-
614
- ```bash title="Quick Basic Demo"
615
-
616
- # Microservice Automation
617
- # Admin App, API, Project
618
- als create --project-name=basic_demo --db-url=basic_demo
619
-
620
- # Logic and Security
621
- # see logic (logic/declare_logic.py, logic/cocktail-napkin.jpg); add an Order and Item
622
- # see security (security/declare_security.py); compare customers, s1 vs. admin
623
- als add-cust
624
- als add-auth --db_url=auth
625
-
626
- # Python Extensibility, Kafka Integration, Rebuild Iteration
627
- # see logic/declare_logic.py (breakpoint for Kafka)
628
- # Swagger: ServicesEndPoint.OrderB2B
629
- als add-cust
630
- als rebuild-from-database --db_url=sqlite:///database/db.sqlite
631
- ```
632
-
633
- </details>
634
-
635
-
636
- &nbsp;
637
-
638
- ## Appendix: GenAI Demo
639
-
640
- This is a "cheat sheet" for experienced ALS users, e.g., to show your colleagues.
641
-
642
- <details markdown>
643
-
644
- <summary>Quick GenAI Demo - Instructions</summary>
645
-
646
- <br>This demo creates and customizes a project, starting from a prompt:
647
-
648
- ```bash title="Quick GenAI Demo"
649
-
650
- # Microservice Automation from GenAI Prompt
651
- # Admin App, API, Project
652
- als genai --using=system/genai/examples/genai_demo/genai_demo.prompt
653
-
654
- # Or, Microservice Automation from Saved Response
655
- # Admin App, API, Project
656
- als genai --repaired-response=system/genai/temp/chatgpt_retry.response
657
-
658
- # Logic and Security
659
- # - see logic (logic/declare_logic.py, logic/cocktail-napkin.jpg); add an Order and Item
660
- # - see security (security/declare_security.py); compare customers, s1 vs. admin
661
- # Python Extensibility, Kafka Integration, Rebuild Iteration
662
- # - see logic/declare_logic.py (breakpoint for Kafka)
663
- # - Swagger: ServicesEndPoint.OrderB2B
664
- als add-cust
665
- ```
666
-
667
- </details>