Skip to content

Commit bb0828b

Browse files
committed
Only show notes tool option to llm for selection when user has documents
1 parent 5dfb59e commit bb0828b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/khoj/routers/helpers.py

+4
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,12 @@ async def aget_data_sources_and_output_format(
357357
source_options_str = ""
358358

359359
agent_sources = agent.input_tools if agent else []
360+
user_has_entries = await EntryAdapters.auser_has_entries(user)
360361

361362
for source, description in tool_descriptions_for_llm.items():
363+
# Skip showing Notes tool as an option if user has no entries
364+
if source == ConversationCommand.Notes and not user_has_entries:
365+
continue
362366
source_options[source.value] = description
363367
if len(agent_sources) == 0 or source.value in agent_sources:
364368
source_options_str += f'- "{source.value}": "{description}"\n'

src/khoj/routers/research.py

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import yaml
66
from fastapi import Request
77

8+
from khoj.database.adapters import EntryAdapters
89
from khoj.database.models import Agent, KhojUser
910
from khoj.processor.conversation import prompts
1011
from khoj.processor.conversation.utils import (
@@ -54,7 +55,11 @@ async def apick_next_tool(
5455
tool_options = dict()
5556
tool_options_str = ""
5657
agent_tools = agent.input_tools if agent else []
58+
user_has_entries = await EntryAdapters.auser_has_entries(user)
5759
for tool, description in function_calling_description_for_llm.items():
60+
# Skip showing Notes tool as an option if user has no entries
61+
if tool == ConversationCommand.Notes and not user_has_entries:
62+
continue
5863
tool_options[tool.value] = description
5964
if len(agent_tools) == 0 or tool.value in agent_tools:
6065
tool_options_str += f'- "{tool.value}": "{description}"\n'

0 commit comments

Comments
 (0)