Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,10 +4,14 @@ import os
|
|
4 |
|
5 |
app = FastAPI()
|
6 |
|
|
|
|
|
|
|
|
|
7 |
pipe = pipeline(
|
8 |
"text-generation",
|
9 |
model="google/gemma-3-1b-it",
|
10 |
-
token=os.environ["HF_TOKEN"],
|
11 |
device="cpu",
|
12 |
max_new_tokens=256,
|
13 |
temperature=0.7
|
@@ -18,4 +22,4 @@ async def generate(request: Request):
|
|
18 |
data = await request.json()
|
19 |
prompt = data.get("prompt", "")
|
20 |
result = pipe(prompt)
|
21 |
-
return {"response": result[0]["generated_text"]}
|
|
|
4 |
|
5 |
app = FastAPI()
|
6 |
|
7 |
+
# Встановлення директорії кешу
|
8 |
+
cache_dir = os.path.expanduser("~/.cache/huggingface/transformers")
|
9 |
+
os.environ["TRANSFORMERS_CACHE"] = cache_dir
|
10 |
+
|
11 |
pipe = pipeline(
|
12 |
"text-generation",
|
13 |
model="google/gemma-3-1b-it",
|
14 |
+
token=os.environ["HF_TOKEN"],
|
15 |
device="cpu",
|
16 |
max_new_tokens=256,
|
17 |
temperature=0.7
|
|
|
22 |
data = await request.json()
|
23 |
prompt = data.get("prompt", "")
|
24 |
result = pipe(prompt)
|
25 |
+
return {"response": result[0]["generated_text"]}
|