Super cool use case @Bellerophon !
I would argue, that the dynamic calculation might be the best solution for your use case, rather than the mapping table.
Here’s a quick step-by-step to get started:
(step 0. Create a TypeScript Code Repository, import your two object types and tailor the code above to return two order objects. Call your function something better (e.g. matchSimilarOrdersToCustomer) and make sure you tag and release it. See the tutorials/docs for help on this, they explain it well. Also make sure that you have created your embeddings for all of the objects – use Pipeline builder for that, and let me suggest Text Embeddings 3 Small for that. Make sure not to start with too much data, as your dev work could get expensive.)
- Create your workshop application and import both object types
- Add an Object List widget and input your customer objects. This list will create a subset, that will contain the selected object. Remove object auto-selection for the next part to work. Select one customer object and proceed to the next step.
- Add a new Object Set variable, and use the function you created. As it’s input, pick the selected object variable that the list above outputs and set k=2, and if you didn’t hardcode the order-object in the function, create a new ObjectSet variable where you just import the entire Order object into, and use that as the last function input. Make sure the value is set to automatically recalculate.
- Create an overlay in Workshop. Add an Object Property widget in the top with the selected Customer object as the input, and as a proof of concept, add an object table in there and use the ObjectSet you just created from the function as it’s input. You should now see two (or what your k-value is set to) order objects in that table.
- Close the overlay, click on the Object List again, and where it says “On Object Selection” you add an event, and pick “Open [whatever you called your overlay]”.
- Now, when you click on a customer in the list, it should open the overlay, showing the customer details, and the object table below will show the two offer-objects with the nearest embeddings to the customer’s embeddings.
This is very rudimentary, but it will be a good way for you to see how things are connected in Foundry. Understanding the whole “lots of objects => drill down => find links / related objects => show to user”-workflow is helpful, as it’s a very common pattern.
With the approach above, you will always have the freshest data, and you can tell the Executives, that it literally calculates this on the fly, rather than having a set update schedule.
Embeddings for new Customer/Order-objects can be automated as part of the ingestion pipeline, requiring calculating only the embedding for that specific entry, rather than recomputing everything as would be the case with a mapping table.
Lastly, for larger comparisons (e.g. for generating email/sms-pairs of customers/orders), you can do that in a Pipeline, where the output can be used to feed an email service with customer information + the most relevant orders. That way your company only pays for the work that’s needed to generate value.
Hope this helps, and let us know if you have more questions.