I have an app that takes a text (string) as input (copy-pasting and manually writing text), cleans it, and generates questions. Python and FastAPI are used. It is implemented like this:
-app
- api
- model
- Python scripts for type of question, question generation parameters, question generation parameters request
- init file, index file, and a question generation script that uses
inject, Provide, API Router
- model
- core
- preprocessing
- here there is an init file and a script that contains the text cleaning code
- other folders regarding question generation that are more complicated and only have to do with machine learning
- preprocessing
- model
- again, some transformer configuration
-init, cotainers and main file
I want to make it possible to upload a .txt file (so not just copy-paste input), clean it the same way, and generate questions.
The code for text upload and preprocessing is simple, in my Jupyter notebook it's just:
import string
with open(r'C:\\mypath\\example.txt', 'r', encoding="utf8") as infile:
data = infile.read()
# the same code that is used in the app for text cleaning
# it tansforms this data into new_data
with open(r'C:\\mypath\\example_edited.txt', 'w', encoding="utf8") as outfile:
outfile.write(new_data)
But now I don't know where in the app it should be. I looked here and here, and I don't figure it out. I am new to FastAPI and devops in general and a hint would be more than helpful.