Improve data source, output mode selection

- Set output mode to single string. Specify output schema in prompt
  - Both thesee should encourage model to select only 1 output mode
    instead of encouraging it in prompt too many times
  - Output schema should also improve schema following in general
- Standardize variable, func name of io selector for readability
- Fix chat actors to test the io selector chat actor
- Make chat actor return sources, output separately for better
  disambiguation, at least during tests, for now
This commit is contained in:
Debanjum
2024-11-18 12:49:48 -08:00
parent e3fd51d14b
commit 653127bf1d
6 changed files with 104 additions and 88 deletions

View File

@@ -7,7 +7,7 @@ from freezegun import freeze_time
from khoj.database.models import Agent, Entry, KhojUser
from khoj.processor.conversation import prompts
from khoj.processor.conversation.utils import message_to_log
from khoj.routers.helpers import aget_relevant_tools_to_execute
from khoj.routers.helpers import aget_data_sources_and_output_format
from tests.helpers import ConversationFactory
SKIP_TESTS = True
@@ -735,7 +735,7 @@ async def test_get_correct_tools_online(client_offline_chat):
user_query = "What's the weather in Patagonia this week?"
# Act
tools = await aget_relevant_tools_to_execute(user_query, {}, is_task=False)
tools = await aget_data_sources_and_output_format(user_query, {}, is_task=False)
# Assert
tools = [tool.value for tool in tools]
@@ -750,7 +750,7 @@ async def test_get_correct_tools_notes(client_offline_chat):
user_query = "Where did I go for my first battleship training?"
# Act
tools = await aget_relevant_tools_to_execute(user_query, {}, is_task=False)
tools = await aget_data_sources_and_output_format(user_query, {}, is_task=False)
# Assert
tools = [tool.value for tool in tools]
@@ -765,7 +765,7 @@ async def test_get_correct_tools_online_or_general_and_notes(client_offline_chat
user_query = "What's the highest point in Patagonia and have I been there?"
# Act
tools = await aget_relevant_tools_to_execute(user_query, {}, is_task=False)
tools = await aget_data_sources_and_output_format(user_query, {}, is_task=False)
# Assert
tools = [tool.value for tool in tools]
@@ -782,7 +782,7 @@ async def test_get_correct_tools_general(client_offline_chat):
user_query = "How many noble gases are there?"
# Act
tools = await aget_relevant_tools_to_execute(user_query, {}, is_task=False)
tools = await aget_data_sources_and_output_format(user_query, {}, is_task=False)
# Assert
tools = [tool.value for tool in tools]
@@ -806,7 +806,7 @@ async def test_get_correct_tools_with_chat_history(client_offline_chat, default_
chat_history = create_conversation(chat_log, default_user2)
# Act
tools = await aget_relevant_tools_to_execute(user_query, chat_history, is_task=False)
tools = await aget_data_sources_and_output_format(user_query, chat_history, is_task=False)
# Assert
tools = [tool.value for tool in tools]