Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
# Use a pipeline as a high-level helper
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
pipe = pipeline("text-generation", model="meta-llama/Llama-3.2-3B")
|
6 |
+
|
7 |
+
app = FastAPI()
|
8 |
+
|
9 |
+
|
10 |
+
@app.get('/')
|
11 |
+
def home():
|
12 |
+
return {"hello": "Detail"}
|
13 |
+
|
14 |
+
|
15 |
+
@app.get('/ask')
|
16 |
+
def ask(prompt: str):
|
17 |
+
result = pipe(prompt)
|
18 |
+
return result[0]
|