Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -4,15 +4,6 @@ from fastapi import FastAPI
|
|
4 |
from pydantic import BaseModel
|
5 |
import re
|
6 |
import os
|
7 |
-
import transformers
|
8 |
-
import torch
|
9 |
-
|
10 |
-
|
11 |
-
model_id = "meta-llama/Meta-Llama-3-8B"
|
12 |
-
|
13 |
-
pipeline = transformers.pipeline(
|
14 |
-
"text-generation", model=model_id, model_kwargs={"torch_dtype": torch.bfloat16}, device_map="auto"
|
15 |
-
)
|
16 |
|
17 |
|
18 |
app = FastAPI()
|
@@ -106,19 +97,7 @@ async def root(item: Item):
|
|
106 |
return {"error": str(e), "status_code": 500}
|
107 |
|
108 |
|
109 |
-
@app.post("/summarize-v3")
|
110 |
-
async def root(item: Item):
|
111 |
-
|
112 |
-
try:
|
113 |
-
|
114 |
-
article = extract_article_content(item.url)
|
115 |
|
116 |
-
output = pipeline("Summarize the following news article for me:", article)
|
117 |
-
|
118 |
-
return {"summary": output}
|
119 |
-
|
120 |
-
except requests.RequestException as e:
|
121 |
-
return {"error": str(e), "status_code": 500}
|
122 |
|
123 |
|
124 |
|
|
|
4 |
from pydantic import BaseModel
|
5 |
import re
|
6 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
|
9 |
app = FastAPI()
|
|
|
97 |
return {"error": str(e), "status_code": 500}
|
98 |
|
99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
|
103 |
|