Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions ex_app/lib/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@
def load_conversation(checkpointer, conversation_token: str):
if conversation_token == '' or conversation_token == '{}':
return
print(checkpointer.storage)
checkpointer.storage = checkpointer.serde.loads(verify_signature(conversation_token, key).encode())
print(checkpointer.storage)

def export_conversation(checkpointer):
return add_signature(checkpointer.serde.dumps(checkpointer.storage).decode('utf-8'), key)
Expand Down
22 changes: 20 additions & 2 deletions ex_app/lib/all_tools/ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def ask_context_chat(question: str) -> str:
'scopeList': [],
'scopeListMeta': '',
}
task_output = run_task(nc, "context_chat:context_chat", task_input)
task_output = run_task(nc, "context_chat:context_chat", task_input).output
return task_output['output']

@tool
Expand All @@ -39,10 +39,28 @@ def transcribe_file(file_url: str) -> str:
task_input = {
'input': get_file_id_from_file_url(file_url),
}
task_output = run_task(nc, "core:audio2text", task_input)
task_output = run_task(nc, "core:audio2text", task_input).output
return task_output['output']


@tool
@safe_tool
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"
:return: a download link to the generated document
"""
tasktype = "richdocuments:text_to_" + format
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"

return [
ask_context_chat,
transcribe_file,
generate_document,
]
5 changes: 2 additions & 3 deletions ex_app/lib/all_tools/lib/task_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ def run_task(nc, type, task_input):
log(nc, LogLvl.DEBUG, task)
except ValidationError as e:
raise Exception("Failed to parse Nextcloud TaskProcessing task result") from e

if task.status != "STATUS_SUCCESSFUL":
raise Exception("Nextcloud TaskProcessing Task failed")

if not isinstance(task.output, dict) or "output" not in task.output:
if not isinstance(task.output, dict) or ("file" not in task.output and "output" not in task.output):
raise Exception('"output" key not found in Nextcloud TaskProcessing task result')

return task.output
return task
2 changes: 1 addition & 1 deletion ex_app/lib/all_tools/talk.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def send_message_to_conversation(conversation_name: str, message: str):
def list_messages_in_conversation(conversation_name: str, n_messages: int = 30):
"""
List messages of a conversation in talk
:param conversation_name: The name of the conversation to list messages of
:param conversation_name: The name of the conversation to list messages of (can only be one conversation per Tool call, obtainable via list_talk_conversations)
:param n_messages: The number of messages to receive
:return:
"""
Expand Down
2 changes: 2 additions & 0 deletions ex_app/lib/memorysaver.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-FileCopyrightText: 2024 LangChain, Inc.
# SPDX-License-Identifier: MIT
Copy link
Member

@marcelklehr marcelklehr Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can turn it into AGPL-3.0-or-later if we want, MIT License doesn't prevent that. Might be nicer to have a uniform license for everything. Choice is yours :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have MIT license in there for GH actions, so I think it's fine for now.

import logging
import os
import pickle
Expand Down