Skip to content

Commit c388010

Browse files
committed
update dev doc
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
1 parent 1464d61 commit c388010

File tree

1 file changed

+33
-12
lines changed

1 file changed

+33
-12
lines changed

docs/developer/web-integration.md

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ A helper function is exposed as `OCA.Assistant.openAssistantForm`. It opens the
2828

2929
It accepts one parameter which is an object that can contain those keys:
3030
* appId: [string, mandatory] app id of the app currently displayed
31-
* identifier: [string, optional, default: ''] the task identifier (if the task is scheduled, this helps to identify the task when receiving the "task finished" event in the backend)
31+
* customId: [string, optional, default: ''] the task custom ID (if the task is scheduled, this helps to identify the task when receiving the "task finished" event in the backend)
3232
* taskType: [string, optional, default: last used task type] initially selected task type. It can be a text processing task type class or `speech-to-text` or `OCP\TextToImage\Task`
33-
* input: [string, optional, default: '', DEPRECATED] initial input prompt (for task types that only require a prompt)
3433
* inputs: [object, optional, default: {}] initial inputs (specific to each task type)
3534
* isInsideViewer: [boolean, optional, default: false] should be true if this function is called while the Viewer is displayed
3635
* closeOnResult: [boolean, optional, default: false] If true, the modal will be closed after running a synchronous task and getting its result
@@ -47,15 +46,17 @@ The promise resolves with a task object which looks like:
4746
```javascript
4847
{
4948
appId: 'text',
50-
category: 1, // 0: text generation, 1: image generation, 2: speech-to-text
5149
id: 310, // the assistant task ID
52-
identifier: 'my custom identifier',
53-
inputs: { prompt: 'give me a short summary of a simple settings section about GitHub' },
50+
customId: 'my custom identifier',
51+
input: { input: 'give me a short summary of a simple settings section about GitHub' },
5452
ocpTaskId: 152, // the underlying OCP task ID
55-
output: 'blabla',
56-
status: 3, // 0: unknown, 1: scheduled, 2: running, 3: sucessful, 4: failed
57-
taskType: 'OCP\\TextProcessing\\FreePromptTaskType',
58-
timestamp: 1711545305,
53+
output: { output: 'blabla' },
54+
status: 'STATUS_SUCCESSFUL', // 0: unknown, 1: scheduled, 2: running, 3: sucessful, 4: failed
55+
type: 'core:text2text',
56+
lastUpdated: 1711545305,
57+
scheduledAt: 1711545301,
58+
startedAt: 1711545302,
59+
endedAt: 1711545303,
5960
userId: 'janedoe',
6061
}
6162
```
@@ -64,9 +65,9 @@ Complete example:
6465
``` javascript
6566
OCA.Assistant.openAssistantForm({
6667
appId: 'my_app_id',
67-
identifier: 'my custom identifier',
68-
taskType: 'OCP\\TextProcessing\\FreePromptTaskType',
69-
inputs: { prompt: 'count to 3' },
68+
customId: 'my custom identifier',
69+
taskType: 'core:text2text',
70+
inputs: { input: 'count to 3' },
7071
actionButtons: [
7172
{
7273
label: 'Label 1',
@@ -87,3 +88,23 @@ OCA.Assistant.openAssistantForm({
8788
console.debug('assistant promise failure', error)
8889
})
8990
```
91+
92+
### Populate input fields with the content of a file
93+
94+
You might want to initialize an input field with the content of a file.
95+
This is possible by passing a file path or ID like this:
96+
97+
``` javascript
98+
OCA.Assistant.openAssistantForm({
99+
appId: 'my_app_id',
100+
customId: 'my custom identifier',
101+
taskType: 'core:text2text',
102+
inputs: { input: { fileId: 123 } },
103+
})
104+
OCA.Assistant.openAssistantForm({
105+
appId: 'my_app_id',
106+
customId: 'my custom identifier',
107+
taskType: 'core:text2text',
108+
inputs: { input: { filePath: '/path/to/file.txt' } },
109+
})
110+
```

0 commit comments

Comments
 (0)