mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 13:18:18 +00:00
Only show notes tool option to llm for selection when user has documents
This commit is contained in:
@@ -357,8 +357,12 @@ async def aget_data_sources_and_output_format(
|
||||
source_options_str = ""
|
||||
|
||||
agent_sources = agent.input_tools if agent else []
|
||||
user_has_entries = await EntryAdapters.auser_has_entries(user)
|
||||
|
||||
for source, description in tool_descriptions_for_llm.items():
|
||||
# Skip showing Notes tool as an option if user has no entries
|
||||
if source == ConversationCommand.Notes and not user_has_entries:
|
||||
continue
|
||||
source_options[source.value] = description
|
||||
if len(agent_sources) == 0 or source.value in agent_sources:
|
||||
source_options_str += f'- "{source.value}": "{description}"\n'
|
||||
|
||||
@@ -5,6 +5,7 @@ from typing import Callable, Dict, List, Optional
|
||||
import yaml
|
||||
from fastapi import Request
|
||||
|
||||
from khoj.database.adapters import EntryAdapters
|
||||
from khoj.database.models import Agent, KhojUser
|
||||
from khoj.processor.conversation import prompts
|
||||
from khoj.processor.conversation.utils import (
|
||||
@@ -54,7 +55,11 @@ async def apick_next_tool(
|
||||
tool_options = dict()
|
||||
tool_options_str = ""
|
||||
agent_tools = agent.input_tools if agent else []
|
||||
user_has_entries = await EntryAdapters.auser_has_entries(user)
|
||||
for tool, description in function_calling_description_for_llm.items():
|
||||
# Skip showing Notes tool as an option if user has no entries
|
||||
if tool == ConversationCommand.Notes and not user_has_entries:
|
||||
continue
|
||||
tool_options[tool.value] = description
|
||||
if len(agent_tools) == 0 or tool.value in agent_tools:
|
||||
tool_options_str += f'- "{tool.value}": "{description}"\n'
|
||||
|
||||
Reference in New Issue
Block a user