diff --git a/backend/app/services/chat_service.py b/backend/app/services/chat_service.py index 3d7cf2e..3ff842e 100644 --- a/backend/app/services/chat_service.py +++ b/backend/app/services/chat_service.py @@ -219,7 +219,7 @@ TOOLS = [ "type": "function", "function": { "name": "query_database", - "description": "Execute a read-only SQL SELECT query against the database. Key columns: products(id, name, pim_id, category_key, cad_file_id, is_active), orders(id, order_number, status, tenant_id), order_lines(id, order_id, product_id, render_status, material_override, render_overrides). Use :tenant_id parameter for tenant filtering. Category is 'category_key' not 'category'.", + "description": "Execute a read-only SQL SELECT query against the database. Key tables/columns: products(id, name, pim_id, category_key, cad_file_id, is_active, tenant_id), orders(id, order_number, status, tenant_id), order_lines(id, order_id, product_id, render_status, material_override, render_overrides), cad_files(id, mesh_attributes->'dimensions_mm' with {x,y,z} in mm, parsed_objects, processing_status). To get product dimensions: JOIN cad_files cf ON cf.id = p.cad_file_id and use cf.mesh_attributes->'dimensions_mm'. Use :tenant_id parameter for tenant filtering. Category is 'category_key' not 'category'.", "parameters": { "type": "object", "properties": { @@ -327,7 +327,10 @@ async def _tool_search_products(db: AsyncSession, tenant_id: str, query: str = " sql = """ SELECT p.id, p.name, p.pim_id, p.category_key, p.baureihe, p.cad_file_id IS NOT NULL AS has_step, - cf.processing_status + cf.processing_status, + cf.mesh_attributes->'dimensions_mm'->>'x' AS dim_x_mm, + cf.mesh_attributes->'dimensions_mm'->>'y' AS dim_y_mm, + cf.mesh_attributes->'dimensions_mm'->>'z' AS dim_z_mm FROM products p LEFT JOIN cad_files cf ON cf.id = p.cad_file_id WHERE p.tenant_id = :tenant_id