File size: 311 Bytes
6bb0951
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
from fastapi import FastAPI
from datasets import load_dataset
from transformers import AutoTokenizer

app = FastAPI()

@app.get("/")
def greet_json():
    # Example: Loading a dataset as part of the API
    dataset = load_dataset("squad")
    return {"Hello": "World!", "dataset_length": len(dataset["train"])}