Moldable Chat: Generating code
How do we get a chat to generate code? We provide tools and a bit of guidance in the form of explanations.
Say, you want to build a bubble sorter that you can try quickly. Ask for examples and see what happens:
c := GtL gt
gtPageExplanation: 'Inspector phlow views by example';
sendMarkdown: 'Create a {{gtClass:BubbleSorter}} class implementing bubblesort. Create at least two examples for it in a separate class. Ensure that the examples are green.'
This will likely work as a first shot. Go change something in the algorithm, like changing the sign of the swap comparison in the algorithm, and then ask it to fix the examples (investigate the executed tools to see what the LLM does):
c sendMarkdown: 'Check the examples about {{gtClass:BubbleSorter}}. If they are red, make them green'
Or ask it to transform the algorithm to retain explainable steps:
c sendMarkdown: 'Add an explicit object for each comparison step. The {{gtClass:BubbleSorterStep}} should remember the two items to compare, whether there was a swap and the state of the collection before the comparison. Add a view to exemplify the step. Add a view to exemplify the overall algorithm'
The chat above uses the default tools defined in GtLTools>>#gt
. In addition it also has a couple of explanation pages that we rely on for typical development. You can obtain the same setup in GtL>>#gt
. Try it here with your prompt:
GtL gt sendMarkdown: ''