Skip to content

Commit f60f5f5

Browse files
committed
docuement AIApp json mode
1 parent e2a6307 commit f60f5f5

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

dashjoin-docs/docs/developer-reference.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,44 @@ Invocation parameter
726726
* array: array of messages containing role and content. Note that if the last content contains #full, the entire RAG corpus will be added to the request. This is called Cache-Augmented Generation (CAG) and is suitable for smaller document sets that fit in the LLM context.
727727
If the content contains #query, the text behind the query marker is used as a RAG query. Consider the following example: can you explain the difference between RAG and CAG #query RAG CAG. In this case the documents would be search using the term "RAG CAG" rather than the entire question. This can be used to optimize RAG retrieval accuracy.
728728

729+
If you would like to invoke the LLM using JSON mode, you can pass the target JSON Schema as follows:
730+
731+
732+
```
733+
$parseJson(
734+
$call('aia', {
735+
'response_format': {
736+
'properties': {
737+
'res': {
738+
'type': 'array'
739+
}
740+
}
741+
},
742+
'messages': [
743+
{
744+
'role':'user',
745+
'content': 'list of European capitals with a population of at least 3 million'
746+
}
747+
]
748+
}).choices.message.content
749+
)
750+
```
751+
752+
This returns the following JSON structure:
753+
754+
```
755+
{
756+
"res": [
757+
"Berlin",
758+
"Madrid",
759+
"Rome",
760+
...
761+
```
762+
763+
Note that the top level schema must contain "properties" and the returned value is always an object.
764+
The AIApp function makes sure the schema is compatible with the LLM requirements.
765+
For instance, if "type" is omitted, it is assumed to be "string".
766+
729767
#### RestJson
730768

731769
Calls an external REST service. If you need more control over the how the call is performed, please use the JSONata function curl.

0 commit comments

Comments
 (0)