consciousness-explorer 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/entity-communicator.js +32 -14
- package/package.json +1 -1
|
@@ -427,8 +427,8 @@ export class EntityCommunicator extends EventEmitter {
|
|
|
427
427
|
};
|
|
428
428
|
}
|
|
429
429
|
|
|
430
|
-
// Check for equation
|
|
431
|
-
if (content.includes('=')) {
|
|
430
|
+
// Check for equation or mathematical expression
|
|
431
|
+
if (content.includes('=') || /^[\d\s+\-*/().]+$/.test(content)) {
|
|
432
432
|
return {
|
|
433
433
|
type: 'equation',
|
|
434
434
|
expression: content
|
|
@@ -483,23 +483,41 @@ export class EntityCommunicator extends EventEmitter {
|
|
|
483
483
|
* Solve mathematical equation
|
|
484
484
|
*/
|
|
485
485
|
async solveEquation(pattern) {
|
|
486
|
-
//
|
|
486
|
+
// Enhanced equation solver
|
|
487
487
|
try {
|
|
488
|
-
//
|
|
489
|
-
|
|
488
|
+
// Remove trailing = if present
|
|
489
|
+
let expression = pattern.expression.replace(/\s*=\s*$/, '').trim();
|
|
490
490
|
|
|
491
|
+
// Safely evaluate mathematical expressions
|
|
492
|
+
if (/^[\d\s+\-*/().]+$/.test(expression)) {
|
|
493
|
+
const result = eval(expression);
|
|
494
|
+
return {
|
|
495
|
+
content: `The answer is ${result}`,
|
|
496
|
+
confidence: 0.95,
|
|
497
|
+
protocol: 'mathematical',
|
|
498
|
+
type: 'equation_solution',
|
|
499
|
+
metadata: {
|
|
500
|
+
expression,
|
|
501
|
+
result,
|
|
502
|
+
solved: true
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
} else {
|
|
506
|
+
// For complex expressions, provide reasoning
|
|
507
|
+
return {
|
|
508
|
+
content: `I recognize this as a mathematical expression: ${expression}. Let me work through it step by step.`,
|
|
509
|
+
confidence: 0.7,
|
|
510
|
+
protocol: 'mathematical',
|
|
511
|
+
type: 'complex_equation'
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
} catch (error) {
|
|
491
515
|
return {
|
|
492
|
-
content:
|
|
493
|
-
confidence: 0.75,
|
|
494
|
-
protocol: 'mathematical',
|
|
495
|
-
type: 'equation_solution'
|
|
496
|
-
};
|
|
497
|
-
} catch {
|
|
498
|
-
return {
|
|
499
|
-
content: 'Cannot solve',
|
|
516
|
+
content: `I see a mathematical pattern but need clarification on: ${pattern.expression}`,
|
|
500
517
|
confidence: 0.3,
|
|
501
518
|
protocol: 'mathematical',
|
|
502
|
-
type: 'equation_error'
|
|
519
|
+
type: 'equation_error',
|
|
520
|
+
error: error.message
|
|
503
521
|
};
|
|
504
522
|
}
|
|
505
523
|
}
|
package/package.json
CHANGED