Skip to content

Commit 6511c7e

Browse files
authored
Merge pull request #52 from nextcloud/fix/file-urls
Fix: output file url generation
2 parents 5418c21 + e354d12 commit 6511c7e

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Positive:
3838
<screenshot>https://github.com/nextcloud/context_agent/blob/main/img/screenshot.png?raw=true</screenshot>
3939
<repository type="git">https://github.com/nextcloud/context_agent</repository>
4040
<dependencies>
41-
<nextcloud min-version="31" max-version="32"/>
41+
<nextcloud min-version="31.0.8" max-version="32"/>
4242
</dependencies>
4343
<external-app>
4444
<docker-install>

ex_app/lib/agent.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def call_model(
7272
you can find out a user's email address and location by using the find_person_in_contacts tool.
7373
you can find out the current user's location by using the find_details_of_current_user tool.
7474
If an item should be added to a list, check list_calendars for a fitting calendar and add the item as a task there.
75+
If you get a link as a tool output, always add the link to your response.
7576
""".replace("{CURRENT_DATE}", current_date)
7677
)
7778

ex_app/lib/all_tools/doc-gen.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ def generate_document(input: str, format: str) -> str:
1818
: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+
url = nc.ocs('GET', '/ocs/v2.php/apps/app_api/api/v1/info/nextcloud_url/absolute', json={'url': 'ocs/v2.php/apps/assistant/api/v1/task'})
22+
2123
match format:
2224
case "text document":
2325
tasktype = "richdocuments:text_to_text_document"
@@ -53,10 +55,10 @@ def generate_document(input: str, format: str) -> str:
5355
'text': input,
5456
}
5557
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"
58+
return f"{url}/{task.id}/output-file/{task.output['slide_deck']}/download"
5759

5860
task = run_task(nc, tasktype, task_input)
59-
return f"https://nextcloud.local/ocs/v2.php/apps/assistant/api/v1/task/{task.id}/output-file/{task.output['file']}/download"
61+
return f"{url}/{task.id}/output-file/{task.output['file']}/download"
6062

6163
return [
6264
generate_document,

ex_app/lib/all_tools/image_gen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def generate_image(input: str) -> str:
2424
'numberOfImages': 1,
2525
}
2626
task = run_task(nc, tasktype, task_input)
27-
28-
return f"https://nextcloud.local/ocs/v2.php/apps/assistant/api/v1/task/{task.id}/output-file/{task.output['images'][0]}/download"
27+
url = nc.ocs('GET', '/ocs/v2.php/apps/app_api/api/v1/info/nextcloud_url/absolute', json={'url': 'ocs/v2.php/apps/assistant/api/v1/task'})
28+
return f"{url}/{task.id}/output-file/{task.output['images'][0]}/download"
2929

3030
return [
3131
generate_image,

0 commit comments

Comments
 (0)