Moldable Chat: Guiding chats through explanations
Let's ask the LLM for help with a less well-documented part of Glamorous Toolkit: rewrite rules. In this case, we ask it for a rewrite rule that removes self halt statements from the code.
c := GtLChat new markdownResponse; sendMarkdown: 'Provide the rewrite rule for removing all `self halt` statements from methods.'
The response looks confident, but it is typically wrong. We can nudge the LLM by providing relevant explanations in the system instructions:
c := GtLChat new markdownResponse; gtPageExplanation: 'Rewriting Pharo code by example'; sendMarkdown: 'Provide the rewrite rule for removing all `self halt` statements from methods.'
This should produce a better result. If we combine that explanation with an expected response format that knows about rewrite rules, we can quickly explore queries and code transformations:
c := GtLChat new markdownResponse; gtPageExplanation: 'Rewriting Pharo code by example'; addResponseFormatForMagrite: GtLRewriteRule named: 'RewriteRule'; sendMarkdown: 'Provide the rewrite rule for removing all `self halt` statements from methods.'