ApiLogicServer 14.3.25__py3-none-any.whl → 14.4.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.
- api_logic_server_cli/api_logic_server.py +4 -14
- api_logic_server_cli/api_logic_server_info.yaml +3 -3
- api_logic_server_cli/cli.py +16 -7
- api_logic_server_cli/create_from_model/__pycache__/create_db_from_model.cpython-312.pyc +0 -0
- api_logic_server_cli/create_from_model/__pycache__/ont_build.cpython-312.pyc +0 -0
- api_logic_server_cli/create_from_model/__pycache__/ont_create.cpython-312.pyc +0 -0
- api_logic_server_cli/create_from_model/create_db_from_model.py +2 -0
- api_logic_server_cli/create_from_model/ont_build.py +19 -14
- api_logic_server_cli/create_from_model/ont_create.py +5 -5
- api_logic_server_cli/create_from_model/safrs-react-admin-npm-build/static/.DS_Store +0 -0
- api_logic_server_cli/database/nw-gold-fix.sql +62 -0
- api_logic_server_cli/database/nw-gold.sqlite +0 -0
- api_logic_server_cli/{prototypes/manager/webgenai → fragments}/docker-compose.yml +1 -1
- api_logic_server_cli/genai/genai.py +42 -11
- api_logic_server_cli/genai/genai_graphics.py +252 -38
- api_logic_server_cli/genai/genai_svcs.py +20 -12
- api_logic_server_cli/manager.py +19 -10
- api_logic_server_cli/prototypes/.DS_Store +0 -0
- api_logic_server_cli/prototypes/base/.DS_Store +0 -0
- api_logic_server_cli/prototypes/base/.vscode/launch.json +19 -0
- api_logic_server_cli/prototypes/base/api/expose_api_models.py +3 -1
- api_logic_server_cli/prototypes/base/api_logic_server_run.py +5 -2
- api_logic_server_cli/prototypes/base/config/activate_logicbank.py +1 -0
- api_logic_server_cli/prototypes/base/config/config.py +57 -14
- api_logic_server_cli/prototypes/base/config/logging.yml +1 -0
- api_logic_server_cli/prototypes/base/config/server_setup.py +33 -1
- api_logic_server_cli/prototypes/base/database/test_data/readme.md +3 -1
- api_logic_server_cli/prototypes/base/devops/docker-standard-image/docker-compose-standard-image.yml +7 -2
- api_logic_server_cli/prototypes/base/docs/training/logic_bank_api.prompt +314 -0
- api_logic_server_cli/prototypes/base/docs/training/logic_example.py +41 -0
- api_logic_server_cli/prototypes/base/integration/kafka/kafka_producer.py +7 -3
- api_logic_server_cli/prototypes/base/integration/system/FlaskKafka.py +5 -1
- api_logic_server_cli/prototypes/base/ui/templates/bar_chart.jinja +64 -0
- api_logic_server_cli/prototypes/genai_demo/ui/admin/admin.yaml +1 -1
- api_logic_server_cli/prototypes/manager/README.md +26 -4
- api_logic_server_cli/prototypes/manager/system/genai/.DS_Store +0 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/.DS_Store +0 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/.DS_Store +0 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo.prompt +0 -10
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo.response_example +32 -10
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_docs_logic/docs/002_create_db_models.prompt +4 -4
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_docs_logic/docs/003_create_db_models.response +77 -47
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_informal.prompt +1 -1
- api_logic_server_cli/prototypes/manager/system/genai/graphics_templates/dashboard_services.jinja +83 -0
- api_logic_server_cli/prototypes/manager/system/genai/graphics_templates/graphics_dashboard_WIP.py +34 -0
- api_logic_server_cli/prototypes/manager/system/genai/graphics_templates/{graphics_services.py → graphics_services_api_xxx.py} +0 -9
- api_logic_server_cli/prototypes/manager/system/genai/graphics_templates/graphics_services_db.jinja +46 -0
- api_logic_server_cli/prototypes/manager/system/genai/graphics_templates/graphics_services_db_each_method.jinja +36 -0
- api_logic_server_cli/prototypes/manager/system/genai/prompt_inserts/graphics.prompt +7 -3
- api_logic_server_cli/prototypes/manager/system/genai/prompt_inserts/response_format.prompt +8 -1
- api_logic_server_cli/prototypes/manager/system/install-ApiLogicServer-dev/install-ApiLogicServer-dev.ps1 +100 -0
- api_logic_server_cli/prototypes/manager/system/install-ApiLogicServer-dev/install-ApiLogicServer-dev.sh +116 -0
- api_logic_server_cli/prototypes/manager/system/install-ApiLogicServer-dev/readme.md +7 -0
- api_logic_server_cli/prototypes/manager/system/style-guide.yaml +2 -2
- api_logic_server_cli/prototypes/manager/webgenai/README.md +6 -0
- api_logic_server_cli/prototypes/nw/docs/graphics/count_orders_by_category.prompt +1 -0
- api_logic_server_cli/prototypes/nw/docs/graphics/order_count_by_month.prompt +1 -0
- api_logic_server_cli/prototypes/nw/docs/graphics/request copy.json +892 -0
- api_logic_server_cli/prototypes/nw/docs/graphics/request.json +6 -0
- api_logic_server_cli/prototypes/nw/docs/graphics/response.json +17 -0
- api_logic_server_cli/prototypes/nw/docs/graphics/response.yaml +59 -0
- api_logic_server_cli/prototypes/nw/docs/graphics/sales_by_category.prompt +1 -0
- api_logic_server_cli/prototypes/nw/ui/admin/home.js +5 -4
- api_logic_server_cli/prototypes/nw/ui/app_model_custom.yaml +851 -1082
- api_logic_server_cli/prototypes/nw_no_cust/docs/graphics/count_orders_by_category.prompt +1 -0
- api_logic_server_cli/prototypes/nw_no_cust/docs/graphics/sales_by_employee.prompt +1 -0
- api_logic_server_cli/prototypes/nw_no_cust/integration/mcp/1_langchain_loader.py +19 -0
- api_logic_server_cli/prototypes/nw_no_cust/integration/mcp/2_gpt_mcp_prompt.txt +19 -0
- api_logic_server_cli/prototypes/nw_no_cust/integration/mcp/3_executor_test_agent.py +38 -0
- api_logic_server_cli/prototypes/nw_no_cust/integration/mcp/README.md +17 -0
- api_logic_server_cli/prototypes/nw_no_cust/integration/mcp/resources/curl.txt +4 -0
- api_logic_server_cli/prototypes/nw_no_cust/integration/mcp/resources/nw_swagger_3.yaml +16660 -0
- api_logic_server_cli/prototypes/nw_no_cust/integration/mcp/run_executor.py +23 -0
- api_logic_server_cli/prototypes/ont_app/ontimize_seed/nginx/nginx.conf +2 -2
- api_logic_server_cli/prototypes/ont_app/ontimize_seed/package.json +6 -6
- api_logic_server_cli/prototypes/ont_app/ontimize_seed/src/app/app.config.ts +2 -1
- api_logic_server_cli/prototypes/ont_app/ontimize_seed/src/environments/environment.prod.ts +5 -5
- api_logic_server_cli/prototypes/ont_app/ontimize_seed/src/environments/environment.ts +5 -5
- api_logic_server_cli/prototypes/ont_app/templates/app_config.jinja +1 -1
- api_logic_server_cli/prototypes/ont_app/templates/detail_template.html +1 -1
- api_logic_server_cli/prototypes/ont_app/templates/new_template.html +16 -16
- apilogicserver-14.4.0.dist-info/METADATA +76 -0
- {apilogicserver-14.3.25.dist-info → apilogicserver-14.4.0.dist-info}/RECORD +87 -56
- {apilogicserver-14.3.25.dist-info → apilogicserver-14.4.0.dist-info}/WHEEL +1 -1
- api_logic_server_cli/prototypes/manager/system/genai/graphics_templates/service_template_jsonapi_rpc.jinja +0 -37
- api_logic_server_cli/prototypes/manager/system/genai/graphics_templates/service_template_unused.jinja +0 -38
- apilogicserver-14.3.25.dist-info/METADATA +0 -167
- {apilogicserver-14.3.25.dist-info → apilogicserver-14.4.0.dist-info}/entry_points.txt +0 -0
- {apilogicserver-14.3.25.dist-info → apilogicserver-14.4.0.dist-info}/licenses/LICENSE +0 -0
- {apilogicserver-14.3.25.dist-info → apilogicserver-14.4.0.dist-info}/top_level.txt +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
'''
|
|
4
4
|
ApiLogicServer CLI: given a database url, create [and run] customizable ApiLogicProject.
|
|
5
5
|
* Basically clones prototype project (api_logic_server_cli/prototypes/base), and creates:
|
|
6
|
-
* database/models.py for SQLAlchemy
|
|
6
|
+
* database/models.py for SQLAlchemy, using modified sqlacodegen & safrs metadata
|
|
7
7
|
* ui/admin/admin.yaml for the Admin App - using introspected models.py
|
|
8
8
|
* api/expose_api_models.py for a safrs api - using introspected models.py
|
|
9
9
|
* Special provisions for NW Sample, to show customizations.
|
|
@@ -12,26 +12,18 @@ 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.
|
|
15
|
+
__version__ = "14.04.00" # last public release: 14.04.00
|
|
16
16
|
recent_changes = \
|
|
17
17
|
f'\n\nRecent Changes:\n' +\
|
|
18
|
+
"\t04/27/2024 - 14.04.00: Graphics preview, Vibe install fix, Improved IDE Chat Logic, MCP Exploration \n"\
|
|
18
19
|
"\t03/30/2024 - 14.03.25: WebGenAI fixes for Kafka and Keycloak \n"\
|
|
19
20
|
"\t03/19/2024 - 14.03.20: licensed webgenai docker, [87] sra fix for home.js \n"\
|
|
20
21
|
"\t02/26/2024 - 14.03.14: [85: reserved words], genai_demo fixes \n"\
|
|
21
|
-
"\t02/16/2024 - 14.03.12: Docker w/ std container, mgr assistant for local WebG \n"\
|
|
22
|
-
"\t02/13/2024 - 14.03.11: fixes [78: Keycloak, 79: boolean defaulting, 80: Send If missing attribute] \n"\
|
|
23
|
-
"\t01/31/2024 - 14.03.00: Issue 76: exp ending in right paren, Issue 74: Multi-db fix, extended default options, if-based Nat Lang formulas \n"\
|
|
24
|
-
"\t01/29/2024 - 14.02.34: save docs/response.json to fix bad rules for IS_GENAI_DEMO, LogicBank 1.20.23 (all defaults) \n"\
|
|
25
|
-
"\t01/26/2024 - 14.02.31: genai_logic fail-safe, Issue 74: Multi-db fix, support models named Rule, wg logic discovery, if formula \n"\
|
|
26
22
|
"\t01/17/2024 - 14.02.20: WebGenAI support, genai_demo \n"\
|
|
27
23
|
"\t01/06/2024 - 14.01.00: N8N, Rebuild test data, Fixup, Project Import, Improved reporting of missing attributes, Simplified RowDictMaper \n"\
|
|
28
24
|
"\t11/18/2024 - 12.02.00: genai: 'qualified any' now supported in logic training \n"\
|
|
29
25
|
"\t10/31/2024 - 12.01.00: genai: informal rules (eg, Sum of employee salaries cannot exceed department budget) \n"\
|
|
30
|
-
"\t10/21/2024 - 12.00.04: sra 10-22, Prelim support genai --using=dir/project \n"\
|
|
31
26
|
"\t10/12/2024 - 12.00.02: Natural Language Logic \n"\
|
|
32
|
-
"\t10/17/2024 - 11.02.19: singular classes, expanded doc/prompts, logic work-arounds, docs/logic, logic learning, readme \n"\
|
|
33
|
-
"\t10/11/2024 - 11.02.14: NL/Logic with test data calcs, sra 10-07-2024, genai-logic, cs, iteration rebuild \n"\
|
|
34
|
-
"\t08/02/2024 - 11.00.07: App Model Editor UI rework, docs and fix for kc and export \n"\
|
|
35
27
|
"\t07/25/2024 - 11.00.00: Keycloak, App Model Editor \n"\
|
|
36
28
|
"\t03/28/2024 - 10.03.46: Python 3.12, View support, CLI option-names, Keycloak preview \n"\
|
|
37
29
|
"\t12/19/2023 - 10.00.00: Kafka pub/sub, Fix MySQL CHAR/String, list/hash/set types \n"\
|
|
@@ -39,8 +31,6 @@ recent_changes = \
|
|
|
39
31
|
"\t09/14/2023 - 09.03.00: Oracle support \n"\
|
|
40
32
|
"\t06/22/2023 - 09.00.00: Optimistic Locking, safrs 310, SQLAlchemy 2.0.15 \n"\
|
|
41
33
|
"\t05/01/2023 - 08.03.06: allocation sample \n"\
|
|
42
|
-
"\t04/26/2023 - 08.03.00: virt attrs (Issue 56), safrs 3.0.2, readme updates, LogicBank 1.8.4 \n"\
|
|
43
|
-
"\t04/13/2023 - 08.02.00: integratedConsole, logic logging (66), table relns fix (65) \n"\
|
|
44
34
|
"\t02/15/2023 - 08.00.01: Declarative Authorization and Authentication, Werkzeug==2.2.3 \n"\
|
|
45
35
|
"\t01/06/2023 - 07.00.00: Multi-db, sqlite test dbs, tests run, security prototype, env config \n"\
|
|
46
36
|
|
|
@@ -1960,7 +1950,7 @@ from database import <project.bind_key>_models
|
|
|
1960
1950
|
ont_creator = OntCreator(project = build.project)
|
|
1961
1951
|
ont_creator.create_application(show_messages=False)
|
|
1962
1952
|
|
|
1963
|
-
if
|
|
1953
|
+
if self.project_directory_path.joinpath('ui/app_model_custom.yaml').exists():
|
|
1964
1954
|
# eg, nw project contains this for demo purposes
|
|
1965
1955
|
copyfile (src=self.project_directory_path.joinpath('ui/app_model_custom.yaml'),
|
|
1966
1956
|
dst=self.project_directory_path.joinpath('ui/app/app_model.yaml'))
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
last_created_date:
|
|
2
|
-
last_created_project_name:
|
|
3
|
-
last_created_version: 14.03.
|
|
1
|
+
last_created_date: April 27, 2025 12:43:11
|
|
2
|
+
last_created_project_name: genai_demo_
|
|
3
|
+
last_created_version: 14.03.51
|
api_logic_server_cli/cli.py
CHANGED
|
@@ -221,7 +221,7 @@ def main(ctx):
|
|
|
221
221
|
help="Create sample projects")
|
|
222
222
|
@click.option('--open-manager/--no-open-manager', "open_manager",
|
|
223
223
|
default=True, is_flag=True,
|
|
224
|
-
help="
|
|
224
|
+
help="Whether to open IDE at Manager")
|
|
225
225
|
def create_start_manager(ctx, open_with, clean: click.BOOL = True, samples: click.BOOL = True,
|
|
226
226
|
volume: str = "ApiLogicServer", open_manager: click.BOOL = True):
|
|
227
227
|
"""
|
|
@@ -615,14 +615,14 @@ def genai(ctx, using, db_url, repaired_response: str,
|
|
|
615
615
|
Creates new customizable project (overwrites).
|
|
616
616
|
"""
|
|
617
617
|
global command
|
|
618
|
-
import api_logic_server_cli.genai.genai as
|
|
618
|
+
import api_logic_server_cli.genai.genai as genai
|
|
619
619
|
if using is None and repaired_response is None:
|
|
620
620
|
log.error("Error - must provide --using or --repaired-response")
|
|
621
621
|
exit(1)
|
|
622
622
|
defaulted_using = using
|
|
623
623
|
if defaulted_using == 'genai_demo': # default to genai_demo.prompt
|
|
624
624
|
defaulted_using = 'system/genai/examples/genai_demo/genai_demo.prompt'
|
|
625
|
-
|
|
625
|
+
genai.genai_cli_with_retry(using=defaulted_using, db_url=db_url, repaired_response=repaired_response,
|
|
626
626
|
genai_version=genai_version, temperature=temperature,
|
|
627
627
|
retries=retries, opt_locking=opt_locking, genai_active_rules=active_rules,
|
|
628
628
|
prompt_inserts=prompt_inserts, quote=quote, use_relns=use_relns,
|
|
@@ -745,8 +745,11 @@ def genai_logic(ctx, using, genai_version: str, retries: int, suggest: click.BOO
|
|
|
745
745
|
@click.option('--genai-version', 'genai_version',
|
|
746
746
|
default='gpt-4o',
|
|
747
747
|
help="Eg, gpt-3.5-turbo, gpt-4o")
|
|
748
|
+
@click.option('--replace-with', 'replace_with',
|
|
749
|
+
default='!using',
|
|
750
|
+
help="Replace Graphics with this (*/retry, ''/delete)")
|
|
748
751
|
@click.pass_context
|
|
749
|
-
def genai_graphics(ctx, using, genai_version: str):
|
|
752
|
+
def genai_graphics(ctx, using, genai_version: str, replace_with: str):
|
|
750
753
|
"""
|
|
751
754
|
Adds (or suggests) logic to current project.
|
|
752
755
|
"""
|
|
@@ -771,7 +774,7 @@ def genai_graphics(ctx, using, genai_version: str):
|
|
|
771
774
|
log.info(f'... Typical usage - cd into project, use --project_name=. \n')
|
|
772
775
|
exit (1)
|
|
773
776
|
from api_logic_server_cli.genai.genai_graphics import GenAIGraphics
|
|
774
|
-
genai_graphics = GenAIGraphics(using=using, project=project, genai_version=genai_version)
|
|
777
|
+
genai_graphics = GenAIGraphics(using=using, project=project, genai_version=genai_version, replace_with=replace_with)
|
|
775
778
|
pass
|
|
776
779
|
log.info("")
|
|
777
780
|
|
|
@@ -1451,17 +1454,23 @@ def add_auth_cmd(ctx, bind_key_url_separator: str, provider_type :str, db_url: s
|
|
|
1451
1454
|
|
|
1452
1455
|
cd existing_project
|
|
1453
1456
|
|
|
1454
|
-
ApiLogicServer add-auth
|
|
1457
|
+
ApiLogicServer add-auth
|
|
1458
|
+
|
|
1459
|
+
ApiLogicServer add-auth --db-url=add-auth
|
|
1460
|
+
|
|
1455
1461
|
ApiLogicServer add-auth provider_type=keycloak
|
|
1456
1462
|
|
|
1457
1463
|
"""
|
|
1458
1464
|
project_name = resolve_blank_project_name(project_name)
|
|
1459
1465
|
bind_key = "authentication"
|
|
1466
|
+
auth_db_url = db_url
|
|
1467
|
+
if db_url == "auth" and provider_type == "sql":
|
|
1468
|
+
auth_db_url = "add-auth"
|
|
1460
1469
|
project = PR.ProjectRun(command="add_security",
|
|
1461
1470
|
project_name=project_name,
|
|
1462
1471
|
api_name=api_name,
|
|
1463
1472
|
db_url="",
|
|
1464
|
-
auth_db_url=
|
|
1473
|
+
auth_db_url=auth_db_url,
|
|
1465
1474
|
auth_provider_type=provider_type,
|
|
1466
1475
|
bind_key=bind_key,
|
|
1467
1476
|
bind_key_url_separator=bind_key_url_separator,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -12,6 +12,8 @@ log = logging.getLogger('create_from_model.model_creation_services')
|
|
|
12
12
|
def create_db(project: Project):
|
|
13
13
|
""" Create a database from a model file
|
|
14
14
|
|
|
15
|
+
Warning - test data failure is not reported here
|
|
16
|
+
|
|
15
17
|
Args:
|
|
16
18
|
project (Project): contains the model file and db_url locations
|
|
17
19
|
"""
|
|
@@ -90,7 +90,7 @@ class OntBuilder(object):
|
|
|
90
90
|
self.keycloak_realm = "kcals"
|
|
91
91
|
self.keycloak_client_id = "alsclient"
|
|
92
92
|
self.exclude_listpicker = False
|
|
93
|
-
self.apiEndpoint = f"http://{project.host}:{project.port}/
|
|
93
|
+
self.apiEndpoint = f"http://{project.host}:{project.port}/api"
|
|
94
94
|
self.title_translation = []
|
|
95
95
|
self.languages = ["en", "es"] # "fr", "it", "de" etc - used to create i18n json files
|
|
96
96
|
self.locale = "en"
|
|
@@ -211,7 +211,7 @@ class OntBuilder(object):
|
|
|
211
211
|
startSessionPath = "/auth/login"
|
|
212
212
|
'''
|
|
213
213
|
if getattr(self.global_values,"serviceType",None) is None:
|
|
214
|
-
self.global_values["serviceType"] = "
|
|
214
|
+
self.global_values["serviceType"] = "JSONAPI"
|
|
215
215
|
if getattr(self.global_values,"locale",None) is None:
|
|
216
216
|
self.global_values["locale"] = ["en","es"]
|
|
217
217
|
if getattr(self.global_values,"applicationLocales",None) is None:
|
|
@@ -234,12 +234,13 @@ class OntBuilder(object):
|
|
|
234
234
|
for p in menu_group[mg]["menu_item"][mi]["page"]:
|
|
235
235
|
if p == 'home':
|
|
236
236
|
self.generate_home_template(app_path, entity_favorites, mi, each_entity, mi)
|
|
237
|
+
home_template_name = menu_group[mg]["menu_item"][mi]["page"][p]["template_name"]
|
|
238
|
+
self.generate_routing(app_path, mi, each_entity, mi, home_template_name)
|
|
237
239
|
elif p == "detail":
|
|
238
240
|
self.generate_detail_template(app_path, entity_favorites, mi, each_entity, mi)
|
|
239
241
|
elif p == "new":
|
|
240
242
|
self.generate_new_template(app_path, entity_favorites, mi, each_entity, mi)
|
|
241
243
|
|
|
242
|
-
self.generate_routing(app_path, mi, each_entity, mi)
|
|
243
244
|
self.generate_card_home_template(app_path, entity_favorites, mi, each_entity, mi)
|
|
244
245
|
else:
|
|
245
246
|
for each_entity_name, each_entity in app_model.entities.items():
|
|
@@ -250,10 +251,11 @@ class OntBuilder(object):
|
|
|
250
251
|
entity_name = each_entity_name
|
|
251
252
|
|
|
252
253
|
# Each entity will have a home, new, detail, routing template
|
|
254
|
+
template_name = self.find_template(each_entity, "home_template","home_template.html")
|
|
253
255
|
self.generate_home_template(app_path, entity_favorites, each_entity_name, each_entity, entity_name)
|
|
254
256
|
self.generate_new_template(app_path, entity_favorites, each_entity_name, each_entity, entity_name)
|
|
255
257
|
self.generate_detail_template(app_path, entity_favorites, each_entity_name, each_entity, entity_name)
|
|
256
|
-
self.generate_routing(app_path, each_entity_name, each_entity, entity_name)
|
|
258
|
+
self.generate_routing(app_path, each_entity_name, each_entity, entity_name, template_name)
|
|
257
259
|
self.generate_card_home_template(app_path, entity_favorites, each_entity_name, each_entity, entity_name)
|
|
258
260
|
|
|
259
261
|
# menu groups/routing and service config
|
|
@@ -288,8 +290,7 @@ class OntBuilder(object):
|
|
|
288
290
|
file_name="app.config.ts",
|
|
289
291
|
source=app_config,
|
|
290
292
|
)
|
|
291
|
-
def generate_routing(self, app_path, each_entity_name, each_entity, entity_name):
|
|
292
|
-
home_template_name = self.find_template(each_entity, "home_template","home_template.html")
|
|
293
|
+
def generate_routing(self, app_path, each_entity_name, each_entity, entity_name, home_template_name:str ):
|
|
293
294
|
if home_template_name == "home_tree_template.html":
|
|
294
295
|
routing = self.load_routing("tree_routing.jinja", entity_name, each_entity)
|
|
295
296
|
else:
|
|
@@ -656,6 +657,7 @@ class OntBuilder(object):
|
|
|
656
657
|
return ";".join(cols)
|
|
657
658
|
|
|
658
659
|
def get_page(self, page_name, entity_name: str) -> dict:
|
|
660
|
+
#page_name = home, detail, new
|
|
659
661
|
if "application" in self.app_model:
|
|
660
662
|
for app in self.app_model.application:
|
|
661
663
|
# yaml may have multiple apps = only work on the one selected app-build --app={app}
|
|
@@ -666,9 +668,9 @@ class OntBuilder(object):
|
|
|
666
668
|
for mi in menu_group[mg]["menu_item"]:
|
|
667
669
|
#each_entity = self.app_model.entities[mi]
|
|
668
670
|
if mi == entity_name:
|
|
669
|
-
for
|
|
670
|
-
if page_name ==
|
|
671
|
-
return menu_group[mg]["menu_item"][mi]["page"][
|
|
671
|
+
for pg_name in menu_group[mg]["menu_item"][mi]["page"]:
|
|
672
|
+
if page_name == pg_name:
|
|
673
|
+
return menu_group[mg]["menu_item"][mi]["page"][pg_name]
|
|
672
674
|
return None
|
|
673
675
|
def get_menu_group(self):
|
|
674
676
|
menu_groups = []
|
|
@@ -718,9 +720,11 @@ class OntBuilder(object):
|
|
|
718
720
|
elif template_type == 'INTEGER':
|
|
719
721
|
return self.table_integer_template.render(col_var)
|
|
720
722
|
elif template_type == "DATE":
|
|
721
|
-
return self.
|
|
723
|
+
return self.table_column.render(col_var)
|
|
724
|
+
#return self.date_template.render(col_var)
|
|
722
725
|
elif template_type == "TIMESTAMP":
|
|
723
|
-
return self.
|
|
726
|
+
return self.table_column.render(col_var)
|
|
727
|
+
#return self.timestamp_template.render(col_var)
|
|
724
728
|
elif template_type in ["REAL", "DECIMAL", "NUMERIC"]:
|
|
725
729
|
return self.table_real_template.render(col_var)
|
|
726
730
|
elif template_type == "table_column":
|
|
@@ -729,7 +733,8 @@ class OntBuilder(object):
|
|
|
729
733
|
return self.check_circle_template.render(col_var)
|
|
730
734
|
else:
|
|
731
735
|
if template_type == "TEXTAREA":
|
|
732
|
-
return self.
|
|
736
|
+
return self.table_column.render(col_var)
|
|
737
|
+
#return self.table_textarea_template.render(col_var)
|
|
733
738
|
else:
|
|
734
739
|
return self.table_text_template.render(col_var)
|
|
735
740
|
|
|
@@ -738,7 +743,7 @@ class OntBuilder(object):
|
|
|
738
743
|
if hasattr(column, "template") and column.template != DotMap():
|
|
739
744
|
return column.template.upper()
|
|
740
745
|
if hasattr(column, "type") and column.type != DotMap():
|
|
741
|
-
if column.type.startswith("DECIMAL") or column.type.startswith("NUMERIC"):
|
|
746
|
+
if column.type.startswith("DECIMAL") or column.type.startswith("NUMERIC") or column.type.startswith("FLOAT"):
|
|
742
747
|
return "REAL"
|
|
743
748
|
elif column.type == 'INTEGER':
|
|
744
749
|
return "INTEGER"
|
|
@@ -1300,7 +1305,7 @@ def find_column(entity, column_name) -> any:
|
|
|
1300
1305
|
)
|
|
1301
1306
|
|
|
1302
1307
|
def gen_app_service_config(entities: any) -> str:
|
|
1303
|
-
t = Template("export const SERVICE_CONFIG
|
|
1308
|
+
t = Template("export const SERVICE_CONFIG ={ {{ children }} };")
|
|
1304
1309
|
child_template = Template("'{{ name }}': { 'path': '/{{ name }}' }")
|
|
1305
1310
|
sep = ""
|
|
1306
1311
|
config = ""
|
|
@@ -268,10 +268,10 @@ class OntCreator(object):
|
|
|
268
268
|
each_attribute.type = "text"
|
|
269
269
|
each_attribute.template = "text"
|
|
270
270
|
else:
|
|
271
|
-
each_attribute.type = resource_attribute.db_type
|
|
271
|
+
each_attribute.type = resource_attribute.db_type.upper().split("(")[0] #VARCHAR, DECIMAL, NUMERIC, etc
|
|
272
272
|
each_attribute.template = self.compute_field_template(each_attribute)
|
|
273
|
-
if hasattr(resource_attribute,"default"):
|
|
274
|
-
|
|
273
|
+
if hasattr(resource_attribute,"default") and "::" not in resource_attribute.default:
|
|
274
|
+
each_attribute.default = resource_attribute.default
|
|
275
275
|
return each_attribute
|
|
276
276
|
|
|
277
277
|
|
|
@@ -286,7 +286,7 @@ class OntCreator(object):
|
|
|
286
286
|
"""
|
|
287
287
|
if hasattr(column, "type") and column.type != DotMap():
|
|
288
288
|
col_type = column.type.upper().split("(")[0]
|
|
289
|
-
if col_type in ["SERIAL","SERIAL4"]:
|
|
289
|
+
if col_type in ["SERIAL","SERIAL4","SERIAL8"]:
|
|
290
290
|
rv = "nif"
|
|
291
291
|
if col_type in ["DECIMAL","NUMERIC"]:
|
|
292
292
|
rv = "real"
|
|
@@ -334,7 +334,7 @@ class OntCreator(object):
|
|
|
334
334
|
style_guide.keycloak_url= "http://localhost:8080"
|
|
335
335
|
style_guide.keycloak_realm = "kcals"
|
|
336
336
|
style_guide.keycloak_client_id = "alsclient"
|
|
337
|
-
style_guide.serviceType = "
|
|
337
|
+
style_guide.serviceType = "JSONAPI" # OntimizeEE or JSONAPI
|
|
338
338
|
style_guide.locale = "en"
|
|
339
339
|
style_guide.applicationLocales = ["en","es"]
|
|
340
340
|
style_guide.startSessionPath = "/auth/login" #Used by JSONAPI only
|
|
Binary file
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
Alter table "Product" rename to TempData;
|
|
2
|
+
|
|
3
|
+
CREATE TABLE "Product" (
|
|
4
|
+
"Id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
5
|
+
"ProductName" VARCHAR(8000) NULL,
|
|
6
|
+
"SupplierId" INTEGER NOT NULL,
|
|
7
|
+
"CategoryId" INTEGER NOT NULL,
|
|
8
|
+
"QuantityPerUnit" VARCHAR(8000) NULL,
|
|
9
|
+
"UnitPrice" DECIMAL NOT NULL,
|
|
10
|
+
"UnitsInStock" INTEGER NOT NULL,
|
|
11
|
+
"UnitsOnOrder" INTEGER NOT NULL,
|
|
12
|
+
"ReorderLevel" INTEGER NOT NULL,
|
|
13
|
+
"Discontinued" INTEGER NOT NULL,
|
|
14
|
+
"UnitsShipped" INTEGER,
|
|
15
|
+
FOREIGN KEY("CategoryId") REFERENCES "CategoryTableNameTest"("Id")
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
INSERT INTO Product
|
|
19
|
+
SELECT *
|
|
20
|
+
FROM TempData;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
Drop table TempData;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
Alter table "OrderDetail" rename to TempData1;
|
|
27
|
+
|
|
28
|
+
CREATE TABLE OrderDetail (
|
|
29
|
+
"Id" INTEGER,
|
|
30
|
+
"OrderId" INTEGER NOT NULL,
|
|
31
|
+
"ProductId" INTEGER NOT NULL,
|
|
32
|
+
"UnitPrice" DECIMAL,
|
|
33
|
+
"Quantity" INTEGER NOT NULL DEFAULT 1,
|
|
34
|
+
"Discount" DOUBLE DEFAULT 0,
|
|
35
|
+
"Amount" Decimal,
|
|
36
|
+
"ShippedDate" VARCHAR(8000),
|
|
37
|
+
PRIMARY KEY("Id" AUTOINCREMENT),
|
|
38
|
+
FOREIGN KEY("OrderId") REFERENCES "Order" on delete cascade
|
|
39
|
+
FOREIGN KEY("ProductId") REFERENCES "Product" on delete set null
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
INSERT INTO OrderDetail
|
|
43
|
+
SELECT *
|
|
44
|
+
FROM TempData1;
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
drop table TempData1;
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
CREATE VIEW ProductDetails_View as
|
|
51
|
+
select
|
|
52
|
+
p.*,
|
|
53
|
+
c.CategoryName_ColumnName, c.Description as [CategoryDescription],
|
|
54
|
+
s.CompanyName as [SupplierName], s.Region as [SupplierRegion]
|
|
55
|
+
from "Product" p
|
|
56
|
+
join "CategoryTableNameTest" c on p.CategoryId = c.id
|
|
57
|
+
join [Supplier] s on s.id = p.SupplierId
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
INSERT INTO Region (RegionDescription)
|
|
61
|
+
SELECT DISTINCT ShipRegion
|
|
62
|
+
FROM "Order";
|
|
Binary file
|
|
@@ -43,11 +43,11 @@ def import_module_from_path(module_name, file_path):
|
|
|
43
43
|
class GenAI(object):
|
|
44
44
|
""" Create project from genai prompt(s).
|
|
45
45
|
|
|
46
|
-
Called by api_logic_server, to run ChatGPT (or
|
|
46
|
+
Called by api_logic_server, to run ChatGPT (or response file) to create SQLAlchemy model
|
|
47
47
|
|
|
48
48
|
api_logic_server then uses model to create db, proceeds with normal project creation.
|
|
49
49
|
|
|
50
|
-
* there is also a callback to genai to
|
|
50
|
+
* NB: there is also a callback to genai to genai#insert_logic.. (& graphics) into created project
|
|
51
51
|
"""
|
|
52
52
|
|
|
53
53
|
def __init__(self, project: Project):
|
|
@@ -71,7 +71,8 @@ class GenAI(object):
|
|
|
71
71
|
"""
|
|
72
72
|
Main Driver for GenAI - called by api_logic_server, to
|
|
73
73
|
* run ChatGPT (or respone file) to create_db_models.py - models & test data
|
|
74
|
-
* which then used
|
|
74
|
+
* which then used by apiLogic_server#api_logic_server_cli/create_from_model/create_db_from_model.py, for normal project creation.
|
|
75
|
+
* warning - test data failure here is not reported
|
|
75
76
|
|
|
76
77
|
The key argument is `--using`
|
|
77
78
|
* It can be a file, dir (conversation) or text argument.
|
|
@@ -152,9 +153,11 @@ class GenAI(object):
|
|
|
152
153
|
# main driver starts here
|
|
153
154
|
#######################################################
|
|
154
155
|
|
|
155
|
-
log.info(f'\nGenAI [{self.project.project_name}] creating microservice...')
|
|
156
|
+
log.info(f'\n\nGenAI [{self.project.project_name}] creating microservice...')
|
|
156
157
|
log.info(f'.. .. --using prompt: {self.project.genai_using}')
|
|
157
|
-
log.info(f'.. ..
|
|
158
|
+
log.info(f'.. .. --project-name[self.project.project_name]: {self.project.project_name}')
|
|
159
|
+
log.info(f'.. .. project.project_directory_actual: {self.project.project_directory_actual}')
|
|
160
|
+
log.info(f'.. .. in pwd: {os.getcwd()}\n')
|
|
158
161
|
|
|
159
162
|
if self.project.genai_repaired_response != '':
|
|
160
163
|
log.info(f'.. retry from [repaired] response file: {self.project.genai_repaired_response}')
|
|
@@ -183,12 +186,22 @@ class GenAI(object):
|
|
|
183
186
|
if not genai_demo_response_path.is_file():
|
|
184
187
|
log.debug(f'.. standard genai_demo response not found: {genai_demo_response_path}')
|
|
185
188
|
else:
|
|
186
|
-
with open(genai_demo_response_path, 'r') as response_file:
|
|
187
|
-
response_dict = json.load(response_file)
|
|
189
|
+
with open(genai_demo_response_path, 'r') as response_file: # fail-safe demo
|
|
190
|
+
response_dict = json.load(response_file) # BUT, the prompt is in wg? which needs graphics
|
|
188
191
|
log.debug(f'.. used standard genai_demo response: {genai_demo_response_path}')
|
|
189
192
|
genai_demo_response_path = Path('system/genai/temp/response.json')
|
|
190
193
|
with open(genai_demo_response_path, 'w') as response_file:
|
|
191
194
|
json.dump(response_dict, response_file, indent=4)
|
|
195
|
+
# the request is a cli arg; for wg: sra/src/components/apifab/WebGenAICreate.tsx
|
|
196
|
+
if limit_tables := False: # failed experiment to limit table iterations for genai_demo
|
|
197
|
+
# eg, fails to: Add Sales Rep table, as a parent of Order.
|
|
198
|
+
genai_demo_request_path = Path('system/genai/temp/request.json')
|
|
199
|
+
utils.replace_string_in_file(in_file=genai_demo_request_path,
|
|
200
|
+
search_for='at least 12 tables',
|
|
201
|
+
replace_with='only the requested and added tables')
|
|
202
|
+
self.messages[0]['content'] = self.messages[0]['content'].replace(
|
|
203
|
+
'at least 12 tables', 'only the requested and added tables')
|
|
204
|
+
pass
|
|
192
205
|
|
|
193
206
|
else: # for retry from corrected response... eg system/genai/temp/chatgpt_retry.response
|
|
194
207
|
self.resolved_model = "(n/a: model not used for repaired response)"
|
|
@@ -316,7 +329,7 @@ class GenAI(object):
|
|
|
316
329
|
log.debug(f'.. from file: {self.project.genai_using}')
|
|
317
330
|
raw_prompt = file.read()
|
|
318
331
|
prompt = self.get_prompt__with_inserts(raw_prompt=raw_prompt, for_iteration=False) # insert db-specific logic
|
|
319
|
-
self.logic_enabled = True
|
|
332
|
+
self.logic_enabled = True
|
|
320
333
|
if os.environ.get("APILOGICPROJECT_LOGIC_ENABLED") is not None and \
|
|
321
334
|
os.environ.get("APILOGICPROJECT_LOGIC_ENABLED") == 'False':
|
|
322
335
|
self.logic_enabled = False
|
|
@@ -398,13 +411,20 @@ class GenAI(object):
|
|
|
398
411
|
return learning_requests # TODO - what if no learning requests?
|
|
399
412
|
|
|
400
413
|
def get_prompt__with_inserts(self, raw_prompt: str, for_iteration: bool = False) -> str:
|
|
401
|
-
""" prompt-engineering:
|
|
414
|
+
""" prompt-engineering for both initial & iteration:
|
|
402
415
|
|
|
403
416
|
1. insert db-specific logic into prompt
|
|
404
|
-
2. insert iteration prompt (
|
|
417
|
+
2. insert iteration prompt (iff for_iteration)
|
|
405
418
|
3. insert logic_inserts.prompt ('1 line: Use LogicBank to create declare_logic()...')
|
|
406
419
|
4. designates prompt-format (response_format.prompt)
|
|
407
420
|
|
|
421
|
+
Eg, initial creation: expands system/genai/prompt_inserts/sqlite_inserts.prompt
|
|
422
|
+
1. use sqlalchemy to create...
|
|
423
|
+
2. <requirements>prompt</requirements>
|
|
424
|
+
3. Use autonum.. (sql hints)
|
|
425
|
+
4. Graphics training...
|
|
426
|
+
5. Response format
|
|
427
|
+
|
|
408
428
|
Args:
|
|
409
429
|
raw_prompt (str): the prompt from file or text argument
|
|
410
430
|
for_iteration (bool, optional): Inserts 'Update the prior response...' Defaults to False.
|
|
@@ -473,6 +493,8 @@ class GenAI(object):
|
|
|
473
493
|
|
|
474
494
|
Also creates the doc directory for record of prompt, response.
|
|
475
495
|
|
|
496
|
+
And, invokes genai_graphics
|
|
497
|
+
|
|
476
498
|
TODO - use genai_rules_from_response
|
|
477
499
|
|
|
478
500
|
"""
|
|
@@ -513,6 +535,12 @@ class GenAI(object):
|
|
|
513
535
|
log.debug(f'.. removed hallucination: {each_line}')
|
|
514
536
|
return return_line
|
|
515
537
|
|
|
538
|
+
log.info(f'\n\nGenAI [{self.project.project_name}] creating microservice...')
|
|
539
|
+
log.info(f'.. .. --using prompt: {self.project.genai_using}')
|
|
540
|
+
log.info(f'.. .. --project-name[self.project.project_name]: {self.project.project_name}')
|
|
541
|
+
log.info(f'.. .. project.project_directory_actual: {self.project.project_directory_actual}')
|
|
542
|
+
log.info(f'.. .. in pwd: {os.getcwd()}\n')
|
|
543
|
+
|
|
516
544
|
logic_file = self.project.project_directory_path.joinpath('logic/declare_logic.py')
|
|
517
545
|
if self.logic_enabled:
|
|
518
546
|
translated_logic = genai_svcs.get_code_update_logic_file(rule_list = self.response_dict.rules,
|
|
@@ -576,7 +604,10 @@ class GenAI(object):
|
|
|
576
604
|
except: # intentional try/catch/bury - it's just docs, so don't fail
|
|
577
605
|
import traceback
|
|
578
606
|
log.error(f"\n\nERROR creating genai project docs: {docs_dir}\n\n{traceback.format_exc()}")
|
|
579
|
-
genai_graphics = GenAIGraphics(project=self.project,
|
|
607
|
+
genai_graphics = GenAIGraphics(project=self.project,
|
|
608
|
+
replace_with='!new-wg',
|
|
609
|
+
using=None,
|
|
610
|
+
genai_version=self.project.genai_version)
|
|
580
611
|
|
|
581
612
|
def save_prompt_messages_to_system_genai_temp_project(self):
|
|
582
613
|
"""
|