Spaces:
Running
Running
WISDOM tool: choice between conversation context or custom
Browse filesUser can now choose:
- "Use my conversation" - pulls from chat history (default)
- "I'll write context" - shows textarea for custom situation/question
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- static/index.html +37 -8
static/index.html
CHANGED
|
@@ -1045,6 +1045,7 @@
|
|
| 1045 |
};
|
| 1046 |
|
| 1047 |
let selectedTradition = null;
|
|
|
|
| 1048 |
|
| 1049 |
// NVC Feelings vocabulary (from Marshall Rosenberg)
|
| 1050 |
const FEELINGS_DATA = {
|
|
@@ -1243,9 +1244,10 @@ Real grief, real limits. 1-2 sentences.`
|
|
| 1243 |
|
| 1244 |
function showWisdomSelection() {
|
| 1245 |
selectedTradition = null;
|
|
|
|
| 1246 |
const content = document.getElementById('tool-content');
|
| 1247 |
|
| 1248 |
-
let html = '<p style="margin-bottom:
|
| 1249 |
html += '<div class="selection-grid">';
|
| 1250 |
|
| 1251 |
for (const [tradition, desc] of Object.entries(WISDOM_TRADITIONS)) {
|
|
@@ -1254,11 +1256,27 @@ Real grief, real limits. 1-2 sentences.`
|
|
| 1254 |
|
| 1255 |
html += '</div>';
|
| 1256 |
html += '<div class="selected-items" id="tradition-summary" style="display: none;"><h4>Selected tradition:</h4><p id="tradition-selected"></p></div>';
|
| 1257 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1258 |
|
| 1259 |
content.innerHTML = html;
|
| 1260 |
}
|
| 1261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1262 |
function selectTradition(tradition) {
|
| 1263 |
// Clear previous selection
|
| 1264 |
document.querySelectorAll('#tool-content .selection-btn').forEach(btn => btn.classList.remove('selected'));
|
|
@@ -1537,10 +1555,21 @@ Draw wisdom from NVC, attachment theory, and relational psychology - but embed i
|
|
| 1537 |
|
| 1538 |
// Handle WISDOM tool submission
|
| 1539 |
if (activeTool === 'wisdom' && selectedTradition) {
|
| 1540 |
-
|
| 1541 |
|
| 1542 |
-
|
| 1543 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1544 |
|
| 1545 |
addToolLoading();
|
| 1546 |
const isVerbose = document.getElementById('toggle-verbose')?.checked || false;
|
|
@@ -1554,12 +1583,12 @@ Draw wisdom from NVC, attachment theory, and relational psychology - but embed i
|
|
| 1554 |
user_draft: userInput || '',
|
| 1555 |
user_input: `The user draws wisdom from: ${selectedTradition}.
|
| 1556 |
|
| 1557 |
-
|
| 1558 |
-
${
|
| 1559 |
|
| 1560 |
${userInput ? 'User adds: ' + userInput : ''}
|
| 1561 |
|
| 1562 |
-
Based on the themes
|
| 1563 |
verbose: isVerbose
|
| 1564 |
})
|
| 1565 |
});
|
|
|
|
| 1045 |
};
|
| 1046 |
|
| 1047 |
let selectedTradition = null;
|
| 1048 |
+
let wisdomSource = 'conversation'; // 'conversation' or 'custom'
|
| 1049 |
|
| 1050 |
// NVC Feelings vocabulary (from Marshall Rosenberg)
|
| 1051 |
const FEELINGS_DATA = {
|
|
|
|
| 1244 |
|
| 1245 |
function showWisdomSelection() {
|
| 1246 |
selectedTradition = null;
|
| 1247 |
+
wisdomSource = 'conversation';
|
| 1248 |
const content = document.getElementById('tool-content');
|
| 1249 |
|
| 1250 |
+
let html = '<p style="margin-bottom: 12px; color: var(--text-secondary);">Choose a wisdom tradition:</p>';
|
| 1251 |
html += '<div class="selection-grid">';
|
| 1252 |
|
| 1253 |
for (const [tradition, desc] of Object.entries(WISDOM_TRADITIONS)) {
|
|
|
|
| 1256 |
|
| 1257 |
html += '</div>';
|
| 1258 |
html += '<div class="selected-items" id="tradition-summary" style="display: none;"><h4>Selected tradition:</h4><p id="tradition-selected"></p></div>';
|
| 1259 |
+
|
| 1260 |
+
html += '<p style="margin-top: 20px; margin-bottom: 12px; color: var(--text-secondary);">What should the wisdom speak to?</p>';
|
| 1261 |
+
html += '<div class="selection-grid">';
|
| 1262 |
+
html += `<button class="selection-btn selected" onclick="setWisdomSource('conversation')" id="wisdom-src-conv">Use my conversation</button>`;
|
| 1263 |
+
html += `<button class="selection-btn" onclick="setWisdomSource('custom')" id="wisdom-src-custom">I'll write context</button>`;
|
| 1264 |
+
html += '</div>';
|
| 1265 |
+
|
| 1266 |
+
html += '<div id="wisdom-custom-input" style="display: none; margin-top: 12px;">';
|
| 1267 |
+
html += '<textarea id="wisdom-context" rows="3" placeholder="What situation or question do you want wisdom for?" style="width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text-primary); font-size: 0.9rem; resize: none;"></textarea>';
|
| 1268 |
+
html += '</div>';
|
| 1269 |
|
| 1270 |
content.innerHTML = html;
|
| 1271 |
}
|
| 1272 |
|
| 1273 |
+
function setWisdomSource(source) {
|
| 1274 |
+
wisdomSource = source;
|
| 1275 |
+
document.getElementById('wisdom-src-conv').classList.toggle('selected', source === 'conversation');
|
| 1276 |
+
document.getElementById('wisdom-src-custom').classList.toggle('selected', source === 'custom');
|
| 1277 |
+
document.getElementById('wisdom-custom-input').style.display = source === 'custom' ? 'block' : 'none';
|
| 1278 |
+
}
|
| 1279 |
+
|
| 1280 |
function selectTradition(tradition) {
|
| 1281 |
// Clear previous selection
|
| 1282 |
document.querySelectorAll('#tool-content .selection-btn').forEach(btn => btn.classList.remove('selected'));
|
|
|
|
| 1555 |
|
| 1556 |
// Handle WISDOM tool submission
|
| 1557 |
if (activeTool === 'wisdom' && selectedTradition) {
|
| 1558 |
+
let contextText = '';
|
| 1559 |
|
| 1560 |
+
if (wisdomSource === 'custom') {
|
| 1561 |
+
const customContext = document.getElementById('wisdom-context')?.value?.trim();
|
| 1562 |
+
if (!customContext) {
|
| 1563 |
+
addToolMsg('tool', 'Please write some context for the wisdom to speak to.', 'Note');
|
| 1564 |
+
return;
|
| 1565 |
+
}
|
| 1566 |
+
contextText = customContext;
|
| 1567 |
+
addToolMsg('user', `Drawing from ${selectedTradition} for: "${contextText}"`);
|
| 1568 |
+
} else {
|
| 1569 |
+
const convContext = conversationHistory.map(m => `${m.role === 'user' ? 'User' : 'Partner'}: ${m.content}`).join('\n');
|
| 1570 |
+
contextText = convContext || 'A difficult conversation about connection and understanding.';
|
| 1571 |
+
addToolMsg('user', `Drawing from: ${selectedTradition} (using conversation)`);
|
| 1572 |
+
}
|
| 1573 |
|
| 1574 |
addToolLoading();
|
| 1575 |
const isVerbose = document.getElementById('toggle-verbose')?.checked || false;
|
|
|
|
| 1583 |
user_draft: userInput || '',
|
| 1584 |
user_input: `The user draws wisdom from: ${selectedTradition}.
|
| 1585 |
|
| 1586 |
+
Context:
|
| 1587 |
+
${contextText}
|
| 1588 |
|
| 1589 |
${userInput ? 'User adds: ' + userInput : ''}
|
| 1590 |
|
| 1591 |
+
Based on the themes here (conflict, connection, fear, love, boundaries, etc.), provide ONE relevant quote from ${selectedTradition} that speaks to this situation.`,
|
| 1592 |
verbose: isVerbose
|
| 1593 |
})
|
| 1594 |
});
|