ApiLogicServer 14.2.20__py3-none-any.whl → 14.3.7__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.2.20.dist-info → ApiLogicServer-14.3.7.dist-info}/METADATA +2 -2
- {ApiLogicServer-14.2.20.dist-info → ApiLogicServer-14.3.7.dist-info}/RECORD +90 -69
- api_logic_server_cli/api_logic_server.py +5 -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__/api_logic_server_utils.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/api_logic_server_utils.py +4 -0
- api_logic_server_cli/create_from_model/ont_build.py +53 -19
- api_logic_server_cli/create_from_model/ont_create.py +14 -5
- api_logic_server_cli/fragments/declare_logic.py +72 -0
- api_logic_server_cli/{prototypes/manager/system/genai/create_db_models_inserts/logic_discovery_prefix.py → fragments/declare_logic_begin.py} +2 -1
- api_logic_server_cli/fragments/declare_logic_end.py +52 -0
- api_logic_server_cli/genai/genai.py +25 -8
- api_logic_server_cli/genai/genai_logic_builder.py +14 -11
- api_logic_server_cli/genai/genai_svcs.py +104 -7
- api_logic_server_cli/manager.py +20 -16
- api_logic_server_cli/model_migrator/model_migrator_start.py +1 -1
- api_logic_server_cli/model_migrator/reposreader.py +9 -1
- api_logic_server_cli/model_migrator/rule_obj.py +24 -6
- api_logic_server_cli/prototypes/base/api/api_discovery/ontimize_api.py +4 -1
- api_logic_server_cli/prototypes/base/api/system/expression_parser.py +10 -4
- api_logic_server_cli/prototypes/base/config/activate_logicbank.py +8 -4
- api_logic_server_cli/prototypes/base/database/bind_dbs.py +1 -1
- api_logic_server_cli/prototypes/base/database/test_data/readme.md +5 -5
- api_logic_server_cli/prototypes/base/integration/kafka/kafka_producer.py +32 -8
- api_logic_server_cli/prototypes/base/integration/system/RowDictMapper.py +33 -16
- api_logic_server_cli/prototypes/base/logic/declare_logic.py +9 -3
- api_logic_server_cli/prototypes/base/logic/load_verify_rules.py +217 -0
- api_logic_server_cli/prototypes/base/logic/logic_discovery/auto_discovery.py +22 -13
- 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 +58 -62
- 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/launch.json +1 -1
- api_logic_server_cli/prototypes/manager/README.md +19 -4
- 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 +34 -26
- 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/genai_demo/genai_demo_iteration_discount/.DS_Store +0 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/000_you_are.prompt +1 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/001_logic_training.prompt +314 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/002_create_db_models.prompt +150 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/003_create_db_models.response +134 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/004_iteratio_logic.prompt +131 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/005_create_db_models.response-example +141 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/create_db_models.py +105 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/db.dbml +70 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/readme.md +6 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/response.json +178 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/wg_dev_merge/base_genai_demo_no_logic/logic/declare_logic.py +0 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/wg_dev_merge/dev_demo_no_logic_fixed/logic/declare_logic.py +0 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/wg_dev_merge/wg_demo_no_logic_fixed/genai/examples/genai_demo/wg_dev_merge/base_genai_demo_no_logic/logic/declare_logic.py +0 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/wg_dev_merge/wg_demo_no_logic_fixed/genai/examples/genai_demo/wg_dev_merge/dev_demo_no_logic_fixed/logic/declare_logic.py +0 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/wg_dev_merge/wg_demo_no_logic_fixed/genai/examples/genai_demo/wg_dev_merge/wg_genai_demo_no_logic_fixed_from_CLI/logic/declare_logic.py +0 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/wg_dev_merge/wg_demo_no_logic_fixed/logic/declare_logic.py +0 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/wg_dev_merge/wg_demo_no_logic_fixed/system/genai/examples/genai_demo/wg_dev_merge/base_genai_demo_no_logic/logic/declare_logic.py +0 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/wg_dev_merge/wg_demo_no_logic_fixed/system/genai/examples/genai_demo/wg_dev_merge/dev_demo_no_logic_fixed/logic/declare_logic.py +0 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/wg_dev_merge/wg_demo_no_logic_fixed/system/genai/examples/genai_demo/wg_dev_merge/wg_genai_demo_no_logic_fixed_from_CLI/logic/declare_logic.py +0 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/time_tracking_billing/002_create_db_models.prompt +194 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/time_tracking_billing/003_create_db_models.response +298 -0
- api_logic_server_cli/prototypes/{genai_demo/database/chatgpt/sample_ai.sqlite → manager/system/genai/examples/time_tracking_billing/db.sqlite} +0 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/time_tracking_billing/readme.md +61 -0
- api_logic_server_cli/prototypes/manager/system/genai/learning_requests/logic_bank_api.prompt +29 -11
- api_logic_server_cli/prototypes/manager/system/genai/prompt_inserts/iteration.prompt +2 -1
- api_logic_server_cli/prototypes/nw_no_cust/venv_setup/system_note.txt +1 -1
- api_logic_server_cli/prototypes/ont_app/templates/home_tree_template.html +9 -0
- api_logic_server_cli/prototypes/ont_app/templates/tree_routing.jinja +32 -0
- 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 +4 -2
- api_logic_server_cli/tools/mini_skel/logic/load_verify_rules.py +1 -1
- api_logic_server_cli/model_migrator/system/custom_endpoint.py +0 -545
- api_logic_server_cli/prototypes/base/database/test_data/z_test_data_rows.py +0 -98
- 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_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.2.20.dist-info → ApiLogicServer-14.3.7.dist-info}/LICENSE +0 -0
- {ApiLogicServer-14.2.20.dist-info → ApiLogicServer-14.3.7.dist-info}/WHEEL +0 -0
- {ApiLogicServer-14.2.20.dist-info → ApiLogicServer-14.3.7.dist-info}/entry_points.txt +0 -0
- {ApiLogicServer-14.2.20.dist-info → ApiLogicServer-14.3.7.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,150 @@
|
|
|
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>
|
|
4
|
+
Create a system with customers, orders, items and products.
|
|
5
|
+
|
|
6
|
+
Include a notes field for orders.
|
|
7
|
+
|
|
8
|
+
Use LogicBank to enforce these requirements (do not generate check constraints); be sure to update the data model and *all* test data with any attributes used in the logic:
|
|
9
|
+
|
|
10
|
+
Use case: Check Credit
|
|
11
|
+
1. The Customer's balance is less than the credit limit
|
|
12
|
+
2. The Customer's balance is the sum of the Order amount_total where date_shipped is null
|
|
13
|
+
3. The Order's amount_total is the sum of the Item amount
|
|
14
|
+
4. The Item amount is the quantity * unit_price
|
|
15
|
+
5. The Item unit_price is copied from the Product unit_price
|
|
16
|
+
|
|
17
|
+
Ensure each customer has a unique name.
|
|
18
|
+
|
|
19
|
+
Ensure each Item quantity is not null.
|
|
20
|
+
|
|
21
|
+
Ensure each order has a valid customer_id that exists in the Customer table.
|
|
22
|
+
.
|
|
23
|
+
</Requirements>
|
|
24
|
+
|
|
25
|
+
Hints: use autonum keys (for all tables - including for link/join/junction/intersection tables), allow nulls, foreign keys, no check constraints.
|
|
26
|
+
|
|
27
|
+
Be sure to create classes, never tables.
|
|
28
|
+
Class names are singular, and first letter is capitalized.
|
|
29
|
+
|
|
30
|
+
If you create sum, count or formula Logic Bank rules, then you MUST create a corresponding column in the data model.
|
|
31
|
+
|
|
32
|
+
Remember that SQLite DateTime type only accepts Python datetime and date objects as input,
|
|
33
|
+
this means you can not enter string attributes where a date or datetime object is expected.
|
|
34
|
+
|
|
35
|
+
Don't install additional packages.
|
|
36
|
+
Don't use the faker pip package.
|
|
37
|
+
|
|
38
|
+
When creating SQLAlchemy data model classes, follow these guidelines carefully:
|
|
39
|
+
* Use foreign key columns instead of relationship names for the data.
|
|
40
|
+
* Do not specify nullable unless explicitly specified.
|
|
41
|
+
* Do not use unique unless explicitly specified.
|
|
42
|
+
* Do not use Float unless explicitly specified.
|
|
43
|
+
* Generate the classes ONLY.
|
|
44
|
+
* Do NOT generate imports.
|
|
45
|
+
* Do NOT generate connect statements.
|
|
46
|
+
* Do NOT generate engines.
|
|
47
|
+
|
|
48
|
+
Create 4 rows of test data for each table, and follow these guidelines carefully:
|
|
49
|
+
* Create separate objects for each test data row, not in arrays.
|
|
50
|
+
* Be sure to initialize derived attributes for test data rows - including all sums and counts, but do not rely on Logic Bank,
|
|
51
|
+
and do not generate db.execute statements.
|
|
52
|
+
* Do not create arrays of test data.
|
|
53
|
+
* Do not create a function to load test data.
|
|
54
|
+
* Do not print the test data.
|
|
55
|
+
* Use double quotes " for strings.
|
|
56
|
+
* For test data, format dates as date(year, month, day).
|
|
57
|
+
|
|
58
|
+
<responseFormat>
|
|
59
|
+
class Rule(BaseModel):
|
|
60
|
+
name: str
|
|
61
|
+
description: str
|
|
62
|
+
use_case: str # specified use case or requirement name (use 'General' if missing)
|
|
63
|
+
entity: str # the entity being constrained or derived
|
|
64
|
+
code: str # logicbank rule code
|
|
65
|
+
|
|
66
|
+
class Model(BaseModel):
|
|
67
|
+
classname: str
|
|
68
|
+
code: str # sqlalchemy model code
|
|
69
|
+
sqlite_create: str # sqlite create table statement
|
|
70
|
+
description: str
|
|
71
|
+
name: str
|
|
72
|
+
|
|
73
|
+
class TestDataRow(BaseModel):
|
|
74
|
+
test_data_row_variable: str # the Python test data row variable
|
|
75
|
+
code: str # Python code to create a test data row instance
|
|
76
|
+
|
|
77
|
+
class WGResult(BaseModel): # must match system/genai/prompt_inserts/response_format.prompt
|
|
78
|
+
# response: str # result
|
|
79
|
+
models : List[Model] # list of sqlalchemy classes in the response
|
|
80
|
+
rules : List[Rule] # list rule declarations
|
|
81
|
+
test_data: str
|
|
82
|
+
test_data_rows: List[TestDataRow] # list of test data rows
|
|
83
|
+
test_data_sqlite: str # test data as sqlite INSERT statements
|
|
84
|
+
name: str # suggest a short name for the project
|
|
85
|
+
|
|
86
|
+
Format the response as a WGResult.
|
|
87
|
+
|
|
88
|
+
</responseFormat>
|
|
89
|
+
|
|
90
|
+
<responseFormat>
|
|
91
|
+
|
|
92
|
+
class Rule(BaseModel):
|
|
93
|
+
|
|
94
|
+
name: str
|
|
95
|
+
|
|
96
|
+
description: str
|
|
97
|
+
|
|
98
|
+
use_case: str # specified use case or requirement name (use 'General' if missing)
|
|
99
|
+
|
|
100
|
+
entity: str # the entity being constrained or derived
|
|
101
|
+
|
|
102
|
+
code: str # logicbank rule code
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class Model(BaseModel):
|
|
107
|
+
|
|
108
|
+
classname: str
|
|
109
|
+
|
|
110
|
+
code: str # sqlalchemy model code
|
|
111
|
+
|
|
112
|
+
sqlite_create: str # sqlite create table statement
|
|
113
|
+
|
|
114
|
+
description: str
|
|
115
|
+
|
|
116
|
+
name: str
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class TestDataRow(BaseModel):
|
|
121
|
+
|
|
122
|
+
test_data_row_variable: str # the Python test data row variable
|
|
123
|
+
|
|
124
|
+
code: str # Python code to create a test data row instance
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class WGResult(BaseModel): # must match system/genai/prompt_inserts/response_format.prompt
|
|
129
|
+
|
|
130
|
+
# response: str # result
|
|
131
|
+
|
|
132
|
+
models : List[Model] # list of sqlalchemy classes in the response
|
|
133
|
+
|
|
134
|
+
rules : List[Rule] # list rule declarations
|
|
135
|
+
|
|
136
|
+
test_data: str
|
|
137
|
+
|
|
138
|
+
test_data_rows: List[TestDataRow] # list of test data rows
|
|
139
|
+
|
|
140
|
+
test_data_sqlite: str # test data as sqlite INSERT statements
|
|
141
|
+
|
|
142
|
+
name: str # suggest a short name for the project
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
Format the response as a WGResult.
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
</responseFormat>
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
{
|
|
2
|
+
"models": [
|
|
3
|
+
{
|
|
4
|
+
"classname": "Customer",
|
|
5
|
+
"code": "class Customer(Base):\n __tablename__ = 'customer'\n\n id = Column(Integer, primary_key=True)\n name = Column(String, unique=True)\n credit_limit = Column(Integer)\n balance = Column(Integer)\n ",
|
|
6
|
+
"description": "Model for customers, ensuring unique names and supporting logic for balance computation.",
|
|
7
|
+
"name": "Customer"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"classname": "Order",
|
|
11
|
+
"code": "class Order(Base):\n __tablename__ = 'order'\n\n id = Column(Integer, primary_key=True)\n customer_id = Column(Integer, ForeignKey('customer.id'), nullable=False)\n date_shipped = Column(DateTime)\n amount_total = Column(Integer)\n notes = Column(String)\n ",
|
|
12
|
+
"description": "Model for orders, with a reference to customers, a notes field, and computed total amount for logic enforcement.",
|
|
13
|
+
"name": "Order"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"classname": "Product",
|
|
17
|
+
"code": "class Product(Base):\n __tablename__ = 'product'\n\n id = Column(Integer, primary_key=True)\n unit_price = Column(Integer)\n \n ",
|
|
18
|
+
"description": "Model for products, storing unit prices to be copied to items.",
|
|
19
|
+
"name": "Product"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"classname": "Item",
|
|
23
|
+
"code": "class Item(Base):\n __tablename__ = 'item'\n\n id = Column(Integer, primary_key=True)\n order_id = Column(Integer, ForeignKey('order.id'))\n product_id = Column(Integer, ForeignKey('product.id'))\n quantity = Column(Integer, nullable=False)\n unit_price = Column(Integer)\n amount = Column(Integer)\n ",
|
|
24
|
+
"description": "Model for items, referencing orders and products, using unit_price copied from products and calculated amount.",
|
|
25
|
+
"name": "Item"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"rules": [
|
|
29
|
+
{
|
|
30
|
+
"name": "Customer Balance Constraint",
|
|
31
|
+
"description": "Ensures that a Customer's balance does not exceed its credit limit.",
|
|
32
|
+
"use_case": "Check Credit",
|
|
33
|
+
"entity": "Customer",
|
|
34
|
+
"code": "Rule.constraint(validate=Customer,\n as_condition=lambda row: row.balance <= row.credit_limit,\n error_msg=\"Customer balance ({row.balance}) exceeds credit limit ({row.credit_limit})\")"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "Customer Balance Computation",
|
|
38
|
+
"description": "Calculates Customer's balance as sum of Order amounts where date_shipped is null.",
|
|
39
|
+
"use_case": "Check Credit",
|
|
40
|
+
"entity": "Customer",
|
|
41
|
+
"code": "Rule.sum(derive=Customer.balance, as_sum_of=Order.amount_total, \n where=lambda row: row.date_shipped is None)"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "Order Amount Total",
|
|
45
|
+
"description": "Calculates Order amount_total as sum of Item amounts.",
|
|
46
|
+
"use_case": "Check Credit",
|
|
47
|
+
"entity": "Order",
|
|
48
|
+
"code": "Rule.sum(derive=Order.amount_total, as_sum_of=Item.amount)"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "Item Amount Calculation",
|
|
52
|
+
"description": "Calculates Item's amount as the product of quantity and unit_price.",
|
|
53
|
+
"use_case": "Check Credit",
|
|
54
|
+
"entity": "Item",
|
|
55
|
+
"code": "Rule.formula(derive=Item.amount, as_expression=lambda row: row.quantity * row.unit_price)"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "Item Unit Price Copy",
|
|
59
|
+
"description": "Copies Product's unit_price to item's unit_price.",
|
|
60
|
+
"use_case": "Check Credit",
|
|
61
|
+
"entity": "Item",
|
|
62
|
+
"code": "Rule.copy(derive=Item.unit_price, from_parent=Product.unit_price)"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"test_data": "# Test Customers\ntest_customer_1 = Customer(id=1, name=\"Customer A\", credit_limit=5000, balance=0)\ntest_customer_2 = Customer(id=2, name=\"Customer B\", credit_limit=6000, balance=0)\ntest_customer_3 = Customer(id=3, name=\"Customer C\", credit_limit=7000, balance=0)\ntest_customer_4 = Customer(id=4, name=\"Customer D\", credit_limit=8000, balance=0)\n\n# Test Products\ntest_product_1 = Product(id=1, unit_price=10)\ntest_product_2 = Product(id=2, unit_price=15)\ntest_product_3 = Product(id=3, unit_price=20)\ntest_product_4 = Product(id=4, unit_price=25)\n\n# Test Orders\ntest_order_1 = Order(id=1, customer_id=1, date_shipped=None, amount_total=0, notes=\"First order\")\ntest_order_2 = Order(id=2, customer_id=2, date_shipped=None, amount_total=0, notes=\"Second order\")\ntest_order_3 = Order(id=3, customer_id=3, date_shipped=None, amount_total=0, notes=\"Third order\")\ntest_order_4 = Order(id=4, customer_id=4, date_shipped=None, amount_total=0, notes=\"Fourth order\")\n\n# Test Items\ntest_item_1 = Item(id=1, order_id=1, product_id=1, quantity=2, unit_price=10, amount=20)\ntest_item_2 = Item(id=2, order_id=2, product_id=2, quantity=3, unit_price=15, amount=45)\ntest_item_3 = Item(id=3, order_id=3, product_id=3, quantity=4, unit_price=20, amount=80)\ntest_item_4 = Item(id=4, order_id=4, product_id=4, quantity=5, unit_price=25, amount=125)",
|
|
66
|
+
"test_data_rows": [
|
|
67
|
+
{
|
|
68
|
+
"test_data_row_variable": "test_customer_1",
|
|
69
|
+
"code": "test_customer_1 = Customer(id=1, name=\"Customer A\", credit_limit=5000, balance=0)"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"test_data_row_variable": "test_customer_2",
|
|
73
|
+
"code": "test_customer_2 = Customer(id=2, name=\"Customer B\", credit_limit=6000, balance=0)"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"test_data_row_variable": "test_customer_3",
|
|
77
|
+
"code": "test_customer_3 = Customer(id=3, name=\"Customer C\", credit_limit=7000, balance=0)"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"test_data_row_variable": "test_customer_4",
|
|
81
|
+
"code": "test_customer_4 = Customer(id=4, name=\"Customer D\", credit_limit=8000, balance=0)"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"test_data_row_variable": "test_product_1",
|
|
85
|
+
"code": "test_product_1 = Product(id=1, unit_price=10)"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"test_data_row_variable": "test_product_2",
|
|
89
|
+
"code": "test_product_2 = Product(id=2, unit_price=15)"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"test_data_row_variable": "test_product_3",
|
|
93
|
+
"code": "test_product_3 = Product(id=3, unit_price=20)"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"test_data_row_variable": "test_product_4",
|
|
97
|
+
"code": "test_product_4 = Product(id=4, unit_price=25)"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"test_data_row_variable": "test_order_1",
|
|
101
|
+
"code": "test_order_1 = Order(id=1, customer_id=1, date_shipped=None, amount_total=0, notes=\"First order\")"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"test_data_row_variable": "test_order_2",
|
|
105
|
+
"code": "test_order_2 = Order(id=2, customer_id=2, date_shipped=None, amount_total=0, notes=\"Second order\")"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"test_data_row_variable": "test_order_3",
|
|
109
|
+
"code": "test_order_3 = Order(id=3, customer_id=3, date_shipped=None, amount_total=0, notes=\"Third order\")"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"test_data_row_variable": "test_order_4",
|
|
113
|
+
"code": "test_order_4 = Order(id=4, customer_id=4, date_shipped=None, amount_total=0, notes=\"Fourth order\")"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"test_data_row_variable": "test_item_1",
|
|
117
|
+
"code": "test_item_1 = Item(id=1, order_id=1, product_id=1, quantity=2, unit_price=10, amount=20)"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"test_data_row_variable": "test_item_2",
|
|
121
|
+
"code": "test_item_2 = Item(id=2, order_id=2, product_id=2, quantity=3, unit_price=15, amount=45)"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"test_data_row_variable": "test_item_3",
|
|
125
|
+
"code": "test_item_3 = Item(id=3, order_id=3, product_id=3, quantity=4, unit_price=20, amount=80)"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"test_data_row_variable": "test_item_4",
|
|
129
|
+
"code": "test_item_4 = Item(id=4, order_id=4, product_id=4, quantity=5, unit_price=25, amount=125)"
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
"test_data_sqlite": "-- Test Customers\nINSERT INTO customer (id, name, credit_limit, balance) VALUES (1, 'Customer A', 5000, 0);\nINSERT INTO customer (id, name, credit_limit, balance) VALUES (2, 'Customer B', 6000, 0);\nINSERT INTO customer (id, name, credit_limit, balance) VALUES (3, 'Customer C', 7000, 0);\nINSERT INTO customer (id, name, credit_limit, balance) VALUES (4, 'Customer D', 8000, 0);\n\n-- Test Products\nINSERT INTO product (id, unit_price) VALUES (1, 10);\nINSERT INTO product (id, unit_price) VALUES (2, 15);\nINSERT INTO product (id, unit_price) VALUES (3, 20);\nINSERT INTO product (id, unit_price) VALUES (4, 25);\n\n-- Test Orders\nINSERT INTO \"order\" (id, customer_id, date_shipped, amount_total, notes) VALUES (1, 1, NULL, 0, 'First order');\nINSERT INTO \"order\" (id, customer_id, date_shipped, amount_total, notes) VALUES (2, 2, NULL, 0, 'Second order');\nINSERT INTO \"order\" (id, customer_id, date_shipped, amount_total, notes) VALUES (3, 3, NULL, 0, 'Third order');\nINSERT INTO \"order\" (id, customer_id, date_shipped, amount_total, notes) VALUES (4, 4, NULL, 0, 'Fourth order');\n\n-- Test Items\nINSERT INTO item (id, order_id, product_id, quantity, unit_price, amount) VALUES (1, 1, 1, 2, 10, 20);\nINSERT INTO item (id, order_id, product_id, quantity, unit_price, amount) VALUES (2, 2, 2, 3, 15, 45);\nINSERT INTO item (id, order_id, product_id, quantity, unit_price, amount) VALUES (3, 3, 3, 4, 20, 80);\nINSERT INTO item (id, order_id, product_id, quantity, unit_price, amount) VALUES (4, 4, 4, 5, 25, 125);",
|
|
133
|
+
"name": "Order Management System"
|
|
134
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
Update the prior response - be sure not to lose classes and test data already created.
|
|
2
|
+
|
|
3
|
+
Provide a 10% discount when buying more than 10 carbon neutral products
|
|
4
|
+
|
|
5
|
+
The Item carbon neutral is copied from the Product carbon neutral
|
|
6
|
+
|
|
7
|
+
Hints: use autonum keys (for all tables - including for link/join/junction/intersection tables), allow nulls, foreign keys, no check constraints.
|
|
8
|
+
|
|
9
|
+
Be sure to create classes, never tables.
|
|
10
|
+
|
|
11
|
+
If you create sum, count or formula Logic Bank rules, then you MUST create a corresponding column in the data model.
|
|
12
|
+
|
|
13
|
+
Remember that SQLite DateTime type only accepts Python datetime and date objects as input,
|
|
14
|
+
this means you can not enter string attributes where a date or datetime object is expected.
|
|
15
|
+
|
|
16
|
+
Don't install additional packages.
|
|
17
|
+
Don't use the faker pip package.
|
|
18
|
+
|
|
19
|
+
When creating SQLAlchemy data model classes, follow these guidelines carefully:
|
|
20
|
+
* Use foreign key columns instead of relationship names for the data.
|
|
21
|
+
* Do not specify nullable unless explicitly specified.
|
|
22
|
+
* Do not use unique unless explicitly specified.
|
|
23
|
+
* Do not use Float unless explicitly specified.
|
|
24
|
+
* Generate the classes ONLY.
|
|
25
|
+
* Do NOT generate imports.
|
|
26
|
+
* Do NOT generate connect statements.
|
|
27
|
+
* Do NOT generate engines.
|
|
28
|
+
|
|
29
|
+
Create 4 rows of test data for each table, and follow these guidelines carefully:
|
|
30
|
+
* Create separate objects for each test data row, not in arrays.
|
|
31
|
+
* Be sure to initialize derived attributes for test data rows - including all sums and counts, but do not rely on Logic Bank,
|
|
32
|
+
and do not generate db.execute statements.
|
|
33
|
+
* Do not create arrays of test data.
|
|
34
|
+
* Do not create a function to load test data.
|
|
35
|
+
* Do not print the test data.
|
|
36
|
+
* Use double quotes " for strings.
|
|
37
|
+
* For test data, format dates as date(year, month, day).
|
|
38
|
+
|
|
39
|
+
<responseFormat>
|
|
40
|
+
class Rule(BaseModel):
|
|
41
|
+
name: str
|
|
42
|
+
description: str
|
|
43
|
+
use_case: str # specified use case or requirement name (use 'General' if missing)
|
|
44
|
+
entity: str # the entity being constrained or derived
|
|
45
|
+
code: str # logicbank rule code
|
|
46
|
+
|
|
47
|
+
class Model(BaseModel):
|
|
48
|
+
classname: str
|
|
49
|
+
code: str # sqlalchemy model code
|
|
50
|
+
sqlite_create: str # sqlite create table statement
|
|
51
|
+
description: str
|
|
52
|
+
name: str
|
|
53
|
+
|
|
54
|
+
class TestDataRow(BaseModel):
|
|
55
|
+
test_data_row_variable: str # the Python test data row variable
|
|
56
|
+
code: str # Python code to create a test data row instance
|
|
57
|
+
|
|
58
|
+
class WGResult(BaseModel): # must match system/genai/prompt_inserts/response_format.prompt
|
|
59
|
+
# response: str # result
|
|
60
|
+
models : List[Model] # list of sqlalchemy classes in the response
|
|
61
|
+
rules : List[Rule] # list rule declarations
|
|
62
|
+
test_data: str
|
|
63
|
+
test_data_rows: List[TestDataRow] # list of test data rows
|
|
64
|
+
test_data_sqlite: str # test data as sqlite INSERT statements
|
|
65
|
+
name: str # suggest a short name for the project
|
|
66
|
+
|
|
67
|
+
Format the response as a WGResult.
|
|
68
|
+
|
|
69
|
+
</responseFormat>
|
|
70
|
+
|
|
71
|
+
<responseFormat>
|
|
72
|
+
|
|
73
|
+
class Rule(BaseModel):
|
|
74
|
+
|
|
75
|
+
name: str
|
|
76
|
+
|
|
77
|
+
description: str
|
|
78
|
+
|
|
79
|
+
use_case: str # specified use case or requirement name (use 'General' if missing)
|
|
80
|
+
|
|
81
|
+
entity: str # the entity being constrained or derived
|
|
82
|
+
|
|
83
|
+
code: str # logicbank rule code
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class Model(BaseModel):
|
|
88
|
+
|
|
89
|
+
classname: str
|
|
90
|
+
|
|
91
|
+
code: str # sqlalchemy model code
|
|
92
|
+
|
|
93
|
+
sqlite_create: str # sqlite create table statement
|
|
94
|
+
|
|
95
|
+
description: str
|
|
96
|
+
|
|
97
|
+
name: str
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class TestDataRow(BaseModel):
|
|
102
|
+
|
|
103
|
+
test_data_row_variable: str # the Python test data row variable
|
|
104
|
+
|
|
105
|
+
code: str # Python code to create a test data row instance
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class WGResult(BaseModel): # must match system/genai/prompt_inserts/response_format.prompt
|
|
110
|
+
|
|
111
|
+
# response: str # result
|
|
112
|
+
|
|
113
|
+
models : List[Model] # list of sqlalchemy classes in the response
|
|
114
|
+
|
|
115
|
+
rules : List[Rule] # list rule declarations
|
|
116
|
+
|
|
117
|
+
test_data: str
|
|
118
|
+
|
|
119
|
+
test_data_rows: List[TestDataRow] # list of test data rows
|
|
120
|
+
|
|
121
|
+
test_data_sqlite: str # test data as sqlite INSERT statements
|
|
122
|
+
|
|
123
|
+
name: str # suggest a short name for the project
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
Format the response as a WGResult.
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
</responseFormat>
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
{
|
|
2
|
+
"models": [
|
|
3
|
+
{
|
|
4
|
+
"classname": "Customer",
|
|
5
|
+
"code": "class Customer(Base):\n __tablename__ = 'customer'\n\n id = Column(Integer, primary_key=True, autoincrement=True)\n name = Column(String(8000), unique=True)\n balance = Column(DECIMAL)\n credit_limit = Column(DECIMAL)",
|
|
6
|
+
"description": "Class representing customers with unique names and credit limits.",
|
|
7
|
+
"name": "Customer"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"classname": "Order",
|
|
11
|
+
"code": "class Order(Base):\n __tablename__ = 'order'\n\n id = Column(Integer, primary_key=True, autoincrement=True)\n customer_id = Column(Integer, ForeignKey('customer.id'))\n amount_total = Column(DECIMAL)\n date_shipped = Column(DateTime)\n notes = Column(String(8000))",
|
|
12
|
+
"description": "Class representing orders linked to customers, with notes and shipment date.",
|
|
13
|
+
"name": "Order"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"classname": "Item",
|
|
17
|
+
"code": "class Item(Base):\n __tablename__ = 'item'\n\n id = Column(Integer, primary_key=True, autoincrement=True)\n order_id = Column(Integer, ForeignKey('order.id'))\n product_id = Column(Integer, ForeignKey('product.id'))\n quantity = Column(Integer, nullable=False)\n amount = Column(DECIMAL)\n unit_price = Column(DECIMAL)\n carbon_neutral = Column(Boolean)",
|
|
18
|
+
"description": "Class representing items with quantity, amount, and carbon neutral status.",
|
|
19
|
+
"name": "Item"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"classname": "Product",
|
|
23
|
+
"code": "class Product(Base):\n __tablename__ = 'product'\n\n id = Column(Integer, primary_key=True, autoincrement=True)\n name = Column(String(8000))\n unit_price = Column(DECIMAL)\n carbon_neutral = Column(Boolean)",
|
|
24
|
+
"description": "Class representing products with their unit prices and carbon neutral status.",
|
|
25
|
+
"name": "Product"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"rules": [
|
|
29
|
+
{
|
|
30
|
+
"name": "Customer Balance Sum",
|
|
31
|
+
"description": "Customer's balance is the sum of the Order amount_total where date_shipped is null.",
|
|
32
|
+
"use_case": "Check Credit",
|
|
33
|
+
"entity": "Customer",
|
|
34
|
+
"code": "Rule.sum(derive=Customer.balance, as_sum_of=Order.amount_total, where=lambda row: row.date_shipped is None)"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "Order Amount Total",
|
|
38
|
+
"description": "The Order's amount_total is the sum of the Item amount.",
|
|
39
|
+
"use_case": "Check Credit",
|
|
40
|
+
"entity": "Order",
|
|
41
|
+
"code": "Rule.sum(derive=Order.amount_total, as_sum_of=Item.amount)"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "Item Amount Formula",
|
|
45
|
+
"description": "The Item amount is the quantity * unit_price.",
|
|
46
|
+
"use_case": "Check Credit",
|
|
47
|
+
"entity": "Item",
|
|
48
|
+
"code": "Rule.formula(derive=Item.amount, as_expression=lambda row: row.quantity * row.unit_price if not row.carbon_neutral or row.quantity <= 10 else 0.9 * row.quantity * row.unit_price)"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "Item Unit Price Copy",
|
|
52
|
+
"description": "The Item unit_price is copied from the Product unit_price.",
|
|
53
|
+
"use_case": "Check Credit",
|
|
54
|
+
"entity": "Item",
|
|
55
|
+
"code": "Rule.copy(derive=Item.unit_price, from_parent=Product.unit_price)"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "Customer Credit Constraint",
|
|
59
|
+
"description": "The Customer's balance must be less than the credit limit.",
|
|
60
|
+
"use_case": "Check Credit",
|
|
61
|
+
"entity": "Customer",
|
|
62
|
+
"code": "Rule.constraint(validate=Customer, as_condition=lambda row: row.balance <= row.credit_limit, error_msg='Customer balance ({row.balance}) exceeds credit limit ({row.credit_limit})')"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "Item Carbon Neutral Copy",
|
|
66
|
+
"description": "Copy carbon neutral status from Product to Item.",
|
|
67
|
+
"use_case": "General",
|
|
68
|
+
"entity": "Item",
|
|
69
|
+
"code": "Rule.copy(derive=Item.carbon_neutral, from_parent=Product.carbon_neutral)"
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
"test_data": "Sample test data includes initial customers, orders with associated items, and products.",
|
|
73
|
+
"test_data_rows": [
|
|
74
|
+
{
|
|
75
|
+
"test_data_row_variable": "customer1",
|
|
76
|
+
"code": "customer1 = Customer(id=1, name=\"Customer A\", balance=0.0, credit_limit=1000.0)"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"test_data_row_variable": "customer2",
|
|
80
|
+
"code": "customer2 = Customer(id=2, name=\"Customer B\", balance=0.0, credit_limit=1500.0)"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"test_data_row_variable": "customer3",
|
|
84
|
+
"code": "customer3 = Customer(id=3, name=\"Customer C\", balance=0.0, credit_limit=2000.0)"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"test_data_row_variable": "customer4",
|
|
88
|
+
"code": "customer4 = Customer(id=4, name=\"Customer D\", balance=0.0, credit_limit=2500.0)"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"test_data_row_variable": "product1",
|
|
92
|
+
"code": "product1 = Product(id=1, name=\"Product A\", unit_price=10.0, carbon_neutral=True)"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"test_data_row_variable": "product2",
|
|
96
|
+
"code": "product2 = Product(id=2, name=\"Product B\", unit_price=20.0, carbon_neutral=False)"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"test_data_row_variable": "product3",
|
|
100
|
+
"code": "product3 = Product(id=3, name=\"Product C\", unit_price=30.0, carbon_neutral=True)"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"test_data_row_variable": "product4",
|
|
104
|
+
"code": "product4 = Product(id=4, name=\"Product D\", unit_price=40.0, carbon_neutral=False)"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"test_data_row_variable": "order1",
|
|
108
|
+
"code": "order1 = Order(id=1, customer_id=1, amount_total=0.0, date_shipped=None, notes='Urgent order')"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"test_data_row_variable": "order2",
|
|
112
|
+
"code": "order2 = Order(id=2, customer_id=2, amount_total=0.0, date_shipped=None, notes='Regular order')"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"test_data_row_variable": "order3",
|
|
116
|
+
"code": "order3 = Order(id=3, customer_id=3, amount_total=0.0, date_shipped=None, notes='Delayed order')"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"test_data_row_variable": "order4",
|
|
120
|
+
"code": "order4 = Order(id=4, customer_id=4, amount_total=0.0, date_shipped=None, notes='Important client')"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"test_data_row_variable": "item1",
|
|
124
|
+
"code": "item1 = Item(id=1, order_id=1, product_id=1, quantity=15, amount=135.0, unit_price=10.0, carbon_neutral=True)"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"test_data_row_variable": "item2",
|
|
128
|
+
"code": "item2 = Item(id=2, order_id=1, product_id=2, quantity=5, amount=100.0, unit_price=20.0, carbon_neutral=False)"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"test_data_row_variable": "item3",
|
|
132
|
+
"code": "item3 = Item(id=3, order_id=2, product_id=3, quantity=8, amount=216.0, unit_price=30.0, carbon_neutral=True)"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"test_data_row_variable": "item4",
|
|
136
|
+
"code": "item4 = Item(id=4, order_id=3, product_id=4, quantity=2, amount=80.0, unit_price=40.0, carbon_neutral=False)"
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
"test_data_sqlite": "INSERT INTO customer (id, name, balance, credit_limit) VALUES\n(1, \"Customer A\", 0.0, 1000.0),\n(2, \"Customer B\", 0.0, 1500.0),\n(3, \"Customer C\", 0.0, 2000.0),\n(4, \"Customer D\", 0.0, 2500.0);\n\nINSERT INTO product (id, name, unit_price, carbon_neutral) VALUES\n(1, \"Product A\", 10.0, 1),\n(2, \"Product B\", 20.0, 0),\n(3, \"Product C\", 30.0, 1),\n(4, \"Product D\", 40.0, 0);\n\nINSERT INTO \"order\" (id, customer_id, amount_total, date_shipped, notes) VALUES\n(1, 1, 0.0, NULL, 'Urgent order'),\n(2, 2, 0.0, NULL, 'Regular order'),\n(3, 3, 0.0, NULL, 'Delayed order'),\n(4, 4, 0.0, NULL, 'Important client');\n\nINSERT INTO item (id, order_id, product_id, quantity, amount, unit_price, carbon_neutral) VALUES\n(1, 1, 1, 15, 135.0, 10.0, 1),\n(2, 1, 2, 5, 100.0, 20.0, 0),\n(3, 2, 3, 8, 216.0, 30.0, 1),\n(4, 3, 4, 2, 80.0, 40.0, 0);",
|
|
140
|
+
"name": "CustomerOrderSystem"
|
|
141
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# using resolved_model self.resolved_model FIXME
|
|
2
|
+
# created from response, to create create_db_models.sqlite, with test data
|
|
3
|
+
# that is used to create project
|
|
4
|
+
# should run without error in manager
|
|
5
|
+
# if not, check for decimal, indent, or import issues
|
|
6
|
+
|
|
7
|
+
import decimal
|
|
8
|
+
import logging
|
|
9
|
+
import sqlalchemy
|
|
10
|
+
from sqlalchemy.sql import func
|
|
11
|
+
from logic_bank.logic_bank import Rule
|
|
12
|
+
from sqlalchemy import create_engine, Column, Integer, String, Float, ForeignKey, Date, DateTime, Numeric, Boolean, Text, DECIMAL
|
|
13
|
+
from sqlalchemy.types import *
|
|
14
|
+
from sqlalchemy.ext.declarative import declarative_base
|
|
15
|
+
from sqlalchemy.orm import sessionmaker
|
|
16
|
+
from sqlalchemy.orm import relationship
|
|
17
|
+
from sqlalchemy.orm import Mapped
|
|
18
|
+
from datetime import date
|
|
19
|
+
from datetime import datetime
|
|
20
|
+
from typing import List
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
logging.getLogger('sqlalchemy.engine.Engine').disabled = True # remove for additional logging
|
|
24
|
+
|
|
25
|
+
Base = declarative_base() # from system/genai/create_db_models_inserts/create_db_models_prefix.py
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
from sqlalchemy.dialects.sqlite import *
|
|
29
|
+
|
|
30
|
+
class CustomerAccount(Base):
|
|
31
|
+
"""description: This table holds customer account details with credit checks."""
|
|
32
|
+
"""
|
|
33
|
+
description: This table holds customer account details with credit checks.
|
|
34
|
+
"""
|
|
35
|
+
__tablename__ = 'customer_account'
|
|
36
|
+
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
37
|
+
name = Column(String, nullable=True)
|
|
38
|
+
email = Column(String, nullable=True)
|
|
39
|
+
balance = Column(Float, nullable=True)
|
|
40
|
+
credit_limit = Column(Float, nullable=True)
|
|
41
|
+
|
|
42
|
+
class Address(Base):
|
|
43
|
+
"""description: This table contains addresses associated with CustomerAccount."""
|
|
44
|
+
"""
|
|
45
|
+
description: This table contains addresses associated with CustomerAccount.
|
|
46
|
+
"""
|
|
47
|
+
__tablename__ = 'address'
|
|
48
|
+
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
49
|
+
customer_account_id = Column(Integer, ForeignKey('customer_account.id'),
|
|
50
|
+
nullable=False)
|
|
51
|
+
street = Column(String, nullable=True)
|
|
52
|
+
city = Column(String, nullable=True)
|
|
53
|
+
state = Column(String, nullable=True)
|
|
54
|
+
zip_code = Column(String, nullable=True)
|
|
55
|
+
|
|
56
|
+
class SalesRep(Base):
|
|
57
|
+
"""description: This table contains sales representative details."""
|
|
58
|
+
"""
|
|
59
|
+
description: This table contains sales representative details.
|
|
60
|
+
"""
|
|
61
|
+
__tablename__ = 'sales_rep'
|
|
62
|
+
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
63
|
+
name = Column(String, nullable=True)
|
|
64
|
+
region = Column(String, nullable=True)
|
|
65
|
+
|
|
66
|
+
class Order(Base):
|
|
67
|
+
"""description: This table contains order details with an assigned sales representative."""
|
|
68
|
+
"""
|
|
69
|
+
description: This table contains order details with an assigned sales representative.
|
|
70
|
+
"""
|
|
71
|
+
__tablename__ = 'order'
|
|
72
|
+
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
73
|
+
customer_account_id = Column(Integer, ForeignKey('customer_account.id'),
|
|
74
|
+
nullable=False)
|
|
75
|
+
order_date = Column(Date, nullable=True)
|
|
76
|
+
sales_rep_id = Column(Integer, ForeignKey('sales_rep.id'), nullable=False)
|
|
77
|
+
notes = Column(String, nullable=True)
|
|
78
|
+
amount_total = Column(Float, nullable=True)
|
|
79
|
+
|
|
80
|
+
class Item(Base):
|
|
81
|
+
"""description: This table links orders to products for each item on an order."""
|
|
82
|
+
"""
|
|
83
|
+
description: This table links orders to products for each item on an order.
|
|
84
|
+
"""
|
|
85
|
+
__tablename__ = 'item'
|
|
86
|
+
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
87
|
+
order_id = Column(Integer, ForeignKey('order.id'), nullable=False)
|
|
88
|
+
product_id = Column(Integer, ForeignKey('product.id'), nullable=False)
|
|
89
|
+
quantity = Column(Integer, nullable=True)
|
|
90
|
+
unit_price = Column(Float, nullable=True)
|
|
91
|
+
amount = Column(Float, nullable=True)
|
|
92
|
+
|
|
93
|
+
class Product(Base):
|
|
94
|
+
"""description: This table contains product information."""
|
|
95
|
+
"""
|
|
96
|
+
description: This table contains product information.
|
|
97
|
+
"""
|
|
98
|
+
__tablename__ = 'product'
|
|
99
|
+
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
100
|
+
name = Column(String, nullable=True)
|
|
101
|
+
price = Column(Float, nullable=True)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# end of model classes
|
|
105
|
+
|