Using structured outputs

Structured Outputs allow for providing a JSON schema for the outputs that the model has to adhere to in its responses.

First, we need to develop a schema that we want the responses to follow.

format := {'type' -> 'object'.
		'properties'
			-> {'min' -> {'type' -> 'number'} asDictionary.
					'max' -> {'type' -> 'number'} asDictionary.
					'unit' -> {'type' -> 'string'} asDictionary} asDictionary.
		'required'
			-> {'min'.
					'max'.
					'unit'}} asDictionary
  

We can then provide it to a chat and interact with it.

chat := GtLlmChat new
		provider: (GtOllamaProvider new
				model: 'llama3.1';
				format: format).

chat
	sendMessage: 'Hello Llama! What is the normal temperature range of the human body?'