Skip to main content
Glama
pattern-learner.js1.44 kB
/** * Manages the learning of interaction patterns. * * @author Cline */ const { log } = require('../utils/logger'); class PatternLearner { constructor(preferenceStore) { this.preferenceStore = preferenceStore; } /** * Learns from an interaction and stores successful patterns. * @param {string} originalPrompt - The user's original message. * @param {string} enhancedPrompt - The prompt after enhancement. * @param {string} result - The result from the Gemini API. * @param {string} contextKey - The detected context key. * @param {string|null} toolName - The name of the tool that executed the interaction. */ async learnFromInteraction(originalPrompt, enhancedPrompt, result, contextKey, toolName = null) { log(`Learning from interaction: context=${contextKey}, tool=${toolName || 'N/A'}`, 'pattern-learner'); const pattern = { original: originalPrompt, enhanced: enhancedPrompt, context: contextKey, tool: toolName, // Store the tool name timestamp: new Date().toISOString(), success: true, // In future, we could analyze result to determine success }; this.preferenceStore.addPattern(contextKey, pattern); // The preferenceStore.addPattern now handles saving internally, no need to call savePreferences explicitly log(`Stored interaction pattern for context: ${contextKey}`, 'pattern-learner'); } } module.exports = PatternLearner;

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Garblesnarff/gemini-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server