How to get new data when /get_session_questions reach the end?

There's some way to add tasks to an stream on execution time?
I had a loader function that get data from database, and apply tokens and make_tasks, this last function returns an interator, but don't find the way to make get_questions re-start the loader process when stream reach the end


I'm not 100% sure whether I'm answering the right question here. If this isn't what you mean, please don't hesitate to clarify :slight_smile:

There's currently no way to repopulate the stream of questions once the process is already running. You have to stop the service and start it again. However, you have full control of the queue of questions in Python, so you can always make sure the new stream and state that's loaded in is the same as it would have been if you had been able to repopulate while it was there.

An endpoint to modify the stream is definitely a feature request we could consider. But the good news is you could already do this yourself. You can import the, and add your own routes to it. The source is provided within Prodigy, so you can browse the code to see how the endpoints are defined and how to access the controller. It should be fairly easy to add a route that does what you want --- FastAPI has excellent documentation, and we can always give you some extra pointers if you need them.

1 Like

Thanks @honnibal
Your answer is related to my question

Would be perfect to trigger some callback when get_questions is called to let us add more (new) tasks to the stream


Another option for you:

Your recipe can return a Controller instance, instead of the dictionary of components (translate from one style to the other by writing Controller.from_components(), passing in the dictionary you would otherwise return.

This will let you create a subclass of the controller. You could then specify your own get_questions() method, invoking the superclass's version before or after your own logic.