Spaces error with custom webpage

I have a call that is made using a FastAPI site that I built. I’m calling a “def generate_response” function

python @app.post("/api/generate") async def generate_text(request: Request):
`

This call works locally but fails when on huggingface spaces

Getting the following error: "Failed to fetch data. Reason: Network response was not ok. Status: 504 - "

hi @aus10powell , could you please provide more context? we might be able to help you, do you have a Space demo? or Gradio project

Hi,

Thanks the spaces site is: TwitterAccounts - a Hugging Face Space by aus10powell

The code snippet in the post is within the app.py file if that helps. I’d be happy to add more detail but the code might make more sense. Please let me know if it needs to be broken down more.

sorry I don’t have access to your logs. Considering that you app is functional overall, my guess would be that the model loading in the POST request function is not ideal, could you move this to the app loading, thus loading the language package model only once

nlp = spacy.load("en_core_web_sm")
nlp.add_pipe("sentencizer")
1 Like

I’ll play around with that thanks!

1 Like