| name | file-store |
| description | Using FileStore to wrap files (images, PDFs, data) for use in EDSL survey scenarios. |
FileStore: Working with Files in EDSL
Creating a FileStore
Use FileStore(path=...) to wrap any file for use in surveys:
from edsl import FileStore
fs = FileStore(path="photo.png")
This works with many file types: images (png, jpeg, svg), documents (pdf, docx, pptx), data (csv, xlsx, json), text (txt, md, html), code (py, sql), databases (db/sqlite), video (mp4, webm), and LaTeX.
Using FileStore in Scenarios
Pass a FileStore as a scenario value, then reference it in question text with Jinja2 templating:
from edsl import FileStore, Scenario, QuestionFreeText, Survey
fs = FileStore(path="chart.png")
scenario = Scenario({"file_path": fs})
q = QuestionFreeText(
question_name="describe",
question_text="What is in this image: {{ scenario.file_path }}?"
)
survey = Survey([q])
results = survey.by(scenario).run()
The {{ scenario.file_path }} placeholder is replaced with the file content at runtime, so the model sees the actual image/document.
Multiple Files with ScenarioList
Process many files by creating a scenario for each:
from edsl import FileStore, Scenario, ScenarioList
filenames = ["doc1.pdf", "doc2.pdf", "doc3.pdf"]
scenarios = ScenarioList([
Scenario({: FileStore(path=f)}) f filenames
])
results = survey.by(scenarios).run()