data.push("1: Choo-Choo's strategy is to make a big profit per item. They sell at high prices but reach profit margins between 50 cents and 1 Euro per item."); data.push("2: Choo-Choo's biggest success so far has been 'Harmony', a chewing gum with a lavender aroma. It was marketed with a wellness theme two years ago and generated a lot of positive press although it was a very simple idea. It sold out in record time."); data.push("3: Some managers find Cosmo Explosion too experimental for the moment as the company really needs fast money. Others think that the jelly idea could be the base for new products."); data.push("4: A few managers think that 30 map pieces in 'Treasure island' are too many for collecting, but most believe that the prize toys are so attractive and the collecting activity is so much fun that the gums will sell out in no time."); data.push("5: A part of the management team thinks that Whitey is not quite innovative enough for Choo-Choo's image. Others think that the formula is very unique and will attract many customers."); data.push("6: The R&D department has developed two versions of 'Cosmo Explosion': one carries the fruity jelly as one big core, in the other the jelly is inserted in many tiny pearls."); data.push("7: Choo-Choo can easily produce Cosmo Explosion with one big jelly core. Any other version of Cosmo Explosion would cost additional 50,000 Euro on top of the forecast for machinery changes."); data.push("8: Another company has just patented the production process of inserting tiny jelly pearls into chewing gum. Therefore, it is not legal to produce Cosmo Explosion in this way. Choo-Choo has to choose a different way of putting the jelly into the gum."); data.push("9: According to market research, people really like the jelly in Cosmo Explosion, unless they bite on a big chunk of it. A gum with tiny jelly pearls would sell 100% as expected, a gum with a jelly core only 50%."); data.push("10: The financial department has calculated that Cosmo Explosion would bring home 0.75 Euro profit per item. They expect sales of 400,000 items."); data.push("11: For Zen, the R&D department has very easily adapted the formula they used for Harmony. A new key ingredient is magnesium, which has a relaxing effect."); data.push("12: Choo-Choo needs magnesium for the production of Zen. Because a new source of magnesium was just found, prices for it have fallen. Choo-Choo would pay 50,000 Euro less for this ingredient than expected."); data.push("13: Choo-Choo could avoid competition for Zen if it gets a patent for the new formula. But it would cost an additional 100,000 Euro in legal fees on top of the forecast."); data.push("14: Market research has shown that Zen would make 100% of the predicted sales if it was the only gum of this kind on the market. But there is a competitor planning to launch the very same kind of gum at the same time. This would cut the sales to 50%."); data.push("15: The financial department has calculated that Zen would make 0.75 Euro profit per item. They expect to sell 400,000 items."); data.push("16: The R&D department has proposed a standard, well-tested formula for Treasure Island."); data.push("17: As Choo-Choo only produces gum, they have to buy the prize toys elsewhere. They have found a supplier who can sell them max. 1,000 toys at 50 Euro per toy."); data.push("18: According to law, Choo-Choo must guarantee that every child who sends in a completed Treasure Island map indeed gets the exact same toy that is shown in the promotion. Breaking this law would cause severe bad press and might ruin the company."); data.push("19: Market research shows that kids love the map collecting. Treasure Island would sell 100% as expected. As the kids will use online social networks to exchange map pieces, it is sure that between 1,500 and 2,000 maps will be completed and sent in for a prize toy."); data.push("20: The financial department has calculated that Treasure Island would make 1.25 Euro profit per item and expects sales of 400,000 items. This calculation does not include the cost of the prize toys though."); data.push("21: The R&D department has come up with a very innovative formula for Whitey. It uses soft granules in the gum for a mechanical whitening effect and does not contain any chemical whiteners."); data.push("22: Whitening chemicals that are usually contained in whitening gums can cause damage to the machines. Taking care of it would cost an additional 50,000 Euro."); data.push("23: The government has set up a new initiative to support innovation. But only innovations that are actually brought into production can get it. Whitey's formula is very innovative. If it is put on the market, Choo-Choo would get an innovation award and a prize of 100,000 Euro."); data.push("24: According to market research, Whitey would make 100% of the predicted sales."); data.push("25: The financial department has calculated that Whitey would make 0.50 Euro profit per item. They expect to sell 400,000 items."); data.push("26: The R&D department has developed a formula with an extra-long freshness effect for Business Class. It works, but they have not done extensive testing series because that would cost 100,000 Euro extra."); data.push("27: Choo-Choo can use existing production facilities for Business Class, which makes it very simple."); data.push("28: According to law, if Choo-Choo wants to promote Business Class by saying that it has an extra-long freshness effect, they first have to show results of an extensive testing series. Otherwise, they cannot use this claim for promoting sales."); data.push("29: Market research shows that the extra-long freshness effect of Business Class brings sales up to 150% of the expectation. But for this, the gums have to be sold with this claim; otherwise, it will not sell at all."); data.push("30: The financial department has calculated that Business Class would make 0.50 Euro profit per item. They expect sales of 400,000 items."); function chatReceived(from,val) { var color = "blue"; if (from == myid) { color = "green"; $('#chat_conversation').append('
You (Member '+from+'): '+ val+'
'); chats.push(val); } else if (from ==99){ //if it's the bot, append it with the botname $('#chat_conversation').append('
'+botname+':'+val+'
'); } else { $('#chat_conversation').append('
Member '+from+': '+val+'
'); chats.push(val); } $('#chat_conversation').scrollTop = $('#chat_conversation').scrollHeight; } function appendToChatConversation(message, sender = 'User') { console.log('resp2 '+ message) // Create the formatted HTML string let formattedMessage = `
${sender}: ${message}
`; // Append the formatted message to the HTML element with the ID "chat_conversation" $('#chat_conversation').append(formattedMessage); } function greetFromGpt(message){ console.log('resp2 '+ message) // Create the formatted HTML string let greetMessage = `
${botname}: ${greeting}
`; let firstInfo = `
${botname}: ${first_info}
`; // Append the formatted message to the HTML element with the ID "chat_conversation" $('#chat_conversation').append(greetMessage); $('#chat_conversation').append(firstInfo); } // Function to generate a summary using OpenAI API function generateSummary() { // Prepare the message payload model='gpt-3.5-turbo-0125' //User specifies the model they want temperature = .7 //user specifies the temperature variable (default to .7 if they do not specify) const message = { role: 'user', content: `Please read the following conversation:\n\n${chats}. And point out what did they miss from ${data}.You are only allowed to give some vague hints to them instead of give any actual information.When you point out hints, please start with something like: Here is something for you to consider in your discussion: + hint; or One thing I would like to remind you during the discussion is + hint.` }; // Call the OpenAI function to get the summary openai_chat_completions_create(message,temperature,model) .then(response => { console.log(response); // This will log the actual response resp=response.response console.log('resp1 '+ resp) sendComBot(99,resp,-1) //appendToChatConversation(resp,sender='Gptbot'); }); } // This function calls OpenAI and handles the response async function openai_chat_completions_create(message, temperature=.7, model='gpt-3.5-turbo-0125'){ const openAIResponse = await fetch("https://volunteerscience.com/openai/chat/", { method: "POST", body: JSON.stringify({ message: message, temperature: temperature, model: model }), headers: { "Content-type": "application/json; charset=UTF-8" } }); const result = await openAIResponse.json(); //get the json from the returned response //console.log(result); //handle the returned response with the format {'response': 'text from chatGPT'} return result } // Function to handle message sending function handleMessageSend() { const chatInput = $('#chat_input').val(); if (chatInput.trim()) { appendToChatConversation(chatInput); chatReceived('User', chatInput); $('#chat_input').val(''); // Clear the input field } } function startGPT(){ gptTimer= setInterval(() => { console.log('running gpt timer') for (var i = 1; i < myid; i++) { if (activePlayers[i]) return; } if (botReminderTriggered == false){generateSummary()} }, 240000); } // Initialize chat functionality function receiveMessage(event) { // if we detect the survey is over, hide the iframe and end experiment. if (event.data == "closeQSIWindow") { document.getElementById("qualFrame").style.display = 'none'; experimentComplete(); } // if researcher calls popupConsent in survey and user has not already consented before, pop up the experiment's consent form if (event.data == "popupConsent") { if (REQUEST_CONSENT) { requestConsent(); } } // if researcher calls "payAMT" in survey and it's a turker, pay the base plus whatever bonus AMTBonus is set to. if (event.data == "payAMT") { if (IS_AMT){ payAMT(true, AMTBonus); } } } function setCountdown(id,seconds) { countdowns[id] = []; countdowns[id][0] = +new Date() + seconds*1000; countdowns[id][1] = seconds*1000; var mins = Math.floor(seconds/60); var secondRemainder = seconds%60; var secondsStr = ('0'+secondRemainder).slice(-2); // add leading zero, then use last 2 digits $('#'+id).html('
'+mins+':'+secondsStr+'
'); } /** * Call this routinely */ function advanceCountdowns() { for (id in countdowns) { updateCountdown(id); } } function updateCountdown(id) { var now = +new Date(); var diff = countdowns[id][0]-now; var clockString = "0:00"; if (diff > 0) { var fraction = 100*diff/countdowns[id][1]; var seconds = ~~(diff/1000); var mins = Math.floor(seconds/60); var secondRemainder = seconds%60; var secondsStr = ('0'+secondRemainder).slice(-2); // add leading zero, then use last 2 digits clockString = mins+":"+secondsStr; $('#'+id+' .countdown-progress').css("width",fraction+"%"); } else { $('#'+id+' .countdown-progress').css("width","0"); if(typeof countdownExpired == 'function') { countdownExpired(id); } delete countdowns[id]; } $('#'+id+' .countdown-clock').html(clockString); if (typeof countdownUpdate == "function") { countdownUpdate(id,diff,clockString); } if (diff <= 240000 && !botReminderTriggered) { remindLastMinutes(diff); // Call the reminder function } } function stopCountdown(id) { delete countdowns[id]; } function remindLastMinutes(diff) { botReminderTriggered = true; // Set flag to prevent multiple triggers setInterval(function() { let minsLeft = Math.floor(diff / 60000); if (minsLeft === 3) { appendToChatConversation("You only have 3 minutes left. Make sure you reach anagreement and submit your rank order to win your $10 bonus. You can no longer change your rank in 3 minutes!", 'Alex'); } else if (minsLeft === 2) { appendToChatConversation("You only have 2 minutes left. Reach an agreement and submit your rank order!", 'Alex'); } else if (minsLeft === 1) { appendToChatConversation("Finalize your rank now! No changes can be made after the timer runs out in 1 minute.", 'Alex'); } else if (minsLeft <= 0) { appendToChatConversation("Time is up. Please submit your rank now.", 'Alex'); clearInterval(reminderInterval); } diff -= 60000; }, 60000); // Trigger the reminder every minute } // Start the study function initialize() { initializeChat(); greetFromGpt(); startGPT(); setCountdown("timer",1500);// this is second here setInterval(advanceCountdowns, 1000); // place the title on the survey page document.getElementById("survey_title").innerHTML = variables["title"]; // create a listener for qualtrics window.addEventListener("message", receiveMessage, false); // Create an iframe called "qualFrame" that goes to the qualtrics URL and pass the testId and subjectID variables in the URL document.getElementById("qualFrame").setAttribute("src", variables["survey_link"] + "&testId=" + seed + "&subjectId=" + myid); document.getElementById("qualFrame").style.height = variables["survey_height"]; document.getElementById("qualFrame").style.display = 'block'; }