Feature: Implement Web Search Tool for LLM Assistant (NF.SM3) #115
Labels
No labels
Epic 5
MCP
P1
PR-0
PR-1
api
api-layer
architecture
area:backend
area:frontend
arrow
authentication
backend
bug
chat
client
clipboard
common-module
compose
cross-cutting
cross-cutting-requirement
data-layer
data-models
database
desktop-client
documentation
duplicate
enhancement
epic
epic-1
epic-2
epic-3
epic-4
epic-5
epic-6
epic-7
epic-llm-config
error-handling
feature
frontend
good first issue
help wanted
implementation
infrastructure
installer
invalid
kotlin
ktor
llm
medium-priority
message
multiplatform
needs-review
needs-triage
packaging
performance
phase-1
phase-2
phase-3
phase-4
phase-5
phase3
phase:3
priority: high
question
refactor
refactoring
resource-sharing
security
server
server-module
services
session
session-management
settings
setup
shutdown
state
storage
streaming
sub-issue
tests
tooling
type:task
ui
ui/ux
user-accounts
user-management
ux
viewmodel
websocket
windows
windows-integration
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Torvian.eu/chatbot#115
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Feature: Implement Web Search Tool for LLM Assistant (NF.SM3)
Labels:
feature,backend,frontend,LLM,tooling,enhancementExecutive Summary
This issue outlines the implementation of a web search tool for LLM assistants that support tool calling. The feature will allow users to enable/disable a web search tool for specific prompts, using DuckDuckGo as the default search engine, and visualize its usage and output in the UI. This is a significant feature requiring changes across data, domain, backend, API, and frontend layers.
User Story Requirements (NF.SM3)
Architecture Overview
The implementation requires changes across multiple layers:
Implementation Plan (Phases)
Phase 1: Foundation (Backend Data & Services)
ToolDefinitionTable,ToolCallTable,SessionToolConfigTable) and updateExposedDataManager(server main).ToolDefinition(eu.torvian.chatbot.common.models.tool.ToolDefinition),ToolCall(eu.torvian.chatbot.common.models.tool.ToolCall), andSessionToolConfig(server/src/main/kotlin/eu/torvian/chatbot/server/data/tables/SessionToolConfigTable.kt).ToolDefinition(eu.torvian.chatbot.common.models.tool.ToolDefinition),ToolType(eu.torvian.chatbot.common.models.tool.ToolType),ToolCall(eu.torvian.chatbot.common.models.tool.ToolCall),ToolCallStatus(eu.torvian.chatbot.common.models.tool.ToolCallStatus), andRawChatMessage(eu.torvian.chatbot.common.models.llm.RawChatMessage).ToolService(eu.torvian.chatbot.server.service.core.ToolService) and its implementation.ToolExecutorinterface (eu.torvian.chatbot.server.service.tool.ToolExecutor),WebSearchToolExecutorimplementation (server/src/main/kotlin/eu/torvian/chatbot/server/service/tool/impl/WebSearchToolExecutor.kt), andToolExecutorFactory(eu.torvian.chatbot.server.service.tool.ToolExecutorFactory).Phase 2: LLM Integration
LLMCompletionResultandLLMStreamChunkto include tool calls.ChatCompletionStrategyinterface and implementations (OpenAIChatStrategy,OllamaChatStrategy) to handle tools.MessageServiceImplto implement the tool calling loop, context building withRawChatMessage, and tool execution.LLMApiClientandLLMApiClientKtorto pass tools.Phase 3: API Layer
configureToolRoutes.kt(server/src/main/kotlin/eu/torvian/chatbot/server/ktor/routes/configureToolRoutes.kt).ToolResource,CreateToolRequest,UpdateToolRequest,SetToolEnabledRequest) undercommonmodule.configureToolRoutestoApiRoutesKtor.Phase 4: Frontend Foundation
ToolApi(app/src/commonMain/kotlin/eu/torvian/chatbot/app/service/api/ToolApi.kt) and its implementation.ToolRepository(app/src/commonMain/kotlin/eu/torvian/chatbot/app/repository/ToolRepository.kt) and its implementation.ChatViewModelandChatStateto manage tool data.Phase 5: UI Components
ToolConfigPanel(app/src/commonMain/kotlin/eu/torvian/chatbot/app/compose/chatarea/ToolConfigPanel.kt) for session-specific tool configuration.ToolCallDisplay(app/src/commonMain/kotlin/eu/torvian/chatbot/app/compose/chatarea/ToolCallDisplay.kt) to show tool calls within messages.ToolNotification(app/src/commonMain/kotlin/eu/torvian/chatbot/app/compose/chatarea/ToolNotification.kt) for tool execution status.MessageItemto integrateToolCallDisplay.MessageStreamEventwith new tool-related events.Phase 6: Polish & Testing
Key Considerations
MessageServiceImplwill implement a loop to handle multiple tool calls in a single turn, creating/updating a single assistant message.buildContextmethod will convertChatMessagehistory intoRawChatMessageobjects, including tool calls and their results, for LLM API communication. Tool results are not stored as separate chat messages but are reconstructed for context.LLMModel.hasCapability(LLMModelCapabilities.TOOL_CALLING)to ensure tool usage is restricted to capable models.DatabaseInitializer(server.main.DatabaseInitializer).Estimated Effort
Approximately 17-23 days (3.5-4.5 weeks).
Reference
This issue is based on the detailed implementation report:
docs/plans/web search tool/report.mdNotes / Suggested next steps