Passing jsPsych plugin response into Pyscript function and back again #2987
Replies: 1 comment
-
Have you checked if the package that you use for the NLP model is present in this list? I would first make sure that you can use your NLP model in PyScript independently from the jsPsych framework. If that works, I think you should be able to combine both by using some of the approaches mentioned here. If that does not work, I think you should be able to set up Flask so that it accepts an HTTP request with the word as parameter and returns the output word as a response. In jsPsych you can then make an ajax call after the survey finishes and use that as input for the button response. Let me know if you need any further advice here, I'd be happy to think along :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I'm trying to set up a task where the participant inputs a word e.g. using the survey-text plugin, and that word is then passed to a python script. The python script processes the word using an NLP model, then outputs another word, which I would then like to pass back and use in the jsPsychHtmlKeyboardResponse plugin to show the participant.
So my question is: How can I pass a participant response from a jsPsych plugin to a python script, then pass the output of the python script back to use in another jsPsych plugin?
I think I might be able to do this using Pyscript, so I've added it in the head tag here, and that part seems to be working fine:
<link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" /> <script defer src="https://pyscript.net/latest/pyscript.js"></script>
If this can't be done using Pyscript, does anyone have an example using Flask?
Does anyone know how I could achieve this?
I would be very grateful for any advice!
Beta Was this translation helpful? Give feedback.
All reactions