mathrok
Version:
AI-powered symbolic mathematics library combining traditional Computer Algebra System (CAS) capabilities with natural language processing for math problem solving
90 lines • 2.74 kB
TypeScript
/**
* Context Manager for Natural Language Processing
* Handles conversation context, variable tracking, and multi-turn interactions
*/
export interface ConversationContext {
variables: Record<string, any>;
previousResults: any[];
currentTopic: string;
difficulty: 'beginner' | 'intermediate' | 'advanced';
preferences: UserPreferences;
history: QueryHistory[];
}
export interface UserPreferences {
explanationStyle: 'concise' | 'detailed' | 'step-by-step';
mathematicalNotation: 'standard' | 'latex' | 'plain';
showSteps: boolean;
showAlternatives: boolean;
educationalMode: boolean;
}
export interface QueryHistory {
query: string;
result: any;
timestamp: number;
operation: string;
confidence: number;
}
export interface ContextualHint {
type: 'next_step' | 'alternative_method' | 'common_mistake' | 'concept_explanation';
content: string;
confidence: number;
relevance: number;
}
/**
* Context Manager for maintaining conversation state and providing contextual assistance
*/
export declare class ContextManager {
private context;
private readonly maxHistorySize;
constructor(initialPreferences?: Partial<UserPreferences>);
/**
* Update context with new query and result
*/
updateContext(query: string, result: any, operation: string, confidence: number): void;
/**
* Get contextual information for query processing
*/
getContextualInfo(): {
variables: Record<string, any>;
recentOperations: string[];
currentTopic: string;
suggestedVariables: string[];
};
/**
* Generate contextual hints based on current state
*/
generateContextualHints(currentQuery: string, currentOperation: string): ContextualHint[];
/**
* Check if query references previous results
*/
resolveReferences(query: string): string;
/**
* Get learning progression suggestions
*/
getLearningProgression(currentOperation: string): {
prerequisites: string[];
nextTopics: string[];
practiceProblems: string[];
};
/**
* Update user preferences
*/
updatePreferences(preferences: Partial<UserPreferences>): void;
/**
* Get current context state
*/
getContext(): ConversationContext;
/**
* Reset context (new conversation)
*/
resetContext(): void;
private updateVariables;
private updateCurrentTopic;
private getSuggestedVariables;
private generateNextStepHint;
private generateAlternativeMethodHint;
private generateCommonMistakeHint;
private generateConceptExplanationHint;
private getLastResultString;
}
//# sourceMappingURL=context.d.ts.map