ApiLogicServer 16.0.0__py3-none-any.whl → 16.0.3__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.
@@ -5,7 +5,7 @@ This template provides a clean reference implementation for AI value computation
5
5
  alongside deterministic rules, using the Request Pattern with early events.
6
6
 
7
7
  Pattern: Early event with wrapper function that returns populated request object
8
- version: 3.1 - proper initialization of ai_request data
8
+ version: 3.0
9
9
  date: November 21, 2025
10
10
  source: docs/training/probabilistic_template.py
11
11
 
@@ -136,31 +136,24 @@ def select_supplier_via_ai(row: models.SysSupplierReq, old_row, logic_row: Logic
136
136
  row.fallback_used = True
137
137
  return
138
138
 
139
- # Check for test context first (BEFORE API key check)
139
+ # Load test context for world conditions (not for predetermined supplier selection)
140
140
  from pathlib import Path
141
141
  import yaml
142
142
 
143
143
  config_dir = Path(__file__).resolve().parent.parent.parent.parent / 'config'
144
144
  context_file = config_dir / 'ai_test_context.yaml'
145
145
 
146
- selected_supplier = None
147
-
146
+ test_context = {}
148
147
  if context_file.exists():
149
148
  with open(str(context_file), 'r') as f:
150
- test_context = yaml.safe_load(f)
151
- if test_context and 'selected_supplier_id' in test_context:
152
- supplier_id = test_context['selected_supplier_id']
153
- selected_supplier = next((s for s in suppliers if s.supplier_id == supplier_id), None)
154
- if selected_supplier:
155
- candidate_summary = ', '.join([f"{s.supplier.name if s.supplier else 'Unknown'}(${s.unit_cost})" for s in suppliers])
156
- world = test_context.get('world_conditions', 'normal conditions')
157
- row.request = f"Select supplier for {product.name}: Candidates=[{candidate_summary}], World={world}"
158
- row.reason = f"TEST MODE: Selected {selected_supplier.supplier.name if selected_supplier.supplier else 'supplier'} (${selected_supplier.unit_cost}) - world: {world}"
159
- logic_row.log(f"Using test context: supplier {supplier_id}")
160
- row.fallback_used = False
149
+ test_context = yaml.safe_load(f) or {}
161
150
 
162
- # If no test context, try AI (check for API key)
163
- if not selected_supplier:
151
+ world_conditions = test_context.get('world_conditions', 'normal conditions')
152
+
153
+ selected_supplier = None
154
+
155
+ # Try AI (check for API key)
156
+ if True: # Always try AI unless no key
164
157
  api_key = os.getenv("APILOGICSERVER_CHATGPT_APIKEY")
165
158
  if api_key:
166
159
  try:
@@ -170,18 +163,22 @@ def select_supplier_via_ai(row: models.SysSupplierReq, old_row, logic_row: Logic
170
163
 
171
164
  client = OpenAI(api_key=api_key)
172
165
 
173
- # Build candidate data for prompt
166
+ # Build candidate data for prompt - include ALL supplier fields for AI decision
174
167
  candidate_data = []
175
168
  for supplier in suppliers:
169
+ supplier_obj = supplier.supplier
176
170
  candidate_data.append({
177
171
  'supplier_id': supplier.supplier_id,
178
- 'supplier_name': supplier.supplier.name if supplier.supplier else 'Unknown',
172
+ 'supplier_name': supplier_obj.name if supplier_obj else 'Unknown',
173
+ 'supplier_region': supplier_obj.region if supplier_obj else None,
174
+ 'supplier_contact': supplier_obj.contact_name if supplier_obj else None,
175
+ 'supplier_phone': supplier_obj.phone if supplier_obj else None,
176
+ 'supplier_email': supplier_obj.email if supplier_obj else None,
179
177
  'unit_cost': float(supplier.unit_cost) if supplier.unit_cost else 0.0,
180
- 'lead_time_days': supplier.lead_time_days if hasattr(supplier, 'lead_time_days') else None
178
+ 'lead_time_days': supplier.lead_time_days if hasattr(supplier, 'lead_time_days') else None,
179
+ 'supplier_part_number': supplier.supplier_part_number if hasattr(supplier, 'supplier_part_number') else None
181
180
  })
182
181
 
183
- world_conditions = test_context.get('world_conditions', 'normal conditions') if 'test_context' in locals() else 'normal conditions'
184
-
185
182
  prompt = f"""
186
183
  You are a supply chain optimization expert. Select the best supplier from the candidates below.
187
184
 
@@ -200,11 +197,14 @@ Respond with ONLY valid JSON in this exact format (no markdown, no code blocks):
200
197
  }}
201
198
  """
202
199
 
203
- # Populate request field with actual prompt summary
204
- candidate_list = ', '.join([c['supplier_name'] + '($' + str(c['unit_cost']) + ')' for c in candidate_data])
205
- row.request = f"AI Prompt: Product={product.name}, World={world_conditions}, Candidates={len(candidate_data)}: {candidate_list}"
200
+ # Populate request field with actual prompt summary including key fields
201
+ candidate_summary = ', '.join([
202
+ f"{c['supplier_name']}(${c['unit_cost']}, {c['supplier_region'] or 'unknown region'}, {c['lead_time_days'] or '?'}days)"
203
+ for c in candidate_data
204
+ ])
205
+ row.request = f"Select supplier for {product.name}: Candidates=[{candidate_summary}], World={world_conditions}"
206
206
 
207
- logic_row.log(f"Calling OpenAI API with {len(candidate_data)} candidates")
207
+ logic_row.log(f"Calling OpenAI API with {len(candidate_data)} candidates, world conditions: {world_conditions}")
208
208
 
209
209
  response = client.chat.completions.create(
210
210
  model="gpt-4o-2024-08-06",
@@ -225,7 +225,7 @@ Respond with ONLY valid JSON in this exact format (no markdown, no code blocks):
225
225
  selected_supplier = next((s for s in suppliers if s.supplier_id == ai_result['chosen_supplier_id']), None)
226
226
  if selected_supplier:
227
227
  supplier_name = selected_supplier.supplier.name if selected_supplier.supplier else 'Unknown'
228
- row.reason = f"AI: {supplier_name} (${selected_supplier.unit_cost}) - {ai_result.get('reason', 'No reason provided')}"
228
+ row.reason = f"Selected {supplier_name} (${selected_supplier.unit_cost}) - {ai_result.get('reason', 'No reason provided')}"
229
229
  row.fallback_used = False
230
230
  else:
231
231
  logic_row.log(f"AI selected invalid supplier_id {ai_result['chosen_supplier_id']}, using fallback")
@@ -3,25 +3,25 @@ use: welcome for basic_demo - please start the tour
3
3
  instuctions: copy api_logic_server_cli/prototypes/base/.github/.copilot-instructions.md, then paste as the Welcome section
4
4
  ---
5
5
 
6
- ## Welcome
7
-
8
- **Welcome! This is your basic_demo project.**
6
+ ## Welcome to the `basic_demo` project
9
7
 
10
8
  This is a complete, working microservice auto-generated from a database schema - **uncustomized**, so you can see what to expect when you create projects from your own databases.
11
9
 
12
- **What's already created from introspecting the database schema:**
10
+ Created from database schema introspection:
13
11
  - **Admin Web Application** - Live at `http://localhost:5656`
14
- - **REST API Endpoints** - All database tables exposed at `/api/*`
12
+ - **REST API Endpoints** - All database tables exposed at MCP discoverable `/api/*`
15
13
  - **Database Models** - Complete SQLAlchemy ORM in `database/models.py`
16
14
  - **Authentication System** - JWT-based auth framework
17
15
  - **Business Logic Engine** - Declarative rules system
18
16
 
19
17
  ---
20
18
 
21
- **First, we'll briefly explore what's automatically created. Then I'll show you how I can help you customize it - adding logic, security, and API endpoints.**
19
+ **Ready to explore?** Just say me "guide me through" to begin the interactive tutorial
22
20
 
21
+ * Brief exploration of what's already created
22
+ * Customizing logic, security, and the API
23
23
 
24
- **Ready to explore?** Just say me "guide me through" to begin the interactive tutorial.
24
+ ---
25
25
 
26
26
  **Or, self-demo?** Open `readme_ai_mcp.md` to explore logic, ai and mcp.
27
27
 
@@ -20,5 +20,6 @@
20
20
  "workbench.editorAssociations": {
21
21
  "*.md": "vscode.markdown.preview.editor"
22
22
  },
23
+ "workbench.startupEditor": "readme",
23
24
  "workbench.colorTheme": "Arduino Light"
24
25
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ApiLogicServer
3
- Version: 16.0.0
3
+ Version: 16.0.3
4
4
  Author-email: Val Huber <apilogicserver@gmail.com>
5
5
  License-Expression: BSD-3-Clause
6
6
  Project-URL: Homepage, https://www.genai-logic.com
@@ -1,5 +1,5 @@
1
1
  api_logic_server_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- api_logic_server_cli/api_logic_server.py,sha256=WOTLdg7MkjeoeRvRyE1rfH8OSj_gTl5xMJODBx4qxDE,105152
2
+ api_logic_server_cli/api_logic_server.py,sha256=JxgkpASNi72szMR4SZ4vv2-cUPDl16Kn7LSuxYC9ciQ,105173
3
3
  api_logic_server_cli/api_logic_server_info.yaml,sha256=wzqFVXFXtbCPMFWmDG5k_cP4efr7YAhyhWIlYdpKGRc,132
4
4
  api_logic_server_cli/cli.py,sha256=xAqTOhq-OnXU2HEQgzsGC9yKrGcAgKUt_8b9U2bV5No,87831
5
5
  api_logic_server_cli/cli_args_base.py,sha256=7cVM6BeizwttYAwUu1FUyuLuvWufvgt0TFeA8FI6tu0,3304
@@ -423,7 +423,8 @@ api_logic_server_cli/prototypes/base/.devcontainer-option/For_VSCode.dockerfile,
423
423
  api_logic_server_cli/prototypes/base/.devcontainer-option/devcontainer.json,sha256=tk-mGd4XdmbpKUqUeGmcPMzX3RDc6am9-de8c-rFmSo,2361
424
424
  api_logic_server_cli/prototypes/base/.devcontainer-option/readme.md,sha256=-sSneMDne1fqEoox2hXUGmoO8ewgi34y7lJwGTidSpY,104
425
425
  api_logic_server_cli/prototypes/base/.devcontainer-option/setup.sh,sha256=pOvGjZ7jgRQzFkD93mNICmcC2y66Dexrq4bCnSSVwtU,310
426
- api_logic_server_cli/prototypes/base/.github/.copilot-instructions.md,sha256=-nizGXBHLOBFbbaBF8UpsFVA_Mv2_b4bVhMrAvWvxxs,50003
426
+ api_logic_server_cli/prototypes/base/.github/.copilot-instructions.md,sha256=vKiqqf79mvrow0frrIJYxtg1-PRvpH6VjJaLWUUFn60,51519
427
+ api_logic_server_cli/prototypes/base/.github/welcome.md,sha256=eQMgc33vtKZNRYkO-CAl-c7bUMfAlbtBw2Dk2pNQWaQ,777
427
428
  api_logic_server_cli/prototypes/base/.idea/runConfigurations/ApiLogicServer.xml,sha256=eFzhe9NH-VNjcPWbPsRQy5o-MugJR9IWklA1Fo8wtYg,1127
428
429
  api_logic_server_cli/prototypes/base/.idea/runConfigurations/Report_Behave_Logic.xml,sha256=I3jlEf-TPzc-1NY843v6AcQIQ8QJD3z9KvxTYSZWMtY,1306
429
430
  api_logic_server_cli/prototypes/base/.idea/runConfigurations/Run_Behave.xml,sha256=CTzF0P4w7o4FzOi-eSpru0HczSEGtJsKqkQ7VWRyxPc,1196
@@ -533,12 +534,12 @@ api_logic_server_cli/prototypes/base/docs/training/admin_app_1_context.prompt.md
533
534
  api_logic_server_cli/prototypes/base/docs/training/admin_app_2_functionality.prompt.md,sha256=iWMoAkETeQjWWPrNj1AcI4HFGLlgS0-HP9oBYXhdTNI,1705
534
535
  api_logic_server_cli/prototypes/base/docs/training/admin_app_3_architecture.prompt.md,sha256=5KtRBihPbxTQEvLJ51w104Z0HfDGFEmQc3ysek6EsXA,925
535
536
  api_logic_server_cli/prototypes/base/docs/training/genai_logic_patterns.md,sha256=STjzKjziXvsWd7hVLn3zBQLVPJi5II25IDCI8-IMYcs,14666
536
- api_logic_server_cli/prototypes/base/docs/training/logic_bank_api.prompt,sha256=flQB6tG59M6jXAxCBpLyR8osUbe9RlX5QyoAWAvIJWA,17106
537
+ api_logic_server_cli/prototypes/base/docs/training/logic_bank_api.prompt,sha256=acTiWoigb7BiajAHskqgh22wLy9fsW7WdAwynAe5ji0,17019
537
538
  api_logic_server_cli/prototypes/base/docs/training/logic_bank_patterns.prompt,sha256=qNdA0efdlZECT6DiL8o1Iw-pPPDa1KVRrtKV84x8KJA,14850
538
539
  api_logic_server_cli/prototypes/base/docs/training/logic_example.py,sha256=yAot6uHy1gu94ufeYDx3f0iJ1_czsDywSAdm_yu4E2o,1325
539
- api_logic_server_cli/prototypes/base/docs/training/probabilistic_logic.prompt,sha256=VKYV1ruTPAsK3AN4HgbFcQmuhTszYnpcK0trfFl9NQ4,42487
540
- api_logic_server_cli/prototypes/base/docs/training/probabilistic_logic_guide.md,sha256=rUgsWeRDUhIxMVTMgHBJizl9nCKXiMjPnKJyeCw6SXU,14922
541
- api_logic_server_cli/prototypes/base/docs/training/probabilistic_template.py,sha256=W3ei_nlmfwUhQirq-L_M75BNnckyQEFwpKwNjQjtnRE,14450
540
+ api_logic_server_cli/prototypes/base/docs/training/probabilistic_logic.prompt,sha256=xu06ynvBbp-KkCEqMI5h_Gn4k95dZIDUdQfI6gjRFR8,42549
541
+ api_logic_server_cli/prototypes/base/docs/training/probabilistic_logic_guide.md,sha256=ZPV7kWjo2S6lM2M_1aesh9WtFD0ME2tyr3HUCA4OEsE,16618
542
+ api_logic_server_cli/prototypes/base/docs/training/probabilistic_template.py,sha256=V9zldqIpcs2CR2ysy6ZoVab7FqzeSkb9b60aanGt97c,14204
542
543
  api_logic_server_cli/prototypes/base/docs/training/react_map.prompt.md,sha256=8B9bDjk4sL1t5LzYLKjuf78UPDmhj9assRZTIOvlwN4,891
543
544
  api_logic_server_cli/prototypes/base/docs/training/react_tree.prompt.md,sha256=Eoi4Q3H4x-PQOjonUjQ1o6xkiFtcEA_hg8tuFP-qk80,652
544
545
  api_logic_server_cli/prototypes/base/docs/training/readme_training.md,sha256=EilDTYaDPoGCD9ef5Efs8eDn8ZNQTgGN7_QnJ4LrO2s,120
@@ -628,8 +629,7 @@ api_logic_server_cli/prototypes/base/venv_setup/venv.sh,sha256=aWX9fa8fe6aO9ifBI
628
629
  api_logic_server_cli/prototypes/basic_demo/_config.yml,sha256=KIUQQpjgj7hP_Z2Fksq90E52UnbKnyom-v9L_eIfqZo,170
629
630
  api_logic_server_cli/prototypes/basic_demo/readme.md,sha256=Ii0WojbHMHpg6bgMlg9WyadzXVZePM2Nk89kmKHuGTM,18722
630
631
  api_logic_server_cli/prototypes/basic_demo/tutor.md,sha256=nlIkqcqkVXBDe3Rktcr4puZxrrTFDl1s_Id8nA5GwA4,45516
631
- api_logic_server_cli/prototypes/basic_demo/.github/.copilot-instructions.md,sha256=g8J1YNXgr8tFe9F-g-J9SArnUHsMC7q2cacgPMVKlXY,50943
632
- api_logic_server_cli/prototypes/basic_demo/.github/welcome.md,sha256=s8Ea7BD-3DZvPSgjPT_IkHP8XRzZfMfAhHhgIZpNFgw,1645
632
+ api_logic_server_cli/prototypes/basic_demo/.github/welcome.md,sha256=c-lwKq6JDiLwMzqoRnn3bPX0GTYop9lt4mBAkfYbq6w,1553
633
633
  api_logic_server_cli/prototypes/basic_demo/_layouts/redirect.html,sha256=-0kMPGYI88fb787IzYmdi7ySZUhgpUlP0vodrg8-NRM,457
634
634
  api_logic_server_cli/prototypes/basic_demo/customizations/api/api_discovery/openapi.py,sha256=kLQ7Fn1J7tzuNJHBXF2AiwtzvQ-0JxJ6z-MfFryAtLk,3887
635
635
  api_logic_server_cli/prototypes/basic_demo/customizations/config/default.env,sha256=-rjXJrjR4vjMr9YCVYVchaJw7qMBlbvQ3KfR_wri_XM,412
@@ -816,7 +816,7 @@ api_logic_server_cli/prototypes/manager/.github/.copilot-instructions.md,sha256=
816
816
  api_logic_server_cli/prototypes/manager/.github/sync-to-dev-src.sh,sha256=hZbc5fJXnYiLWvN-OcQzYRsPBESmt6B9y581CczuwHM,1915
817
817
  api_logic_server_cli/prototypes/manager/.github/welcome.md,sha256=9Wtufrx0wRf_5jgne8K9T6Sntm2yhyR3bnFKL_ch_0M,1841
818
818
  api_logic_server_cli/prototypes/manager/.vscode/launch.json,sha256=B9NaDoTvJsXg1qeEuhG3RdRk4M2RpnpHBW6b8oXrBn4,33551
819
- api_logic_server_cli/prototypes/manager/.vscode/settings.json,sha256=Zj9oPObeI-KVh1l4b3uuF1vkezKomVqnhP241h6ZB-M,619
819
+ api_logic_server_cli/prototypes/manager/.vscode/settings.json,sha256=Ceq5Z34iC6hXNoPLahFHKAn39wjdh2VZqshkWAOXu9g,660
820
820
  api_logic_server_cli/prototypes/manager/samples/readme_samples.md,sha256=qSX2SpJnqK9PTu1quEw3GHJvQLNfCaJ-Fr3ljn6_MpE,3632
821
821
  api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/.env,sha256=VCYAc9rxtOuDpv4Og6QwVV8bhzipEGu4sf--kI4Lq5k,355
822
822
  api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/.gitignore,sha256=PAO98cVvjgAL_mvXCMS_Vfk7bT2Vd1-j9a8_nB2qxqs,190
@@ -2872,9 +2872,9 @@ api_logic_server_cli/tools/mini_skel/database/system/SAFRSBaseX.py,sha256=p8C7AF
2872
2872
  api_logic_server_cli/tools/mini_skel/database/system/TestDataBase.py,sha256=U02SYqThsbY5g3DX7XGaiMxjZBuOpzvtPS6RfI1WQFg,371
2873
2873
  api_logic_server_cli/tools/mini_skel/logic/declare_logic.py,sha256=fTrlHyqMeZsw_TyEXFa1VlYBL7fzjZab5ONSXO7aApo,175
2874
2874
  api_logic_server_cli/tools/mini_skel/logic/load_verify_rules.py,sha256=Rr5bySJpYCZmNPF2h-phcPJ53nAOPcT_ohZpCD93-a0,7530
2875
- apilogicserver-16.0.0.dist-info/licenses/LICENSE,sha256=67BS7VC-Z8GpaR3wijngQJkHWV04qJrwQArVgn9ldoI,1485
2876
- apilogicserver-16.0.0.dist-info/METADATA,sha256=D77WBWxLWETNAd7ZKYtS3dIF1Bk9I3FZy8LGo--TIKs,26461
2877
- apilogicserver-16.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
2878
- apilogicserver-16.0.0.dist-info/entry_points.txt,sha256=W9EVNvf09h8n6rJChmVj2gzxVQ6BXXZa2x3wri0lFGc,259
2879
- apilogicserver-16.0.0.dist-info/top_level.txt,sha256=-r0AT_GEApleihg-jIh0OMvzzc0BO1RuhhOpE91H5qI,21
2880
- apilogicserver-16.0.0.dist-info/RECORD,,
2875
+ apilogicserver-16.0.3.dist-info/licenses/LICENSE,sha256=67BS7VC-Z8GpaR3wijngQJkHWV04qJrwQArVgn9ldoI,1485
2876
+ apilogicserver-16.0.3.dist-info/METADATA,sha256=JqR1jCCc7xmZX7Hx598rBCfJb4cJTow6b_P7j7Rm-WM,26461
2877
+ apilogicserver-16.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
2878
+ apilogicserver-16.0.3.dist-info/entry_points.txt,sha256=W9EVNvf09h8n6rJChmVj2gzxVQ6BXXZa2x3wri0lFGc,259
2879
+ apilogicserver-16.0.3.dist-info/top_level.txt,sha256=-r0AT_GEApleihg-jIh0OMvzzc0BO1RuhhOpE91H5qI,21
2880
+ apilogicserver-16.0.3.dist-info/RECORD,,