ApiLogicServer 14.3.0__py3-none-any.whl → 14.3.11__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.
- {ApiLogicServer-14.3.0.dist-info → ApiLogicServer-14.3.11.dist-info}/METADATA +3 -3
- {ApiLogicServer-14.3.0.dist-info → ApiLogicServer-14.3.11.dist-info}/RECORD +58 -54
- api_logic_server_cli/api_logic_server.py +2 -1
- api_logic_server_cli/api_logic_server_info.yaml +3 -3
- api_logic_server_cli/cli.py +5 -2
- api_logic_server_cli/create_from_model/__pycache__/ont_build.cpython-312.pyc +0 -0
- api_logic_server_cli/create_from_model/ont_build.py +9 -9
- api_logic_server_cli/create_from_model/safrs-react-admin-npm-build/asset-manifest.json +3 -3
- api_logic_server_cli/create_from_model/safrs-react-admin-npm-build/build-0213.txt +1 -0
- api_logic_server_cli/create_from_model/safrs-react-admin-npm-build/index.html +1 -1
- api_logic_server_cli/create_from_model/safrs-react-admin-npm-build/static/js/main.7c8c0e37.js +3 -0
- api_logic_server_cli/create_from_model/safrs-react-admin-npm-build/static/js/{main.bfe80d1d.js.map → main.7c8c0e37.js.map} +1 -1
- api_logic_server_cli/database/nw-gold.sqlite +0 -0
- api_logic_server_cli/genai/genai.py +13 -3
- api_logic_server_cli/genai/genai_svcs.py +2 -0
- api_logic_server_cli/manager.py +20 -16
- api_logic_server_cli/prototypes/base/api/system/expression_parser.py +10 -4
- api_logic_server_cli/prototypes/base/devops/docker-image/env.list +7 -2
- api_logic_server_cli/prototypes/base/integration/kafka/kafka_producer.py +31 -8
- api_logic_server_cli/prototypes/base/integration/system/RowDictMapper.py +33 -16
- api_logic_server_cli/prototypes/base/logic/declare_logic.py +1 -0
- api_logic_server_cli/prototypes/base/logic/load_verify_rules.py +2 -1
- api_logic_server_cli/prototypes/genai_demo/api/customize_api.py +9 -11
- api_logic_server_cli/prototypes/genai_demo/database/.DS_Store +0 -0
- api_logic_server_cli/prototypes/genai_demo/database/db.sqlite +0 -0
- api_logic_server_cli/prototypes/genai_demo/database/models.py +52 -42
- api_logic_server_cli/prototypes/genai_demo/integration/row_dict_maps/OrderB2B.py +4 -6
- api_logic_server_cli/prototypes/genai_demo/integration/row_dict_maps/__pycache__/OrderB2B.cpython-312.pyc +0 -0
- api_logic_server_cli/prototypes/genai_demo/integration/row_dict_maps/row_dict_maps_readme.md +3 -0
- api_logic_server_cli/prototypes/genai_demo/logic/__pycache__/declare_logic.cpython-312.pyc +0 -0
- api_logic_server_cli/prototypes/genai_demo/logic/__pycache__/load_verify_rules.cpython-312.pyc +0 -0
- api_logic_server_cli/prototypes/genai_demo/logic/declare_logic.py +57 -69
- api_logic_server_cli/prototypes/genai_demo/logic/load_verify_rules.py +216 -0
- api_logic_server_cli/prototypes/genai_demo/logic/logic_discovery/__pycache__/__init__.cpython-312.pyc +0 -0
- api_logic_server_cli/prototypes/genai_demo/logic/logic_discovery/__pycache__/auto_discovery.cpython-312.pyc +0 -0
- api_logic_server_cli/prototypes/genai_demo/logic/logic_discovery/__pycache__/error_testing.cpython-312.pyc +0 -0
- api_logic_server_cli/prototypes/genai_demo/logic/logic_discovery/auto_discovery.py +52 -0
- api_logic_server_cli/prototypes/genai_demo/logic/readme_declare_logic.md +172 -0
- api_logic_server_cli/prototypes/genai_demo/security/__pycache__/declare_security.cpython-312.pyc +0 -0
- api_logic_server_cli/prototypes/genai_demo/ui/admin/admin.yaml +86 -53
- api_logic_server_cli/prototypes/manager/.vscode/ApiLogicServer.code-workspace +2 -2
- api_logic_server_cli/prototypes/manager/.vscode/launch.json +21 -21
- api_logic_server_cli/prototypes/manager/README.md +1 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo.prompt +4 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo.response_example +15 -8
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_informal.prompt +3 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/time_tracking_billing/002_create_db_models.prompt +3 -132
- api_logic_server_cli/prototypes/manager/system/genai/examples/time_tracking_billing/Invoice Made Ready.png +0 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/time_tracking_billing/readme.md +59 -6
- api_logic_server_cli/prototypes/manager/system/genai/learning_requests/logic_bank_api.prompt +22 -1
- api_logic_server_cli/prototypes/nw/logic/declare_logic.py +1 -1
- api_logic_server_cli/sqlacodegen_wrapper/sqlacodegen/sqlacodegen/__pycache__/codegen.cpython-312.pyc +0 -0
- api_logic_server_cli/sqlacodegen_wrapper/sqlacodegen/sqlacodegen/codegen.py +2 -1
- api_logic_server_cli/create_from_model/safrs-react-admin-npm-build/build-0106.txt +0 -1
- api_logic_server_cli/create_from_model/safrs-react-admin-npm-build/static/js/main.bfe80d1d.js +0 -3
- api_logic_server_cli/prototypes/genai_demo/database/chatgpt/__pycache__/copilot_models.cpython-312.pyc +0 -0
- api_logic_server_cli/prototypes/genai_demo/database/chatgpt/__pycache__/sample_ai_models.cpython-312.pyc +0 -0
- api_logic_server_cli/prototypes/genai_demo/database/chatgpt/sample_ai.chatgpt +0 -16
- api_logic_server_cli/prototypes/genai_demo/database/chatgpt/sample_ai.sql +0 -66
- api_logic_server_cli/prototypes/genai_demo/database/chatgpt/sample_ai.sqlite +0 -0
- api_logic_server_cli/prototypes/genai_demo/database/chatgpt/sample_ai_items.sqlite +0 -0
- api_logic_server_cli/prototypes/genai_demo/database/chatgpt/sample_ai_models.py +0 -156
- api_logic_server_cli/prototypes/genai_demo/database/chatgpt/sample_ai_models.sqlite +0 -0
- api_logic_server_cli/prototypes/genai_demo/logic/cocktail-napkin.jpg +0 -0
- {ApiLogicServer-14.3.0.dist-info → ApiLogicServer-14.3.11.dist-info}/LICENSE +0 -0
- {ApiLogicServer-14.3.0.dist-info → ApiLogicServer-14.3.11.dist-info}/WHEEL +0 -0
- {ApiLogicServer-14.3.0.dist-info → ApiLogicServer-14.3.11.dist-info}/entry_points.txt +0 -0
- {ApiLogicServer-14.3.0.dist-info → ApiLogicServer-14.3.11.dist-info}/top_level.txt +0 -0
- /api_logic_server_cli/create_from_model/safrs-react-admin-npm-build/static/js/{main.bfe80d1d.js.LICENSE.txt → main.7c8c0e37.js.LICENSE.txt} +0 -0
|
@@ -1,109 +1,142 @@
|
|
|
1
1
|
about:
|
|
2
|
-
date:
|
|
3
|
-
merged:
|
|
4
|
-
at: January 28, 2024 13:17:27
|
|
5
|
-
new_attributes: 'Product.CarbonNeutral '
|
|
6
|
-
new_resources: ''
|
|
7
|
-
new_tab_groups: ''
|
|
2
|
+
date: February 02, 2025 11:44:16
|
|
8
3
|
recent_changes: works with modified safrs-react-admin
|
|
9
4
|
version: 0.0.0
|
|
10
5
|
api_root: '{http_type}://{swagger_host}:{port}/{api}'
|
|
11
|
-
authentication:
|
|
12
|
-
endpoint: '{http_type}://{swagger_host}:{port}/api/auth/login'
|
|
6
|
+
authentication: '{system-default}'
|
|
13
7
|
info:
|
|
14
8
|
number_relationships: 3
|
|
15
9
|
number_tables: 4
|
|
10
|
+
info_toggle_checked: true
|
|
16
11
|
resources:
|
|
17
12
|
Customer:
|
|
18
13
|
attributes:
|
|
19
|
-
- label: '
|
|
20
|
-
name:
|
|
21
|
-
required: true
|
|
14
|
+
- label: ' name*'
|
|
15
|
+
name: name
|
|
22
16
|
search: true
|
|
23
17
|
sort: true
|
|
24
|
-
- name:
|
|
25
|
-
|
|
26
|
-
- name:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
- name: balance
|
|
19
|
+
type: DECIMAL
|
|
20
|
+
- name: credit_limit
|
|
21
|
+
type: DECIMAL
|
|
22
|
+
- name: id
|
|
23
|
+
description: Represents a customer in the system with unique name, balance, and
|
|
24
|
+
credit limit attributes.
|
|
25
|
+
info_list: Represents a customer in the system with unique name, balance, and
|
|
26
|
+
credit limit attributes.
|
|
30
27
|
tab_groups:
|
|
31
28
|
- direction: tomany
|
|
32
29
|
fks:
|
|
33
|
-
-
|
|
30
|
+
- customer_id
|
|
34
31
|
name: OrderList
|
|
35
32
|
resource: Order
|
|
36
33
|
type: Customer
|
|
37
|
-
user_key:
|
|
34
|
+
user_key: name
|
|
38
35
|
Item:
|
|
39
36
|
attributes:
|
|
40
|
-
- label: '
|
|
41
|
-
name:
|
|
37
|
+
- label: ' id*'
|
|
38
|
+
name: id
|
|
42
39
|
search: true
|
|
43
40
|
sort: true
|
|
44
|
-
- name:
|
|
45
|
-
- name:
|
|
46
|
-
- name:
|
|
41
|
+
- name: order_id
|
|
42
|
+
- name: product_id
|
|
43
|
+
- name: quantity
|
|
47
44
|
required: true
|
|
48
|
-
- name:
|
|
49
|
-
|
|
45
|
+
- name: unit_price
|
|
46
|
+
type: DECIMAL
|
|
47
|
+
- name: amount
|
|
48
|
+
type: DECIMAL
|
|
49
|
+
description: Represents an item in an order, including quantity and pricing details.
|
|
50
|
+
info_list: Represents an item in an order, including quantity and pricing details.
|
|
50
51
|
tab_groups:
|
|
51
52
|
- direction: toone
|
|
52
53
|
fks:
|
|
53
|
-
-
|
|
54
|
-
name:
|
|
54
|
+
- order_id
|
|
55
|
+
name: order
|
|
55
56
|
resource: Order
|
|
56
57
|
- direction: toone
|
|
57
58
|
fks:
|
|
58
|
-
-
|
|
59
|
-
name:
|
|
59
|
+
- product_id
|
|
60
|
+
name: product
|
|
60
61
|
resource: Product
|
|
61
62
|
type: Item
|
|
62
|
-
user_key:
|
|
63
|
+
user_key: id
|
|
63
64
|
Order:
|
|
64
65
|
attributes:
|
|
65
|
-
- label: '
|
|
66
|
-
name:
|
|
66
|
+
- label: ' id*'
|
|
67
|
+
name: id
|
|
67
68
|
search: true
|
|
68
69
|
sort: true
|
|
69
|
-
- name:
|
|
70
|
-
- name:
|
|
71
|
-
|
|
72
|
-
- name:
|
|
73
|
-
- name:
|
|
70
|
+
- name: customer_id
|
|
71
|
+
- name: amount_total
|
|
72
|
+
type: DECIMAL
|
|
73
|
+
- name: notes
|
|
74
|
+
- name: date_shipped
|
|
75
|
+
type: DATE
|
|
76
|
+
description: Represents an order made by a customer, including a notes field.
|
|
77
|
+
info_list: Represents an order made by a customer, including a notes field.
|
|
74
78
|
tab_groups:
|
|
75
79
|
- direction: tomany
|
|
76
80
|
fks:
|
|
77
|
-
-
|
|
81
|
+
- order_id
|
|
78
82
|
name: ItemList
|
|
79
83
|
resource: Item
|
|
80
84
|
- direction: toone
|
|
81
85
|
fks:
|
|
82
|
-
-
|
|
83
|
-
name:
|
|
86
|
+
- customer_id
|
|
87
|
+
name: customer
|
|
84
88
|
resource: Customer
|
|
85
89
|
type: Order
|
|
86
|
-
user_key:
|
|
90
|
+
user_key: id
|
|
87
91
|
Product:
|
|
88
92
|
attributes:
|
|
89
|
-
- label: '
|
|
90
|
-
name:
|
|
91
|
-
required: true
|
|
93
|
+
- label: ' name*'
|
|
94
|
+
name: name
|
|
92
95
|
search: true
|
|
93
96
|
sort: true
|
|
94
|
-
- name:
|
|
95
|
-
|
|
96
|
-
- name:
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
- name: unit_price
|
|
98
|
+
type: DECIMAL
|
|
99
|
+
- name: carbon_neutral
|
|
100
|
+
type: BOOLEAN
|
|
101
|
+
- name: id
|
|
102
|
+
description: Represents a product available in the system with a unit price.
|
|
103
|
+
info_list: Represents a product available in the system with a unit price.
|
|
99
104
|
tab_groups:
|
|
100
105
|
- direction: tomany
|
|
101
106
|
fks:
|
|
102
|
-
-
|
|
107
|
+
- product_id
|
|
103
108
|
name: ItemList
|
|
104
109
|
resource: Item
|
|
105
110
|
type: Product
|
|
106
|
-
user_key:
|
|
111
|
+
user_key: name
|
|
107
112
|
settings:
|
|
108
|
-
HomeJS:
|
|
113
|
+
HomeJS: /admin-app/home.js
|
|
109
114
|
max_list_columns: 8
|
|
115
|
+
style_guide:
|
|
116
|
+
applicationLocales:
|
|
117
|
+
- en
|
|
118
|
+
- es
|
|
119
|
+
currency_symbol: $
|
|
120
|
+
currency_symbol_position: left
|
|
121
|
+
date_format: LL
|
|
122
|
+
decimal_max: '1000000000'
|
|
123
|
+
decimal_min: '0'
|
|
124
|
+
decimal_separator: .
|
|
125
|
+
detail_mode: tab
|
|
126
|
+
edit_on_mode: dblclick
|
|
127
|
+
exclude_listpicker: false
|
|
128
|
+
include_translation: 'false'
|
|
129
|
+
keycloak_client_id: alsclient
|
|
130
|
+
keycloak_realm: kcals
|
|
131
|
+
keycloak_url: http://localhost:8080
|
|
132
|
+
locale: en
|
|
133
|
+
max_decimal_digits: '4'
|
|
134
|
+
min_decimal_digits: '2'
|
|
135
|
+
new_mode: dialog
|
|
136
|
+
pick_style: list
|
|
137
|
+
row_height: small,
|
|
138
|
+
serviceType: OntimizeEE
|
|
139
|
+
startSessionPath: /auth/login
|
|
140
|
+
style: light
|
|
141
|
+
thousand_separator: ','
|
|
142
|
+
use_keycloak: 'false'
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"workbench.editorAssociations": {
|
|
10
10
|
"*.md": "vscode.markdown.preview.editor"
|
|
11
11
|
},
|
|
12
|
-
"workbench.colorTheme": "Office Theme (
|
|
13
|
-
"workbench.preferredLightColorTheme": "Office Theme (
|
|
12
|
+
"workbench.colorTheme": "Office Theme (Publisher)",
|
|
13
|
+
"workbench.preferredLightColorTheme": "Office Theme (Publisher)"
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"internalConsoleOptions": "openOnSessionStart"
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
|
-
"name": " 1.1 GENAI - Iterate (first, add prompt to system/genai/temp/<project>)",
|
|
27
|
+
"name": " - 1.1 GENAI - Iterate (first, add prompt to system/genai/temp/<project>)",
|
|
28
28
|
"type": "debugpy",
|
|
29
29
|
"request": "launch",
|
|
30
30
|
"program": "${workspaceFolder}/venv/lib/python3.12/site-packages/api_logic_server_cli/cli.py",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"internalConsoleOptions": "openOnSessionStart"
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
|
-
"name": " 1.2 GENAI - Retry from repaired chatgpt response",
|
|
46
|
+
"name": " - 1.2 GENAI - Retry from repaired chatgpt response",
|
|
47
47
|
"type": "debugpy",
|
|
48
48
|
"request": "launch",
|
|
49
49
|
"program": "${workspaceFolder}/venv/lib/python3.12/site-packages/api_logic_server_cli/cli.py",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"internalConsoleOptions": "openOnSessionStart"
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
|
-
"name": " 1.3 GENAI - Retry from repaired model",
|
|
66
|
+
"name": " - 1.3 GENAI - Retry from repaired model",
|
|
67
67
|
"type": "debugpy",
|
|
68
68
|
"request": "launch",
|
|
69
69
|
"program": "${workspaceFolder}/venv/lib/python3.12/site-packages/api_logic_server_cli/cli.py",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"internalConsoleOptions": "openOnSessionStart"
|
|
85
85
|
},
|
|
86
86
|
{
|
|
87
|
-
"name": " 1.4 GENAI - Postgresql",
|
|
87
|
+
"name": " - 1.4 GENAI - Postgresql",
|
|
88
88
|
"type": "debugpy",
|
|
89
89
|
"request": "launch",
|
|
90
90
|
"program": "${workspaceFolder}/venv/lib/python3.12/site-packages/api_logic_server_cli/cli.py",
|
|
@@ -124,21 +124,7 @@
|
|
|
124
124
|
"internalConsoleOptions": "openOnSessionStart"
|
|
125
125
|
},
|
|
126
126
|
{
|
|
127
|
-
"name": " -
|
|
128
|
-
"type": "debugpy",
|
|
129
|
-
"request": "launch",
|
|
130
|
-
"cwd": "${workspaceFolder}/${input:runProjectName}",
|
|
131
|
-
"env": {
|
|
132
|
-
"PYTHONHASHSEED": "0",
|
|
133
|
-
"APILOGICSERVER_DEBUG": "False",
|
|
134
|
-
"OPT_LOCKING": "optional"},
|
|
135
|
-
"justMyCode": false,
|
|
136
|
-
"program": "api_logic_server_run.py",
|
|
137
|
-
"redirectOutput": true,
|
|
138
|
-
"console": "integratedTerminal"
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
"name": "ApiLogicServer Create nw_sample_nocust",
|
|
127
|
+
"name": " - ApiLogicServer Create nw_sample_nocust",
|
|
142
128
|
"type": "debugpy",
|
|
143
129
|
"request": "launch",
|
|
144
130
|
"program": "${workspaceFolder}/venv/lib/python3.12/site-packages/api_logic_server_cli/cli.py",
|
|
@@ -157,7 +143,7 @@
|
|
|
157
143
|
"internalConsoleOptions": "openOnSessionStart"
|
|
158
144
|
},
|
|
159
145
|
{
|
|
160
|
-
"name": "ApiLogicServer Create nw_sample With Customizations",
|
|
146
|
+
"name": " - ApiLogicServer Create nw_sample With Customizations",
|
|
161
147
|
"type": "debugpy",
|
|
162
148
|
"request": "launch",
|
|
163
149
|
"program": "${workspaceFolder}/venv/lib/python3.12/site-packages/api_logic_server_cli/cli.py",
|
|
@@ -175,6 +161,20 @@
|
|
|
175
161
|
"console": "internalConsole",
|
|
176
162
|
"internalConsoleOptions": "openOnSessionStart"
|
|
177
163
|
},
|
|
164
|
+
{
|
|
165
|
+
"name": "API Logic Server Run (run project from manager)",
|
|
166
|
+
"type": "debugpy",
|
|
167
|
+
"request": "launch",
|
|
168
|
+
"cwd": "${workspaceFolder}/${input:runProjectName}",
|
|
169
|
+
"env": {
|
|
170
|
+
"PYTHONHASHSEED": "0",
|
|
171
|
+
"APILOGICSERVER_DEBUG": "False",
|
|
172
|
+
"OPT_LOCKING": "optional"},
|
|
173
|
+
"justMyCode": false,
|
|
174
|
+
"program": "api_logic_server_run.py",
|
|
175
|
+
"redirectOutput": true,
|
|
176
|
+
"console": "integratedTerminal"
|
|
177
|
+
},
|
|
178
178
|
{
|
|
179
179
|
"name": "App Model Editor - Prepare",
|
|
180
180
|
"type": "node",
|
|
@@ -730,7 +730,7 @@
|
|
|
730
730
|
"id": "runProjectName",
|
|
731
731
|
"type": "promptString",
|
|
732
732
|
"description": "Project Name (folder) to run",
|
|
733
|
-
"default": "
|
|
733
|
+
"default": "genai_demo"
|
|
734
734
|
},
|
|
735
735
|
{
|
|
736
736
|
"id": "inputGenaiProjectName",
|
|
@@ -109,7 +109,7 @@ als genai --using=system/genai/examples/genai_demo/genai_demo.prompt --project-n
|
|
|
109
109
|
|
|
110
110
|
|
|
111
111
|
```bash
|
|
112
|
-
als genai --repaired-response=system/genai/examples/genai_demo/
|
|
112
|
+
als genai --repaired-response=system/genai/examples/genai_demo/genai_demo.response_example --project-name=genai_demo
|
|
113
113
|
```
|
|
114
114
|
|
|
115
115
|
Verify it's operating properly:
|
|
@@ -4,13 +4,16 @@ Include a notes field for orders.
|
|
|
4
4
|
|
|
5
5
|
Use LogicBank to enforce business logic.
|
|
6
6
|
|
|
7
|
-
Use case: Check Credit
|
|
7
|
+
Use case: Check Credit
|
|
8
8
|
1. The Customer's balance is less than the credit limit
|
|
9
9
|
2. The Customer's balance is the sum of the Order amount_total where date_shipped is null
|
|
10
10
|
3. The Order's amount_total is the sum of the Item amount
|
|
11
11
|
4. The Item amount is the quantity * unit_price
|
|
12
12
|
5. The Item unit_price is copied from the Product unit_price
|
|
13
13
|
|
|
14
|
+
Use case: App Integration
|
|
15
|
+
1. Send the Order to Kafka topic 'order_shipping' if the date_shipped is not None.
|
|
16
|
+
|
|
14
17
|
Ensure each customer has a unique name.
|
|
15
18
|
|
|
16
19
|
Ensure each Item quantity is not null.
|
api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo.response_example
CHANGED
|
@@ -60,25 +60,32 @@
|
|
|
60
60
|
"use_case": "Store the Item.unit_price as a copy from Product.unit_price",
|
|
61
61
|
"entity": "Item",
|
|
62
62
|
"code": "Rule.copy(derive=Item.unit_price, from_parent=Product.unit_price)"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "Order Kafka Integration",
|
|
66
|
+
"description": "Sends the order to Kafka topic 'order_shipping' if the date shipped is not None.",
|
|
67
|
+
"use_case": "App Integration",
|
|
68
|
+
"entity": "Order",
|
|
69
|
+
"code": "Rule.after_flush_row_event(on_class=Order, calling=kafka_producer.send_row_to_kafka, if_condition=lambda row: row.date_shipped is not None, with_args={\"topic\": \"order_shipping\"})"
|
|
63
70
|
}
|
|
64
71
|
],
|
|
65
72
|
"test_data": "Insert test data into the tables with values compatible with the derived logic.",
|
|
66
73
|
"test_data_rows": [
|
|
67
74
|
{
|
|
68
75
|
"test_data_row_variable": "test_customer_1",
|
|
69
|
-
"code": "test_customer_1 = Customer(name='Customer 1', balance=
|
|
76
|
+
"code": "test_customer_1 = Customer(name='Customer 1', balance=150, credit_limit=1000)"
|
|
70
77
|
},
|
|
71
78
|
{
|
|
72
79
|
"test_data_row_variable": "test_customer_2",
|
|
73
|
-
"code": "test_customer_2 = Customer(name='Customer 2', balance=
|
|
80
|
+
"code": "test_customer_2 = Customer(name='Customer 2', balance=275, credit_limit=750)"
|
|
74
81
|
},
|
|
75
82
|
{
|
|
76
83
|
"test_data_row_variable": "test_customer_3",
|
|
77
|
-
"code": "test_customer_3 = Customer(name='Customer 3', balance=
|
|
84
|
+
"code": "test_customer_3 = Customer(name='Customer 3', balance=150, credit_limit=1500)"
|
|
78
85
|
},
|
|
79
86
|
{
|
|
80
87
|
"test_data_row_variable": "test_customer_4",
|
|
81
|
-
"code": "test_customer_4 = Customer(name='Customer 4', balance=
|
|
88
|
+
"code": "test_customer_4 = Customer(name='Customer 4', balance=0, credit_limit=1200)"
|
|
82
89
|
},
|
|
83
90
|
{
|
|
84
91
|
"test_data_row_variable": "test_order_1",
|
|
@@ -86,11 +93,11 @@
|
|
|
86
93
|
},
|
|
87
94
|
{
|
|
88
95
|
"test_data_row_variable": "test_order_2",
|
|
89
|
-
"code": "test_order_2 = Order(customer_id=2, notes='Order 2 notes', amount_total=
|
|
96
|
+
"code": "test_order_2 = Order(customer_id=2, notes='Order 2 notes', amount_total=225)"
|
|
90
97
|
},
|
|
91
98
|
{
|
|
92
99
|
"test_data_row_variable": "test_order_3",
|
|
93
|
-
"code": "test_order_3 = Order(customer_id=2, notes='Order 3 notes', amount_total=
|
|
100
|
+
"code": "test_order_3 = Order(customer_id=2, notes='Order 3 notes', amount_total=50)"
|
|
94
101
|
},
|
|
95
102
|
{
|
|
96
103
|
"test_data_row_variable": "test_order_4",
|
|
@@ -102,11 +109,11 @@
|
|
|
102
109
|
},
|
|
103
110
|
{
|
|
104
111
|
"test_data_row_variable": "test_item_2",
|
|
105
|
-
"code": "test_item_2 = Item(order_id=2, product_id=2, quantity=2, unit_price=
|
|
112
|
+
"code": "test_item_2 = Item(order_id=2, product_id=2, quantity=2, unit_price=25, amount=50)"
|
|
106
113
|
},
|
|
107
114
|
{
|
|
108
115
|
"test_data_row_variable": "test_item_3",
|
|
109
|
-
"code": "test_item_3 = Item(order_id=3, product_id=3, quantity=
|
|
116
|
+
"code": "test_item_3 = Item(order_id=3, product_id=3, quantity=3, unit_price=75, amount=225)"
|
|
110
117
|
},
|
|
111
118
|
{
|
|
112
119
|
"test_data_row_variable": "test_item_4",
|
api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_informal.prompt
CHANGED
|
@@ -11,6 +11,9 @@ Use case: Check Credit
|
|
|
11
11
|
4. The Item amount is the quantity * unit_price
|
|
12
12
|
5. The Item unit_price is copied from the Product unit_price
|
|
13
13
|
|
|
14
|
+
Use case: App Integration
|
|
15
|
+
1. Send the Order to Kafka topic 'order_shipping' if the date_shipped is not None.
|
|
16
|
+
|
|
14
17
|
Ensure each customer has a unique name.
|
|
15
18
|
|
|
16
19
|
Ensure each Item quantity is not null.
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Requirements:
|
|
3
|
-
<Requirements>
|
|
1
|
+
|
|
4
2
|
Generate a project time tracking and invoice application
|
|
5
3
|
|
|
6
4
|
Use these names for tables and attributes:
|
|
@@ -53,142 +51,15 @@ Formula: is_paid when invoice balance is than or equal to zero
|
|
|
53
51
|
Task Count is count of InvoiceItem
|
|
54
52
|
Task completed count is count of InvoiceItem where is_completed is True
|
|
55
53
|
Formula: is ready when Task Count is equal to Task Completed Count
|
|
54
|
+
When Invoice is_ready send row to Kafka with topic 'invoice_ready'
|
|
56
55
|
|
|
57
56
|
|
|
58
57
|
Use Case: InvoiceItem
|
|
59
58
|
InvoiceItem task amount is copied from Task total task amount billed
|
|
60
|
-
|
|
59
|
+
Task is_completed is sum of InvoiceItem is_completed
|
|
61
60
|
|
|
62
61
|
|
|
63
62
|
|
|
64
63
|
.
|
|
65
64
|
Create at least 8 tables (models)
|
|
66
65
|
.
|
|
67
|
-
</Requirements>
|
|
68
|
-
|
|
69
|
-
Hints: use autonum keys (for all tables - including for link/join/junction/intersection tables), allow nulls, foreign keys, no check constraints.
|
|
70
|
-
|
|
71
|
-
Be sure to create classes, never tables.
|
|
72
|
-
Class names are singular, and first letter is capitalized.
|
|
73
|
-
|
|
74
|
-
If you create sum, count or formula Logic Bank rules, then you MUST create a corresponding column in the data model.
|
|
75
|
-
|
|
76
|
-
Remember that SQLite DateTime type only accepts Python datetime and date objects as input,
|
|
77
|
-
this means you can not enter string attributes where a date or datetime object is expected.
|
|
78
|
-
|
|
79
|
-
Don't install additional packages.
|
|
80
|
-
Don't use the faker pip package.
|
|
81
|
-
|
|
82
|
-
When creating SQLAlchemy data model classes, follow these guidelines carefully:
|
|
83
|
-
* Use foreign key columns instead of relationship names for the data.
|
|
84
|
-
* Do not specify nullable unless explicitly specified.
|
|
85
|
-
* Do not use unique unless explicitly specified.
|
|
86
|
-
* Do not use Float unless explicitly specified.
|
|
87
|
-
* Generate the classes ONLY.
|
|
88
|
-
* Do NOT generate imports.
|
|
89
|
-
* Do NOT generate connect statements.
|
|
90
|
-
* Do NOT generate engines.
|
|
91
|
-
|
|
92
|
-
Create 4 rows of test data for each table, and follow these guidelines carefully:
|
|
93
|
-
* Create separate objects for each test data row, not in arrays.
|
|
94
|
-
* Be sure to initialize derived attributes for test data rows - including all sums and counts, but do not rely on Logic Bank,
|
|
95
|
-
and do not generate db.execute statements.
|
|
96
|
-
* Do not create arrays of test data.
|
|
97
|
-
* Do not create a function to load test data.
|
|
98
|
-
* Do not print the test data.
|
|
99
|
-
* Use double quotes " for strings.
|
|
100
|
-
* For test data, format dates as date(year, month, day).
|
|
101
|
-
|
|
102
|
-
<responseFormat>
|
|
103
|
-
class Rule(BaseModel):
|
|
104
|
-
name: str
|
|
105
|
-
description: str
|
|
106
|
-
use_case: str # specified use case or requirement name (use 'General' if missing)
|
|
107
|
-
entity: str # the entity being constrained or derived
|
|
108
|
-
code: str # logicbank rule code
|
|
109
|
-
|
|
110
|
-
class Model(BaseModel):
|
|
111
|
-
classname: str
|
|
112
|
-
code: str # sqlalchemy model code
|
|
113
|
-
sqlite_create: str # sqlite create table statement
|
|
114
|
-
description: str
|
|
115
|
-
name: str
|
|
116
|
-
|
|
117
|
-
class TestDataRow(BaseModel):
|
|
118
|
-
test_data_row_variable: str # the Python test data row variable
|
|
119
|
-
code: str # Python code to create a test data row instance
|
|
120
|
-
|
|
121
|
-
class WGResult(BaseModel): # must match system/genai/prompt_inserts/response_format.prompt
|
|
122
|
-
# response: str # result
|
|
123
|
-
models : List[Model] # list of sqlalchemy classes in the response
|
|
124
|
-
rules : List[Rule] # list rule declarations
|
|
125
|
-
test_data: str
|
|
126
|
-
test_data_rows: List[TestDataRow] # list of test data rows
|
|
127
|
-
test_data_sqlite: str # test data as sqlite INSERT statements
|
|
128
|
-
name: str # suggest a short name for the project
|
|
129
|
-
|
|
130
|
-
Format the response as a WGResult.
|
|
131
|
-
|
|
132
|
-
</responseFormat>
|
|
133
|
-
|
|
134
|
-
<responseFormat>
|
|
135
|
-
|
|
136
|
-
class Rule(BaseModel):
|
|
137
|
-
|
|
138
|
-
name: str
|
|
139
|
-
|
|
140
|
-
description: str
|
|
141
|
-
|
|
142
|
-
use_case: str # specified use case or requirement name (use 'General' if missing)
|
|
143
|
-
|
|
144
|
-
entity: str # the entity being constrained or derived
|
|
145
|
-
|
|
146
|
-
code: str # logicbank rule code
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
class Model(BaseModel):
|
|
151
|
-
|
|
152
|
-
classname: str
|
|
153
|
-
|
|
154
|
-
code: str # sqlalchemy model code
|
|
155
|
-
|
|
156
|
-
sqlite_create: str # sqlite create table statement
|
|
157
|
-
|
|
158
|
-
description: str
|
|
159
|
-
|
|
160
|
-
name: str
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
class TestDataRow(BaseModel):
|
|
165
|
-
|
|
166
|
-
test_data_row_variable: str # the Python test data row variable
|
|
167
|
-
|
|
168
|
-
code: str # Python code to create a test data row instance
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
class WGResult(BaseModel): # must match system/genai/prompt_inserts/response_format.prompt
|
|
173
|
-
|
|
174
|
-
# response: str # result
|
|
175
|
-
|
|
176
|
-
models : List[Model] # list of sqlalchemy classes in the response
|
|
177
|
-
|
|
178
|
-
rules : List[Rule] # list rule declarations
|
|
179
|
-
|
|
180
|
-
test_data: str
|
|
181
|
-
|
|
182
|
-
test_data_rows: List[TestDataRow] # list of test data rows
|
|
183
|
-
|
|
184
|
-
test_data_sqlite: str # test data as sqlite INSERT statements
|
|
185
|
-
|
|
186
|
-
name: str # suggest a short name for the project
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
Format the response as a WGResult.
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
</responseFormat>
|
|
Binary file
|
api_logic_server_cli/prototypes/manager/system/genai/examples/time_tracking_billing/readme.md
CHANGED
|
@@ -1,8 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
# Time Tracking and Billing
|
|
2
|
+
Here, we create a time-tracking system, being specific about tables and columns in the [002_create_db_models.prompt](./). Each table has additional attributes that are used to hold sums, counts, and formula. Each table has a Use Case definition that describes the business logic using natural language.
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
## Command Line - create this system:
|
|
5
5
|
```bash
|
|
6
|
-
# create the
|
|
7
|
-
als genai --project-name=
|
|
8
|
-
```
|
|
6
|
+
# create the time_track system
|
|
7
|
+
$als genai --project-name=time_track --using=system/genai/examples/time_tracking_billing/002_create_db_models.prompt
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Review the created system
|
|
11
|
+
Open the time_track in VSCode or CodeSpaces and start the ApiLogicServer (F5). This will start the server and the react-admin site (http://localhost:5656). You should see Client, Project, Task, Timesheet, Person, and Invoice with sample data generated by WebGenAI.
|
|
12
|
+
|
|
13
|
+
## Review the Logic
|
|
14
|
+
The /logic directory contains the generated logic (/logic/wg_rules). This will show how natural language is translated into LogicBank rules (/logic/wg_rules/active_rules_export.py). The other rules[n].py in the wg_rules folder are used and tested by WebGenAI and can be ignored.
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
# Exported Rules:
|
|
18
|
+
# Rule 1
|
|
19
|
+
# Total Hours entered is sum of timesheet hours worked
|
|
20
|
+
Rule.sum(derive=Person.total_hours_entered, as_sum_of=Timesheet.hours_worked)
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Add Security and Enable Defaults
|
|
25
|
+
The authentication service can be added using the command line
|
|
26
|
+
```
|
|
27
|
+
$als add-auth --provider-type=sql # Local SQLIte
|
|
28
|
+
$als add-auth --provider-type=keycloak # Local KeyCloak (see docs)
|
|
29
|
+
$als add-auth --provider-type=sql --db-url={database config} # Use SQL database User/Role
|
|
30
|
+
```
|
|
31
|
+
To ensure defaults are applied (impacts rules) we need to add a global environment variable in the environment and restart the application.
|
|
32
|
+
ALL_DEFAULTS=True
|
|
33
|
+
|
|
34
|
+
## Add Ontimize Application
|
|
35
|
+
To create an angular Ontimize application, you need to follow these steps. Note the name 'app' is your project name which you can change or create another project.
|
|
36
|
+
```
|
|
37
|
+
$cd timetrack
|
|
38
|
+
$als app-create --app=app #if the ui/app folder does not exist
|
|
39
|
+
$als app-build --app=app # generates pages from the API entities
|
|
40
|
+
$cd ui/app
|
|
41
|
+
|
|
42
|
+
$npm install && npm start # install and start the NodeJS/Angular app
|
|
43
|
+
|
|
44
|
+
# Launch your new Ontimize application (http://localhost:4299)
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Testing Time Tracker and Billing
|
|
49
|
+
You can delete the existing sample data or you can start by entering new data. To test the logic - follow these steps:
|
|
50
|
+
```
|
|
51
|
+
1. Enter new Client
|
|
52
|
+
2. Enter new Person (works for Client, Billing Rate 100)
|
|
53
|
+
3. Enter new Project for client
|
|
54
|
+
4. Enter new Task for Project
|
|
55
|
+
5. Enter new Timesheet - enter task and person for client (enter hours worked)
|
|
56
|
+
|
|
57
|
+
Watch Rules fired in log and then review the sums, counts, formula and constraints.
|
|
58
|
+
Note: The Client total amount should be the same value as Project, Task, and Timesheet.
|
|
59
|
+
|
|
60
|
+
Bonus: Enter an Invoice for a Client/Project then add Invoice Item for a specific Client Task. Once the invoice is ready - we can add a new Event (logic) to send to Kafka.
|
|
61
|
+
```
|
api_logic_server_cli/prototypes/manager/system/genai/learning_requests/logic_bank_api.prompt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Here is the simplified API for LogicBank:
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Translate the user prompt into a series of calls to Rule methods, described here.
|
|
4
4
|
|
|
5
5
|
Do not generate import statements.
|
|
6
6
|
|
|
@@ -126,6 +126,27 @@ class Rule:
|
|
|
126
126
|
return Copy(derive=derive, from_parent=from_parent)
|
|
127
127
|
|
|
128
128
|
|
|
129
|
+
@staticmethod
|
|
130
|
+
def after_flush_row_event(on_class: object, calling: Callable = None,
|
|
131
|
+
if_condition: any = None,
|
|
132
|
+
when_condition: any = None,
|
|
133
|
+
with_args: dict = None):
|
|
134
|
+
|
|
135
|
+
Example:
|
|
136
|
+
Prompt:
|
|
137
|
+
Send the Order to Kafka topic 'order_shipping' if the date_shipped is not None
|
|
138
|
+
Response:
|
|
139
|
+
Rule.after_flush_row_event(on_class=Order, calling=kafka_producer.send_row_to_kafka,
|
|
140
|
+
if_condition=lambda row: row.date_shipped is not None,
|
|
141
|
+
with_args={"topic": "order_shipping"})
|
|
142
|
+
Prompt:
|
|
143
|
+
Send the Product to Kafka topic 'ready_to_ship' if the is_complete is True
|
|
144
|
+
Response:
|
|
145
|
+
Rule.after_flush_row_event(on_class=Product, calling=kafka_producer.send_row_to_kafka,
|
|
146
|
+
if_condition=lambda row: row.is_complete is True,
|
|
147
|
+
with_args={"topic": "ready_to_ship"})
|
|
148
|
+
|
|
149
|
+
|
|
129
150
|
Expanded example:
|
|
130
151
|
|
|
131
152
|
Prompt:
|