LLM tools by example
A tool can be used by an LLM chat to execute logic. For example, the below chat looks up the definition of a class using GtLToolForClassLookup
.
messageWithToolCallExample
<gtExample>
<noTest>
| chat |
chat := self currentChat.
chat tools: (GtLTools withAll: {GtLToolForClassLookup new}).
chat markdownResponse.
chat sendMarkdown: 'Use tools and give me a description of the class BlElement'.
self waitForChatRunIsDoneThen: [
self assert: self currentChat messages size equals: 2 ].
^ chat
A tool's implementation has a name, takes arguments and returns an instance of GtLDomainObject
. This instance knows how to serialize itself. For OpenAI it serializes by implementing GtLDomainObject>>#serializeToOpenAIResponseJsonObject
.
Each tool has corresponding examples that test its logic in isolation. For example, GtLToolForClassLookup
has examples in GtLToolForClassLookupExamples
.