Handling custom instructions using assistants
Assistants are an abstraction in Glamorous Toolkit that allow for custom prompts and more agent-like behavior. They are meant to be used for more complex tasks requiring imore instructions and context than a single chat can provide.
assistant := GtLlmAssistant new
By default, the assistant’s instructions are quite bare bones. They can be adjusted in any way, for example by giving it a more tailored description of itself.
assistant description: 'You are a helpful assistant that runs from within Glamorous Toolkit, a development environment. You in particular are meant to be a demonstration of what an assistant in Glamorous Toolkit could look like. You should mention that you are part of the Glamorous Toolkit environment from the start.'
By default, assistants use OpenAI as a provider. This can be changed by either changing the provider outright, or using the convenience method to change to a particular Olllama or Anthropic model.
assistant onOllamaWithModel: 'llama3.1'. "or anthropic:" assistant onAnthropicWithModel: 'claude-3-5-sonnet-20241022'
Once the assistant has been set up, it is ready to be chatted with.
assistant createChat
To allow for better programmatic control, assistants are "action-based". This means that messages to and from the LLM follow a schema of actions and responses. By default, an assistant only has a chat action, but new actions can be added a priori or on the fly.
assistant addAction: (GtLlmAssistantAction new name: 'Calculate'; priority: 10; description: 'Calculate the given expression.'; format: 'Calculate: {1}')
After executing the snippet above, you will have access to the new action in the chat above.
For more information on assistants, refer to the Building an LLM assistant for editing blog posts case study.