I am following this tutorial to learn docker with hf spaces.
This is the code in app.py.
from fastapi import FastAPI
from transformers import pipeline
app = FastAPI(docs_url="/", openapi_url="/api/v1/openapi.json")
pipe = pipeline('text2text-generation',
model='google/flan-t5-small')
@app.get("/generate")
def generate(text:str):
output = pipe(text)
return {"output": output[0]["generated_text"]}
I’m getting following error -
Failed to load API definition
Fetch error
response status is 404 /api/v1/openapi.json
I have tried without the openapi_url argument inside FastAPI() (as written in the blog)
but that is also giving the same error.
Would appreciate some help in how to resolve this.
PS: I ran the docker image locally and it’s not giving any issues.