Spaces:
Runtime error
Runtime error
Delete app.py
Browse files
app.py
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
from fastapi import FastAPI
|
2 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
3 |
-
|
4 |
-
app = FastAPI()
|
5 |
-
|
6 |
-
model_id = "gpt2" # Replace with your desired model
|
7 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
8 |
-
model = AutoModelForCausalLM.from_pretrained(model_id)
|
9 |
-
generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
10 |
-
|
11 |
-
@app.get("/")
|
12 |
-
def generate_text(prompt: str):
|
13 |
-
result = generator(prompt)
|
14 |
-
return {"generated_text": result[0]["generated_text"]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|