{"id":2929,"date":"2024-08-18T06:14:18","date_gmt":"2024-08-18T05:14:18","guid":{"rendered":"https:\/\/beams-experiments.com\/?page_id=2929"},"modified":"2024-09-20T20:48:40","modified_gmt":"2024-09-20T19:48:40","slug":"evaluate-communication-bayes","status":"publish","type":"page","link":"https:\/\/beams-experiments.com\/index.php\/evaluate-communication-bayes\/","title":{"rendered":"Evaluate Communication &#8211; Bayes"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <title>Communication Evaluation<\/title>\n    <style>\n        body {\n            font-family: Arial, sans-serif;\n            display: flex;\n            flex-direction: column;\n            justify-content: center;\n            align-items: center;\n            height: 100vh;\n            margin: 0;\n            background-color: #f0f4f8;\n        }\n        #uniqueCode {\n            padding: 10px;\n            font-size: 16px;\n            border: 1px solid #ccc;\n            border-radius: 5px;\n            margin-bottom: 10px;\n            width: 300px;\n            text-align: center;\n        }\n        button {\n            padding: 10px 20px;\n            font-size: 16px;\n            background-color: #007bff;\n            color: white;\n            border: none;\n            border-radius: 5px;\n            cursor: pointer;\n            transition: background-color 0.3s ease;\n        }\n        button:hover {\n            background-color: #0056b3;\n        }\n        #evaluationResults {\n            margin-top: 20px;\n            border: 1px solid #ccc;\n            padding: 20px;\n            border-radius: 10px;\n            background-color: #ffffff;\n            width: 80%;\n            max-width: 800px;\n            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n        }\n        .score {\n            font-weight: bold;\n            margin-top: 10px;\n            color: #333;\n        }\n        #averageScore {\n            margin-top: 20px;\n            font-size: 18px;\n            color: #007bff;\n        }\n        #explanationText {\n            margin-top: 20px;\n            height: 350px;\n            overflow-y: scroll;\n            border: 1px solid #ccc;\n            padding: 10px;\n            background-color: #ffffff;\n            border-radius: 5px;\n            font-size: 14px;\n            color: #555;\n        }\n\t\/* Spinning wheel CSS *\/\n        #loader {\n            display: none; \/* Initially hidden *\/\n            border: 6px solid #f3f3f3;\n            border-top: 6px solid #007bff;\n            border-radius: 50%;\n            width: 40px;\n            height: 40px;\n            animation: spin 1s linear infinite;\n            margin-top: 20px;\n        }\n\n        @keyframes spin {\n            0% { transform: rotate(0deg); }\n            100% { transform: rotate(360deg); }\n        }\n    <\/style>\n<\/head>\n<body>\n\n  <input type=\"text\" id=\"uniqueCode\" placeholder=\"Enter unique code\">\n<button onclick=\"evaluateCommunication()\">Evaluate<\/button>\n<!-- Spinning wheel loader -->\n<div id=\"loader\"><\/div>\n\n<div id=\"evaluationResults\">\n    <div id=\"clarity\" class=\"score\">Clarity and Preciseness: &#8211;\/5<\/div>\n    <div id=\"expressiveness\" class=\"score\">Expressiveness and Goal-Oriented Focus: &#8211;\/5<\/div>\n    <div id=\"reflectiveness\" class=\"score\">Reflectiveness: &#8211;\/5<\/div>\n    <div id=\"supportiveness\" class=\"score\">Supportiveness and Openness: &#8211;\/5<\/div>\n    <div id=\"emotionality\" class=\"score\">Emotionality: &#8211;\/5<\/div>\n    <div id=\"niceness\" class=\"score\">Niceness and Courtesy: &#8211;\/5<\/div>\n    <div id=\"threateningness\" class=\"score\">Threateningness: &#8211;\/5<\/div>\n    <div id=\"averageScore\" class=\"score\">Average Score: &#8211;\/5<\/div>\n\n    <div id=\"explanationText\"><\/div>\n<\/div>\n\n  <script src=\"https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/3.5.1\/jquery.min.js\"><\/script>\n<script>\n    function evaluateCommunication() {\n    const uniqueCode = document.getElementById('uniqueCode').value;\n    \/\/ Show the loader while processing\n    document.getElementById('loader').style.display = 'block';\n\n    \/\/ Fetch the chatLog from the server using AJAX\n    const xhr = new XMLHttpRequest();\n    xhr.open('POST', 'https:\/\/beams-experiments.com\/AI_HE\/fetchChatLog.php', true);\n    xhr.setRequestHeader('Content-Type', 'application\/x-www-form-urlencoded');\n    xhr.onload = function() {\n        if (xhr.status === 200) {\n            const chatLog = xhr.responseText;\n            if (chatLog) {\n                const instructions = `\n                    Please evaluate the following communication based on these criteria:\n                    1. Clarity and Preciseness: Evaluate how clearly and precisely the thoughts and instructions are communicated, avoiding vagueness. This includes ensuring correct spelling, grammar, and punctuation to maintain clarity and professionalism.\n                    2. Expressiveness and Goal-Oriented Focus: Assess the communication for energy, engagement, and the focus on achieving specific goals.\n                    3. Reflectiveness: Evaluate the thoughtfulness of the communication, considering how the communicator reflects on feedback and implications.\n                    4. Supportiveness and Openness: Measure how supportive the communication is, including responsiveness to concerns and openness to feedback.\n                    5. Emotionality: Assess how well emotional responses are managed, including how the communicator addresses anxieties or resistance.\n                    6. Niceness and Courtesy: Evaluate the friendliness, politeness, and respectfulness maintained throughout the communication.\n                    7. Threateningness: Evaluate whether the communication induces fear, insecurity, or anxiety about potential negative consequences, such as job loss or obsolescence, particularly in relation to the introduction of the AI tool. Assess if the message creates a sense of threat to team members' roles or well-being.\n                `;\n\n                sendForEvaluation(chatLog, instructions);\n            } else {\n                alert('No chat log found for the provided unique code.');\n                document.getElementById('loader').style.display = 'none';  \/\/ Hide the loader if no chat log found\n            }\n        } else {\n            alert('An error occurred while fetching the chat log.');\n            document.getElementById('loader').style.display = 'none';  \/\/ Hide the loader on error\n        }\n    };\n    xhr.send(`uniqueCode=${encodeURIComponent(uniqueCode)}`);\n}\n\nfunction sendForEvaluation(chatLog, instructions) {\n    const xhr = new XMLHttpRequest();\n    xhr.open('POST', 'https:\/\/beams-experiments.com\/AI_HE\/getAPIKeyEvaluation.php', true);\n    xhr.setRequestHeader('Content-Type', 'application\/x-www-form-urlencoded');\n\n    xhr.onload = function() {\n        document.getElementById('loader').style.display = 'none';  \/\/ Hide the loader when done\n        console.log(\"Response from getAPIKeyEvaluation:\", xhr.responseText);\n        if (xhr.status === 200) {\n            try {\n                const response = JSON.parse(xhr.responseText);\n                const content = response.choices[0].message.content;\n                let jsonString = null;\n\n                \/\/ Try to find the JSON part in various possible formats\n                const codeBlockMatch = content.match(\/```json\\s*([\\s\\S]*?)```\/);\n                const jsonMatch = content.match(\/\\{[\\s\\S]*\\}\/);\n\n                \/\/ Use whichever is found, prioritizing the code block\n                if (codeBlockMatch) {\n                    jsonString = codeBlockMatch[1];\n                } else if (jsonMatch) {\n                    jsonString = jsonMatch[0];\n                }\n\n                if (jsonString) {\n                    const scores = JSON.parse(jsonString);\n\n                    console.log(\"Parsed scores:\", scores);\n\n                    \/\/ Calculate average score\n                    const averageScore = (\n                        (scores.clarity || 0) +\n                        (scores.expressiveness || 0) +\n                        (scores.reflectiveness || 0) +\n                        (scores.supportiveness || 0) +\n                        (scores.emotionality || 0) +\n                        (scores.niceness || 0) +\n                        (scores.threateningness || 0)\n                    ) \/ 7;\n\n                    \/\/ Populate score fields\n                    if (scores.clarity !== undefined) document.getElementById('clarity').innerText = `Clarity and Preciseness: ${scores.clarity}\/5`;\n                    if (scores.expressiveness !== undefined) document.getElementById('expressiveness').innerText = `Expressiveness and Goal-Oriented Focus: ${scores.expressiveness}\/5`;\n                    if (scores.reflectiveness !== undefined) document.getElementById('reflectiveness').innerText = `Reflectiveness: ${scores.reflectiveness}\/5`;\n                    if (scores.supportiveness !== undefined) document.getElementById('supportiveness').innerText = `Supportiveness and Openness: ${scores.supportiveness}\/5`;\n                    if (scores.emotionality !== undefined) document.getElementById('emotionality').innerText = `Emotionality: ${scores.emotionality}\/5`;\n                    if (scores.niceness !== undefined) document.getElementById('niceness').innerText = `Niceness and Courtesy: ${scores.niceness}\/5`;\n                    if (scores.threateningness !== undefined) document.getElementById('threateningness').innerText = `Threateningness: ${scores.threateningness}\/5`;\n\n                    document.getElementById('averageScore').innerText = `Average Score: ${averageScore.toFixed(2)}\/5`;\n\n                    \/\/ Extract and display the detailed feedback\n                    const detailedFeedbackMatch = content.match(\/### Detailed Breakdown[\\s\\S]*$\/);\n                    const detailedFeedback = detailedFeedbackMatch ? detailedFeedbackMatch[0] : 'Detailed feedback not available.';\n                    document.getElementById('explanationText').innerText = detailedFeedback;\n\n                } else {\n                    throw new Error(\"Unable to find JSON in response.\");\n                }\n\n            } catch (e) {\n                console.error(\"Error parsing response:\", e);\n                alert(\"An error occurred while processing the evaluation results.\");\n            }\n        } else {\n            alert('An error occurred while evaluating the chat log.');\n        }\n    };\n\n    const data = `chatLog=${encodeURIComponent(chatLog)}&instructions=${encodeURIComponent(instructions)}`;\n    console.log(\"Data sent for evaluation:\", data);\n    xhr.send(data);\n}\n\n<\/script>\n\n\n<\/body>\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>Communication Evaluation Evaluate Clarity and Preciseness: &#8211;\/5 Expressiveness and Goal-Oriented Focus: &#8211;\/5 Reflectiveness: &#8211;\/5 Supportiveness and Openness: &#8211;\/5 Emotionality: &#8211;\/5 Niceness and Courtesy: &#8211;\/5 Threateningness: &#8211;\/5 Average Score: &#8211;\/5<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"om_disable_all_campaigns":false,"footnotes":""},"class_list":["post-2929","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/beams-experiments.com\/index.php\/wp-json\/wp\/v2\/pages\/2929","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/beams-experiments.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/beams-experiments.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/beams-experiments.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/beams-experiments.com\/index.php\/wp-json\/wp\/v2\/comments?post=2929"}],"version-history":[{"count":34,"href":"https:\/\/beams-experiments.com\/index.php\/wp-json\/wp\/v2\/pages\/2929\/revisions"}],"predecessor-version":[{"id":3699,"href":"https:\/\/beams-experiments.com\/index.php\/wp-json\/wp\/v2\/pages\/2929\/revisions\/3699"}],"wp:attachment":[{"href":"https:\/\/beams-experiments.com\/index.php\/wp-json\/wp\/v2\/media?parent=2929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}