ApiLogicServer 14.3.7__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.
Files changed (28) hide show
  1. {ApiLogicServer-14.3.7.dist-info → ApiLogicServer-14.3.11.dist-info}/METADATA +3 -3
  2. {ApiLogicServer-14.3.7.dist-info → ApiLogicServer-14.3.11.dist-info}/RECORD +26 -25
  3. api_logic_server_cli/api_logic_server.py +2 -2
  4. api_logic_server_cli/api_logic_server_info.yaml +3 -3
  5. api_logic_server_cli/create_from_model/ont_build.py +8 -8
  6. api_logic_server_cli/create_from_model/safrs-react-admin-npm-build/asset-manifest.json +3 -3
  7. api_logic_server_cli/create_from_model/safrs-react-admin-npm-build/build-0213.txt +1 -0
  8. api_logic_server_cli/create_from_model/safrs-react-admin-npm-build/index.html +1 -1
  9. api_logic_server_cli/create_from_model/safrs-react-admin-npm-build/static/js/main.7c8c0e37.js +3 -0
  10. api_logic_server_cli/create_from_model/safrs-react-admin-npm-build/static/js/{main.bfe80d1d.js.map → main.7c8c0e37.js.map} +1 -1
  11. api_logic_server_cli/database/nw-gold.sqlite +0 -0
  12. api_logic_server_cli/genai/genai.py +9 -3
  13. api_logic_server_cli/prototypes/base/devops/docker-image/env.list +7 -2
  14. api_logic_server_cli/prototypes/base/integration/kafka/kafka_producer.py +2 -3
  15. api_logic_server_cli/prototypes/manager/.vscode/ApiLogicServer.code-workspace +2 -2
  16. api_logic_server_cli/prototypes/manager/.vscode/launch.json +20 -20
  17. api_logic_server_cli/prototypes/manager/system/genai/examples/time_tracking_billing/002_create_db_models.prompt +3 -132
  18. api_logic_server_cli/prototypes/manager/system/genai/examples/time_tracking_billing/Invoice Made Ready.png +0 -0
  19. api_logic_server_cli/prototypes/manager/system/genai/examples/time_tracking_billing/readme.md +3 -3
  20. api_logic_server_cli/prototypes/manager/system/genai/learning_requests/logic_bank_api.prompt +7 -0
  21. api_logic_server_cli/prototypes/nw/logic/declare_logic.py +1 -1
  22. api_logic_server_cli/create_from_model/safrs-react-admin-npm-build/build-0106.txt +0 -1
  23. api_logic_server_cli/create_from_model/safrs-react-admin-npm-build/static/js/main.bfe80d1d.js +0 -3
  24. {ApiLogicServer-14.3.7.dist-info → ApiLogicServer-14.3.11.dist-info}/LICENSE +0 -0
  25. {ApiLogicServer-14.3.7.dist-info → ApiLogicServer-14.3.11.dist-info}/WHEEL +0 -0
  26. {ApiLogicServer-14.3.7.dist-info → ApiLogicServer-14.3.11.dist-info}/entry_points.txt +0 -0
  27. {ApiLogicServer-14.3.7.dist-info → ApiLogicServer-14.3.11.dist-info}/top_level.txt +0 -0
  28. /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
@@ -315,8 +315,14 @@ class GenAI(object):
315
315
  log.debug(f'.. from file: {self.project.genai_using}')
316
316
  raw_prompt = file.read()
317
317
  prompt = self.get_prompt__with_inserts(raw_prompt=raw_prompt, for_iteration=False) # insert db-specific logic
318
- self.logic_enabled = False
319
- if 'LogicBank' in prompt and K_LogicBankOff not in prompt: # if prompt has logic, we need to insert the training
318
+ self.logic_enabled = True
319
+ if os.environ.get("APILOGICPROJECT_LOGIC_ENABLED") is not None and \
320
+ os.environ.get("APILOGICPROJECT_LOGIC_ENABLED") == 'False':
321
+ self.logic_enabled = False
322
+ log.info("*** Initial Logic Disabled: {self.logic_enabled}")
323
+ else:
324
+ log.debug(f'.. Initial Logic enabled: {self.logic_enabled}')
325
+ if self.logic_enabled == True or ('LogicBank' in prompt and K_LogicBankOff not in prompt): # if prompt has logic, we need to insert the training
320
326
  prompt_messages.extend( self.get_prompt_learning_requests())
321
327
  self.logic_enabled = True
322
328
  if prompt.startswith('You are a '): # if it's a preset, we need to insert the prompt
@@ -329,7 +335,7 @@ class GenAI(object):
329
335
  active_rules_json_path = Path(self.project.genai_using).joinpath('logic/active_rules.json')
330
336
  # assert active_rules_json_path.exists(), f"Missing active_rules.json: {active_rules_json_path}"
331
337
  if not active_rules_json_path.exists():
332
- log.info("*** Internal error: --active_rules specified, but no --using/logic/active_rules.json found - try to proced")
338
+ log.info("*** Internal error: --active_rules specified, but no --using/logic/active_rules.json found - try to proceed")
333
339
  else:
334
340
  with open(active_rules_json_path, 'r') as file:
335
341
  active_rules_str = file.read()
@@ -40,11 +40,16 @@
40
40
  # whether to invoke dbinit befoce connecting...
41
41
  # APILOGICSERVER_ORACLE_THICK=~/Downloads/instantclient_19_16
42
42
 
43
+ # enables aggregate defaulting, and defaulting for all numerics and strings
44
+ # used to initialize rows prior to logic, to avoid excessive None testing
45
+ # AGGREGATE_DEFAULTS=True
46
+ # ALL_DEFAULTS=True
47
+
43
48
  APILOGICPROJECT_VERBOSE=True
44
49
 
45
50
  # APILOGICPROJECT_LOG_CONFIG=
46
- """ name of log.yml file (eg, config/logging_prod.yml) """
51
+ # name of log.yml file (eg, config/logging_prod.yml)
47
52
 
48
53
  # APILOGICPROJECT_STOP_OK=FALSE
49
- """ dev only - enable stop url: http://localhost:5656/stop?msg=reason """
54
+ # dev only - enable stop url: http://localhost:5656/stop?msg=reason
50
55
 
@@ -1,6 +1,6 @@
1
1
  """
2
2
 
3
- Version 2.0
3
+ Version 2.1
4
4
 
5
5
  Invoked at server start (api_logic_server_run.py -> config/setup.py)
6
6
 
@@ -117,5 +117,4 @@ def send_kafka_message(kafka_topic: str, kafka_key: str = None, msg: str="", jso
117
117
 
118
118
 
119
119
  def send_row_to_kafka(row: object, old_row: object, logic_row: LogicRow, with_args: dict):
120
- if logic_row.row.date_shipped is not None:
121
- send_kafka_message(logic_row=logic_row, kafka_topic=with_args["topic"])
120
+ send_kafka_message(logic_row=logic_row, kafka_topic=with_args["topic"])
@@ -9,7 +9,7 @@
9
9
  "workbench.editorAssociations": {
10
10
  "*.md": "vscode.markdown.preview.editor"
11
11
  },
12
- "workbench.colorTheme": "Office Theme (Excel)",
13
- "workbench.preferredLightColorTheme": "Office Theme (Excel)"
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": " - API Logic Server Run (run project from manager)",
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",
@@ -1,6 +1,4 @@
1
- Use SQLAlchemy to create a sqlite database named system/genai/temp/create_db_models.sqlite for the following requirements. These requirements are very important!
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
- InvoiceItem is_completed is sum of Task is_completed when True
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>
@@ -49,8 +49,8 @@ $npm install && npm start # install and start the NodeJS/Angular app
49
49
  You can delete the existing sample data or you can start by entering new data. To test the logic - follow these steps:
50
50
  ```
51
51
  1. Enter new Client
52
- 2. Enter new Person (works for Client)
53
- 3. Enter new Project for client (enter billing rate)
52
+ 2. Enter new Person (works for Client, Billing Rate 100)
53
+ 3. Enter new Project for client
54
54
  4. Enter new Task for Project
55
55
  5. Enter new Timesheet - enter task and person for client (enter hours worked)
56
56
 
@@ -58,4 +58,4 @@ Watch Rules fired in log and then review the sums, counts, formula and constrain
58
58
  Note: The Client total amount should be the same value as Project, Task, and Timesheet.
59
59
 
60
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
- ```
61
+ ```
@@ -139,6 +139,13 @@ class Rule:
139
139
  Rule.after_flush_row_event(on_class=Order, calling=kafka_producer.send_row_to_kafka,
140
140
  if_condition=lambda row: row.date_shipped is not None,
141
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
+
142
149
 
143
150
  Expanded example:
144
151
 
@@ -191,7 +191,7 @@ def declare_logic():
191
191
 
192
192
 
193
193
  def ship_ready_orders_only(row: Order, old_row: Order, logic_row: LogicRow) -> bool:
194
- invalid_row = row.Ready == False and row.ShippedDate is not None and old_row.ShippedDate is None
194
+ invalid_row = logic_row.is_updated() and row.Ready == False and row.ShippedDate is not None and old_row.ShippedDate is None
195
195
  return not invalid_row
196
196
 
197
197
  Rule.constraint(validate=Order, # Do not ship orders that are not ready
@@ -1 +0,0 @@
1
- Mon Jan 6 08:27:06 CET 2025