Add system message to LLM requests and improve indicator type resolution
- Introduced a system message in LlmController to clarify that tools are optional for LLM responses, enhancing user guidance. - Refactored indicator type resolution in IndicatorTools to support fuzzy matching and provide suggestions for invalid types, improving user experience and error handling. - Updated methods to utilize the new resolution logic, ensuring consistent handling of indicator types across the application.
This commit is contained in:
@@ -57,6 +57,23 @@ public class LlmController : BaseController
|
||||
var availableTools = await _mcpService.GetAvailableToolsAsync();
|
||||
request.Tools = availableTools.ToList();
|
||||
|
||||
// Add system message to clarify that tools are optional and the LLM can respond directly
|
||||
// Check if a system message already exists
|
||||
var hasSystemMessage = request.Messages.Any(m => m.Role == "system");
|
||||
if (!hasSystemMessage)
|
||||
{
|
||||
var systemMessage = new LlmMessage
|
||||
{
|
||||
Role = "system",
|
||||
Content = "You are a helpful AI assistant with expertise in quantitative finance, algorithmic trading, and financial mathematics. " +
|
||||
"You can answer questions directly using your knowledge. " +
|
||||
"Tools are available for specific operations (backtesting, agent management, market data retrieval, etc.) but are optional. " +
|
||||
"Use tools only when they are needed for the specific task. " +
|
||||
"For general questions, explanations, calculations, or discussions, respond directly without using tools."
|
||||
};
|
||||
request.Messages.Insert(0, systemMessage);
|
||||
}
|
||||
|
||||
// Send chat request to LLM
|
||||
var response = await _llmService.ChatAsync(user, request);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user