@@ -13,15 +13,48 @@ def get_tools(nc: Nextcloud):
1313 @safe_tool
1414 def generate_document (input : str , format : str ) -> str :
1515 """
16- Generate a document with the input string as description
16+ Generate a document with the input string as description.
1717 :param text: the instructions for the document
18- :param format: the format of the generated file, available are "text_document" and "spreadsheet_document "
18+ :param format: the format of the generated file, allowed values are "text document", "pdf", "spreadsheet", "excel spreadsheet" and "slides "
1919 :return: a download link to the generated document
2020 """
21- tasktype = "richdocuments:text_to_" + format
22- task_input = {
23- 'text' : input ,
24- }
21+ match format :
22+ case "text document" :
23+ tasktype = "richdocuments:text_to_text_document"
24+ task_input = {
25+ 'text' : input ,
26+ 'target_format' : 'docx'
27+ }
28+
29+ case "pdf" :
30+ tasktype = "richdocuments:text_to_text_document"
31+ task_input = {
32+ 'text' : input ,
33+ 'target_format' : 'pdf'
34+ }
35+
36+ case "spreadsheet" :
37+ tasktype = "richdocuments:text_to_spreadsheet_document"
38+ task_input = {
39+ 'text' : input ,
40+ 'target_format' : 'ods'
41+ }
42+
43+ case "excel spreadsheet" :
44+ tasktype = "richdocuments:text_to_spreadsheet_document"
45+ task_input = {
46+ 'text' : input ,
47+ 'target_format' : 'xlsx'
48+ }
49+
50+ case "slides" :
51+ tasktype = "richdocuments:slide_deck_generation"
52+ task_input = {
53+ 'text' : input ,
54+ }
55+ task = run_task (nc , tasktype , task_input )
56+ return f"https://nextcloud.local/ocs/v2.php/apps/assistant/api/v1/task/{ task .id } /output-file/{ task .output ['slide_deck' ]} /download"
57+
2558 task = run_task (nc , tasktype , task_input )
2659 return f"https://nextcloud.local/ocs/v2.php/apps/assistant/api/v1/task/{ task .id } /output-file/{ task .output ['file' ]} /download"
2760
0 commit comments