Building an LLM assistant for editing blog posts

By default, the gt4llm framework comes with a tutor for editing blog posts. To get a background on what a tutor is, refer to Handling custom instructions using tutors. For the purposes of this case study, it can be conceptualized as an AI assistant or agent with custom instructions.

blogPostText := 'This is the start of a blog post on LLM. It ain’t much, but it’s mine.' asRopedText
  
GtOpenAIBlogPostTutor new createChatOn: blogPostText
  

This tutor has been evolved from a generic tutor. We can refine a generic tutor to get to a similar result. This page demonstrates how to do that.

We start by instantiating a generic tutor with a description.

tutor := GtLlmTutor new
		description: 'You are an assistant that is used to interactively work on blog posts.'
  

We want the tutor to work on text, so we create it and give information on how to serialize and deserialize it for the tutor.

blogPostText := 'This is the start of a blog post on LLM. It ain’t much, but it’s mine.' asRopedText.

serializableText := GtLlmSerializableValueHolder new
		name: 'Post';
		content: blogPostText;
		serializer: #asString;
		updater: [ :aText :aString | 
			aText deleteAll
				appendString: aString;
				yourself ]
  

From there, we can create a chat and tell it to work with our text.

chat := tutor createChat.

chat onInstance: serializableText
  

As of now, the tutor has no specific actions, however. Let’s add a simple one now.

tutor addAction: (GtLlmTutorAction new
	    name: 'Create title';
	    priority: 10;
		description: 'Create title. Put result in the `Text` property. Do not use quotes of any kind. Be crisp.')
  

Ideally, we would add examples, but since we have none, a description of the action will need to be neough. From here, we can reify the tutor. To do so, click on the reify button on any of the messages in the chat. You will be allowed to create a tutor class as well as a message class. The latter then allows you to add custom views for your messages, such as the diff view in GtOpenAIBlogPostTutor GtLlmTutor subclass: #GtOpenAIBlogPostTutor instanceVariableNames: '' classVariableNames: '' package: 'Gt4OpenAI-Tutor' above.