deepumanju commited on
Commit
b9c43aa
1 Parent(s): d4b090e

Delete main.py

Browse files
Files changed (1) hide show
  1. main.py +0 -22
main.py DELETED
@@ -1,22 +0,0 @@
1
- from fastapi import FastAPI, HTTPException
2
- from transformers import pipeline
3
- app=FastAPI()
4
- pipe = pipeline("text2text-generation", model="google/flan-t5-small")
5
- @app.get("/")
6
- def welcome():
7
- """
8
- Welcoming page.
9
- """
10
- return {"message": "Welcome to the Text-to-Text Generation API! Use the /generate endpoint to transform text."}
11
-
12
- @app.post("/generate")
13
- def generate_text(data: str):
14
- """
15
- Generate text from the input text using the text-to-text generation model.
16
- """
17
- try:
18
- # Perform text-to-text generation
19
- generated = generate_text(data.str, max_length=50, num_return_sequences=1)
20
- return {"input": data.str, "generated_text": generated[0]["generated_text"]}
21
- except Exception as e:
22
- raise HTTPException(status_code=500, detail=str(e))