Skip to main content
FileStore represents a file and its contents for use in EDSL or storage on Expected Parrot. A scenario can contain a FileStore attachment, or rows extracted from a file can become separate scenarios. For complete examples of asking questions about PDFs, images, video, and audio, see Files and media as scenarios.

Rows from a CSV and a whole-file attachment

This self-contained example writes a two-row CSV using Python’s CSV writer, constructs a FileStore, and loads the rows as scenarios. It makes no model calls or uploads.
rows has two scenarios, each with record_id and feedback. The attachment scenario instead holds the complete file under document. Loading a CSV into rows is useful for one classification per record; attaching a whole document is useful when the model needs the document itself.

Images, PDFs, and other media

Use a FileStore value in a scenario and reference its field in the question. For example, Scenario({"image": FileStore("image.png")}) attaches an image that the question can reference with {{ scenario.image }}. A plain path string carries only the filename. The Scenarios page contains worked examples for:

Storage and sharing

Creating a FileStore reads local data. Calling push() uploads it to Expected Parrot and requires authentication. Set visibility explicitly and retain the returned identifier. See Saving and sharing objects for posting and retrieving research materials. For example, save a PDF on Expected Parrot and retrieve it as a scenario attachment:
Reference {{ scenario.document }} in your question, then pass document to question.by(document). You can also pass a shared file URL to FileStore.pull(). Access follows the object’s sharing permissions. To extract PDF text after retrieval, use ScenarioList.from_source("pdf", retrieved_report.to_tempfile()) after importing ScenarioList.

Common methods

Using the CSV created in the example above:
attachment contains one complete file, while rows contains the CSV records. Choose the input that matches what each respondent should evaluate.

Read, preview, and convert files

FileStore.from_file_upload_answer(file_info) retrieves one uploaded file from a human survey answer; see file upload responses.

Generate image inputs

ImageGeneration produces FileStore objects that can be attached to scenarios. This example uses a local test service that returns a tiny placeholder image, without a provider request:
For actual generation, choose a model supported by the image service, for example ImageGeneration(model="MODEL_NAME", service_name="google"), with the provider credential configured. Image generation can incur costs. Pass input_images=[file] when the chosen service supports editing or image-conditioned generation. Provider-specific parameters can be supplied at construction or to generate(). In a notebook with an active event loop or an asynchronous function, use await generator.async_generate(prompt) instead of generate(). A single generated image returns one FileStore; multiple images return a list. With return_type="generated_image", the return value instead contains GeneratedImage metadata. Use its to_filestore() to access the file, token_usage() for usage information, and cost() for the model-price-based cost calculation; missing usage can be estimated rather than measured.