File size: 884 Bytes
d242fb9
 
 
 
386dae2
d242fb9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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"]}