mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-08 05:39:13 +00:00
Use new online/websearch logic and add agent to chat_metadata
This commit is contained in:
@@ -368,14 +368,21 @@ async def websocket_endpoint(
|
|||||||
conversation_commands.remove(ConversationCommand.Notes)
|
conversation_commands.remove(ConversationCommand.Notes)
|
||||||
|
|
||||||
if ConversationCommand.Online in conversation_commands:
|
if ConversationCommand.Online in conversation_commands:
|
||||||
|
if not online_search_enabled():
|
||||||
|
conversation_commands.remove(ConversationCommand.Online)
|
||||||
|
# If online search is not enabled, try to read webpages directly
|
||||||
|
if ConversationCommand.Webpage not in conversation_commands:
|
||||||
|
conversation_commands.append(ConversationCommand.Webpage)
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
await send_status_update("**Operation**: Searching the web for relevant information...")
|
await send_status_update("**Operation**: Searching the web for relevant information...")
|
||||||
online_results = await search_online(defiltered_query, meta_log, location)
|
online_results = await search_online(defiltered_query, meta_log, location)
|
||||||
online_searches = ", ".join([f"{query}" for query in online_results.keys()])
|
online_searches = ", ".join([f"{query}" for query in online_results.keys()])
|
||||||
await send_status_update(f"**Online searches**: {online_searches}")
|
await send_status_update(f"**Online searches**: {online_searches}")
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
|
logger.warning(f"Error searching online: {e}. Attempting to respond without online results")
|
||||||
await send_complete_llm_response(
|
await send_complete_llm_response(
|
||||||
"Please set your SERPER_DEV_API_KEY to get started with online searches 🌐"
|
f"Error searching online: {e}. Attempting to respond without online results"
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -436,6 +443,8 @@ async def websocket_endpoint(
|
|||||||
user_name,
|
user_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
chat_metadata["agent"] = conversation.agent.slug if conversation.agent else None
|
||||||
|
|
||||||
update_telemetry_state(
|
update_telemetry_state(
|
||||||
request=websocket,
|
request=websocket,
|
||||||
telemetry_type="api",
|
telemetry_type="api",
|
||||||
|
|||||||
Reference in New Issue
Block a user