From 759e8084fca1a6f5564f8981c2daff161eefe499 Mon Sep 17 00:00:00 2001 From: Jana Peper Date: Wed, 21 May 2025 14:08:43 +0200 Subject: [PATCH 1/3] feat: add slides gen tool Signed-off-by: Jana Peper --- ex_app/lib/all_tools/doc-gen.py | 18 ++++++++++++++++-- ex_app/lib/all_tools/lib/task_processing.py | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ex_app/lib/all_tools/doc-gen.py b/ex_app/lib/all_tools/doc-gen.py index 0bc6ba1..3fd2e82 100644 --- a/ex_app/lib/all_tools/doc-gen.py +++ b/ex_app/lib/all_tools/doc-gen.py @@ -15,10 +15,24 @@ def generate_document(input: str, format: str) -> str: """ Generate a document with the input string as description :param text: the instructions for the document - :param format: the format of the generated file, available are "text_document" and "spreadsheet_document" + :param format: the format of the generated file, available are "text document", "word document", "pdf" "spreadsheet" and "slides" :return: a download link to the generated document """ - tasktype = "richdocuments:text_to_" + format + match format: + case "text document": + tasktype = "richdocuments:text_to_text_document" + + case "spreadsheet": + tasktype = "richdocuments:text_to_spreadsheet_document" + + case "slides": + tasktype = "richdocuments:slide_deck_generation" + task_input = { + 'text': input, + } + task = run_task(nc, tasktype, task_input) + return f"https://nextcloud.local/ocs/v2.php/apps/assistant/api/v1/task/{task.id}/output-file/{task.output['slide_deck']}/download" + task_input = { 'text': input, } diff --git a/ex_app/lib/all_tools/lib/task_processing.py b/ex_app/lib/all_tools/lib/task_processing.py index 613a539..770eef6 100644 --- a/ex_app/lib/all_tools/lib/task_processing.py +++ b/ex_app/lib/all_tools/lib/task_processing.py @@ -61,7 +61,7 @@ def run_task(nc, type, task_input): if task.status != "STATUS_SUCCESSFUL": raise Exception("Nextcloud TaskProcessing Task failed") - if not isinstance(task.output, dict) or all(x not in ["file", "output", "images"] for x in task.output): + if not isinstance(task.output, dict) or all(x not in ["file", "output", "images", "slide_deck"] for x in task.output): raise Exception('"output" key not found in Nextcloud TaskProcessing task result') return task \ No newline at end of file From 731fbde8f82df8a49dac4294fe4038d0b3b2da86 Mon Sep 17 00:00:00 2001 From: Jana Peper Date: Wed, 21 May 2025 14:46:06 +0200 Subject: [PATCH 2/3] feat: add pdf and ods files gen Signed-off-by: Jana Peper --- ex_app/lib/all_tools/doc-gen.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/ex_app/lib/all_tools/doc-gen.py b/ex_app/lib/all_tools/doc-gen.py index 3fd2e82..6462195 100644 --- a/ex_app/lib/all_tools/doc-gen.py +++ b/ex_app/lib/all_tools/doc-gen.py @@ -13,17 +13,39 @@ def get_tools(nc: Nextcloud): @safe_tool def generate_document(input: str, format: str) -> str: """ - Generate a document with the input string as description + Generate a document with the input string as description. :param text: the instructions for the document - :param format: the format of the generated file, available are "text document", "word document", "pdf" "spreadsheet" and "slides" + :param format: the format of the generated file, available are "text document", "pdf", "spreadsheet", "excel spreadsheet" and "slides" :return: a download link to the generated document """ match format: case "text document": tasktype = "richdocuments:text_to_text_document" + task_input = { + 'text': input, + 'target_format': 'docx' + } + + case "pdf": + tasktype = "richdocuments:text_to_text_document" + task_input = { + 'text': input, + 'target_format': 'pdf' + } case "spreadsheet": tasktype = "richdocuments:text_to_spreadsheet_document" + task_input = { + 'text': input, + 'target_format': 'ods' + } + + case "excel spreadsheet": + tasktype = "richdocuments:text_to_spreadsheet_document" + task_input = { + 'text': input, + 'target_format': 'xlsx' + } case "slides": tasktype = "richdocuments:slide_deck_generation" @@ -33,9 +55,6 @@ def generate_document(input: str, format: str) -> str: task = run_task(nc, tasktype, task_input) return f"https://nextcloud.local/ocs/v2.php/apps/assistant/api/v1/task/{task.id}/output-file/{task.output['slide_deck']}/download" - task_input = { - 'text': input, - } task = run_task(nc, tasktype, task_input) return f"https://nextcloud.local/ocs/v2.php/apps/assistant/api/v1/task/{task.id}/output-file/{task.output['file']}/download" From 31f20f1803c3a2e0f015508bb5778c4a9ca4efe7 Mon Sep 17 00:00:00 2001 From: janepie <49834966+janepie@users.noreply.github.com> Date: Mon, 2 Jun 2025 14:30:33 +0200 Subject: [PATCH 3/3] Update param description Co-authored-by: Julien Veyssier Signed-off-by: janepie <49834966+janepie@users.noreply.github.com> --- ex_app/lib/all_tools/doc-gen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ex_app/lib/all_tools/doc-gen.py b/ex_app/lib/all_tools/doc-gen.py index 6462195..4106f1d 100644 --- a/ex_app/lib/all_tools/doc-gen.py +++ b/ex_app/lib/all_tools/doc-gen.py @@ -15,7 +15,7 @@ def generate_document(input: str, format: str) -> str: """ Generate a document with the input string as description. :param text: the instructions for the document - :param format: the format of the generated file, available are "text document", "pdf", "spreadsheet", "excel spreadsheet" and "slides" + :param format: the format of the generated file, allowed values are "text document", "pdf", "spreadsheet", "excel spreadsheet" and "slides" :return: a download link to the generated document """ match format: