ApiLogicServer 14.3.20__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 +5 -14
- api_logic_server_cli/api_logic_server_info.yaml +3 -3
- api_logic_server_cli/cli.py +52 -5
- 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/fragments/docker-compose.yml +27 -0
- api_logic_server_cli/genai/genai.py +43 -11
- api_logic_server_cli/genai/genai_graphics.py +379 -0
- api_logic_server_cli/genai/genai_logic_builder.py +2 -2
- api_logic_server_cli/genai/genai_svcs.py +24 -8
- 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 +95 -24
- 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/graphics/readme.md +12 -0
- 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/security/authentication_provider/keycloak/auth_provider.py +1 -1
- api_logic_server_cli/prototypes/base/security/declare_security.py +4 -0
- api_logic_server_cli/prototypes/base/ui/admin/admin_loader.py +3 -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 +56 -5
- 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 -8
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo.response_example +90 -60
- 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_api_xxx.py +32 -0
- 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/graphics_templates/html_template.jinja +76 -0
- api_logic_server_cli/prototypes/manager/system/genai/graphics_templates/index.html +19 -0
- api_logic_server_cli/prototypes/manager/system/genai/graphics_templates/sales_by_region.jinja +63 -0
- api_logic_server_cli/prototypes/manager/system/genai/prompt_inserts/graphics.prompt +22 -0
- api_logic_server_cli/prototypes/manager/system/genai/prompt_inserts/graphics_request.prompt +5 -0
- api_logic_server_cli/prototypes/manager/system/genai/prompt_inserts/response_format.prompt +15 -0
- api_logic_server_cli/prototypes/manager/system/genai/prompt_inserts/sqlite_inserts.prompt +2 -0
- 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/request copy.json +892 -0
- api_logic_server_cli/prototypes/nw_no_cust/docs/graphics/request.json +6 -0
- api_logic_server_cli/prototypes/nw_no_cust/docs/graphics/response.json +17 -0
- api_logic_server_cli/prototypes/nw_no_cust/docs/graphics/response.yaml +59 -0
- api_logic_server_cli/prototypes/nw_no_cust/docs/graphics/sales_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.20.dist-info → apilogicserver-14.4.0.dist-info}/RECORD +102 -59
- {apilogicserver-14.3.20.dist-info → apilogicserver-14.4.0.dist-info}/WHEEL +1 -1
- api_logic_server_cli/prototypes/manager/system/genai/prompt_inserts/zsqlite_inserts_iterations.prompt +0 -29
- api_logic_server_cli/prototypes/manager/webgenai/docker-compose-webg.yml +0 -33
- api_logic_server_cli/prototypes/manager/webgenai/webg_config/license.json +0 -6
- api_logic_server_cli/prototypes/manager/webgenai/webg_config/web_genai.txt +0 -13
- apilogicserver-14.3.20.dist-info/METADATA +0 -167
- {apilogicserver-14.3.20.dist-info → apilogicserver-14.4.0.dist-info}/entry_points.txt +0 -0
- {apilogicserver-14.3.20.dist-info → apilogicserver-14.4.0.dist-info}/licenses/LICENSE +0 -0
- {apilogicserver-14.3.20.dist-info → apilogicserver-14.4.0.dist-info}/top_level.txt +0 -0
|
@@ -12,25 +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
|
-
"\
|
|
18
|
+
"\t04/27/2024 - 14.04.00: Graphics preview, Vibe install fix, Improved IDE Chat Logic, MCP Exploration \n"\
|
|
19
|
+
"\t03/30/2024 - 14.03.25: WebGenAI fixes for Kafka and Keycloak \n"\
|
|
20
|
+
"\t03/19/2024 - 14.03.20: licensed webgenai docker, [87] sra fix for home.js \n"\
|
|
19
21
|
"\t02/26/2024 - 14.03.14: [85: reserved words], genai_demo fixes \n"\
|
|
20
|
-
"\t02/16/2024 - 14.03.12: Docker w/ std container, mgr assistant for local WebG \n"\
|
|
21
|
-
"\t02/13/2024 - 14.03.11: fixes [78: Keycloak, 79: boolean defaulting, 80: Send If missing attribute] \n"\
|
|
22
|
-
"\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"\
|
|
23
|
-
"\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"\
|
|
24
|
-
"\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"\
|
|
25
22
|
"\t01/17/2024 - 14.02.20: WebGenAI support, genai_demo \n"\
|
|
26
23
|
"\t01/06/2024 - 14.01.00: N8N, Rebuild test data, Fixup, Project Import, Improved reporting of missing attributes, Simplified RowDictMaper \n"\
|
|
27
24
|
"\t11/18/2024 - 12.02.00: genai: 'qualified any' now supported in logic training \n"\
|
|
28
25
|
"\t10/31/2024 - 12.01.00: genai: informal rules (eg, Sum of employee salaries cannot exceed department budget) \n"\
|
|
29
|
-
"\t10/21/2024 - 12.00.04: sra 10-22, Prelim support genai --using=dir/project \n"\
|
|
30
26
|
"\t10/12/2024 - 12.00.02: Natural Language Logic \n"\
|
|
31
|
-
"\t10/17/2024 - 11.02.19: singular classes, expanded doc/prompts, logic work-arounds, docs/logic, logic learning, readme \n"\
|
|
32
|
-
"\t10/11/2024 - 11.02.14: NL/Logic with test data calcs, sra 10-07-2024, genai-logic, cs, iteration rebuild \n"\
|
|
33
|
-
"\t08/02/2024 - 11.00.07: App Model Editor UI rework, docs and fix for kc and export \n"\
|
|
34
27
|
"\t07/25/2024 - 11.00.00: Keycloak, App Model Editor \n"\
|
|
35
28
|
"\t03/28/2024 - 10.03.46: Python 3.12, View support, CLI option-names, Keycloak preview \n"\
|
|
36
29
|
"\t12/19/2023 - 10.00.00: Kafka pub/sub, Fix MySQL CHAR/String, list/hash/set types \n"\
|
|
@@ -38,8 +31,6 @@ recent_changes = \
|
|
|
38
31
|
"\t09/14/2023 - 09.03.00: Oracle support \n"\
|
|
39
32
|
"\t06/22/2023 - 09.00.00: Optimistic Locking, safrs 310, SQLAlchemy 2.0.15 \n"\
|
|
40
33
|
"\t05/01/2023 - 08.03.06: allocation sample \n"\
|
|
41
|
-
"\t04/26/2023 - 08.03.00: virt attrs (Issue 56), safrs 3.0.2, readme updates, LogicBank 1.8.4 \n"\
|
|
42
|
-
"\t04/13/2023 - 08.02.00: integratedConsole, logic logging (66), table relns fix (65) \n"\
|
|
43
34
|
"\t02/15/2023 - 08.00.01: Declarative Authorization and Authentication, Werkzeug==2.2.3 \n"\
|
|
44
35
|
"\t01/06/2023 - 07.00.00: Multi-db, sqlite test dbs, tests run, security prototype, env config \n"\
|
|
45
36
|
|
|
@@ -1959,7 +1950,7 @@ from database import <project.bind_key>_models
|
|
|
1959
1950
|
ont_creator = OntCreator(project = build.project)
|
|
1960
1951
|
ont_creator.create_application(show_messages=False)
|
|
1961
1952
|
|
|
1962
|
-
if
|
|
1953
|
+
if self.project_directory_path.joinpath('ui/app_model_custom.yaml').exists():
|
|
1963
1954
|
# eg, nw project contains this for demo purposes
|
|
1964
1955
|
copyfile (src=self.project_directory_path.joinpath('ui/app_model_custom.yaml'),
|
|
1965
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,
|
|
@@ -738,6 +738,47 @@ def genai_logic(ctx, using, genai_version: str, retries: int, suggest: click.BOO
|
|
|
738
738
|
log.info("")
|
|
739
739
|
|
|
740
740
|
|
|
741
|
+
@main.command("genai-graphics", cls=HideDunderCommand)
|
|
742
|
+
@click.option('--using',
|
|
743
|
+
default=f'docs/graphics',
|
|
744
|
+
help="File or dir")
|
|
745
|
+
@click.option('--genai-version', 'genai_version',
|
|
746
|
+
default='gpt-4o',
|
|
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)")
|
|
751
|
+
@click.pass_context
|
|
752
|
+
def genai_graphics(ctx, using, genai_version: str, replace_with: str):
|
|
753
|
+
"""
|
|
754
|
+
Adds (or suggests) logic to current project.
|
|
755
|
+
"""
|
|
756
|
+
global command
|
|
757
|
+
project_dir = resolve_blank_project_name('')
|
|
758
|
+
project_name = Path(project_dir).name
|
|
759
|
+
project = PR.ProjectRun(command="add_security",
|
|
760
|
+
project_name=project_name,
|
|
761
|
+
db_url="",
|
|
762
|
+
execute=False
|
|
763
|
+
)
|
|
764
|
+
project.project_directory, project.api_name, project.merge_into_prototype = \
|
|
765
|
+
create_utils.get_project_directory_and_api_name(project)
|
|
766
|
+
project.project_directory_actual = os.path.abspath(os.getcwd()) # make path absolute, not relative (no /../)
|
|
767
|
+
project.project_directory_path = Path(project.project_directory_actual)
|
|
768
|
+
models_py_path = project.project_directory_path.joinpath('database/models.py')
|
|
769
|
+
project.abs_db_url, project.nw_db_status, project.model_file_name = \
|
|
770
|
+
create_utils.get_abs_db_url("0. Using Sample DB", project, is_auth=True)
|
|
771
|
+
|
|
772
|
+
if not models_py_path.exists():
|
|
773
|
+
log.info(f'... Error - does not appear to be a project: {str(project.project_directory_path)}')
|
|
774
|
+
log.info(f'... Typical usage - cd into project, use --project_name=. \n')
|
|
775
|
+
exit (1)
|
|
776
|
+
from api_logic_server_cli.genai.genai_graphics import GenAIGraphics
|
|
777
|
+
genai_graphics = GenAIGraphics(using=using, project=project, genai_version=genai_version, replace_with=replace_with)
|
|
778
|
+
pass
|
|
779
|
+
log.info("")
|
|
780
|
+
|
|
781
|
+
|
|
741
782
|
@main.command("genai-create", cls=HideDunderCommand)
|
|
742
783
|
@click.option('--project-name', 'project_name',
|
|
743
784
|
default=f'{last_created_project_name}',
|
|
@@ -1413,17 +1454,23 @@ def add_auth_cmd(ctx, bind_key_url_separator: str, provider_type :str, db_url: s
|
|
|
1413
1454
|
|
|
1414
1455
|
cd existing_project
|
|
1415
1456
|
|
|
1416
|
-
ApiLogicServer add-auth
|
|
1457
|
+
ApiLogicServer add-auth
|
|
1458
|
+
|
|
1459
|
+
ApiLogicServer add-auth --db-url=add-auth
|
|
1460
|
+
|
|
1417
1461
|
ApiLogicServer add-auth provider_type=keycloak
|
|
1418
1462
|
|
|
1419
1463
|
"""
|
|
1420
1464
|
project_name = resolve_blank_project_name(project_name)
|
|
1421
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"
|
|
1422
1469
|
project = PR.ProjectRun(command="add_security",
|
|
1423
1470
|
project_name=project_name,
|
|
1424
1471
|
api_name=api_name,
|
|
1425
1472
|
db_url="",
|
|
1426
|
-
auth_db_url=
|
|
1473
|
+
auth_db_url=auth_db_url,
|
|
1427
1474
|
auth_provider_type=provider_type,
|
|
1428
1475
|
bind_key=bind_key,
|
|
1429
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
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Run WebGenAI locally from docker container (created by Manager)
|
|
2
|
+
|
|
3
|
+
# cd webgenai
|
|
4
|
+
|
|
5
|
+
# docker compose up
|
|
6
|
+
# docker compose down
|
|
7
|
+
|
|
8
|
+
name: webgenai
|
|
9
|
+
services:
|
|
10
|
+
web_genai:
|
|
11
|
+
stdin_open: true
|
|
12
|
+
tty: true
|
|
13
|
+
container_name: webgenai
|
|
14
|
+
ports:
|
|
15
|
+
- 8282:80
|
|
16
|
+
volumes:
|
|
17
|
+
- ./webg_temp:/tmp
|
|
18
|
+
- ./webg_config:/config
|
|
19
|
+
- ./webg_projects:/opt/projects
|
|
20
|
+
image: apilogicserver/web_genai
|
|
21
|
+
user: root
|
|
22
|
+
environment:
|
|
23
|
+
- APILOGICPROJECT_EXTERNAL_PORT=8282
|
|
24
|
+
- APILOGICPROJECT_PORT=5657
|
|
25
|
+
- APILOGICPROJECT_EXTERNAL_HOST=localhost
|
|
26
|
+
- GENAI_LOGIC_APIKEY=<paste license here from registration email>
|
|
27
|
+
- APILOGICSERVER_CHATGPT_APIKEY=<sk-proj-your-openai-key-here>
|
|
@@ -27,6 +27,7 @@ from api_logic_server_cli.genai.genai_svcs import K_LogicBankOff
|
|
|
27
27
|
from api_logic_server_cli.genai.genai_svcs import K_LogicBankTraining
|
|
28
28
|
from api_logic_server_cli.genai.genai_svcs import fix_and_write_model_file as fix_and_write_model_file_svcs
|
|
29
29
|
import api_logic_server_cli.genai.genai_svcs as genai_svcs
|
|
30
|
+
from api_logic_server_cli.genai.genai_graphics import GenAIGraphics
|
|
30
31
|
|
|
31
32
|
log = logging.getLogger(__name__)
|
|
32
33
|
|
|
@@ -42,11 +43,11 @@ def import_module_from_path(module_name, file_path):
|
|
|
42
43
|
class GenAI(object):
|
|
43
44
|
""" Create project from genai prompt(s).
|
|
44
45
|
|
|
45
|
-
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
|
|
46
47
|
|
|
47
48
|
api_logic_server then uses model to create db, proceeds with normal project creation.
|
|
48
49
|
|
|
49
|
-
* 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
|
|
50
51
|
"""
|
|
51
52
|
|
|
52
53
|
def __init__(self, project: Project):
|
|
@@ -70,7 +71,8 @@ class GenAI(object):
|
|
|
70
71
|
"""
|
|
71
72
|
Main Driver for GenAI - called by api_logic_server, to
|
|
72
73
|
* run ChatGPT (or respone file) to create_db_models.py - models & test data
|
|
73
|
-
* 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
|
|
74
76
|
|
|
75
77
|
The key argument is `--using`
|
|
76
78
|
* It can be a file, dir (conversation) or text argument.
|
|
@@ -151,9 +153,11 @@ class GenAI(object):
|
|
|
151
153
|
# main driver starts here
|
|
152
154
|
#######################################################
|
|
153
155
|
|
|
154
|
-
log.info(f'\nGenAI [{self.project.project_name}] creating microservice...')
|
|
156
|
+
log.info(f'\n\nGenAI [{self.project.project_name}] creating microservice...')
|
|
155
157
|
log.info(f'.. .. --using prompt: {self.project.genai_using}')
|
|
156
|
-
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')
|
|
157
161
|
|
|
158
162
|
if self.project.genai_repaired_response != '':
|
|
159
163
|
log.info(f'.. retry from [repaired] response file: {self.project.genai_repaired_response}')
|
|
@@ -182,12 +186,22 @@ class GenAI(object):
|
|
|
182
186
|
if not genai_demo_response_path.is_file():
|
|
183
187
|
log.debug(f'.. standard genai_demo response not found: {genai_demo_response_path}')
|
|
184
188
|
else:
|
|
185
|
-
with open(genai_demo_response_path, 'r') as response_file:
|
|
186
|
-
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
|
|
187
191
|
log.debug(f'.. used standard genai_demo response: {genai_demo_response_path}')
|
|
188
192
|
genai_demo_response_path = Path('system/genai/temp/response.json')
|
|
189
193
|
with open(genai_demo_response_path, 'w') as response_file:
|
|
190
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
|
|
191
205
|
|
|
192
206
|
else: # for retry from corrected response... eg system/genai/temp/chatgpt_retry.response
|
|
193
207
|
self.resolved_model = "(n/a: model not used for repaired response)"
|
|
@@ -315,7 +329,7 @@ class GenAI(object):
|
|
|
315
329
|
log.debug(f'.. from file: {self.project.genai_using}')
|
|
316
330
|
raw_prompt = file.read()
|
|
317
331
|
prompt = self.get_prompt__with_inserts(raw_prompt=raw_prompt, for_iteration=False) # insert db-specific logic
|
|
318
|
-
self.logic_enabled = True
|
|
332
|
+
self.logic_enabled = True
|
|
319
333
|
if os.environ.get("APILOGICPROJECT_LOGIC_ENABLED") is not None and \
|
|
320
334
|
os.environ.get("APILOGICPROJECT_LOGIC_ENABLED") == 'False':
|
|
321
335
|
self.logic_enabled = False
|
|
@@ -397,13 +411,20 @@ class GenAI(object):
|
|
|
397
411
|
return learning_requests # TODO - what if no learning requests?
|
|
398
412
|
|
|
399
413
|
def get_prompt__with_inserts(self, raw_prompt: str, for_iteration: bool = False) -> str:
|
|
400
|
-
""" prompt-engineering:
|
|
414
|
+
""" prompt-engineering for both initial & iteration:
|
|
401
415
|
|
|
402
416
|
1. insert db-specific logic into prompt
|
|
403
|
-
2. insert iteration prompt (
|
|
417
|
+
2. insert iteration prompt (iff for_iteration)
|
|
404
418
|
3. insert logic_inserts.prompt ('1 line: Use LogicBank to create declare_logic()...')
|
|
405
419
|
4. designates prompt-format (response_format.prompt)
|
|
406
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
|
+
|
|
407
428
|
Args:
|
|
408
429
|
raw_prompt (str): the prompt from file or text argument
|
|
409
430
|
for_iteration (bool, optional): Inserts 'Update the prior response...' Defaults to False.
|
|
@@ -472,6 +493,8 @@ class GenAI(object):
|
|
|
472
493
|
|
|
473
494
|
Also creates the doc directory for record of prompt, response.
|
|
474
495
|
|
|
496
|
+
And, invokes genai_graphics
|
|
497
|
+
|
|
475
498
|
TODO - use genai_rules_from_response
|
|
476
499
|
|
|
477
500
|
"""
|
|
@@ -512,6 +535,12 @@ class GenAI(object):
|
|
|
512
535
|
log.debug(f'.. removed hallucination: {each_line}')
|
|
513
536
|
return return_line
|
|
514
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
|
+
|
|
515
544
|
logic_file = self.project.project_directory_path.joinpath('logic/declare_logic.py')
|
|
516
545
|
if self.logic_enabled:
|
|
517
546
|
translated_logic = genai_svcs.get_code_update_logic_file(rule_list = self.response_dict.rules,
|
|
@@ -575,7 +604,10 @@ class GenAI(object):
|
|
|
575
604
|
except: # intentional try/catch/bury - it's just docs, so don't fail
|
|
576
605
|
import traceback
|
|
577
606
|
log.error(f"\n\nERROR creating genai project docs: {docs_dir}\n\n{traceback.format_exc()}")
|
|
578
|
-
|
|
607
|
+
genai_graphics = GenAIGraphics(project=self.project,
|
|
608
|
+
replace_with='!new-wg',
|
|
609
|
+
using=None,
|
|
610
|
+
genai_version=self.project.genai_version)
|
|
579
611
|
|
|
580
612
|
def save_prompt_messages_to_system_genai_temp_project(self):
|
|
581
613
|
"""
|