Using textcat to classify web app text input

Hi all,

We are building a Q&A model and looking for a way to rapidly generate, and subsequently annotate, new data. I believe all of the pieces are available to do so with Prodigy, but haven't quite seen a way to put them together.

Ideal use: We'd like to have a text field on the Prodigy web server where users could input a question. This text would be run through some of our code and a response would be generated dynamically. This response would be presented to the user, and the user would be able to annotate the response with a class (i.e., textcat with a numeric score) to rate the response.

I've seen that we can build custom loaders with a while True loop (Integrating Prodigy with Custom Platform and adding raw data dynamically without restarting Server - #2 by ines) to continuously load data, but that assumes the custom loader is polling some API or database. Is it possible to add a text input on the web server that the custom loader is polling (or called on Submit)? Otherwise it seems we need to have another web app that accepts text input from an end-user and sends it to a database, which the custom loader would be polling.

Any help is much appreciated -- thanks!

Hi! I'm not sure if going via the stream here is the best solution because the stream is assembled in Python, so if you're collecting free-form input, you'd have to send it back to the server and re-add it to the stream with your dynamic response. It's possible but probably less convenient.

Another option could be to spin up a really simple API endpoint (e.g. with FastAPI), and then generate your response in JavaScript. You can provide custom JavaScript via the "javascript" setting of the recipe and then use the html interface to add a "Submit" button. On click, you can then send the user input to your API and update the UI accordingly. For example:

<textarea id="input"></textarea>
<button id="submit">Submit</button>
<div id="result"></div>
document.addEventListener('prodigymount,' () => {
    const input = document.querySelector('#input')
    const submit = document.querySelector('#submit')
    const result = document.querySelector('#result')
    submit.addEventListener('click', () => {
        // post/sent input.value to your API endpoint 
        // and set result.textContent to response
    })
})