You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: dashjoin-docs/docs/developer-reference.md
+41-6Lines changed: 41 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -194,13 +194,47 @@ The key specifies the action button's label, the value contains the expression t
194
194
195
195
#### aichat
196
196
197
-
Chatbot widget for interacting with large language models.
197
+
Chatbot widget for interacting with large language models. This widget displays chat contents which are represented
198
+
by an array of messages. The messages contain a role (system, user, assistant) and a content. The content is usually
199
+
a string, but may also contain images and documents (see the OpenAI documentation).
198
200
199
-
* url: LLM Service URL or function name
200
-
* name: Chatbot name
201
-
* tagline: Chatbot tagline
202
-
* logo: Logo URL
203
-
* system_prompt: AI system prompt
201
+
The widget displays the chat and calls expressions when
202
+
203
+
* a new question is asked
204
+
* a file is uploaded
205
+
* a file is deleted
206
+
207
+
The expressions must handle the event, perform any kind of desired DB updates and return data to the widget.
208
+
209
+
* expression: an expression to compute the initial state of the widget:
210
+
211
+
```
212
+
{
213
+
"messages": [{role, content}], // the chat messages
214
+
"query": string // contents of the text field
215
+
"files": {name: {value: dataURL, metadata: any}} // files associated with the chat (e.g. for RAG)
216
+
"queryFiles": // like files, represents files that will be sent with the next message (e.g. a pic to be sent to OCR)
217
+
"tools": [string] // names of Invoke functions to be used as tools
218
+
"toolsSelectable": boolean // like the widget setting, allows the setting to be dynamic
219
+
"uploadEnabled": boolean // like the widget setting, allows the setting to be dynamic
220
+
}
221
+
```
222
+
223
+
* onChat: called when the send button (or CTRL Enter) is pressed. Sends the state as a parameter. Expects the new value for messages. Usually, this is the user's query and the LLM answer appended to messages
224
+
* onUpload: called when the user uploads a file. The 'upload' parameter contains {name (the file name), value (the file encoded as a data URL)}. The expression must return a structure {type, metadata}. Type 'files' describes whether the file is associated with the entire chat (e.g. for RAG) or 'queryFiles' is to be sent with the next message. Metadata can be any data the expression computes for the file. An example might be document IDs returned from a RAG vector DB.
225
+
* onDelete: called when the user deletes a file. The 'delete' parameter contains {name, value, metadata, type (files or queryFiles)}
226
+
* toolsSelectable: allow user to (de)select tools
227
+
* uploadEnabled: allow user to upload files
228
+
229
+
The following example shows a minimal configuration with the "always answer yes" AI.
"expression": "{'messages': [{'role': 'system', 'content': 'the system prompt of the say yes AI'}]}",
236
+
}
237
+
```
204
238
205
239
#### analytics
206
240
@@ -1024,6 +1058,7 @@ streamXml | $streamXml(url, jsonPointer) | Parses XML at the url, converts it to
1024
1058
streamCsv | $streamCsv(url, options) | Parses CSV at the url and splits it at the record boundaries. By default, CSV is parsed as RFC4180. Options can be provided, where the key is a "with" method like withDelimiter and the value is the argument. Please see the [documentation](https://commons.apache.org/proper/commons-csv/apidocs/org/apache/commons/csv/CSVFormat.html) for more details.
1025
1059
streamDb | $streamDb(database, table) | Streams records from the database table specified
1026
1060
curl | $curl(method, url, data?, headers?) | Full fledged HTTP client. Use header {"Authorization": credential} to reference a credential set defined in functions. Use header {"dj-timeout-seconds": ...} to define a HTTP timeout other than the default of 10s. Use header {"dj-encoding": ...} to encode in UTF_8 (default), BASE_64, ISO_8859_1. Use header {"dj-produces": "text/plain"} to return plain text rather than JSON. Use header {"Content-Type": "multipart/form-data"} to upload files encoded in data URLs in the data object (see Input widget)
1061
+
chat | $chat(url, query, messages, tools?, options?, headers?) | Encapsulates API calls to LLMs running at url. Query is the next user message. messages is an array of role / content containing the previous chat interactions. Tools is an array of strings referencing Invoke functions in the function catalog that should be used as tools during the LLM call. Options contains additional LLM parameters like "model": "gpt-4o-mini", etc. Finally, headers works like with the curl function.
1027
1062
openJson | $openJson(url) | Parses JSON at the url
1028
1063
openCsv | $openCsv(url, options) | Parses CSV at the url and converts it to JSON. By default, CSV is parsed as RFC4180. Options can be provided, where the key is a "with" method like withDelimiter and the value is the argument. Please see the [documentation](https://commons.apache.org/proper/commons-csv/apidocs/org/apache/commons/csv/CSVFormat.html) for more details.
1029
1064
openXml | $openXml(url, arrays) | Parses XML at the url and converts it to JSON. In this process, openXml guesses which XML tags need to be converted to arrays and which become simple fields. This process might produce inconsistent results when the XML tree contains lists with single entries. To avoid this, you can optionally pass a list of tag names that must be arrays.
0 commit comments