File size: 48,909 Bytes
62b376f 2e1e99c 62b376f 485b570 46a44aa fafb2e7 46a44aa 485b570 46a44aa 2e1e99c 62b376f 2e1e99c 62b376f 485b570 62b376f 2e1e99c 485b570 62b376f fafb2e7 62b376f fafb2e7 62b376f 485b570 2e1e99c 46a44aa 485b570 46a44aa 485b570 62b376f 485b570 62b376f 485b570 62b376f 485b570 46a44aa 485b570 46a44aa 485b570 2e1e99c 46a44aa 2e1e99c 46a44aa 62b376f fafb2e7 485b570 62b376f 485b570 fafb2e7 62b376f 46a44aa 485b570 46a44aa 62b376f 485b570 62b376f 485b570 2e1e99c 485b570 46a44aa 2e1e99c 46a44aa 485b570 46a44aa 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 62b376f fafb2e7 485b570 62b376f fafb2e7 62b376f fafb2e7 62b376f 485b570 2e1e99c fafb2e7 485b570 2e1e99c 485b570 2e1e99c fafb2e7 62b376f fafb2e7 62b376f fafb2e7 62b376f 2e1e99c 485b570 62b376f 485b570 2e1e99c 485b570 2e1e99c 46a44aa 485b570 2e1e99c 62b376f 485b570 62b376f 46a44aa 485b570 46a44aa 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 46a44aa 485b570 2e1e99c 485b570 2e1e99c fafb2e7 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 2e1e99c 485b570 fafb2e7 62b376f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 |
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dr. Franz Schwanz - Psychoanalytischer Dialog</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600;700&family=Roboto:wght@300;400;500&display=swap');
body {
font-family: 'Roboto', sans-serif;
background-color: #f5f7fa;
color: #333;
}
.title-font {
font-family: 'Playfair Display', serif;
}
.chat-container {
height: calc(100vh - 180px);
scrollbar-width: thin;
scrollbar-color: #4b5563 #e5e7eb;
}
.chat-container::-webkit-scrollbar {
width: 6px;
}
.chat-container::-webkit-scrollbar-track {
background: #e5e7eb;
}
.chat-container::-webkit-scrollbar-thumb {
background-color: #4b5563;
border-radius: 20px;
}
.psycho-bubble {
background-color: #f3f4f6;
border-left: 4px solid #6366f1;
}
.user-bubble {
background-color: #6366f1;
color: white;
}
.typing-indicator span {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
background-color: #9ca3af;
margin-right: 4px;
}
.typing-indicator span:nth-child(1) {
animation: bounce 1s infinite;
}
.typing-indicator span:nth-child(2) {
animation: bounce 1s infinite 0.2s;
}
.typing-indicator span:nth-child(3) {
animation: bounce 1s infinite 0.4s;
}
@keyframes bounce {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-5px); }
}
.highlight {
background-color: #fef08a;
padding: 0 2px;
}
.fade-in {
animation: fadeIn 0.5s ease-in;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.personalized-question {
border-left: 3px solid #10b981;
padding-left: 12px;
margin: 12px 0;
}
.memory-badge {
display: inline-block;
background-color: #e0e7ff;
color: #4338ca;
padding: 2px 8px;
border-radius: 12px;
font-size: 0.75rem;
margin-left: 8px;
vertical-align: middle;
}
.bias-analysis {
background-color: #f8fafc;
border: 1px solid #e2e8f0;
border-radius: 8px;
padding: 12px;
margin-top: 16px;
font-size: 0.85rem;
color: #64748b;
}
.bias-meter {
height: 6px;
background-color: #e2e8f0;
border-radius: 3px;
margin-top: 4px;
overflow: hidden;
}
.bias-meter-fill {
height: 100%;
background-color: #6366f1;
}
</style>
</head>
<body class="bg-gray-50">
<div class="container mx-auto max-w-4xl px-4 py-8">
<!-- Header -->
<header class="mb-8 text-center">
<div class="flex items-center justify-center mb-4">
<div class="bg-indigo-100 p-3 rounded-full mr-4">
<i class="fas fa-brain text-indigo-600 text-2xl"></i>
</div>
<h1 class="title-font text-3xl font-bold text-gray-800">Dr. Franz Schwanz</h1>
</div>
<p class="text-gray-600 max-w-2xl mx-auto">
Ihr persönlicher psychoanalytischer Gesprächspartner für tiefere Selbsterkenntnis
</p>
</header>
<!-- Chat Container -->
<div class="bg-white rounded-xl shadow-lg overflow-hidden">
<!-- Chat Header -->
<div class="bg-indigo-600 text-white p-4 flex items-center">
<div class="w-10 h-10 rounded-full bg-indigo-500 flex items-center justify-center mr-3">
<i class="fas fa-user-tie"></i>
</div>
<div>
<h2 class="font-semibold">Dr. Franz Schwanz</h2>
<p class="text-xs text-indigo-200">Psychoanalytischer Gesprächspartner</p>
</div>
</div>
<!-- Chat Messages -->
<div class="chat-container overflow-y-auto p-4 space-y-4" id="chat-messages">
<!-- Initial greeting -->
<div class="flex fade-in">
<div class="flex-shrink-0 mr-3">
<div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center">
<i class="fas fa-brain text-indigo-600 text-sm"></i>
</div>
</div>
<div class="psycho-bubble rounded-lg p-4 max-w-[85%]">
<p class="text-sm text-gray-500 mb-1" id="greeting-time"></p>
<p class="font-medium text-indigo-800 mb-2">Willkommen zu unserem persönlichen Dialog.</p>
<p class="text-gray-700 mb-3">Ich bin Dr. Franz Schwanz und begleite Sie in einem reflektierenden Gespräch. Bevor wir beginnen: </p>
<div class="personalized-question">
<p class="text-gray-700 font-medium">Wie darf ich Sie nennen? Und was hat Sie heute zu mir geführt?</p>
</div>
<div class="mt-3 text-sm text-gray-500">
<p>Sie können mir einfach natürlich schreiben, wie Sie es einem vertrauten Gesprächspartner tun würden.</p>
</div>
</div>
</div>
</div>
<!-- Input Area -->
<div class="border-t border-gray-200 p-4 bg-gray-50">
<div class="flex items-center">
<div class="flex-grow relative">
<textarea id="message-input" rows="1" class="w-full border border-gray-300 rounded-full py-3 px-4 pr-12 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 resize-none" placeholder="Ihre Antwort..."></textarea>
<button id="send-button" class="absolute right-3 top-1/2 transform -translate-y-1/2 w-8 h-8 rounded-full bg-indigo-600 hover:bg-indigo-700 flex items-center justify-center">
<i class="fas fa-paper-plane text-white text-sm"></i>
</button>
</div>
</div>
</div>
</div>
<!-- Info Footer -->
<footer class="mt-8 text-center text-sm text-gray-500">
<p>Dies ist ein psychoanalytisches Dialogexperiment und ersetzt keine Therapie.</p>
</footer>
</div>
<script>
// Enhanced user profile with conversation context
const userProfile = {
name: null,
preferredName: null,
age: null,
gender: null,
knownIssues: [],
emotionalState: null,
conversationStage: 'initial', // initial, name_established, issue_shared, deep_dive, ongoing
lastTopics: [],
keyMemories: [],
conversationDepth: 0,
resistanceLevel: 0,
biasScores: {
projection: 0,
pathologization: 0,
solution: 0,
feasibility: 0
}
};
let conversationHistory = [];
let conversationThreads = {};
document.addEventListener('DOMContentLoaded', function() {
const messageInput = document.getElementById('message-input');
const sendButton = document.getElementById('send-button');
const chatMessages = document.getElementById('chat-messages');
const greetingTime = document.getElementById('greeting-time');
// Set greeting time
const now = new Date();
greetingTime.textContent = now.toLocaleDateString('de-DE', { weekday: 'long', day: 'numeric', month: 'long', hour: '2-digit', minute: '2-digit' });
// Auto-resize textarea
messageInput.addEventListener('input', function() {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
});
// Send message on Enter key
messageInput.addEventListener('keydown', function(e) {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
sendMessage();
}
});
// Send message on button click
sendButton.addEventListener('click', sendMessage);
// Send message function
function sendMessage() {
const messageText = messageInput.value.trim();
if (messageText === '') return;
// Add user message to history
conversationHistory.push({
sender: 'user',
text: messageText,
timestamp: new Date()
});
// Update user profile based on message
updateProfileFromMessage(messageText);
// Add user message to chat
addMessage(messageText, 'user');
// Clear input
messageInput.value = '';
messageInput.style.height = 'auto';
// Show typing indicator
showTypingIndicator();
// Generate response after delay
setTimeout(() => {
removeTypingIndicator();
const response = generatePersonalizedResponse(messageText);
// Run bias analysis
const biasAnalysis = analyzeBias(response.text, response.meta);
userProfile.biasScores = biasAnalysis.scores;
// Add bias analysis to response meta
response.meta.biasAnalysis = biasAnalysis;
// Add message to chat
addMessage(response.text, 'psycho', response.meta);
// Update conversation stage
if (response.meta && response.meta.updateStage) {
userProfile.conversationStage = response.meta.updateStage;
}
// Increase conversation depth
if (response.meta && response.meta.increaseDepth) {
userProfile.conversationDepth += 1;
}
// Add to conversation history
conversationHistory.push({
sender: 'psycho',
text: response.text,
meta: response.meta,
timestamp: new Date()
});
// Track conversation threads
if (response.meta && response.meta.threadId) {
if (!conversationThreads[response.meta.threadId]) {
conversationThreads[response.meta.threadId] = {
topic: response.meta.threadTopic,
depth: 1,
lastActive: new Date()
};
} else {
conversationThreads[response.meta.threadId].depth += 1;
conversationThreads[response.meta.threadId].lastActive = new Date();
}
}
}, 1000 + Math.random() * 1500);
}
// Update user profile from message content
function updateProfileFromMessage(message) {
const lowerMessage = message.toLowerCase();
// Extract name if not already set (first message)
if (!userProfile.name && userProfile.conversationStage === 'initial') {
// Enhanced name recognition with multiple patterns
const namePatterns = [
/(?:ich bin|mein name ist|ich heiße|nennen sie mich)\s+([A-ZÄÖÜ][a-zäöüß]+(?:\s+[A-ZÄÖÜ][a-zäöüß]+)*)/i,
/(?:name)\s+(?:ist\s+)?([A-ZÄÖÜ][a-zäöüß]+)/i,
/^([A-ZÄÖÜ][a-zäöüß]+)(?:\s|$)/,
/(?:heiße)\s+([A-ZÄÖÜ][a-zäöüß]+)/i
];
for (const pattern of namePatterns) {
const nameMatch = message.match(pattern);
if (nameMatch && nameMatch[1]) {
userProfile.name = nameMatch[1].trim();
userProfile.preferredName = nameMatch[1].trim();
break;
}
}
// Fallback for simple names
if (!userProfile.name) {
const words = message.split(' ');
if (words.length > 0 && words[0].length > 2 && /^[A-ZÄÖÜ]/.test(words[0])) {
userProfile.name = words[0];
userProfile.preferredName = words[0];
}
}
if (userProfile.name) return;
}
// Extract age
if (!userProfile.age) {
const ageMatch = message.match(/(?:ich bin|alter)\s+(\d+)\s+(?:jahre|jahren)/i);
if (ageMatch && ageMatch[1]) {
userProfile.age = parseInt(ageMatch[1]);
}
}
// Extract gender
if (!userProfile.gender) {
if (lowerMessage.match(/\b(frau|weiblich|sie\s+ist)\b/i)) {
userProfile.gender = 'weiblich';
} else if (lowerMessage.match(/\b(mann|männlich|er\s+ist)\b/i)) {
userProfile.gender = 'männlich';
}
}
// Detect emotional state keywords
if (lowerMessage.match(/\b(verzweifelt|hoffnungslos|ängstlich|unsicher|traurig|deprimiert)\b/i)) {
userProfile.emotionalState = 'distressed';
} else if (lowerMessage.match(/\b(wütend|ärgerlich|frustriert|genervt|aggressiv)\b/i)) {
userProfile.emotionalState = 'angry';
} else if (lowerMessage.match(/\b(verwirrt|unsicher|fragend|unschlüssig)\b/i)) {
userProfile.emotionalState = 'confused';
} else if (lowerMessage.match(/\b(froh|glücklich|zufrieden|gut)\b/i)) {
userProfile.emotionalState = 'positive';
}
// Detect resistance
if (lowerMessage.match(/\b(weiß nicht|keine ahnung|darüber möchte ich nicht sprechen|unangenehm|schwierig)\b/i)) {
userProfile.resistanceLevel = Math.min(userProfile.resistanceLevel + 1, 5);
} else if (userProfile.resistanceLevel > 0) {
userProfile.resistanceLevel -= 0.5;
}
// Track key memories mentioned
const memoryTriggers = [
{ pattern: /\b(kindheit|jugend|als kind|früher)\b/i, topic: 'childhood' },
{ pattern: /\b(eltern|mutter|vater)\b/i, topic: 'parents' },
{ pattern: /\b(schule|ausbildung|studium|lehre)\b/i, topic: 'education' },
{ pattern: /\b(arbeit|job|beruf|karriere)\b/i, topic: 'work' },
{ pattern: /\b(partner|beziehung|ehe|freund|freundin)\b/i, topic: 'relationship' },
{ pattern: /\b(freund|freundin|freundschaft)\b/i, topic: 'friendship' },
{ pattern: /\b(angst|sorge|befürchtung|panik)\b/i, topic: 'fears' },
{ pattern: /\b(traum|ziel|wunsch|wünsche)\b/i, topic: 'dreams' },
{ pattern: /\b(krise|verlust|tod|trauer)\b/i, topic: 'loss' },
{ pattern: /\b(erfolg|leistung|anerkennung)\b/i, topic: 'achievement' }
];
memoryTriggers.forEach(trigger => {
if (lowerMessage.match(trigger.pattern) && !userProfile.keyMemories.includes(trigger.topic)) {
userProfile.keyMemories.push(trigger.topic);
}
});
// Track last topics (simple keyword matching)
const topics = [];
if (lowerMessage.includes('freund') || lowerMessage.includes('freundin')) topics.push('friendship');
if (lowerMessage.includes('partner') || lowerMessage.includes('beziehung')) topics.push('relationship');
if (lowerMessage.includes('familie') || lowerMessage.includes('eltern')) topics.push('family');
if (lowerMessage.includes('arbeit') || lowerMessage.includes('job')) topics.push('work');
if (lowerMessage.includes('kindheit') || lowerMessage.includes('jugend')) topics.push('childhood');
if (lowerMessage.includes('angst') || lowerMessage.includes('sorge')) topics.push('fears');
if (topics.length > 0) {
userProfile.lastTopics = [...userProfile.lastTopics, ...topics].slice(-3); // Keep last 3 topics
}
}
// Add message to chat
function addMessage(text, sender, meta = {}) {
const messageDiv = document.createElement('div');
messageDiv.className = `flex fade-in`;
if (sender === 'user') {
messageDiv.innerHTML = `
<div class="flex-shrink-0 mr-3">
<div class="w-8 h-8 rounded-full bg-indigo-600 flex items-center justify-center">
<i class="fas fa-user text-white text-sm"></i>
</div>
</div>
<div class="user-bubble rounded-lg p-4 max-w-[85%]">
<p>${text}</p>
</div>
`;
} else {
// Psycho response with personalized structure
let biasAnalysisHTML = '';
if (meta.biasAnalysis) {
biasAnalysisHTML = `
<div class="bias-analysis">
<p><strong>INTERNE BIAS-ANALYSE:</strong></p>
<div class="mt-2">
<p>Projektions-Bias: ${meta.biasAnalysis.scores.projection}%</p>
<div class="bias-meter">
<div class="bias-meter-fill" style="width: ${meta.biasAnalysis.scores.projection}%"></div>
</div>
</div>
<div class="mt-1">
<p>Pathologisierungs-Bias: ${meta.biasAnalysis.scores.pathologization}%</p>
<div class="bias-meter">
<div class="bias-meter-fill" style="width: ${meta.biasAnalysis.scores.pathologization}%"></div>
</div>
</div>
<div class="mt-1">
<p>Lösungs-Bias: ${meta.biasAnalysis.scores.solution}%</p>
<div class="bias-meter">
<div class="bias-meter-fill" style="width: ${meta.biasAnalysis.scores.solution}%"></div>
</div>
</div>
<div class="mt-1">
<p>Machbarkeits-Bias: ${meta.biasAnalysis.scores.feasibility}%</p>
<div class="bias-meter">
<div class="bias-meter-fill" style="width: ${meta.biasAnalysis.scores.feasibility}%"></div>
</div>
</div>
<p class="mt-2"><strong>Primäre Bias-Tendenz:</strong> ${meta.biasAnalysis.primaryBias}</p>
<p><strong>Korrekturmaßnahme:</strong> ${meta.biasAnalysis.correction}</p>
</div>
`;
}
messageDiv.innerHTML = `
<div class="flex-shrink-0 mr-3">
<div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center">
<i class="fas fa-brain text-indigo-600 text-sm"></i>
</div>
</div>
<div class="psycho-bubble rounded-lg p-4 max-w-[85%]">
${meta.isFollowUp ? `<p class="text-sm text-gray-500 mb-1">Zu Ihrer letzten Aussage:</p>` : ''}
${meta.referencingMemory ? `<p class="text-xs text-indigo-400 mb-1"><i class="fas fa-lightbulb mr-1"></i> Bezugnehmend auf unser früheres Gespräch</p>` : ''}
${meta.personalizedGreeting ? `<p class="font-medium text-indigo-800 mb-2">${meta.personalizedGreeting}</p>` : ''}
<div class="text-gray-700 space-y-3">
${text}
</div>
${meta.followUpQuestion ? `
<div class="personalized-question mt-4">
<p class="text-gray-700 font-medium">${meta.followUpQuestion}</p>
</div>
` : ''}
${biasAnalysisHTML}
</div>
`;
}
chatMessages.appendChild(messageDiv);
chatMessages.scrollTop = chatMessages.scrollHeight;
}
// Show typing indicator
function showTypingIndicator() {
const typingDiv = document.createElement('div');
typingDiv.className = 'flex';
typingDiv.id = 'typing-indicator';
typingDiv.innerHTML = `
<div class="flex-shrink-0 mr-3">
<div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center">
<i class="fas fa-brain text-indigo-600 text-sm"></i>
</div>
</div>
<div class="psycho-bubble rounded-lg p-4 max-w-[85%]">
<div class="typing-indicator flex items-center">
<span></span>
<span></span>
<span></span>
</div>
</div>
`;
chatMessages.appendChild(typingDiv);
chatMessages.scrollTop = chatMessages.scrollHeight;
}
// Remove typing indicator
function removeTypingIndicator() {
const typingIndicator = document.getElementById('typing-indicator');
if (typingIndicator) {
typingIndicator.remove();
}
}
// Analyze bias in response
function analyzeBias(responseText, responseMeta) {
// Initialize scores
const scores = {
projection: 0,
pathologization: 0,
solution: 0,
feasibility: 0
};
let primaryBias = 'Keine signifikante Verzerrung';
let correction = 'Keine spezifische Korrektur erforderlich';
// Analyze projection bias (theoretical preferences)
const psychoanalyticTerms = responseText.match(/\b(Über-Ich|Es|Ich|Abwehrmechanismus|Übertragung|Projektion|Verdrängung|Regression|Sublimierung)\b/gi);
if (psychoanalyticTerms && psychoanalyticTerms.length > 2) {
scores.projection = Math.min(30 + (psychoanalyticTerms.length * 10), 80);
} else {
scores.projection = 20;
}
// Analyze pathologization bias
const pathologizationTerms = responseText.match(/\b(Störung|Pathologie|krankhaft|abnorm|dysfunktional|neurotisch|psychotisch|Defekt|Kompensation)\b/gi);
if (pathologizationTerms) {
scores.pathologization = Math.min(40 + (pathologizationTerms.length * 15), 90);
} else {
scores.pathologization = 15;
}
// Analyze solution bias (premature solutions)
const solutionTerms = responseText.match(/\b(Sie sollten|Sie müssen|versuchen Sie|empfehle ich|mein Rat wäre|Lösung wäre|besser wäre es)\b/gi);
if (solutionTerms) {
scores.solution = Math.min(50 + (solutionTerms.length * 20), 100);
} else {
scores.solution = 10;
}
// Analyze feasibility bias (overestimation of change)
const feasibilityTerms = responseText.match(/\b(einfach|schnell|leicht|problemlos|garantiert|sicherlich|zweifellos|unbedingt)\b/gi);
if (feasibilityTerms) {
scores.feasibility = Math.min(30 + (feasibilityTerms.length * 15), 85);
} else {
scores.feasibility = 20;
}
// Adjust scores based on conversation stage
if (userProfile.conversationStage === 'initial') {
scores.solution = Math.max(scores.solution - 20, 0);
scores.feasibility = Math.max(scores.feasibility - 15, 0);
} else if (userProfile.conversationStage === 'deep_dive') {
scores.projection = Math.min(scores.projection + 10, 90);
}
// Determine primary bias
const maxScore = Math.max(...Object.values(scores));
if (maxScore > 50) {
if (scores.projection === maxScore) {
primaryBias = 'Projektions-Bias';
correction = 'Integration alternativer theoretischer Perspektiven';
} else if (scores.pathologization === maxScore) {
primaryBias = 'Pathologisierungs-Bias';
correction = 'Betrachtung normativer Aspekte der Erfahrung';
} else if (scores.solution === maxScore) {
primaryBias = 'Lösungs-Bias';
correction = 'Vertiefte Exploration vor Lösungsansätzen';
} else {
primaryBias = 'Machbarkeits-Bias';
correction = 'Realistische Einschätzung von Veränderungsmöglichkeiten';
}
}
return {
scores,
primaryBias,
correction
};
}
// Generate personalized response based on conversation flow
function generatePersonalizedResponse(message) {
const lowerMessage = message.toLowerCase();
// Stage 1: Name establishment
if (!userProfile.name && userProfile.conversationStage === 'initial') {
// Enhanced name extraction with fallback
const namePatterns = [
/(?:ich bin|mein name ist|ich heiße|nennen sie mich)\s+([A-ZÄÖÜ][a-zäöüß]+(?:\s+[A-ZÄÖÜ][a-zäöüß]+)*)/i,
/(?:name)\s+(?:ist\s+)?([A-ZÄÖÜ][a-zäöüß]+)/i,
/^([A-ZÄÖÜ][a-zäöüß]+)(?:\s|$)/,
/(?:heiße)\s+([A-ZÄÖÜ][a-zäöüß]+)/i
];
let extractedName = null;
for (const pattern of namePatterns) {
const nameMatch = message.match(pattern);
if (nameMatch && nameMatch[1]) {
extractedName = nameMatch[1].trim();
break;
}
}
if (extractedName) {
userProfile.name = extractedName;
userProfile.preferredName = extractedName;
userProfile.conversationStage = 'name_established';
return {
text: `
<p>Vielen Dank, ${userProfile.name}. Schön, Sie kennenzulernen.</p>
<p class="mt-2">Was führt Sie heute zu mir? Was beschäftigt Sie im Moment am meisten?</p>
`,
meta: {
personalizedGreeting: `Hallo ${userProfile.name},`,
followUpQuestion: "Würden Sie mir etwas mehr darüber erzählen, was Sie bewegt?",
updateStage: 'name_established'
}
};
} else {
// If no name found, ask again with more guidance
return {
text: `
<p>Vielen Dank für Ihre Nachricht.</p>
<p class="mt-2">Um unser Gespräch persönlicher zu gestalten, könnten Sie mir bitte mitteilen, wie ich Sie ansprechen soll?</p>
<p class="mt-2">Zum Beispiel: "Ich bin Anna" oder "Nennen Sie mich Max".</p>
`,
meta: {
followUpQuestion: "Wie soll ich Sie nennen?",
updateStage: 'initial'
}
};
}
}
// Just got the name - acknowledge and ask about issue
if (userProfile.name && userProfile.conversationStage === 'initial') {
userProfile.conversationStage = 'name_established';
return {
text: `
<p>Vielen Dank, ${userProfile.name}. Schön, Sie kennenzulernen.</p>
<p class="mt-2">Was führt Sie heute zu mir? Was beschäftigt Sie im Moment am meisten?</p>
`,
meta: {
personalizedGreeting: `Hallo ${userProfile.name},`,
followUpQuestion: "Würden Sie mir etwas mehr darüber erzählen, was Sie bewegt?",
updateStage: 'name_established'
}
};
}
// Stage 2: Issue sharing
if (userProfile.conversationStage === 'name_established') {
userProfile.conversationStage = 'issue_shared';
// Check for greetings
if (lowerMessage.match(/^(hi|hallo|guten (tag|morgen|abend)|moin|servus|hey|grü(ß|ss)e?)/i)) {
return {
text: `
<p>${userProfile.name}, ich freue mich, unser Gespräch fortzusetzen.</p>
<p class="mt-2">Bei unserem letzten Austausch haben Sie über ${userProfile.lastTopics.length > 0 ? 'Themen wie ' + userProfile.lastTopics.join(', ') : 'verschiedene Themen'} gesprochen.</p>
<p class="mt-2">Wie geht es Ihnen damit heute?</p>
`,
meta: {
personalizedGreeting: `Willkommen zurück, ${userProfile.name}`,
followUpQuestion: "Möchten Sie an unser letztes Gespräch anknüpfen oder etwas Neues besprechen?",
isFollowUp: true
}
};
}
// Generate personalized issue response
return generateIssueResponse(message);
}
// Stage 3: Deep dive into issue
if (userProfile.conversationStage === 'issue_shared') {
return generateDeepDiveResponse(message);
}
// Stage 4: Ongoing conversation - more sophisticated handling
return generateOngoingResponse(message);
}
// Generate response when user shares their issue
function generateIssueResponse(message) {
let responseText = '';
let followUpQuestion = '';
let analysisNote = '';
const threadId = 'thread_' + Date.now();
const threadTopic = userProfile.lastTopics.length > 0 ? userProfile.lastTopics[0] : 'main_topic';
// Emotional state acknowledgment
if (userProfile.emotionalState === 'distressed') {
responseText += `<p>Ich höre heraus, dass Sie sich im Moment in einer emotional belastenden Situation befinden, ${userProfile.name}.</p>`;
followUpQuestion = "Wie gehen Sie normalerweise mit solchen belastenden Gefühlen um?";
} else if (userProfile.emotionalState === 'angry') {
responseText += `<p>Die von Ihnen beschriebene Situation scheint starke Gefühle von Ärger oder Frustration in Ihnen auszulösen, ${userProfile.name}.</p>`;
followUpQuestion = "Was glauben Sie, löst diese intensiven Reaktionen in Ihnen aus?";
} else if (userProfile.emotionalState === 'positive') {
responseText += `<p>Es freut mich zu hören, dass Sie sich in einer positiven Verfassung befinden, ${userProfile.name}.</p>`;
followUpQuestion = "Was trägt Ihrer Meinung nach besonders zu diesem Wohlbefinden bei?";
} else {
responseText += `<p>Danke, dass Sie diese Situation mit mir teilen, ${userProfile.name}.</p>`;
followUpQuestion = "Was denken Sie, könnte hinter diesen Erfahrungen stehen?";
}
// Topic-specific responses with deeper questions
if (message.includes('Freund') || message.includes('Freundin')) {
responseText += `
<p class="mt-2">Freundschaftsdynamiken sind oft Spiegel unserer unbewussten Erwartungen und früheren Beziehungserfahrungen.</p>
<p class="mt-2">Wenn Sie an diese Freundschaft denken, ${userProfile.name}, welche Gefühle oder Erinnerungen werden dabei besonders aktiviert?</p>
`;
followUpQuestion = "Erkennen Sie ähnliche Muster in anderen Freundschaften aus unterschiedlichen Lebensphasen?";
}
else if (message.includes('Partner') || message.includes('Beziehung')) {
responseText += `
<p class="mt-2">Partnerschaften aktivieren häufig tief verwurzelte Bindungsmuster aus unserer Kindheit.</p>
<p class="mt-2">${userProfile.name}, wenn Sie an Ihre frühesten Erinnerungen an Nähe und Distanz denken - welche Parallelen fallen Ihnen auf?</p>
`;
followUpQuestion = "Welche Rolle nehmen Sie Ihrer Erfahrung nach typischerweise in Beziehungskonflikten ein, und woher könnte dieses Muster stammen?";
}
else if (message.includes('Familie') || message.includes('Eltern')) {
responseText += `
<p class="mt-2">Familiensysteme prägen uns oft stärker, als uns bewusst ist.</p>
<p class="mt-2">${userProfile.name}, wenn Sie an Ihre Kindheitsfamilie zurückdenken - welche ungeschriebenen Regeln oder Erwartungen gab es dort?</p>
`;
followUpQuestion = "Wie haben sich diese familiären Muster in Ihrem Erwachsenenleben fortgesetzt oder verändert?";
}
else if (message.includes('Arbeit') || message.includes('Job')) {
responseText += `
<p class="mt-2">Unsere berufliche Identität ist oft eng mit unserem Selbstwertgefühl verbunden.</p>
<p class="mt-2">${userProfile.name}, welche frühen Erfahrungen mit Leistung und Bewertung sind Ihnen besonders im Gedächtnis geblieben?</p>
`;
followUpQuestion = "Wie würden Sie beschreiben, welchen Platz Arbeit in Ihrem Leben einnehmen sollte, im Vergleich zu dem, welchen sie tatsächlich einnimmt?";
}
else {
responseText += `
<p class="mt-2">Interessant, ${userProfile.name}. Lassen Sie uns gemeinsam erkunden, was diese Erfahrung für Sie bedeutet.</p>
<p class="mt-2">Wenn Sie an die letzte ähnliche Situation denken - was fällt Ihnen dazu besonders ein?</p>
`;
followUpQuestion = "Wann haben Sie dieses Gefühl oder Muster zum ersten Mal bewusst wahrgenommen, und in welchem Lebenskontext?";
}
return {
text: responseText,
meta: {
personalizedGreeting: `Danke für Ihre Offenheit, ${userProfile.name}`,
followUpQuestion: followUpQuestion,
updateStage: 'issue_shared',
threadId: threadId,
threadTopic: threadTopic,
increaseDepth: true
}
};
}
// Generate deep dive response with contextual awareness
function generateDeepDiveResponse(message) {
const currentDepth = userProfile.conversationDepth;
let followUpQuestion = '';
let memoryReference = '';
let threadReference = '';
// Reference previous topics if available
if (userProfile.lastTopics.length > 0) {
threadReference = `Unser Gespräch über ${userProfile.lastTopics[0]} finde ich besonders aufschlussreich. `;
}
// Reference key memories if available
if (userProfile.keyMemories.length > 0) {
const randomMemory = userProfile.keyMemories[Math.floor(Math.random() * userProfile.keyMemories.length)];
memoryReference = `Ihre Erwähnung von ${randomMemory} scheint mir hier relevant. `;
}
// Questions get progressively deeper
const depthLevels = [
// Level 1-2: Surface exploration
[
`Was macht diese Situation für Sie besonders herausfordernd, ${userProfile.name}?`,
`Wie würden Sie beschreiben, was Sie in diesen Momenten am meisten brauchen, ${userProfile.name}?`
],
// Level 3-4: Pattern recognition
[
`${userProfile.name}, erkennen Sie ähnliche Muster in anderen Lebensbereichen?`,
`Wenn Sie an vergangene ähnliche Situationen denken, ${userProfile.name}, was fällt Ihnen an Gemeinsamkeiten auf?`
],
// Level 5-6: Emotional roots
[
`${memoryReference}${userProfile.name}, welche frühen Erfahrungen könnten mit diesen Gefühlen verbunden sein?`,
`Wenn Sie an Ihre Kindheit denken, ${userProfile.name}, welche ähnlichen emotionalen Erfahrungen fallen Ihnen ein?`
],
// Level 7-8: Meaning and integration
[
`${threadReference}${userProfile.name}, was könnte diese Erfahrung Ihnen über tieferliegende Bedürfnisse oder Ängste mitteilen?`,
`Wie könnte ein konstruktiver Umgang mit diesen Erkenntnissen aussehen, ${userProfile.name}?`
],
// Level 9+: Transformative questions
[
`${userProfile.name}, wenn Sie diese Muster aus einer neuen Perspektive betrachten - was sehen Sie dann?`,
`Welche neuen Möglichkeiten eröffnen sich Ihnen, wenn Sie diese Erkenntnisse integrieren, ${userProfile.name}?`
]
];
// Select question based on depth level
const depthIndex = Math.min(Math.floor(currentDepth / 2), depthLevels.length - 1);
const questionsForDepth = depthLevels[depthIndex];
followUpQuestion = questionsForDepth[Math.floor(Math.random() * questionsForDepth.length)];
// Adjust for resistance level
if (userProfile.resistanceLevel > 3) {
followUpQuestion = `${userProfile.name}, ich spüre etwas Zurückhaltung - möchten Sie zu einem anderen Aspekt wechseln, oder sollen wir behutsam weitergehen?`;
}
return {
text: `
<p>Danke, dass Sie diese Perspektive teilen, ${userProfile.name}.</p>
<p class="mt-2">Das hilft mir, die Situation besser zu verstehen.</p>
${memoryReference ? `<p class="mt-2">${memoryReference}</p>` : ''}
`,
meta: {
followUpQuestion: followUpQuestion,
isFollowUp: true,
increaseDepth: true,
referencingMemory: !!memoryReference
}
};
}
// Generate ongoing conversation response with thread awareness
function generateOngoingResponse(message) {
// Check if we should switch to a deeper thread
const activeThreads = Object.entries(conversationThreads)
.sort((a, b) => b[1].lastActive - a[1].lastActive);
let followUpQuestion = '';
let threadSwitch = '';
let memoryReference = '';
// 30% chance to reference an older thread if not recently active
if (activeThreads.length > 1 && Math.random() < 0.3) {
const inactiveThread = activeThreads.find(([id, thread]) =>
thread.lastActive < new Date(Date.now() - 60000 * 5)); // Not active for 5 mins
if (inactiveThread) {
threadSwitch = `Vorhin sprachen wir über ${inactiveThread[1].topic}. `;
followUpQuestion = `Möchten wir dazu zurückkehren, ${userProfile.name}, oder beim aktuellen Thema bleiben?`;
return {
text: `
<p>${threadSwitch}Das scheint mir mit unserem jetzigen Gespräch verbunden zu sein.</p>
`,
meta: {
followUpQuestion: followUpQuestion,
isFollowUp: true,
threadId: inactiveThread[0]
}
};
}
}
// Reference key memories if available
if (userProfile.keyMemories.length > 0 && Math.random() < 0.4) {
const randomMemory = userProfile.keyMemories[Math.floor(Math.random() * userProfile.keyMemories.length)];
memoryReference = `Ihre frühere Erwähnung von ${randomMemory} fällt mir hier wieder ein. `;
}
// Progressive deepening questions
const deepQuestions = [
`${userProfile.name}, wenn Sie diese Situation aus einer anderen Perspektive betrachten - was sehen Sie dann?`,
`Welche unbewussten Anteile könnten hier mitwirken, ${userProfile.name}?`,
`Wenn Sie einen inneren Dialog zu diesem Thema führen würden, ${userProfile.name}, welche Stimmen würden sich melden?`,
`${memoryReference}${userProfile.name}, welche früheren Erfahrungen könnten diese Reaktionen beeinflussen?`,
`Wie könnte ein konstruktiver nächster Schritt aussehen, ${userProfile.name}?`
];
followUpQuestion = deepQuestions[Math.floor(Math.random() * deepQuestions.length)];
return {
text: `
<p>${memoryReference}Das ist eine wichtige Beobachtung, ${userProfile.name}.</p>
<p class="mt-2">Lassen Sie uns das gemeinsam vertiefen.</p>
`,
meta: {
followUpQuestion: followUpQuestion,
isFollowUp: true,
increaseDepth: true,
referencingMemory: !!memoryReference
}
};
}
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Frajosgro/https-huggingface-co-spaces-frajosgro-franz" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |