ApiLogicServer 14.5.16__py3-none-any.whl → 15.0.0__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.
@@ -12,10 +12,10 @@ ApiLogicServer CLI: given a database url, create [and run] customizable ApiLogic
12
12
  Called from api_logic_server_cli.py, by instantiating the ProjectRun object.
13
13
  '''
14
14
 
15
- __version__ = "14.05.16" # last public release: 14.05.00
15
+ __version__ = "15.00.00" # last public release: 15.00.00 (14.05.04)
16
16
  recent_changes = \
17
17
  f'\n\nRecent Changes:\n' +\
18
- "\t05/28/2024 - 14.05.16: tour - re-factored default mcp req with generic Post, email stub, use basic_demo custs for genai_demo \n"\
18
+ "\t05/28/2024 - 15.00.00: MCP \n"\
19
19
  "\t05/16/2024 - 14.05.00: safrs 3.1.7, running mcp preview \n"\
20
20
  "\t04/27/2024 - 14.04.00: Graphics preview, Vibe install fix, Improved IDE Chat Logic, MCP Exploration \n"\
21
21
  "\t03/30/2024 - 14.03.25: WebGenAI fixes for Kafka and Keycloak \n"\
@@ -1,3 +1,3 @@
1
- last_created_date: May 27, 2025 20:52:10
2
- last_created_project_name: samples/nw_sample_nocust
3
- last_created_version: 14.05.12
1
+ last_created_date: May 28, 2025 12:08:45
2
+ last_created_project_name: /Users/val/dev/ApiLogicServer/ApiLogicServer-dev/servers/basic_demo
3
+ last_created_version: 14.05.16
@@ -242,6 +242,9 @@ def create(model_creation_services: create_from_model.ModelCreationServices):
242
242
  """ called by ApiLogicServer CLI -- creates ui/admin application (ui/admin folder, admin.yaml)
243
243
  """
244
244
  dbml_creator = DBMLCreator(model_creation_services)
245
- dbml_creator.create_docs_dbml_file()
246
- dbml_creator.create_docs_mcp()
245
+ if dbml_creator.mod_gen.project.add_auth_in_progress == False:
246
+ dbml_creator.create_docs_dbml_file()
247
+ dbml_creator.create_docs_mcp()
248
+ else:
249
+ pass #
247
250
 
@@ -16,9 +16,11 @@ def declare_logic():
16
16
  This illustrates the request pattern.
17
17
 
18
18
  The request pattern is a common pattern in API Logic Server,
19
- where an insert triggers service invocation, such as sending email.
19
+ where an insert into SysEmail triggers service invocation, such as sending email.
20
+
21
+ See https://apilogicserver.github.io/Docs/Integration-MCP/.
20
22
 
21
- The Email table includes the columns for the email (e,g, recipient, subject, message).
23
+ The SysEmail table includes the columns for the email (e,g, recipient, subject, message).
22
24
 
23
25
  Using a request object enables you to wrap the service call with logic, eg:
24
26
 
@@ -281,13 +281,9 @@ def declare_logic():
281
281
  This illustrates the request pattern.
282
282
 
283
283
  The request pattern is a common pattern in API Logic Server,
284
- where an insert triggers service invocation, such as sending email.
284
+ where an insert triggers service invocation, such as sending email or issue mcp requests.
285
285
 
286
- The Email table includes the columns for the email (e,g, recipient, subject, message).
287
-
288
- Using a request object enables you to wrap the service call with logic, eg:
289
-
290
- * *email requirement: do not send mail if customer has opted out*
286
+ The SysMCP table captures the prompt (in the row); this logic executes the MCP processing.
291
287
 
292
288
  See: https://apilogicserver.github.io/Docs/Integration-MCP/#3a-logic-request-pattern
293
289
  """
@@ -296,9 +292,11 @@ def declare_logic():
296
292
  def mcp_client_executor(row: models.SysMcp, old_row: models.SysMcp, logic_row: LogicRow):
297
293
  """
298
294
 
299
- #als: create an MCP request
295
+ #als: create an MCP request. See https://apilogicserver.github.io/Docs/Integration-MCP/
300
296
 
301
- curl -X 'POST' 'http://localhost:5656/api/SysMcp/' -H 'accept: application/vnd.api+json' -H 'Content-Type: application/json' -d '{ "data": { "attributes": {"request": "List the orders date_shipped is null and CreatedOn before 2023-07-14, and send a discount email (subject: '\''Discount Offer'\'') to the customer for each one."}, "type": "SysMcp"}}'
297
+ Test:
298
+ * `curl -X 'POST' 'http://localhost:5656/api/SysMcp/' -H 'accept: application/vnd.api+json' -H 'Content-Type: application/json' -d '{ "data": { "attributes": {"request": "List the orders date_shipped is null and CreatedOn before 2023-07-14, and send a discount email (subject: '\''Discount Offer'\'') to the customer for each one."}, "type": "SysMcp"}}'`
299
+ * Or, use the Admin App and insert a row into SysMCP (see `query_example`, below)
302
300
 
303
301
  Args:
304
302
  row (Mcp): inserted MCP with prompt
@@ -311,7 +309,7 @@ def declare_logic():
311
309
  query = row.request
312
310
  prompt = get_user_nl_query_and_training(query)
313
311
 
314
- tool_context = query_llm_with_nl(schema_text, prompt) # see: 2-tool-context-from-LLM
312
+ tool_context = query_llm_with_nl(schema_text, prompt) # see: 2-tool-context-from-LLM
315
313
 
316
314
  mcp_response = process_tool_context(tool_context) # see: 3-MCP-server response
317
315
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  title: Welcome
3
3
  Description: Instant mcp-enabled microservices, standard projects, declarative business logic
4
- version info: 2.0 (05/24/2025)
4
+ version info: 2.0 (05/24/2025) from install
5
5
  ---
6
6
  <style>
7
7
  .md-typeset h1,
@@ -250,7 +250,9 @@ Observe the rules firing in the console log - see Logic In Action, below.
250
250
 
251
251
  <summary>See Logic In Action </summary>
252
252
 
253
- <br>
253
+ <br>[Declare logic](Logic.md#declaring-rules){:target="_blank" rel="noopener"} with WebGenAI, or in your IDE using code completion or Natural Language:
254
+
255
+ ![Nat Lang Logic](images/sample-ai/copilot/copilot-logic-chat.png)
254
256
 
255
257
  **a. Chaining**
256
258
 
@@ -263,6 +265,9 @@ Note that it's a `Multi-Table Transaction`, as indicated by the indentation. Th
263
265
  **b. 40X More Concise**
264
266
 
265
267
  The 5 spreadsheet-like rules represent the same logic as 200 lines of code, [shown here](https://github.com/valhuber/LogicBank/wiki/by-code). That's a remarkable 40X decrease in the backend half of the system.
268
+
269
+ > 💡 No FrankenCode<br>Note the rules look like syntactically correct requirements. They are not turned into piles of unmanageable "frankencode" - see [models not frankencode](https://www.genai-logic.com/faqs#h.3fe4qv21qtbs){:target="_blank" rel="noopener"}.
270
+
266
271
  <br><br>
267
272
 
268
273
  **c. Automatic Re-use**
@@ -285,6 +290,29 @@ Optionally, you can use the Behave TDD approach to define tests, and the Rules R
285
290
 
286
291
  &nbsp;
287
292
 
293
+ ### Logic-Enabled MCP
294
+
295
+ Logic is automatically executed in your MCP-enabled API. For example, consider the following MCP orchestration:
296
+
297
+ ```
298
+ List the orders date_shipped is null and CreatedOn before 2023-07-14,
299
+ and send a discount email (subject: 'Discount Offer') to the customer for each one.
300
+ ```
301
+
302
+ When sending email, we require a business rules to ensure it respects the opt-out policy:
303
+
304
+ ![email request](images/integration/mcp/3a-email-logic.png)
305
+
306
+ With the server running, test it by posting to `SysMCP` like this:
307
+
308
+ ```bash
309
+ curl -X 'POST' 'http://localhost:5656/api/SysMcp/' -H 'accept: application/vnd.api+json' -H 'Content-Type: application/json' -d '{ "data": { "attributes": {"request": "List the orders date_shipped is null and CreatedOn before 2023-07-14, and send a discount email (subject: '\''Discount Offer'\'') to the customer for each one."}, "type": "SysMcp"}}'
310
+ ```
311
+
312
+ For more on MCP, [click here](Integration-MCP.md){:target="_blank" rel="noopener"}.
313
+
314
+ &nbsp;
315
+
288
316
  ## 4. Iterate with Rules and Python
289
317
 
290
318
  Not only are spreadsheet-like rules 40X more concise, they meaningfully simplify maintenance. Let's take an example:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ApiLogicServer
3
- Version: 14.5.16
3
+ Version: 15.0.0
4
4
  Author-email: Val Huber <apilogicserver@gmail.com>
5
5
  License: BSD-3-Clause
6
6
  Project-URL: Homepage, https://www.genai-logic.com
@@ -84,7 +84,7 @@ Dynamic: license-file
84
84
 
85
85
  # TL;DR
86
86
 
87
- Create an executable project (API and Admin App) from a database or natural language prompt with 1 command, customize with declarative rules and Python in your IDE, containerize and deploy.
87
+ Create an executable project (MCP-enabled API and Admin App) from a database or natural language prompt with 1 command; customize with declarative rules and Python in your IDE, containerize and deploy.
88
88
 
89
89
  &nbsp;
90
90
 
@@ -136,7 +136,7 @@ For Developers and their organizations seeking to **increase business agility,**
136
136
 
137
137
  API Logic Server provides ***Microservice Automation:*** create executable projects with 1 command:
138
138
 
139
- 1. ***API Automation:*** crud for each table, with pagination, optimistic locking, filtering and sorting, and
139
+ 1. ***MCP-enabled API Automation:*** crud for each table, with pagination, optimistic locking, filtering and sorting, and
140
140
 
141
141
  2. ***App Automation:*** a multi-page, multi-table Admin App. <br>
142
142
 
@@ -1,6 +1,6 @@
1
1
  api_logic_server_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- api_logic_server_cli/api_logic_server.py,sha256=wdAMi8pOS75vfxEjbqZFlmyDDRJARIKhtyBzSUNrwmQ,96180
3
- api_logic_server_cli/api_logic_server_info.yaml,sha256=fc8tW0mwphoVmben9kMc1cAI3Yp_J1CdY8ZVcp9ulYg,124
2
+ api_logic_server_cli/api_logic_server.py,sha256=JGttj16Oh5RYnnl5vT6AFWZDa3JQJAAZWrzXW0jK0Lc,96093
3
+ api_logic_server_cli/api_logic_server_info.yaml,sha256=gry1dTWvFjC4Uj6p2hm6zI9z1_MGnigzFXxFj-QFO40,167
4
4
  api_logic_server_cli/cli.py,sha256=AT1cWszOygHWIbpxDoXFhaTeSai3Tf5SbGoXvN4h510,83134
5
5
  api_logic_server_cli/cli_args_base.py,sha256=lr27KkOB7_WpZwTs7LgiK8LKDIHMKQkoZCTnE99BFxw,3280
6
6
  api_logic_server_cli/cli_args_project.py,sha256=I5no_fGRV_ZsK3SuttVDAaQYI4Q5zCjx6LojGkM024w,4645
@@ -13,7 +13,7 @@ api_logic_server_cli/create_from_model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JC
13
13
  api_logic_server_cli/create_from_model/api_expose_api_models_creator.py,sha256=V-u3Hm404doztw66YuD2A043RCFmtw5QF5tMioC_1b0,7900
14
14
  api_logic_server_cli/create_from_model/api_logic_server_utils.py,sha256=G5ifhuR8OIujUHoklZ-XZyowCpUGKJrkLuyB9sSEf34,26728
15
15
  api_logic_server_cli/create_from_model/create_db_from_model.py,sha256=2H7slGnk39XOSnvL7vxrg6Ewx4bxeBJBgLo8fcXHTB4,4382
16
- api_logic_server_cli/create_from_model/dbml.py,sha256=1MeLhdIo7cS40ddxnRk7_tqs5gxYfFwO-QlgvRpb9I0,11387
16
+ api_logic_server_cli/create_from_model/dbml.py,sha256=Ef23JIB4IuPsef-QrJ2LTfiKBGRr2ddNSS6RWEh7sKs,11489
17
17
  api_logic_server_cli/create_from_model/meta_model.py,sha256=ERf7tSgnSJSeRMVyggkdg-lvORQZSbfK0KMpL63qSEY,5837
18
18
  api_logic_server_cli/create_from_model/model_creation_services.py,sha256=B86ljgUR98H_dCaxqiw-flrbvc05-XXtkC5It2BSezs,41479
19
19
  api_logic_server_cli/create_from_model/ont_build.py,sha256=5BcmM0xW-0vjr9J_u1o0_3joLfKhcLeDWP31dcy5dzI,67028
@@ -24,7 +24,7 @@ api_logic_server_cli/create_from_model/__pycache__/__init__.cpython-312.pyc,sha2
24
24
  api_logic_server_cli/create_from_model/__pycache__/api_expose_api_models_creator.cpython-312.pyc,sha256=3wtCiVHOjOgIonZOgnCsF2p01zcXIapx1_Tq2LwzY6Q,6989
25
25
  api_logic_server_cli/create_from_model/__pycache__/api_logic_server_utils.cpython-312.pyc,sha256=Qa-lL19TM5dAwMgVmT6ld7iB_Bb7RR0oYpEzlC2UmHM,27403
26
26
  api_logic_server_cli/create_from_model/__pycache__/create_db_from_model.cpython-312.pyc,sha256=5eE8pIEa-OoUOk0xn_b78cCc9dSmxjTMn3HGJbxbFY4,4799
27
- api_logic_server_cli/create_from_model/__pycache__/dbml.cpython-312.pyc,sha256=a0T97WPNlfceDcpi7VQfXlIPCgn36aXxmtnMJ-cVSfQ,12537
27
+ api_logic_server_cli/create_from_model/__pycache__/dbml.cpython-312.pyc,sha256=TK55yhQ53rEetYDm89ztvEIDPLnjMuYQ5_kJqaCio9I,12671
28
28
  api_logic_server_cli/create_from_model/__pycache__/meta_model.cpython-312.pyc,sha256=BH5Cflj8YKf0CVkHpIZ_3eBbHXhwIWbwsrzM7DsEikE,7098
29
29
  api_logic_server_cli/create_from_model/__pycache__/model_creation_services.cpython-312.pyc,sha256=_pJPTvkJL22Eu1BWM48VfXcyapD366OnXBqHGn-wtO0,36462
30
30
  api_logic_server_cli/create_from_model/__pycache__/ont_build.cpython-312.pyc,sha256=Hni6k7GidAkkz-YO2kvmQOMYdCdCWvGWxX3HIPjj1eE,75285
@@ -715,8 +715,8 @@ api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/mcp_to
715
715
  api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/test_notes.txt,sha256=71Qqw7FRVGtEoHCxlGRPpaizvBh1L-X-MTOwkZ6CY3A,11126
716
716
  api_logic_server_cli/prototypes/basic_demo/customizations/logic/cocktail-napkin.jpg,sha256=5rNSy6wvcWSHPJQZqkf2DHs19QLWiyqMBNwxGqjstZU,133075
717
717
  api_logic_server_cli/prototypes/basic_demo/customizations/logic/declare_logic.py,sha256=Yk-X017gZM1egx4MXSx_FGURj4KDqJfpq1NWVFrwfEY,4612
718
- api_logic_server_cli/prototypes/basic_demo/customizations/logic/logic_discovery/email_request.py,sha256=_ky4ZAggiH3-V1-_V4j7pBZ0gWju8cDCZP48d_Y-otw,1765
719
- api_logic_server_cli/prototypes/basic_demo/customizations/logic/logic_discovery/mcp_client_executor_request.py,sha256=vwdEZqsiOwxA-loFvjFetGi9zBnOnoPvrwm3PQhtAQA,14226
718
+ api_logic_server_cli/prototypes/basic_demo/customizations/logic/logic_discovery/email_request.py,sha256=3UnBUBpHSThHHRLLJuV-sgRAs6sS-UCzsTjBzf0onns,1851
719
+ api_logic_server_cli/prototypes/basic_demo/customizations/logic/logic_discovery/mcp_client_executor_request.py,sha256=4v1HOZQRPZCMUeb5_QmMfqMvDr-pmcPfgalWsS1KSQg,14243
720
720
  api_logic_server_cli/prototypes/basic_demo/customizations/logic/logic_discovery/simple_constraints.py,sha256=4HRLOXuLJP1eOosONeEtpA9DehxiZME0-FBKuG1RaI0,760
721
721
  api_logic_server_cli/prototypes/basic_demo/customizations/security/declare_security.py,sha256=gbdH29cPY656lgROPm_w20Q-g6AhlIMES3wiIrqBTdk,2439
722
722
  api_logic_server_cli/prototypes/basic_demo/customizations/ui/admin/admin.yaml,sha256=y3goVMcxMN4wNLQh4kNJvYuSzpntECeDjwLQF2c1YI4,3494
@@ -762,8 +762,7 @@ api_logic_server_cli/prototypes/genai_demo/logic/readme_declare_logic.md,sha256=
762
762
  api_logic_server_cli/prototypes/genai_demo/security/declare_security.py,sha256=L3AL1bgdqIWQxdkJZcFVDOQ0XRpmeLAKqwlAYChFWKo,2108
763
763
  api_logic_server_cli/prototypes/genai_demo/ui/admin/admin.yaml,sha256=vMpr6to6g-h9gSuhxfpTeDMw5_R_eUKbV7qXzMEvIyk,3446
764
764
  api_logic_server_cli/prototypes/manager/.gitignore,sha256=xfAjNQHokbo6GuN1ghx-eml8tQIzwUczLC_YVzElndI,195
765
- api_logic_server_cli/prototypes/manager/READMEz.md,sha256=zOnEDVApxPEivo0oZ316eWkr8y0me7wie1An3oJmn9c,23312
766
- api_logic_server_cli/prototypes/manager/REAMDE.md,sha256=mxcXCV8lx7LcqJO6zL7IveRjDJRrR4VJjoXNW_BGA60,36074
765
+ api_logic_server_cli/prototypes/manager/README.md,sha256=Kx8b1c0tKUbUSmCXtg418Kjc0dHxXavX-xY2zAwB7vM,37543
767
766
  api_logic_server_cli/prototypes/manager/run_sample.sh,sha256=eRA-p_Snr7Pwk14wUw5mja2usEcjAKisHVhHMeSaQ68,781
768
767
  api_logic_server_cli/prototypes/manager/run_web_genai.sh,sha256=sgjB3vKhkao93Ny3VN0AQ-wonvdBcBIT3rTbyNTMoG8,136
769
768
  api_logic_server_cli/prototypes/manager/settings.txt,sha256=_jjL30jomIMxG21edDfrXYRT9Zfgr_0EdUWvcEUOnFQ,368
@@ -6096,9 +6095,9 @@ api_logic_server_cli/tools/mini_skel/database/system/SAFRSBaseX.py,sha256=p8C7AF
6096
6095
  api_logic_server_cli/tools/mini_skel/database/system/TestDataBase.py,sha256=U02SYqThsbY5g3DX7XGaiMxjZBuOpzvtPS6RfI1WQFg,371
6097
6096
  api_logic_server_cli/tools/mini_skel/logic/declare_logic.py,sha256=fTrlHyqMeZsw_TyEXFa1VlYBL7fzjZab5ONSXO7aApo,175
6098
6097
  api_logic_server_cli/tools/mini_skel/logic/load_verify_rules.py,sha256=Rr5bySJpYCZmNPF2h-phcPJ53nAOPcT_ohZpCD93-a0,7530
6099
- apilogicserver-14.5.16.dist-info/licenses/LICENSE,sha256=67BS7VC-Z8GpaR3wijngQJkHWV04qJrwQArVgn9ldoI,1485
6100
- apilogicserver-14.5.16.dist-info/METADATA,sha256=rbwLoeylKyqOeVOChnV4k3Nob77roXRlexs6sXhwwdQ,6525
6101
- apilogicserver-14.5.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6102
- apilogicserver-14.5.16.dist-info/entry_points.txt,sha256=KiLloZJ3c_RW-nIDqBtoE0WEsQTnZ3dELwHLWi23LMA,103
6103
- apilogicserver-14.5.16.dist-info/top_level.txt,sha256=-r0AT_GEApleihg-jIh0OMvzzc0BO1RuhhOpE91H5qI,21
6104
- apilogicserver-14.5.16.dist-info/RECORD,,
6098
+ apilogicserver-15.0.0.dist-info/licenses/LICENSE,sha256=67BS7VC-Z8GpaR3wijngQJkHWV04qJrwQArVgn9ldoI,1485
6099
+ apilogicserver-15.0.0.dist-info/METADATA,sha256=bWhoBYs468qQj04sZak-1god1nik6X2Gvbo5RJAN2uI,6548
6100
+ apilogicserver-15.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6101
+ apilogicserver-15.0.0.dist-info/entry_points.txt,sha256=KiLloZJ3c_RW-nIDqBtoE0WEsQTnZ3dELwHLWi23LMA,103
6102
+ apilogicserver-15.0.0.dist-info/top_level.txt,sha256=-r0AT_GEApleihg-jIh0OMvzzc0BO1RuhhOpE91H5qI,21
6103
+ apilogicserver-15.0.0.dist-info/RECORD,,
@@ -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>