For an api foo
, the templates are:
foo/lib/request-tpl.jsonnet
andfoo/lib/document-tpl.jsonnet
.
There are also test files to check conversion.
cd foo
npm ci # once to setup the test project
npm test # run tests
Input:
secret1
: First secret, usually an API keysecret2
: Optionally second secret. In case of OpenAI API, it's an organization IDprompt
parent
: When using in a chain of templates,parent
contains the output of the previous template. Seeopenai-patch-example
how to patch the transformation.
Output:
An object, ready to use for fetch. The expected fields:
url
method
headers
body
: Type is thejson object
, notstring
The header Content-type: application/json
is often required by APIs, even if not mentioned in documentation.
There is a JSON schema for validation: ../tplfa/schemas/request.json.
Input:
response
: body payload
Output:
{
doc: [
{
type: 'markdown',
content: [
{
type: 'text',
text: ... whatever ...
}
]
}
]
}
There could be several `type: markdown' objects.
There is a JSON schema for validation: ../tplfa/schemas/document.json.
The document structure will be more rich in the future. It will be based on the ProseMirror's document model.