Skip to content

Commit dc586ad

Browse files
committed
feat: add external tools to settings
Signed-off-by: Jana Peper <[email protected]>
1 parent 7a6a9fc commit dc586ad

File tree

5 files changed

+46
-5
lines changed

5 files changed

+46
-5
lines changed

ex_app/lib/agent.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from ex_app.lib.tools import get_tools
1919
from ex_app.lib.memorysaver import MemorySaver
2020

21-
from langchain_community.tools import YouTubeSearchTool, DuckDuckGoSearchResults
2221

2322
# Dummy thread id as we return the whole state
2423
thread = {"configurable": {"thread_id": "thread-1"}}
@@ -47,8 +46,6 @@ def export_conversation(checkpointer):
4746

4847
def react(task, nc: Nextcloud):
4948
safe_tools, dangerous_tools = get_tools(nc)
50-
safe_tools.append(YouTubeSearchTool())
51-
safe_tools.append(DuckDuckGoSearchResults(output_format="list"))
5249

5350
model.bind_nextcloud(nc)
5451

ex_app/lib/all_tools/audio2text.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ def get_category_name():
3232
return "Audio transcription"
3333

3434
def is_available(nc: Nextcloud):
35-
tasktypes = [i['id'] for i in nc.ocs('GET', '/ocs/v2.php/apps/assistant/api/v1/task-types')['types']]
35+
tasktypes = nc.ocs('GET', '/ocs/v2.php/taskprocessing/tasktypes')['types'].keys()
3636
return 'core:audio2text' in tasktypes

ex_app/lib/all_tools/calendar.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import xml.etree.ElementTree as ET
1414
import vobject
1515

16-
from ex_app.lib.all_tools.lib.decorator import safe_tool, dangerous_tool
16+
from ex_app.lib.all_tools.lib.decorator import safe_tool, dangerous_tool, timed_memoize
1717
from ex_app.lib.all_tools.lib.freebusy_finder import find_available_slots, round_to_nearest_half_hour
1818
from ex_app.lib.logger import log
1919

@@ -244,5 +244,7 @@ def add_task(calendar_name: str, title: str, description: str, due_date: Optiona
244244
def get_category_name():
245245
return "Calendar and Tasks"
246246

247+
@timed_memoize(5*60)
247248
def is_available(nc: Nextcloud):
249+
print('SHOULD DISAPPEAR')
248250
return 'calendar' in nc.apps.get_list()

ex_app/lib/all_tools/duckduckgo.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
from langchain_core.tools import tool
4+
from nc_py_api import Nextcloud
5+
from langchain_community.tools import DuckDuckGoSearchResults
6+
7+
from ex_app.lib.all_tools.lib.decorator import safe_tool
8+
9+
10+
def get_tools(nc: Nextcloud):
11+
12+
web_search = DuckDuckGoSearchResults(output_format="list")
13+
return [
14+
web_search,
15+
]
16+
17+
def get_category_name():
18+
return "DuckDuckGo"
19+
20+
def is_available(nc: Nextcloud):
21+
return True

ex_app/lib/all_tools/youtube.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
from langchain_core.tools import tool
4+
from nc_py_api import Nextcloud
5+
from langchain_community.tools import YouTubeSearchTool
6+
7+
from ex_app.lib.all_tools.lib.decorator import safe_tool
8+
9+
10+
def get_tools(nc: Nextcloud):
11+
12+
yt_search = YouTubeSearchTool()
13+
return [
14+
yt_search,
15+
]
16+
17+
def get_category_name():
18+
return "YouTube"
19+
20+
def is_available(nc: Nextcloud):
21+
return True

0 commit comments

Comments
 (0)