mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 05:39:12 +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 = ""
|
source_options_str = ""
|
||||||
|
|
||||||
agent_sources = agent.input_tools if agent else []
|
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():
|
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
|
source_options[source.value] = description
|
||||||
if len(agent_sources) == 0 or source.value in agent_sources:
|
if len(agent_sources) == 0 or source.value in agent_sources:
|
||||||
source_options_str += f'- "{source.value}": "{description}"\n'
|
source_options_str += f'- "{source.value}": "{description}"\n'
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from typing import Callable, Dict, List, Optional
|
|||||||
import yaml
|
import yaml
|
||||||
from fastapi import Request
|
from fastapi import Request
|
||||||
|
|
||||||
|
from khoj.database.adapters import EntryAdapters
|
||||||
from khoj.database.models import Agent, KhojUser
|
from khoj.database.models import Agent, KhojUser
|
||||||
from khoj.processor.conversation import prompts
|
from khoj.processor.conversation import prompts
|
||||||
from khoj.processor.conversation.utils import (
|
from khoj.processor.conversation.utils import (
|
||||||
@@ -54,7 +55,11 @@ async def apick_next_tool(
|
|||||||
tool_options = dict()
|
tool_options = dict()
|
||||||
tool_options_str = ""
|
tool_options_str = ""
|
||||||
agent_tools = agent.input_tools if agent else []
|
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():
|
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
|
tool_options[tool.value] = description
|
||||||
if len(agent_tools) == 0 or tool.value in agent_tools:
|
if len(agent_tools) == 0 or tool.value in agent_tools:
|
||||||
tool_options_str += f'- "{tool.value}": "{description}"\n'
|
tool_options_str += f'- "{tool.value}": "{description}"\n'
|
||||||
|
|||||||
Reference in New Issue
Block a user