from fastapi import FastAPI, Body from main_pipeline import run_pipeline, session_data from pydantic import BaseModel app = FastAPI(title='CaPE') class UserInput(BaseModel): text: str @app.post("/pseudonymized-input") async def pseudonymized_input(user_input: UserInput): """ Accept user input and run the full pipeline. Returns the pseudonymized input. """ await run_pipeline(user_input.text) return {"pseudonymized_input": session_data["pseudonymized_input"]} @app.get("/raw-output") async def get_raw_output(): """ Return the raw output received from the LLM. """ return {"raw_output": session_data["raw_output"]} @app.get("/pseudonymized-output") async def get_pseudonymized_output(): """ Return the pseudonymized version of the LLM output. """ return {"pseudonymized_output": session_data["pseudonymized_output"]}